Переглянути джерело

feat(Safari): Add unified plan support for Safari

Enabled desktop sharing and discontinue support for Safari versions prior to 12.1, i.e., the ones with no VP8 support
dev1
Jaya Allamsetty 5 роки тому
джерело
коміт
3882a82f8f

+ 2
- 2
modules/RTC/RTCUtils.js Переглянути файл

@@ -179,7 +179,7 @@ function getConstraints(um, options = {}) {
179 179
     // @see https://github.com/jitsi/lib-jitsi-meet/pull/136
180 180
     const isNewStyleConstraintsSupported
181 181
         = browser.isFirefox()
182
-            || browser.isSafariWithVP8()
182
+            || browser.isSafari()
183 183
             || browser.isReactNative();
184 184
 
185 185
     if (um.indexOf('video') >= 0) {
@@ -1435,7 +1435,7 @@ class RTCUtils extends Listenable {
1435 1435
     isDeviceChangeAvailable(deviceType) {
1436 1436
         return deviceType === 'output' || deviceType === 'audiooutput'
1437 1437
             ? isAudioOutputDeviceChangeAvailable
1438
-            : !browser.isSafariWithVP8();
1438
+            : !browser.isSafari();
1439 1439
     }
1440 1440
 
1441 1441
     /**

+ 2
- 0
modules/RTC/ScreenObtainer.js Переглянути файл

@@ -142,6 +142,8 @@ const ScreenObtainer = {
142 142
 
143 143
             // Legacy Firefox
144 144
             return this.obtainScreenOnFirefox;
145
+        } else if (browser.isSafari() && browser.supportsGetDisplayMedia()) {
146
+            return this.obtainScreenFromGetDisplayMedia;
145 147
         }
146 148
 
147 149
         logger.log(

+ 6
- 21
modules/RTC/TPCUtils.js Переглянути файл

@@ -193,8 +193,7 @@ export class TPCUtils {
193 193
     /**
194 194
      * Adds a track on the RTCRtpSender as part of the unmute operation.
195 195
      * @param {JitsiLocalTrack} localTrack - track to be unmuted.
196
-     * @returns {boolean} Returns true if the operation is successful,
197
-     * false otherwise.
196
+     * @returns {Promise<void>}
198 197
      */
199 198
     addTrackUnmute(localTrack) {
200 199
         const mediaType = localTrack.getType();
@@ -222,24 +221,17 @@ export class TPCUtils {
222 221
 
223 222
             return true;
224 223
         }
225
-        transceiver.sender.replaceTrack(track)
224
+
225
+        return transceiver.sender.replaceTrack(track)
226 226
             .then(() => {
227 227
                 this.pc.localTracks.set(localTrack.rtcId, localTrack);
228
-
229
-                return true;
230
-            })
231
-            .catch(err => {
232
-                logger.error(`Unmute track failed for ${mediaType} track on ${this.pc}, ${err}`);
233
-
234
-                return false;
235 228
             });
236 229
     }
237 230
 
238 231
     /**
239 232
      * Removes the track from the RTCRtpSender as part of the mute operation.
240 233
      * @param {JitsiLocalTrack} localTrack - track to be removed.
241
-     * @returns {boolean} Returns true if the operation is successful,
242
-     * false otherwise.
234
+     * @returns {Promise<void>}
243 235
      */
244 236
     removeTrackMute(localTrack) {
245 237
         const mediaType = localTrack.getType();
@@ -253,17 +245,10 @@ export class TPCUtils {
253 245
         }
254 246
 
255 247
         logger.debug(`Removing ${localTrack} on ${this.pc}`);
256
-        transceiver.sender.replaceTrack(null)
248
+
249
+        return transceiver.sender.replaceTrack(null)
257 250
             .then(() => {
258 251
                 this.pc.localTracks.delete(localTrack.rtcId);
259
-                this.pc.localSSRCs.delete(localTrack.rtcId);
260
-
261
-                return true;
262
-            })
263
-            .catch(err => {
264
-                logger.error(`Mute track failed for ${mediaType} track on ${this.pc}, ${err}`);
265
-
266
-                return false;
267 252
             });
268 253
     }
269 254
 

+ 7
- 8
modules/RTC/TraceablePeerConnection.js Переглянути файл

@@ -1481,15 +1481,15 @@ TraceablePeerConnection.prototype.addTrack = function(track, isInitiator = false
1481 1481
  * the renegotiation is required or <tt>false</tt> otherwise.
1482 1482
  */
1483 1483
 TraceablePeerConnection.prototype.addTrackUnmute = function(track) {
1484
+    if (browser.usesUnifiedPlan()) {
1485
+        return this.tpcUtils.addTrackUnmute(track);
1486
+    }
1484 1487
     if (!this._assertTrackBelongs('addTrackUnmute', track)) {
1485 1488
         // Abort
1486 1489
         return false;
1487 1490
     }
1488 1491
 
1489 1492
     logger.info(`Adding ${track} as unmute to ${this}`);
1490
-    if (browser.usesUnifiedPlan()) {
1491
-        return this.tpcUtils.addTrackUnmute(track);
1492
-    }
1493 1493
     const webRtcStream = track.getOriginalStream();
1494 1494
 
1495 1495
     if (!webRtcStream) {
@@ -1680,6 +1680,9 @@ TraceablePeerConnection.prototype.replaceTrack = function(oldTrack, newTrack) {
1680 1680
  * changed and the renegotiation is required or <tt>false</tt> otherwise.
1681 1681
  */
1682 1682
 TraceablePeerConnection.prototype.removeTrackMute = function(localTrack) {
1683
+    if (browser.usesUnifiedPlan()) {
1684
+        return this.tpcUtils.removeTrackMute(localTrack);
1685
+    }
1683 1686
     const webRtcStream = localTrack.getOriginalStream();
1684 1687
 
1685 1688
     this.trace(
@@ -1690,9 +1693,6 @@ TraceablePeerConnection.prototype.removeTrackMute = function(localTrack) {
1690 1693
         // Abort - nothing to be done here
1691 1694
         return false;
1692 1695
     }
1693
-    if (browser.usesUnifiedPlan()) {
1694
-        return this.tpcUtils.removeTrackMute(localTrack);
1695
-    }
1696 1696
     if (webRtcStream) {
1697 1697
         logger.info(
1698 1698
             `Removing ${localTrack} as mute from ${this}`);
@@ -2480,8 +2480,7 @@ TraceablePeerConnection.prototype.getStats = function(callback, errback) {
2480 2480
     // TODO (brian): After moving all browsers to adapter, check if adapter is
2481 2481
     // accounting for different getStats apis, making the browser-checking-if
2482 2482
     // unnecessary.
2483
-    if (browser.isSafariWithWebrtc() || browser.isFirefox()
2484
-            || browser.isReactNative()) {
2483
+    if (browser.isSafari() || browser.isFirefox() || browser.isReactNative()) {
2485 2484
         // uses the new Promise based getStats
2486 2485
         this.peerconnection.getStats()
2487 2486
             .then(callback)

+ 11
- 42
modules/browser/BrowserCapabilities.js Переглянути файл

@@ -30,7 +30,7 @@ export default class BrowserCapabilities extends BrowserDetection {
30 30
      * strategy or <tt>false</tt> otherwise.
31 31
      */
32 32
     doesVideoMuteByStreamRemove() {
33
-        return this.isChromiumBased();
33
+        return this.isChromiumBased() || this.isSafari();
34 34
     }
35 35
 
36 36
     /**
@@ -61,28 +61,6 @@ export default class BrowserCapabilities extends BrowserDetection {
61 61
             || this.isOpera();
62 62
     }
63 63
 
64
-    /**
65
-     * Checks if current browser is a Safari and a version of Safari that
66
-     * supports native webrtc.
67
-     *
68
-     * @returns {boolean}
69
-     */
70
-    isSafariWithWebrtc() {
71
-        return this.isSafari()
72
-            && !this.isVersionLessThan('11');
73
-    }
74
-
75
-    /**
76
-     * Checks if current browser is a Safari and a version of Safari that
77
-     * supports VP8.
78
-     *
79
-     * @returns {boolean}
80
-     */
81
-    isSafariWithVP8() {
82
-        return this.isSafari()
83
-            && !this.isVersionLessThan('12.1');
84
-    }
85
-
86 64
     /**
87 65
      * Checks if the current browser is supported.
88 66
      *
@@ -92,7 +70,7 @@ export default class BrowserCapabilities extends BrowserDetection {
92 70
         return this.isChromiumBased()
93 71
             || this.isFirefox()
94 72
             || this.isReactNative()
95
-            || this.isSafariWithWebrtc();
73
+            || (this.isSafari() && !this.isVersionLessThan('12.1'));
96 74
     }
97 75
 
98 76
     /**
@@ -112,8 +90,7 @@ export default class BrowserCapabilities extends BrowserDetection {
112 90
      * otherwise.
113 91
      */
114 92
     supportsVideoMuteOnConnInterrupted() {
115
-        return this.isChromiumBased() || this.isReactNative()
116
-            || this.isSafariWithVP8();
93
+        return this.isChromiumBased() || this.isReactNative() || this.isSafari();
117 94
     }
118 95
 
119 96
     /**
@@ -124,7 +101,7 @@ export default class BrowserCapabilities extends BrowserDetection {
124 101
     supportsBandwidthStatistics() {
125 102
         // FIXME bandwidth stats are currently not implemented for FF on our
126 103
         // side, but not sure if not possible ?
127
-        return !this.isFirefox() && !this.isSafariWithWebrtc();
104
+        return !this.isFirefox() && !this.isSafari();
128 105
     }
129 106
 
130 107
     /**
@@ -142,8 +119,7 @@ export default class BrowserCapabilities extends BrowserDetection {
142 119
      * candidates through the legacy getStats() API.
143 120
      */
144 121
     supportsLocalCandidateRttStatistics() {
145
-        return this.isChromiumBased() || this.isReactNative()
146
-            || this.isSafariWithVP8();
122
+        return this.isChromiumBased() || this.isReactNative() || this.isSafari();
147 123
     }
148 124
 
149 125
     /**
@@ -169,7 +145,7 @@ export default class BrowserCapabilities extends BrowserDetection {
169 145
      * @returns {boolean}
170 146
      */
171 147
     supportsRtpSender() {
172
-        return this.isFirefox() || this.isSafariWithVP8();
148
+        return this.isFirefox() || this.isSafari();
173 149
     }
174 150
 
175 151
     /**
@@ -178,7 +154,7 @@ export default class BrowserCapabilities extends BrowserDetection {
178 154
      * @returns {boolean}
179 155
      */
180 156
     supportsRtx() {
181
-        return !this.isFirefox() && !this.usesUnifiedPlan();
157
+        return !this.isFirefox();
182 158
     }
183 159
 
184 160
     /**
@@ -188,14 +164,7 @@ export default class BrowserCapabilities extends BrowserDetection {
188 164
      * @returns {boolean}
189 165
      */
190 166
     supportsVideo() {
191
-        // FIXME: Check if we can use supportsVideoOut and supportsVideoIn. I
192
-        // leave the old implementation here in order not to brake something.
193
-
194
-        // Older versions of Safari using webrtc/adapter do not support video
195
-        // due in part to Safari only supporting H264 and the bridge sending VP8
196
-        // Newer Safari support VP8 and other WebRTC features.
197
-        return !this.isSafariWithWebrtc()
198
-            || (this.isSafariWithVP8() && this.usesPlanB());
167
+        return true;
199 168
     }
200 169
 
201 170
     /**
@@ -213,7 +182,7 @@ export default class BrowserCapabilities extends BrowserDetection {
213 182
      * @returns {boolean}
214 183
      */
215 184
     usesSdpMungingForSimulcast() {
216
-        return this.isChromiumBased() || this.isSafariWithVP8();
185
+        return this.isChromiumBased() || this.isSafari();
217 186
     }
218 187
 
219 188
     /**
@@ -226,7 +195,7 @@ export default class BrowserCapabilities extends BrowserDetection {
226 195
             return true;
227 196
         }
228 197
 
229
-        if (this.isSafariWithVP8() && typeof window.RTCRtpTransceiver !== 'undefined') {
198
+        if (this.isSafari() && typeof window.RTCRtpTransceiver !== 'undefined') {
230 199
             // eslint-disable-next-line max-len
231 200
             // https://trac.webkit.org/changeset/236144/webkit/trunk/LayoutTests/webrtc/video-addLegacyTransceiver.html
232 201
             // eslint-disable-next-line no-undef
@@ -252,7 +221,7 @@ export default class BrowserCapabilities extends BrowserDetection {
252 221
             return !this.isVersionLessThan(REQUIRED_CHROME_VERSION);
253 222
         }
254 223
 
255
-        if (this.isFirefox() || this.isSafariWithWebrtc()) {
224
+        if (this.isFirefox() || this.isSafari()) {
256 225
             return true;
257 226
         }
258 227
 

+ 1
- 1
modules/statistics/RTPStatsCollector.js Переглянути файл

@@ -215,7 +215,7 @@ export default function StatsCollector(
215 215
      * @type {boolean}
216 216
      */
217 217
     this._usesPromiseGetStats
218
-        = browser.isSafariWithWebrtc() || browser.isFirefox();
218
+        = browser.isSafari() || browser.isFirefox();
219 219
 
220 220
     /**
221 221
      * The function which is to be used to retrieve the value associated in a

Завантаження…
Відмінити
Зберегти