Browse Source

Fixes JS error when parsing GUM error

tags/v0.0.2
hristoterezov 9 years ago
parent
commit
c45f3d767d
4 changed files with 38 additions and 28 deletions
  1. 4
    4
      JitsiTrackErrors.js
  2. 13
    8
      lib-jitsi-meet.js
  3. 12
    12
      lib-jitsi-meet.min.js
  4. 9
    4
      modules/RTC/RTCUtils.js

+ 4
- 4
JitsiTrackErrors.js View File

@@ -2,10 +2,10 @@ module.exports = {
2 2
     /**
3 3
      * Returns JitsiTrackErrors based on the error object passed by GUM
4 4
      * @param error the error
5
-     * @param {Object} options the options object given to GUM.
5
+     * @param {Array} devices Array with the requested devices
6 6
      */
7
-    parseError: function (error, options) {
8
-        options = options || {};
7
+    parseError: function (error, devices) {
8
+        devices = devices || [];
9 9
         if (typeof error == "object" && error.constraintName && error.name
10 10
             && (error.name == "ConstraintNotSatisfiedError" ||
11 11
             error.name == "OverconstrainedError") &&
@@ -13,7 +13,7 @@ module.exports = {
13 13
             error.constraintName == "maxWidth" ||
14 14
             error.constraintName == "minHeight" ||
15 15
             error.constraintName == "maxHeight") &&
16
-            options.devices.indexOf("video") !== -1) {
16
+            devices.indexOf("video") !== -1) {
17 17
                 return this.UNSUPPORTED_RESOLUTION;
18 18
         } else {
19 19
             return this.GENERAL;

+ 13
- 8
lib-jitsi-meet.js View File

@@ -1326,10 +1326,10 @@ module.exports = {
1326 1326
     /**
1327 1327
      * Returns JitsiTrackErrors based on the error object passed by GUM
1328 1328
      * @param error the error
1329
-     * @param {Object} options the options object given to GUM.
1329
+     * @param {Array} devices Array with the requested devices
1330 1330
      */
1331
-    parseError: function (error, options) {
1332
-        options = options || {};
1331
+    parseError: function (error, devices) {
1332
+        devices = devices || [];
1333 1333
         if (typeof error == "object" && error.constraintName && error.name
1334 1334
             && (error.name == "ConstraintNotSatisfiedError" ||
1335 1335
             error.name == "OverconstrainedError") &&
@@ -1337,7 +1337,7 @@ module.exports = {
1337 1337
             error.constraintName == "maxWidth" ||
1338 1338
             error.constraintName == "minHeight" ||
1339 1339
             error.constraintName == "maxHeight") &&
1340
-            options.devices.indexOf("video") !== -1) {
1340
+            devices.indexOf("video") !== -1) {
1341 1341
                 return this.UNSUPPORTED_RESOLUTION;
1342 1342
         } else {
1343 1343
             return this.GENERAL;
@@ -2857,6 +2857,8 @@ function obtainDevices(options) {
2857 2857
     }
2858 2858
 
2859 2859
     var device = options.devices.splice(0, 1);
2860
+    var devices = [];
2861
+    devices.push(device);
2860 2862
     options.deviceGUM[device](function (stream) {
2861 2863
             options.streams = options.streams || {};
2862 2864
             options.streams[device] = stream;
@@ -2865,7 +2867,7 @@ function obtainDevices(options) {
2865 2867
         function (error) {
2866 2868
             logger.error(
2867 2869
                 "failed to obtain " + device + " stream - stop", error);
2868
-            options.errorCallback(JitsiTrackErrors.parseError(error));
2870
+            options.errorCallback(JitsiTrackErrors.parseError(error, devices));
2869 2871
         });
2870 2872
 }
2871 2873
 
@@ -3213,14 +3215,16 @@ var RTCUtils = {
3213 3215
                                             desktopStream: desktopStream});
3214 3216
                                     }, function (error) {
3215 3217
                                         reject(
3216
-                                            JitsiTrackErrors.parseError(error));
3218
+                                            JitsiTrackErrors.parseError(error,
3219
+                                                options.devices));
3217 3220
                                     });
3218 3221
                             } else {
3219 3222
                                 successCallback({audioVideo: stream});
3220 3223
                             }
3221 3224
                         },
3222 3225
                         function (error) {
3223
-                            reject(JitsiTrackErrors.parseError(error));
3226
+                            reject(JitsiTrackErrors.parseError(error,
3227
+                                options.devices));
3224 3228
                         },
3225 3229
                         options);
3226 3230
                 } else if (hasDesktop) {
@@ -3229,7 +3233,8 @@ var RTCUtils = {
3229 3233
                             successCallback({desktopStream: stream});
3230 3234
                         }, function (error) {
3231 3235
                             reject(
3232
-                                JitsiTrackErrors.parseError(error));
3236
+                                JitsiTrackErrors.parseError(error,
3237
+                                    ["desktop"]));
3233 3238
                         });
3234 3239
                 }
3235 3240
             }

+ 12
- 12
lib-jitsi-meet.min.js
File diff suppressed because it is too large
View File


+ 9
- 4
modules/RTC/RTCUtils.js View File

@@ -335,6 +335,8 @@ function obtainDevices(options) {
335 335
     }
336 336
 
337 337
     var device = options.devices.splice(0, 1);
338
+    var devices = [];
339
+    devices.push(device);
338 340
     options.deviceGUM[device](function (stream) {
339 341
             options.streams = options.streams || {};
340 342
             options.streams[device] = stream;
@@ -343,7 +345,7 @@ function obtainDevices(options) {
343 345
         function (error) {
344 346
             logger.error(
345 347
                 "failed to obtain " + device + " stream - stop", error);
346
-            options.errorCallback(JitsiTrackErrors.parseError(error));
348
+            options.errorCallback(JitsiTrackErrors.parseError(error, devices));
347 349
         });
348 350
 }
349 351
 
@@ -691,14 +693,16 @@ var RTCUtils = {
691 693
                                             desktopStream: desktopStream});
692 694
                                     }, function (error) {
693 695
                                         reject(
694
-                                            JitsiTrackErrors.parseError(error));
696
+                                            JitsiTrackErrors.parseError(error,
697
+                                                options.devices));
695 698
                                     });
696 699
                             } else {
697 700
                                 successCallback({audioVideo: stream});
698 701
                             }
699 702
                         },
700 703
                         function (error) {
701
-                            reject(JitsiTrackErrors.parseError(error));
704
+                            reject(JitsiTrackErrors.parseError(error,
705
+                                options.devices));
702 706
                         },
703 707
                         options);
704 708
                 } else if (hasDesktop) {
@@ -707,7 +711,8 @@ var RTCUtils = {
707 711
                             successCallback({desktopStream: stream});
708 712
                         }, function (error) {
709 713
                             reject(
710
-                                JitsiTrackErrors.parseError(error));
714
+                                JitsiTrackErrors.parseError(error,
715
+                                    ["desktop"]));
711 716
                         });
712 717
                 }
713 718
             }

Loading…
Cancel
Save