|
@@ -8,6 +8,7 @@
|
8
|
8
|
webkitRTCPeerConnection,
|
9
|
9
|
webkitURL
|
10
|
10
|
*/
|
|
11
|
+
|
11
|
12
|
import { AVAILABLE_DEVICE } from '../../service/statistics/AnalyticsEvents';
|
12
|
13
|
import CameraFacingMode from '../../service/RTC/CameraFacingMode';
|
13
|
14
|
import EventEmitter from 'events';
|
|
@@ -130,8 +131,7 @@ function initRawEnumerateDevicesWithCallback() {
|
130
|
131
|
: function(callback) {
|
131
|
132
|
MediaStreamTrack.getSources(
|
132
|
133
|
sources =>
|
133
|
|
- callback(
|
134
|
|
- sources.map(convertMediaStreamTrackSource)));
|
|
134
|
+ callback(sources.map(convertMediaStreamTrackSource)));
|
135
|
135
|
};
|
136
|
136
|
}
|
137
|
137
|
|
|
@@ -870,7 +870,7 @@ class RTCUtils extends Listenable {
|
870
|
870
|
|
871
|
871
|
/**
|
872
|
872
|
* Depending on the browser, sets difference instance methods for
|
873
|
|
- * interacting with user media and adds methods to native webrtc related
|
|
873
|
+ * interacting with user media and adds methods to native WebRTC-related
|
874
|
874
|
* objects. Also creates an instance variable for peer connection
|
875
|
875
|
* constraints.
|
876
|
876
|
*
|
|
@@ -907,8 +907,7 @@ class RTCUtils extends Listenable {
|
907
|
907
|
|
908
|
908
|
this.getUserMedia
|
909
|
909
|
= (constraints, successCallback, errorCallback) =>
|
910
|
|
- window.navigator.mediaDevices
|
911
|
|
- .getUserMedia(constraints)
|
|
910
|
+ window.navigator.mediaDevices.getUserMedia(constraints)
|
912
|
911
|
.then(stream => {
|
913
|
912
|
successCallback && successCallback(stream);
|
914
|
913
|
|
|
@@ -942,8 +941,8 @@ class RTCUtils extends Listenable {
|
942
|
941
|
}
|
943
|
942
|
});
|
944
|
943
|
|
945
|
|
- this.getStreamID = stream => stream.id;
|
946
|
|
- this.getTrackID = track => track.id;
|
|
944
|
+ this.getStreamID = ({ id }) => id;
|
|
945
|
+ this.getTrackID = ({ id }) => id;
|
947
|
946
|
} else if (browser.isChrome() // this is chrome < 61
|
948
|
947
|
|| browser.isOpera()
|
949
|
948
|
|| browser.isNWJS()
|
|
@@ -951,10 +950,11 @@ class RTCUtils extends Listenable {
|
951
|
950
|
|| browser.isReactNative()) {
|
952
|
951
|
|
953
|
952
|
this.RTCPeerConnectionType = webkitRTCPeerConnection;
|
954
|
|
- const getUserMedia
|
955
|
|
- = navigator.webkitGetUserMedia.bind(navigator);
|
|
953
|
+
|
|
954
|
+ const getUserMedia = navigator.webkitGetUserMedia.bind(navigator);
|
956
|
955
|
|
957
|
956
|
this.getUserMedia = wrapGetUserMedia(getUserMedia);
|
|
957
|
+
|
958
|
958
|
this.enumerateDevices = rawEnumerateDevicesWithCallback;
|
959
|
959
|
|
960
|
960
|
this.attachMediaStream
|
|
@@ -963,26 +963,20 @@ class RTCUtils extends Listenable {
|
963
|
963
|
|
964
|
964
|
return element;
|
965
|
965
|
});
|
966
|
|
- this.getStreamID = function(stream) {
|
967
|
|
- // A. MediaStreams from FF endpoints have the characters '{'
|
968
|
|
- // and '}' that make jQuery choke.
|
969
|
|
- // B. The react-native-webrtc implementation that we use on
|
970
|
|
- // React Native at the time of this writing returns a number
|
971
|
|
- // for the id of MediaStream. Let's just say that a number
|
972
|
|
- // contains no special characters.
|
973
|
|
- const id = stream.id;
|
974
|
|
-
|
975
|
|
- // XXX The return statement is affected by automatic
|
976
|
|
- // semicolon insertion (ASI). No line terminator is allowed
|
977
|
|
- // between the return keyword and the expression.
|
|
966
|
+
|
|
967
|
+ this.getStreamID = function({ id }) {
|
|
968
|
+ // A. MediaStreams from FF endpoints have the characters '{' and
|
|
969
|
+ // '}' that make jQuery choke.
|
|
970
|
+ // B. The react-native-webrtc implementation that we use at the
|
|
971
|
+ // time of this writing returns a number for the id of
|
|
972
|
+ // MediaStream. Let's just say that a number contains no special
|
|
973
|
+ // characters.
|
978
|
974
|
return (
|
979
|
975
|
typeof id === 'number'
|
980
|
976
|
? id
|
981
|
977
|
: SDPUtil.filterSpecialChars(id));
|
982
|
978
|
};
|
983
|
|
- this.getTrackID = function(track) {
|
984
|
|
- return track.id;
|
985
|
|
- };
|
|
979
|
+ this.getTrackID = ({ id }) => id;
|
986
|
980
|
|
987
|
981
|
if (!webkitMediaStream.prototype.getVideoTracks) {
|
988
|
982
|
webkitMediaStream.prototype.getVideoTracks = function() {
|
|
@@ -1019,39 +1013,38 @@ class RTCUtils extends Listenable {
|
1019
|
1013
|
};
|
1020
|
1014
|
|
1021
|
1015
|
// Remote MediaStreamTracks generated by ORTC (within a
|
1022
|
|
- // RTCRtpReceiver) have an internally/random id which does not
|
1023
|
|
- // match the track id signaled in the remote SDP. The shim adds
|
1024
|
|
- // a custom jitsi-id property with the original track id.
|
1025
|
|
- this.getTrackID = function(track) {
|
1026
|
|
- return track.jitsiRemoteId || track.id;
|
1027
|
|
- };
|
|
1016
|
+ // RTCRtpReceiver) have an internally/random id which does not match
|
|
1017
|
+ // the track id signaled in the remote SDP. The shim adds a custom
|
|
1018
|
+ // jitsi-id property with the original track id.
|
|
1019
|
+ this.getTrackID = track => track.jitsiRemoteId || track.id;
|
1028
|
1020
|
} else {
|
1029
|
|
- logger.error('Endpoint does not appear to be WebRTC-capable');
|
|
1021
|
+ const message = 'Endpoint does not appear to be WebRTC-capable';
|
1030
|
1022
|
|
1031
|
|
- throw new Error('Unsupporded endpoint');
|
|
1023
|
+ logger.error(message);
|
|
1024
|
+ throw new Error(message);
|
1032
|
1025
|
}
|
1033
|
1026
|
|
1034
|
1027
|
this._initPCConstraints(options);
|
1035
|
1028
|
|
1036
|
1029
|
screenObtainer.init(
|
1037
|
|
- options, this.getUserMediaWithConstraints.bind(this));
|
|
1030
|
+ options,
|
|
1031
|
+ this.getUserMediaWithConstraints.bind(this));
|
1038
|
1032
|
|
1039
|
|
- if (this.isDeviceListAvailable()
|
1040
|
|
- && rawEnumerateDevicesWithCallback) {
|
|
1033
|
+ if (this.isDeviceListAvailable() && rawEnumerateDevicesWithCallback) {
|
1041
|
1034
|
rawEnumerateDevicesWithCallback(ds => {
|
1042
|
1035
|
availableDevices = ds.splice(0);
|
1043
|
1036
|
|
1044
|
1037
|
logger.debug('Available devices: ', availableDevices);
|
1045
|
1038
|
sendDeviceListToAnalytics(availableDevices);
|
1046
|
1039
|
|
1047
|
|
- eventEmitter.emit(RTCEvents.DEVICE_LIST_AVAILABLE,
|
|
1040
|
+ eventEmitter.emit(
|
|
1041
|
+ RTCEvents.DEVICE_LIST_AVAILABLE,
|
1048
|
1042
|
availableDevices);
|
1049
|
1043
|
|
1050
|
1044
|
if (isDeviceChangeEventSupported) {
|
1051
|
1045
|
navigator.mediaDevices.addEventListener(
|
1052
|
1046
|
'devicechange',
|
1053
|
|
- () => this.enumerateDevices(
|
1054
|
|
- onMediaDevicesListChanged));
|
|
1047
|
+ () => this.enumerateDevices(onMediaDevicesListChanged));
|
1055
|
1048
|
} else {
|
1056
|
1049
|
pollForAvailableMediaDevices();
|
1057
|
1050
|
}
|
|
@@ -1617,10 +1610,10 @@ class RTCUtils extends Listenable {
|
1617
|
1610
|
}
|
1618
|
1611
|
|
1619
|
1612
|
/**
|
1620
|
|
- * Checks if its possible to enumerate available cameras/microphones.
|
|
1613
|
+ * Checks whether it is possible to enumerate available cameras/microphones.
|
1621
|
1614
|
*
|
1622
|
|
- * @returns {boolean} true if the device listing is available or false
|
1623
|
|
- * otherwise.
|
|
1615
|
+ * @returns {boolean} {@code true} if the device listing is available;
|
|
1616
|
+ * {@code false}, otherwise.
|
1624
|
1617
|
*/
|
1625
|
1618
|
isDeviceListAvailable() {
|
1626
|
1619
|
return Boolean(
|