Browse Source

Merge pull request #138 from tsareg/dont_mix_gum_constraint_styles_for_chrome

Don't mix old and new-style for gUM constraints for Chrome, as it fails with TypeError in new Chrome versions
master
Любомир Маринов 9 years ago
parent
commit
8c5ef01d00
1 changed files with 29 additions and 7 deletions
  1. 29
    7
      modules/RTC/RTCUtils.js

+ 29
- 7
modules/RTC/RTCUtils.js View File

109
 function getConstraints(um, options) {
109
 function getConstraints(um, options) {
110
     var constraints = {audio: false, video: false};
110
     var constraints = {audio: false, video: false};
111
 
111
 
112
+    // Don't mix new and old style settings for Chromium as this leads
113
+    // to TypeError in new Chromium versions. @see
114
+    // https://bugs.chromium.org/p/chromium/issues/detail?id=614716
115
+    // This is a temporary solution, in future we will fully split old and
116
+    // new style constraints when new versions of Chromium and Firefox will
117
+    // have stable support of new constraints format. For more information
118
+    // @see https://github.com/jitsi/lib-jitsi-meet/pull/136
119
+    var isNewStyleConstraintsSupported =
120
+        RTCBrowserType.isFirefox() ||
121
+        RTCBrowserType.isReactNative() ||
122
+        RTCBrowserType.isTemasysPluginUsed();
123
+
112
     if (um.indexOf('video') >= 0) {
124
     if (um.indexOf('video') >= 0) {
113
         // same behaviour as true
125
         // same behaviour as true
114
         constraints.video = { mandatory: {}, optional: [] };
126
         constraints.video = { mandatory: {}, optional: [] };
115
 
127
 
116
         if (options.cameraDeviceId) {
128
         if (options.cameraDeviceId) {
117
-            // new style of settings device id (FF only)
118
-            constraints.video.deviceId = options.cameraDeviceId;
119
-            // old style
129
+            if (isNewStyleConstraintsSupported) {
130
+                // New style of setting device id.
131
+                constraints.video.deviceId = options.cameraDeviceId;
132
+            }
133
+            // Old style.
120
             constraints.video.optional.push({
134
             constraints.video.optional.push({
121
                 sourceId: options.cameraDeviceId
135
                 sourceId: options.cameraDeviceId
122
             });
136
             });
126
             // TODO: Maybe use "exact" syntax if options.facingMode is defined,
140
             // TODO: Maybe use "exact" syntax if options.facingMode is defined,
127
             // but this probably needs to be decided when updating other
141
             // but this probably needs to be decided when updating other
128
             // constraints, as we currently don't use "exact" syntax anywhere.
142
             // constraints, as we currently don't use "exact" syntax anywhere.
129
-            constraints.video.facingMode = options.facingMode || 'user';
143
+            if (isNewStyleConstraintsSupported) {
144
+                constraints.video.facingMode = options.facingMode || 'user';
145
+            }
146
+
147
+            constraints.video.optional.push({
148
+                facingMode: options.facingMode || 'user'
149
+            });
130
         }
150
         }
131
 
151
 
132
         constraints.video.optional.push({ googLeakyBucket: true });
152
         constraints.video.optional.push({ googLeakyBucket: true });
142
             // same behaviour as true
162
             // same behaviour as true
143
             constraints.audio = { mandatory: {}, optional: []};
163
             constraints.audio = { mandatory: {}, optional: []};
144
             if (options.micDeviceId) {
164
             if (options.micDeviceId) {
145
-                // new style of settings device id (FF only)
146
-                constraints.audio.deviceId = options.micDeviceId;
147
-                // old style
165
+                if (isNewStyleConstraintsSupported) {
166
+                    // New style of setting device id.
167
+                    constraints.audio.deviceId = options.micDeviceId;
168
+                }
169
+                // Old style.
148
                 constraints.audio.optional.push({
170
                 constraints.audio.optional.push({
149
                     sourceId: options.micDeviceId
171
                     sourceId: options.micDeviceId
150
                 });
172
                 });

Loading…
Cancel
Save