浏览代码

Name the var what it really is and detect potential issue

We were assigning the var, before the type was compared which
could result in accepting "audio" stream for "video" JitsiLocalTrack.
master
paweldomas 9 年前
父节点
当前提交
02d631075d
共有 1 个文件被更改,包括 20 次插入9 次删除
  1. 20
    9
      modules/RTC/JitsiLocalTrack.js

+ 20
- 9
modules/RTC/JitsiLocalTrack.js 查看文件

@@ -1,4 +1,5 @@
1
-/* global Promise */
1
+/* global __filename, Promise */
2
+var logger = require("jitsi-meet-logger").getLogger(__filename);
2 3
 var JitsiTrack = require("./JitsiTrack");
3 4
 var RTCBrowserType = require("./RTCBrowserType");
4 5
 var JitsiTrackEvents = require('../../JitsiTrackEvents');
@@ -137,6 +138,9 @@ JitsiLocalTrack.prototype._setMute = function (mute, resolve, reject) {
137 138
             //FIXME: Maybe here we should set the SRC for the containers to something
138 139
         } else {
139 140
             var self = this;
141
+            // FIXME why are we doing all this audio type checks and
142
+            // convoluted scenarios if we're going this way only
143
+            // for VIDEO media and CAMERA type of video ?
140 144
             var streamOptions = {
141 145
                 devices: (isAudio ? ["audio"] : ["video"]),
142 146
                 resolution: self.resolution
@@ -147,18 +151,25 @@ JitsiLocalTrack.prototype._setMute = function (mute, resolve, reject) {
147 151
                 streamOptions['cameraDeviceId'] = self.deviceId;
148 152
             }
149 153
             RTCUtils.obtainAudioAndVideoPermissions(streamOptions)
150
-                .then(function (streams) {
151
-                    var stream = null;
152
-                    for(var i = 0; i < streams.length; i++) {
153
-                        stream = streams[i];
154
-                        if(stream.type === self.type) {
155
-                            self.stream = stream.stream;
156
-                            self.videoType = stream.videoType;
154
+                .then(function (streamsInfo) {
155
+                    var streamInfo = null;
156
+                    for(var i = 0; i < streamsInfo.length; i++) {
157
+                        if(streamsInfo[i].type === self.type) {
158
+                            streamInfo = streamsInfo[i];
159
+                            self.stream = streamInfo.stream;
160
+                            // This is not good when video type changes after
161
+                            // unmute, but let's not crash here
162
+                            if (self.videoType != streamInfo.videoType) {
163
+                                logger.error(
164
+                                    "Video type has changed after unmute!",
165
+                                    self.videoType, streamInfo.videoType);
166
+                                self.videoType = streamInfo.videoType;
167
+                            }
157 168
                             break;
158 169
                         }
159 170
                     }
160 171
 
161
-                    if(!stream) {
172
+                    if(!streamInfo) {
162 173
                         reject(new Error('track.no_stream_found'));
163 174
                         return;
164 175
                     }

正在加载...
取消
保存