|
@@ -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': [
|