浏览代码

Don't mix old and new-style for gUM constraints for Chrome, as it falls with TypeError in new Chrome versions

tags/v0.0.2
tsareg 9 年前
父节点
当前提交
4a6e28f416
共有 1 个文件被更改,包括 27 次插入7 次删除
  1. 27
    7
      modules/RTC/RTCUtils.js

+ 27
- 7
modules/RTC/RTCUtils.js 查看文件

@@ -114,9 +114,14 @@ function getConstraints(um, options) {
114 114
         constraints.video = { mandatory: {}, optional: [] };
115 115
 
116 116
         if (options.cameraDeviceId) {
117
-            // new style of settings device id (FF only)
118
-            constraints.video.deviceId = options.cameraDeviceId;
119
-            // old style
117
+            // Don't mix new and old style settings for Chrome as this leads to
118
+            // TypeError in new Chrome versions. @see
119
+            // https://bugs.chromium.org/p/chromium/issues/detail?id=614716
120
+            if (!RTCBrowserType.isChrome()) {
121
+                // New style of setting device id.
122
+                constraints.video.deviceId = options.cameraDeviceId;
123
+            }
124
+            // Old style.
120 125
             constraints.video.optional.push({
121 126
                 sourceId: options.cameraDeviceId
122 127
             });
@@ -126,7 +131,17 @@ function getConstraints(um, options) {
126 131
             // TODO: Maybe use "exact" syntax if options.facingMode is defined,
127 132
             // but this probably needs to be decided when updating other
128 133
             // constraints, as we currently don't use "exact" syntax anywhere.
129
-            constraints.video.facingMode = options.facingMode || 'user';
134
+
135
+            // Don't mix new and old style settings for Chrome as this leads to
136
+            // TypeError in new Chrome versions. @see
137
+            // https://bugs.chromium.org/p/chromium/issues/detail?id=614716
138
+            if (!RTCBrowserType.isChrome()) {
139
+                constraints.video.facingMode = options.facingMode || 'user';
140
+            }
141
+
142
+            constraints.video.optional.push({
143
+                facingMode: options.facingMode || 'user'
144
+            });
130 145
         }
131 146
 
132 147
         constraints.video.optional.push({ googLeakyBucket: true });
@@ -142,9 +157,14 @@ function getConstraints(um, options) {
142 157
             // same behaviour as true
143 158
             constraints.audio = { mandatory: {}, optional: []};
144 159
             if (options.micDeviceId) {
145
-                // new style of settings device id (FF only)
146
-                constraints.audio.deviceId = options.micDeviceId;
147
-                // old style
160
+                // Don't mix new and old style settings for Chrome as this leads to
161
+                // TypeError in new Chrome versions. @see
162
+                // https://bugs.chromium.org/p/chromium/issues/detail?id=614716
163
+                if (!RTCBrowserType.isChrome()) {
164
+                    // New style of setting device id.
165
+                    constraints.audio.deviceId = options.micDeviceId;
166
+                }
167
+                // Old style.
148 168
                 constraints.audio.optional.push({
149 169
                     sourceId: options.micDeviceId
150 170
                 });

正在加载...
取消
保存