Просмотр исходного кода

feat(adapter): use with firefox (#628)

* feat(adapter): use with firefox

* squash: add comment about sdptransform workaround
master
virtuacoplenny 7 лет назад
Родитель
Сommit
83436519ed
4 измененных файлов: 19 добавлений и 104 удалений
  1. 2
    37
      modules/RTC/JitsiTrack.js
  2. 3
    2
      modules/RTC/RTCBrowserType.js
  3. 0
    63
      modules/RTC/RTCUtils.js
  4. 14
    2
      modules/xmpp/SDPUtil.js

+ 2
- 37
modules/RTC/JitsiTrack.js Просмотреть файл

3
 import { getLogger } from 'jitsi-meet-logger';
3
 import { getLogger } from 'jitsi-meet-logger';
4
 import * as JitsiTrackEvents from '../../JitsiTrackEvents';
4
 import * as JitsiTrackEvents from '../../JitsiTrackEvents';
5
 import * as MediaType from '../../service/RTC/MediaType';
5
 import * as MediaType from '../../service/RTC/MediaType';
6
-import RTCBrowserType from './RTCBrowserType';
7
 import RTCUtils from './RTCUtils';
6
 import RTCUtils from './RTCUtils';
8
 
7
 
9
 const logger = getLogger(__filename);
8
 const logger = getLogger(__filename);
17
     'track_ended': 'onended'
16
     'track_ended': 'onended'
18
 };
17
 };
19
 
18
 
20
-/**
21
- * This implements 'onended' callback normally fired by WebRTC after the stream
22
- * is stopped. There is no such behaviour yet in FF, so we have to add it.
23
- * @param jitsiTrack our track object holding the original WebRTC stream object
24
- * to which 'onended' handling will be added.
25
- */
26
-function implementOnEndedHandling(jitsiTrack) {
27
-    const stream = jitsiTrack.getOriginalStream();
28
-
29
-    if (!stream) {
30
-        return;
31
-    }
32
-
33
-    const originalStop = stream.stop;
34
-
35
-    stream.stop = function() {
36
-        originalStop.apply(stream);
37
-        if (jitsiTrack.isActive()) {
38
-            stream.onended();
39
-        }
40
-    };
41
-}
42
-
43
 /**
19
 /**
44
  * Adds onended/oninactive handler to a MediaStream.
20
  * Adds onended/oninactive handler to a MediaStream.
45
  * @param mediaStream a MediaStream to attach onended/oninactive handler
21
  * @param mediaStream a MediaStream to attach onended/oninactive handler
119
 
95
 
120
     /* eslint-enable max-params */
96
     /* eslint-enable max-params */
121
 
97
 
122
-    /**
123
-     * Binds the inactive handler.
124
-     * @param {Function} streamInactiveHandler
125
-     * @private
126
-     */
127
-    _bindInactiveHandler(streamInactiveHandler) {
128
-        if (RTCBrowserType.isFirefox()) {
129
-            implementOnEndedHandling(this);
130
-        }
131
-        addMediaStreamInactiveHandler(this.stream, streamInactiveHandler);
132
-    }
133
-
134
     /**
98
     /**
135
      * Sets handler to the WebRTC MediaStream or MediaStreamTrack object
99
      * Sets handler to the WebRTC MediaStream or MediaStreamTrack object
136
      * depending on the passed type.
100
      * depending on the passed type.
203
                 this._setHandler(type, this.handlers.get(type));
167
                 this._setHandler(type, this.handlers.get(type));
204
             }
168
             }
205
             if (this._streamInactiveHandler) {
169
             if (this._streamInactiveHandler) {
206
-                this._bindInactiveHandler(this._streamInactiveHandler);
170
+                addMediaStreamInactiveHandler(
171
+                    this.stream, this._streamInactiveHandler);
207
             }
172
             }
208
         }
173
         }
209
     }
174
     }

+ 3
- 2
modules/RTC/RTCBrowserType.js Просмотреть файл

164
      * @returns {boolean}
164
      * @returns {boolean}
165
      */
165
      */
166
     usesNewGumFlow() {
166
     usesNewGumFlow() {
167
-        return RTCBrowserType.isChrome()
168
-            && RTCBrowserType.getChromeVersion() >= 61;
167
+        return (RTCBrowserType.isChrome()
168
+            && RTCBrowserType.getChromeVersion() >= 61)
169
+            || RTCBrowserType.isFirefox();
169
     },
170
     },
170
 
171
 
