Procházet zdrojové kódy

Add `deviceId` which was used to create `JitsiLocalTrack` to the object to re-use it when unmuting the track

Fixes the issue that when creating local tracks with specific devices after unmuting the new tracks were created with default devices again.
master
Thorsten Basse před 9 roky
rodič
revize
285d5a872c
2 změnil soubory, kde provedl 23 přidání a 6 odebrání
  1. 11
    3
      modules/RTC/JitsiLocalTrack.js
  2. 12
    3
      modules/RTC/RTC.js

+ 11
- 3
modules/RTC/JitsiLocalTrack.js Zobrazit soubor

8
  * @constructor
8
  * @constructor
9
  */
9
  */
10
 function JitsiLocalTrack(stream, videoType,
10
 function JitsiLocalTrack(stream, videoType,
11
-  resolution)
11
+  resolution, deviceId)
12
 {
12
 {
13
     this.videoType = videoType;
13
     this.videoType = videoType;
14
     this.dontFireRemoveEvent = false;
14
     this.dontFireRemoveEvent = false;
15
     this.resolution = resolution;
15
     this.resolution = resolution;
16
+    this.deviceId = deviceId;
16
     this.startMuted = false;
17
     this.startMuted = false;
17
     var self = this;
18
     var self = this;
18
     JitsiTrack.call(this, null, stream,
19
     JitsiTrack.call(this, null, stream,
71
             //FIXME: Maybe here we should set the SRC for the containers to something
72
             //FIXME: Maybe here we should set the SRC for the containers to something
72
         } else {
73
         } else {
73
             var self = this;
74
             var self = this;
74
-            RTCUtils.obtainAudioAndVideoPermissions({
75
+            var streamOptions = {
75
                 devices: (isAudio ? ["audio"] : ["video"]),
76
                 devices: (isAudio ? ["audio"] : ["video"]),
76
-                resolution: self.resolution})
77
+                resolution: self.resolution
78
+            };
79
+            if (isAudio) {
80
+              streamOptions['micDeviceId'] = self.deviceId;
81
+            } else {self.videoType === 'camera'} {
82
+              streamOptions['cameraDeviceId'] = self.deviceId;
83
+            }
84
+            RTCUtils.obtainAudioAndVideoPermissions(streamOptions)
77
                 .then(function (streams) {
85
                 .then(function (streams) {
78
                     var stream = null;
86
                     var stream = null;
79
                     for(var i = 0; i < streams.length; i++) {
87
                     for(var i = 0; i < streams.length; i++) {

+ 12
- 3
modules/RTC/RTC.js Zobrazit soubor

11
 var MediaStreamType = require("../../service/RTC/MediaStreamTypes");
11
 var MediaStreamType = require("../../service/RTC/MediaStreamTypes");
12
 var RTCEvents = require("../../service/RTC/RTCEvents.js");
12
 var RTCEvents = require("../../service/RTC/RTCEvents.js");
13
 
13
 
14
-function createLocalTracks(streams) {
14
+function createLocalTracks(streams, options) {
15
     var newStreams = []
15
     var newStreams = []
16
+    var deviceId = null;
16
     for (var i = 0; i < streams.length; i++) {
17
     for (var i = 0; i < streams.length; i++) {
18
+        if (streams[i].type === 'audio') {
19
+          deviceId = options.micDeviceId;
20
+        } else if (streams[i].videoType === 'camera'){
21
+          deviceId = options.cameraDeviceId;
22
+        }
17
         var localStream = new JitsiLocalTrack(streams[i].stream,
23
         var localStream = new JitsiLocalTrack(streams[i].stream,
18
-            streams[i].videoType, streams[i].resolution);
24
+            streams[i].videoType, streams[i].resolution, deviceId);
19
         newStreams.push(localStream);
25
         newStreams.push(localStream);
20
         if (streams[i].isMuted === true)
26
         if (streams[i].isMuted === true)
21
             localStream.setMute(true);
27
             localStream.setMute(true);
73
  * @param {string} options.micDeviceId
79
  * @param {string} options.micDeviceId
74
  * @returns {*} Promise object that will receive the new JitsiTracks
80
  * @returns {*} Promise object that will receive the new JitsiTracks
75
  */
81
  */
82
+
76
 RTC.obtainAudioAndVideoPermissions = function (options) {
83
 RTC.obtainAudioAndVideoPermissions = function (options) {
77
-    return RTCUtils.obtainAudioAndVideoPermissions(options).then(createLocalTracks);
84
+    return RTCUtils.obtainAudioAndVideoPermissions(options).then(function (streams) {
85
+        return createLocalTracks(streams, options);
86
+    });
78
 }
87
 }
79
 
88
 
80
 RTC.prototype.onIncommingCall = function(event) {
89
 RTC.prototype.onIncommingCall = function(event) {

Načítá se…
Zrušit
Uložit