Selaa lähdekoodia

feat(BworserCapabilities): Allow newer Safari to use video

dev1
Alexander Mishurov 7 vuotta sitten
vanhempi
commit
9659b4e413

+ 1
- 0
modules/RTC/RTCUtils.js Näytä tiedosto

@@ -179,6 +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 183
             || browser.isEdge()
183 184
             || browser.isReactNative();
184 185
 

+ 11
- 11
modules/RTC/TraceablePeerConnection.js Näytä tiedosto

@@ -1435,8 +1435,8 @@ TraceablePeerConnection.prototype._addStream = function(mediaStream) {
1435 1435
  * @param {MediaStream} mediaStream
1436 1436
  */
1437 1437
 TraceablePeerConnection.prototype._removeStream = function(mediaStream) {
1438
-    if (browser.isFirefox()) {
1439
-        this._handleFirefoxRemoveStream(mediaStream);
1438
+    if (browser.supportsRtpSender()) {
1439
+        this._handleSenderRemoveStream(mediaStream);
1440 1440
     } else {
1441 1441
         this.peerconnection.removeStream(mediaStream);
1442 1442
     }
@@ -1500,8 +1500,8 @@ TraceablePeerConnection.prototype.removeTrack = function(localTrack) {
1500 1500
     this.localSSRCs.delete(localTrack.rtcId);
1501 1501
 
1502 1502
     if (webRtcStream) {
1503
-        if (browser.isFirefox()) {
1504
-            this._handleFirefoxRemoveStream(webRtcStream);
1503
+        if (browser.supportsRtpSender()) {
1504
+            this._handleSenderRemoveStream(webRtcStream);
1505 1505
         } else {
1506 1506
             this.peerconnection.removeStream(webRtcStream);
1507 1507
         }
@@ -1541,7 +1541,7 @@ TraceablePeerConnection.prototype.findSenderByStream = function(stream) {
1541 1541
  * renegotiation will be needed. Otherwise no renegotiation is needed.
1542 1542
  */
1543 1543
 TraceablePeerConnection.prototype.replaceTrack = function(oldTrack, newTrack) {
1544
-    if (browser.isFirefox() && oldTrack && newTrack) {
1544
+    if (browser.supportsRtpSender() && oldTrack && newTrack) {
1545 1545
         // Add and than remove stream in FF leads to wrong local SDP. In order
1546 1546
         // to workaround the issue we need to use sender.replaceTrack().
1547 1547
         const sender = this.findSenderByStream(oldTrack.getOriginalStream());
@@ -1628,10 +1628,10 @@ TraceablePeerConnection.prototype.removeTrackMute = function(localTrack) {
1628 1628
 };
1629 1629
 
1630 1630
 /**
1631
- * Remove stream handling for firefox
1631
+ * Remove stream handling for browsers supporting RTPSender
1632 1632
  * @param stream: webrtc media stream
1633 1633
  */
1634
-TraceablePeerConnection.prototype._handleFirefoxRemoveStream = function(
1634
+TraceablePeerConnection.prototype._handleSenderRemoveStream = function(
1635 1635
         stream) {
1636 1636
     if (!stream) {
1637 1637
         // There is nothing to be changed
@@ -1924,7 +1924,7 @@ TraceablePeerConnection.prototype.setRemoteDescription = function(description) {
1924 1924
 
1925 1925
     // Safari WebRTC errors when no supported video codec is found in the offer.
1926 1926
     // To prevent the error, inject H264 into the video mLine.
1927
-    if (browser.isSafariWithWebrtc()) {
1927
+    if (browser.isSafariWithWebrtc() && !browser.isSafariWithVP8()) {
1928 1928
         logger.debug('Maybe injecting H264 into the remote description');
1929 1929
 
1930 1930
         // eslint-disable-next-line no-param-reassign
@@ -2160,10 +2160,10 @@ const _fixAnswerRFC4145Setup = function(offer, answer) {
2160 2160
 };
2161 2161
 
2162 2162
 TraceablePeerConnection.prototype.createAnswer = function(constraints) {
2163
-    if (browser.supportsRtpSender() && this.isSimulcastOn()) {
2163
+    if (browser.isFirefox() && this.isSimulcastOn()) {
2164 2164
         const videoSender
2165 2165
             = this.peerconnection.getSenders().find(sender =>
2166
-                sender.track.kind === 'video');
2166
+                sender.track !== null && sender.track.kind === 'video');
2167 2167
         const simParams = {
2168 2168
             encodings: [
2169 2169
                 {
@@ -2227,7 +2227,7 @@ TraceablePeerConnection.prototype._createOfferOrAnswer = function(
2227 2227
              *  after that, when we try and go back to unified plan it will
2228 2228
              *  complain about unmapped ssrcs)
2229 2229
              */
2230
-            if (!browser.isFirefox()) {
2230
+            if (!browser.usesUnifiedPlan()) {
2231 2231
                 // If there are no local video tracks, then a "recvonly"
2232 2232
                 // SSRC needs to be generated
2233 2233
                 if (!this.hasAnyTracksOfType(MediaType.VIDEO)

+ 37
- 10
modules/browser/BrowserCapabilities.js Näytä tiedosto

@@ -77,6 +77,17 @@ export default class BrowserCapabilities extends BrowserDetection {
77 77
             && !this.isVersionLessThan('11');
78 78
     }
79 79
 
80
+    /**
81
+     * Checks if current browser is a Safari and a version of Safari that
82
+     * supports VP8.
83
+     *
84
+     * @returns {boolean}
85
+     */
86
+    isSafariWithVP8() {
87
+        return this.isSafari()
88
+            && !this.isVersionLessThan('12.1');
89
+    }
90
+
80 91
     /**
81 92
      * Checks if the current browser is supported.
82 93
      *
@@ -97,7 +108,8 @@ export default class BrowserCapabilities extends BrowserDetection {
97 108
      * otherwise.
98 109
      */
99 110
     supportsVideoMuteOnConnInterrupted() {
100
-        return this.isChromiumBased() || this.isReactNative();
111
+        return this.isChromiumBased() || this.isReactNative()
112
+            || this.isSafariWithVP8();
101 113
     }
102 114
 
103 115
     /**
@@ -161,7 +173,8 @@ export default class BrowserCapabilities extends BrowserDetection {
161 173
      * candidates through the legacy getStats() API.
162 174
      */
163 175
     supportsLocalCandidateRttStatistics() {
164
-        return this.isChromiumBased() || this.isReactNative();
176
+        return this.isChromiumBased() || this.isReactNative()
177
+            || this.isSafariWithVP8();
165 178
     }
166 179
 
167 180
     /**
@@ -187,7 +200,7 @@ export default class BrowserCapabilities extends BrowserDetection {
187 200
      * @returns {boolean}
188 201
      */
189 202
     supportsRtpSender() {
190
-        return this.isFirefox();
203
+        return this.isFirefox() || this.isSafariWithVP8();
191 204
     }
192 205
 
193 206
     /**
@@ -196,7 +209,7 @@ export default class BrowserCapabilities extends BrowserDetection {
196 209
      * @returns {boolean}
197 210
      */
198 211
     supportsRtx() {
199
-        return !this.isFirefox();
212
+        return !this.isFirefox() && !this.usesUnifiedPlan();
200 213
     }
201 214
 
202 215
     /**
@@ -204,8 +217,8 @@ export default class BrowserCapabilities extends BrowserDetection {
204 217
      * @returns {boolean}
205 218
      */
206 219
     supportsSimulcast() {
207
-        return this.isChromiumBased()
208
-            || this.isFirefox() || this.isReactNative();
220
+        return this.isChromiumBased() || this.isFirefox()
221
+            || this.isSafariWithVP8() || this.isReactNative();
209 222
     }
210 223
 
211 224
     /**
@@ -218,9 +231,11 @@ export default class BrowserCapabilities extends BrowserDetection {
218 231
         // FIXME: Check if we can use supportsVideoOut and supportsVideoIn. I
219 232
         // leave the old implementation here in order not to brake something.
220 233
 
221
-        // Currently Safari using webrtc/adapter does not support video due in
222
-        // part to Safari only supporting H264 and the bridge sending VP8.
223
-        return !this.isSafariWithWebrtc();
234
+        // Older versions of Safari using webrtc/adapter do not support video
235
+        // due in part to Safari only supporting H264 and the bridge sending VP8
236
+        // Newer Safari support VP8 and other WebRTC features.
237
+        return !this.isSafariWithWebrtc()
238
+            || (this.isSafariWithVP8() && this.usesPlanB());
224 239
     }
225 240
 
226 241
     /**
@@ -238,7 +253,19 @@ export default class BrowserCapabilities extends BrowserDetection {
238 253
      * @returns {boolean}
239 254
      */
240 255
     usesUnifiedPlan() {
241
-        return this.isFirefox();
256
+        if (this.isFirefox()) {
257
+            return true;
258
+        }
259
+
260
+        if (this.isSafariWithVP8()) {
261
+            // eslint-disable-next-line max-len
262
+            // https://trac.webkit.org/changeset/236144/webkit/trunk/LayoutTests/webrtc/video-addLegacyTransceiver.html
263
+            // eslint-disable-next-line no-undef
264
+            return Object.keys(RTCRtpTransceiver.prototype)
265
+                   .indexOf('currentDirection') > -1;
266
+        }
267
+
268
+        return false;
242 269
     }
243 270
 
244 271
     /**

+ 13
- 28
package-lock.json Näytä tiedosto

@@ -1113,9 +1113,9 @@
1113 1113
       }
1114 1114
     },
1115 1115
     "@jitsi/sdp-interop": {
1116
-      "version": "0.1.13",
1117
-      "resolved": "https://registry.npmjs.org/@jitsi/sdp-interop/-/sdp-interop-0.1.13.tgz",
1118
-      "integrity": "sha512-U/UI1W9NULZj7PgP9GVzWfvIQ4T2LJBvMj4dNKclHqLMXIZ9aSuWEeYe/Q9jB+J7vot+M9ofALtO4w5xifffoQ==",
1116
+      "version": "0.1.14",
1117
+      "resolved": "https://registry.npmjs.org/@jitsi/sdp-interop/-/sdp-interop-0.1.14.tgz",
1118
+      "integrity": "sha512-v60VAtBx9LO46c9In9oMNY+Ho5993UMOLHBg6VcrcyoVTIWIeqs/9YjjmrQ3Sf4I5aMRABNl7HTby/1lHcqFJw==",
1119 1119
       "requires": {
1120 1120
         "sdp-transform": "2.3.0"
1121 1121
       }
@@ -5331,8 +5331,7 @@
5331 5331
             "ansi-regex": {
5332 5332
               "version": "2.1.1",
5333 5333
               "bundled": true,
5334
-              "dev": true,
5335
-              "optional": true
5334
+              "dev": true
5336 5335
             },
5337 5336
             "aproba": {
5338 5337
               "version": "1.2.0",
@@ -5375,8 +5374,7 @@
5375 5374
             "code-point-at": {
5376 5375
               "version": "1.1.0",
5377 5376
               "bundled": true,
5378
-              "dev": true,
5379
-              "optional": true
5377
+              "dev": true
5380 5378
             },
5381 5379
             "concat-map": {
5382 5380
               "version": "0.0.1",
@@ -5387,8 +5385,7 @@
5387 5385
             "console-control-strings": {
5388 5386
               "version": "1.1.0",
5389 5387
               "bundled": true,
5390
-              "dev": true,
5391
-              "optional": true
5388
+              "dev": true
5392 5389
             },
5393 5390
             "core-util-is": {
5394 5391
               "version": "1.0.2",
@@ -5505,8 +5502,7 @@
5505 5502
             "inherits": {
5506 5503
               "version": "2.0.3",
5507 5504
               "bundled": true,
5508
-              "dev": true,
5509
-              "optional": true
5505
+              "dev": true
5510 5506
             },
5511 5507
             "ini": {
5512 5508
               "version": "1.3.5",
@@ -5518,7 +5514,6 @@
5518 5514
               "version": "1.0.0",
5519 5515
               "bundled": true,
5520 5516
               "dev": true,
5521
-              "optional": true,
5522 5517
               "requires": {
5523 5518
                 "number-is-nan": "^1.0.0"
5524 5519
               }
@@ -5541,14 +5536,12 @@
5541 5536
             "minimist": {
5542 5537
               "version": "0.0.8",
5543 5538
               "bundled": true,
5544
-              "dev": true,
5545
-              "optional": true
5539
+              "dev": true
5546 5540
             },
5547 5541
             "minipass": {
5548 5542
               "version": "2.2.4",
5549 5543
               "bundled": true,
5550 5544
               "dev": true,
5551
-              "optional": true,
5552 5545
               "requires": {
5553 5546
                 "safe-buffer": "^5.1.1",
5554 5547
                 "yallist": "^3.0.0"
@@ -5567,7 +5560,6 @@
5567 5560
               "version": "0.5.1",
5568 5561
               "bundled": true,
5569 5562
               "dev": true,
5570
-              "optional": true,
5571 5563
               "requires": {
5572 5564
                 "minimist": "0.0.8"
5573 5565
               }
@@ -5648,8 +5640,7 @@
5648 5640
             "number-is-nan": {
5649 5641
               "version": "1.0.1",
5650 5642
               "bundled": true,
5651
-              "dev": true,
5652
-              "optional": true
5643
+              "dev": true
5653 5644
             },
5654 5645
             "object-assign": {
5655 5646
               "version": "4.1.1",
@@ -5661,7 +5652,6 @@
5661 5652
               "version": "1.4.0",
5662 5653
               "bundled": true,
5663 5654
               "dev": true,
5664
-              "optional": true,
5665 5655
               "requires": {
5666 5656
                 "wrappy": "1"
5667 5657
               }
@@ -5747,8 +5737,7 @@
5747 5737
             "safe-buffer": {
5748 5738
               "version": "5.1.1",
5749 5739
               "bundled": true,
5750
-              "dev": true,
5751
-              "optional": true
5740
+              "dev": true
5752 5741
             },
5753 5742
             "safer-buffer": {
5754 5743
               "version": "2.1.2",
@@ -5784,7 +5773,6 @@
5784 5773
               "version": "1.0.2",
5785 5774
               "bundled": true,
5786 5775
               "dev": true,
5787
-              "optional": true,
5788 5776
               "requires": {
5789 5777
                 "code-point-at": "^1.0.0",
5790 5778
                 "is-fullwidth-code-point": "^1.0.0",
@@ -5804,7 +5792,6 @@
5804 5792
               "version": "3.0.1",
5805 5793
               "bundled": true,
5806 5794
               "dev": true,
5807
-              "optional": true,
5808 5795
               "requires": {
5809 5796
                 "ansi-regex": "^2.0.0"
5810 5797
               }
@@ -5848,14 +5835,12 @@
5848 5835
             "wrappy": {
5849 5836
               "version": "1.0.2",
5850 5837
               "bundled": true,
5851
-              "dev": true,
5852
-              "optional": true
5838
+              "dev": true
5853 5839
             },
5854 5840
             "yallist": {
5855 5841
               "version": "3.0.2",
5856 5842
               "bundled": true,
5857
-              "dev": true,
5858
-              "optional": true
5843
+              "dev": true
5859 5844
             }
5860 5845
           }
5861 5846
         },
@@ -6010,7 +5995,7 @@
6010 5995
     },
6011 5996
     "karma-webpack": {
6012 5997
       "version": "3.0.0",
6013
-      "resolved": "https://registry.npmjs.org/karma-webpack/-/karma-webpack-3.0.0.tgz",
5998
+      "resolved": "http://registry.npmjs.org/karma-webpack/-/karma-webpack-3.0.0.tgz",
6014 5999
       "integrity": "sha512-Ja1o9LLoqWaJyUNhTKaXjWiEH9y7a9H3mzP8pYB30SBsgoF5KBS/65NeHFd+QPuT9ITrym8xFt8BZeGbcOfujA==",
6015 6000
       "dev": true,
6016 6001
       "requires": {

+ 1
- 1
package.json Näytä tiedosto

@@ -16,7 +16,7 @@
16 16
   "author": "",
17 17
   "readmeFilename": "README.md",
18 18
   "dependencies": {
19
-    "@jitsi/sdp-interop": "0.1.13",
19
+    "@jitsi/sdp-interop": "0.1.14",
20 20
     "@jitsi/sdp-simulcast": "0.2.1",
21 21
     "async": "0.9.0",
22 22
     "current-executing-script": "0.1.3",

Loading…
Peruuta
Tallenna