瀏覽代碼

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 9 年之前
父節點
當前提交
285d5a872c
共有 2 個檔案被更改,包括 23 行新增6 行删除
  1. 11
    3
      modules/RTC/JitsiLocalTrack.js
  2. 12
    3
      modules/RTC/RTC.js

+ 11
- 3
modules/RTC/JitsiLocalTrack.js 查看文件

@@ -8,11 +8,12 @@ var RTCUtils = require("./RTCUtils");
8 8
  * @constructor
9 9
  */
10 10
 function JitsiLocalTrack(stream, videoType,
11
-  resolution)
11
+  resolution, deviceId)
12 12
 {
13 13
     this.videoType = videoType;
14 14
     this.dontFireRemoveEvent = false;
15 15
     this.resolution = resolution;
16
+    this.deviceId = deviceId;
16 17
     this.startMuted = false;
17 18
     var self = this;
18 19
     JitsiTrack.call(this, null, stream,
@@ -71,9 +72,16 @@ JitsiLocalTrack.prototype._setMute = function (mute) {
71 72
             //FIXME: Maybe here we should set the SRC for the containers to something
72 73
         } else {
73 74
             var self = this;
74
-            RTCUtils.obtainAudioAndVideoPermissions({
75
+            var streamOptions = {
75 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 85
                 .then(function (streams) {
78 86
                     var stream = null;
79 87
                     for(var i = 0; i < streams.length; i++) {

+ 12
- 3
modules/RTC/RTC.js 查看文件

@@ -11,11 +11,17 @@ var DesktopSharingEventTypes
11 11
 var MediaStreamType = require("../../service/RTC/MediaStreamTypes");
12 12
 var RTCEvents = require("../../service/RTC/RTCEvents.js");
13 13
 
14
-function createLocalTracks(streams) {
14
+function createLocalTracks(streams, options) {
15 15
     var newStreams = []
16
+    var deviceId = null;
16 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 23
         var localStream = new JitsiLocalTrack(streams[i].stream,
18
-            streams[i].videoType, streams[i].resolution);
24
+            streams[i].videoType, streams[i].resolution, deviceId);
19 25
         newStreams.push(localStream);
20 26
         if (streams[i].isMuted === true)
21 27
             localStream.setMute(true);
@@ -73,8 +79,11 @@ function RTC(room, options) {
73 79
  * @param {string} options.micDeviceId
74 80
  * @returns {*} Promise object that will receive the new JitsiTracks
75 81
  */
82
+
76 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 89
 RTC.prototype.onIncommingCall = function(event) {

Loading…
取消
儲存