Selaa lähdekoodia

Merge pull request #108 from jitsi/remove-browser-type-check

Remove browser type check
master
Paweł Domas 9 vuotta sitten
vanhempi
commit
ca9f9a7c7e

+ 8
- 2
JitsiConferenceEvents.js Näytä tiedosto

@@ -4,11 +4,17 @@
4 4
  */
5 5
 var JitsiConferenceEvents = {
6 6
     /**
7
-     * A new media track was added to the conference.
7
+     * A new media track was added to the conference. The event provides the
8
+     * following parameters to its listeners:
9
+     *
10
+     * @param {JitsiTrack} track the added JitsiTrack
8 11
      */
9 12
     TRACK_ADDED: "conference.trackAdded",
10 13
     /**
11
-     * The media track was removed from the conference.
14
+     * The media track was removed from the conference. The event provides the
15
+     * following parameters to its listeners:
16
+     *
17
+     * @param {JitsiTrack} track the removed JitsiTrack
12 18
      */
13 19
     TRACK_REMOVED: "conference.trackRemoved",
14 20
     /**

+ 2
- 1
modules/RTC/JitsiLocalTrack.js Näytä tiedosto

@@ -359,7 +359,8 @@ JitsiLocalTrack.prototype.getSSRC = function () {
359 359
 };
360 360
 
361 361
 /**
362
- * Return true;
362
+ * Returns <tt>true</tt>.
363
+ * @returns {boolean} <tt>true</tt>
363 364
  */
364 365
 JitsiLocalTrack.prototype.isLocal = function () {
365 366
     return true;

+ 2
- 2
modules/RTC/JitsiRemoteTrack.js Näytä tiedosto

@@ -32,7 +32,6 @@ JitsiRemoteTrack.prototype.constructor = JitsiRemoteTrack;
32 32
  * @param value the muted status.
33 33
  */
34 34
 JitsiRemoteTrack.prototype.setMute = function (value) {
35
-
36 35
     if(this.muted === value)
37 36
         return;
38 37
 
@@ -69,7 +68,8 @@ JitsiRemoteTrack.prototype.isLocal = function () {
69 68
 };
70 69
 
71 70
 /**
72
- * Return false;
71
+ * Returns the synchronization source identifier (SSRC) of this remote track.
72
+ * @returns {string} the SSRC of this remote track
73 73
  */
74 74
 JitsiRemoteTrack.prototype.getSSRC = function () {
75 75
     return this.ssrc;

+ 2
- 4
modules/RTC/JitsiTrack.js Näytä tiedosto

@@ -237,8 +237,7 @@ JitsiTrack.prototype.dispose = function () {
237 237
  * Returns true if this is a video track and the source of the video is a
238 238
  * screen capture as opposed to a camera.
239 239
  */
240
-JitsiTrack.prototype.isScreenSharing = function(){
241
-
240
+JitsiTrack.prototype.isScreenSharing = function() {
242 241
 };
243 242
 
244 243
 /**
@@ -268,7 +267,7 @@ JitsiTrack.prototype.getId = function () {
268 267
  * @returns {boolean} whether MediaStream is active.
269 268
  */
270 269
 JitsiTrack.prototype.isActive = function () {
271
-    if((typeof this.stream.active !== "undefined"))
270
+    if(typeof this.stream.active !== "undefined")
272 271
         return this.stream.active;
273 272
     else
274 273
         return true;
@@ -299,7 +298,6 @@ JitsiTrack.prototype.off = function (eventId, handler) {
299 298
 JitsiTrack.prototype.addEventListener = JitsiTrack.prototype.on;
300 299
 JitsiTrack.prototype.removeEventListener = JitsiTrack.prototype.off;
301 300
 
302
-
303 301
 /**
304 302
  * Sets the audio level for the stream
305 303
  * @param audioLevel the new audio level

+ 28
- 29
modules/RTC/RTCUtils.js Näytä tiedosto

@@ -483,9 +483,17 @@ function obtainDevices(options) {
483 483
  */
484 484
 function handleLocalStream(streams, resolution) {
485 485
     var audioStream, videoStream, desktopStream, res = [];
486
-    // If this is FF, the stream parameter is *not* a MediaStream object, it's
487
-    // an object with two properties: audioStream, videoStream.
488
-    if (window.webkitMediaStream) {
486
+
487
+    // XXX The function obtainAudioAndVideoPermissions has examined the type of
488
+    // the browser, its capabilities, etc. and has taken the decision whether to
489
+    // invoke getUserMedia per device (e.g. Firefox) or once for both audio and
490
+    // video (e.g. Chrome). In order to not duplicate the logic here, examine
491
+    // the specified streams and figure out what we've received based on
492
+    // obtainAudioAndVideoPermissions' decision.
493
+    if (streams) {
494
+        // As mentioned above, certian types of browser (e.g. Chrome) support
495
+        // (with a result which meets our requirements expressed bellow) calling
496
+        // getUserMedia once for both audio and video.
489 497
         var audioVideo = streams.audioVideo;
490 498
         if (audioVideo) {
491 499
             var audioTracks = audioVideo.getAudioTracks();
@@ -503,39 +511,34 @@ function handleLocalStream(streams, resolution) {
503 511
                     videoStream.addTrack(videoTracks[j]);
504 512
                 }
505 513
             }
514
+        } else {
515
+          // On other types of browser (e.g. Firefox) we choose (namely,
516
+          // obtainAudioAndVideoPermissions) to call getUsermedia per device
517
+          // (type).
518
+          audioStream = streams.audio;
519
+          videoStream = streams.video;
506 520
         }
507
-
508
-        // FIXME Checking streams here is unnecessary because there's
509
-        // streams.audioVideo above.
510
-        if (streams)
511
-            desktopStream = streams.desktopStream;
512
-
513
-    }
514
-    else if (RTCBrowserType.isFirefox() || RTCBrowserType.isTemasysPluginUsed()) {   // Firefox and Temasys plugin
515
-        if (streams) {
516
-            audioStream = streams.audio;
517
-            videoStream = streams.video;
518
-            desktopStream = streams.desktop;
519
-        }
521
+        // Again, different choices on different types of browser.
522
+        desktopStream = streams.desktopStream || streams.desktop;
520 523
     }
521 524
 
522
-    if (desktopStream)
525
+    if (desktopStream) {
523 526
         res.push({
524 527
             stream: desktopStream,
525 528
             track: desktopStream.getVideoTracks()[0],
526 529
             mediaType: MediaType.VIDEO,
527 530
             videoType: VideoType.DESKTOP
528 531
         });
529
-
530
-    if(audioStream)
532
+    }
533
+    if (audioStream) {
531 534
         res.push({
532 535
             stream: audioStream,
533 536
             track: audioStream.getAudioTracks()[0],
534 537
             mediaType: MediaType.AUDIO,
535 538
             videoType: null
536 539
         });
537
-
538
-    if(videoStream)
540
+    }
541
+    if (videoStream) {
539 542
         res.push({
540 543
             stream: videoStream,
541 544
             track: videoStream.getVideoTracks()[0],
@@ -543,6 +546,7 @@ function handleLocalStream(streams, resolution) {
543 546
             videoType: VideoType.CAMERA,
544 547
             resolution: resolution
545 548
         });
549
+    }
546 550
 
547 551
     return res;
548 552
 }
@@ -653,21 +657,16 @@ var RTCUtils = {
653 657
                     return element;
654 658
                 });
655 659
                 this.getStreamID = function (stream) {
656
-                    // streams from FF endpoints have the characters '{' and '}'
660
+                    // Streams from FF endpoints have the characters '{' and '}'
657 661
                     // that make jQuery choke.
658 662
                     return SDPUtil.filter_special_chars(stream.id);
659 663
                 };
660 664
                 this.getVideoSrc = function (element) {
661
-                    if (!element)
662
-                        return null;
663
-                    return element.getAttribute("src");
665
+                    return element ? element.getAttribute("src") : null;
664 666
                 };
665 667
                 this.setVideoSrc = function (element, src) {
666
-                    if (!src) {
667
-                        src = '';
668
-                    }
669 668
                     if (element)
670
-                        element.setAttribute("src", src);
669
+                        element.setAttribute("src", src || '');
671 670
                 };
672 671
                 // DTLS should now be enabled by default but..
673 672
                 this.pc_constraints = {'optional': [

+ 1
- 1
modules/xmpp/ChatRoom.js Näytä tiedosto

@@ -704,8 +704,8 @@ ChatRoom.prototype.removeListener = function (type, listener) {
704 704
 ChatRoom.prototype.remoteTrackAdded = function(data) {
705 705
     // Will figure out current muted status by looking up owner's presence
706 706
     var pres = this.lastPresences[data.owner];
707
-    var mediaType = data.mediaType;
708 707
     if(pres) {
708
+        var mediaType = data.mediaType;
709 709
         var mutedNode = null;
710 710
         if (mediaType === MediaType.AUDIO) {
711 711
             mutedNode = filterNodeFromPresenceJSON(pres, "audiomuted");

+ 3
- 6
modules/xmpp/JingleSessionPC.js Näytä tiedosto

@@ -1257,7 +1257,7 @@ JingleSessionPC.prototype.remoteTrackAdded = function (stream, track) {
1257 1257
     }
1258 1258
 
1259 1259
     var remoteSDP = new SDP(this.peerconnection.remoteDescription.sdp);
1260
-    var medialines = remoteSDP.media.filter(function (mediaLines){
1260
+    var medialines = remoteSDP.media.filter(function (mediaLines) {
1261 1261
         return mediaLines.startsWith("m=" + mediaType);
1262 1262
     });
1263 1263
 
@@ -1268,11 +1268,8 @@ JingleSessionPC.prototype.remoteTrackAdded = function (stream, track) {
1268 1268
 
1269 1269
     var ssrclines = SDPUtil.find_lines(medialines[0], 'a=ssrc:');
1270 1270
     ssrclines = ssrclines.filter(function (line) {
1271
-        if (RTCBrowserType.isTemasysPluginUsed()) {
1272
-            return ((line.indexOf('mslabel:' + streamId) !== -1));
1273
-        } else {
1274
-            return ((line.indexOf('msid:' + streamId) !== -1));
1275
-        }
1271
+        var msid = RTCBrowserType.isTemasysPluginUsed() ? 'mslabel' : 'msid';
1272
+        return line.indexOf(msid + ':' + streamId) !== -1;
1276 1273
     });
1277 1274
 
1278 1275
     var thessrc;

Loading…
Peruuta
Tallenna