171
     /**
172
     /**

+ 0
- 63
modules/RTC/RTCUtils.js Просмотреть файл

5
           RTCIceCandidate: true,
5
           RTCIceCandidate: true,
6
           RTCPeerConnection,
6
           RTCPeerConnection,
7
           RTCSessionDescription: true,
7
           RTCSessionDescription: true,
8
-          mozRTCIceCandidate,
9
-          mozRTCPeerConnection,
10
-          mozRTCSessionDescription,
11
           webkitMediaStream,
8
           webkitMediaStream,
12
           webkitRTCPeerConnection,
9
           webkitRTCPeerConnection,
13
           webkitURL
10
           webkitURL
911
                 };
908
                 };
912
                 this.getStreamID = stream => stream.id;
909
                 this.getStreamID = stream => stream.id;
913
                 this.getTrackID = track => track.id;
910
                 this.getTrackID = track => track.id;
914
-            } else if (RTCBrowserType.isFirefox()) {
915
-                const FFversion = RTCBrowserType.getFirefoxVersion();
916
-
917
-                if (FFversion < 40) {
918
-                    rejectWithWebRTCNotSupported(
919
-                        `Firefox version too old: ${FFversion}.`
920
-                            + ' Required >= 40.',
921
-                        reject);
922
-
923
-                    return;
924
-                }
925
-                this.RTCPeerConnectionType = mozRTCPeerConnection;
926
-                this.getUserMedia
927
-                    = wrapGetUserMedia(
928
-                        navigator.mozGetUserMedia.bind(navigator));
929
-                this.enumerateDevices = rawEnumerateDevicesWithCallback;
930
-                this.pcConstraints = {};
931
-                this.attachMediaStream
932
-                    = wrapAttachMediaStream((element, stream) => {
933
-                        // srcObject is being standardized and FF will
934
-                        // eventually support that unprefixed. FF also supports
935
-                        // the "element.src = URL.createObjectURL(...)" combo,
936
-                        // but that will be deprecated in favour of srcObject.
937
-                        //
938
-                        // https://groups.google.com/forum/#!topic/
939
-                        // mozilla.dev.media/pKOiioXonJg
940
-                        // https://github.com/webrtc/samples/issues/302
941
-                        if (element) {
942
-                            defaultSetVideoSrc(element, stream);
943
-                            if (stream) {
944
-                                element.play();
945
-                            }
946
-                        }
947
-
948
-                        return element;
949
-                    });
950
-                this.getStreamID = function(stream) {
951
-                    let id = stream.id;
952
-
953
-                    if (!id) {
954
-                        let tracks = stream.getVideoTracks();
955
-
956
-                        if (!tracks || tracks.length === 0) {
957
-                            tracks = stream.getAudioTracks();
958
-                        }
959
-                        id = tracks[0].id;
960
-                    }
961
-
962
-                    return SDPUtil.filterSpecialChars(id);
963
-                };
964
-                this.getTrackID = function(track) {
965
-                    return track.id;
966
-                };
967
-
968
-                /* eslint-disable no-global-assign, no-native-reassign */
969
-                RTCSessionDescription = mozRTCSessionDescription;
970
-                RTCIceCandidate = mozRTCIceCandidate;
971
-
972
-                /* eslint-enable no-global-assign, no-native-reassign */
973
-
974
             } else if (RTCBrowserType.isOpera()
911
             } else if (RTCBrowserType.isOpera()
975
                     || RTCBrowserType.isNWJS()
912
                     || RTCBrowserType.isNWJS()
976
                     || RTCBrowserType.isElectron()
913
                     || RTCBrowserType.isElectron()

+ 14
- 2
modules/xmpp/SDPUtil.js Просмотреть файл

587
             }
587
             }
588
         }
588
         }
589
         if (payloadType) {
589
         if (payloadType) {
590
+            // Call toString() on payloads to get around an issue within
591
+            // SDPTransform that sets payloads as a number, instead of a string,
592
+            // when there is only one payload.
590
             const payloadTypes
593
             const payloadTypes
591
-                = videoMLine.payloads.split(' ').map(p => parseInt(p, 10));
594
+                = videoMLine.payloads
595
+                    .toString()
596
+                    .split(' ')
597
+                    .map(p => parseInt(p, 10));
592
             const payloadIndex = payloadTypes.indexOf(payloadType);
598
             const payloadIndex = payloadTypes.indexOf(payloadType);
593
 
599
 
594
             payloadTypes.splice(payloadIndex, 1);
600
             payloadTypes.splice(payloadIndex, 1);
629
 
635
 
630
             removePts.push(...rtxPts.map(item => item.payload));
636
             removePts.push(...rtxPts.map(item => item.payload));
631
 
637
 
632
-            const allPts = videoMLine.payloads.split(' ').map(Number);
638
+            // Call toString() on payloads to get around an issue within
639
+            // SDPTransform that sets payloads as a number, instead of a string,
640
+            // when there is only one payload.
641
+            const allPts = videoMLine.payloads
642
+                .toString()
643
+                .split(' ')
644
+                .map(Number);
633
             const keepPts = allPts.filter(pt => removePts.indexOf(pt) === -1);
645
             const keepPts = allPts.filter(pt => removePts.indexOf(pt) === -1);
634
 
646
 
635
             if (keepPts.length === 0) {
647
             if (keepPts.length === 0) {

Загрузка…
Отмена
Сохранить