瀏覽代碼

Merge pull request #838 from guusdk/pass-options

fix(RTC): Pass options allowing GUM to work with config
dev1
Saúl Ibarra Corretgé 6 年之前
父節點
當前提交
d21965bcf6
No account linked to committer's email address
共有 1 個文件被更改,包括 13 次插入13 次删除
  1. 13
    13
      modules/RTC/RTCUtils.js

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

@@ -1217,7 +1217,7 @@ class RTCUtils extends Listenable {
1217 1217
             };
1218 1218
 
1219 1219
             obtainDevices({
1220
-                devices: options.devices,
1220
+                options,
1221 1221
                 streams: {},
1222 1222
                 successCallback: resolve,
1223 1223
                 errorCallback: reject,
@@ -1551,27 +1551,27 @@ const rtcUtils = new RTCUtils();
1551 1551
 
1552 1552
 /**
1553 1553
  *
1554
- * @param options
1554
+ * @param context Execution context, containing options and callbacks
1555 1555
  */
1556
-function obtainDevices(options) {
1557
-    if (!options.devices || options.devices.length === 0) {
1558
-        return options.successCallback(options.streams || {});
1556
+function obtainDevices(context) {
1557
+    if (!context.options.devices || context.options.devices.length === 0) {
1558
+        return context.successCallback(context.streams || {});
1559 1559
     }
1560 1560
 
1561
-    const device = options.devices.splice(0, 1);
1561
+    const device = context.options.devices.splice(0, 1);
1562 1562
 
1563
-    options.deviceGUM[device]()
1563
+    context.deviceGUM[device](context.options)
1564 1564
         .then(stream => {
1565
-            options.streams = options.streams || {};
1566
-            options.streams[device] = stream;
1567
-            obtainDevices(options);
1565
+            context.streams = context.streams || {};
1566
+            context.streams[device] = stream;
1567
+            obtainDevices(context);
1568 1568
         }, error => {
1569
-            Object.keys(options.streams).forEach(
1570
-                d => rtcUtils.stopMediaStream(options.streams[d]));
1569
+            Object.keys(context.streams).forEach(
1570
+                d => rtcUtils.stopMediaStream(context.streams[d]));
1571 1571
             logger.error(
1572 1572
                 `failed to obtain ${device} stream - stop`, error);
1573 1573
 
1574
-            options.errorCallback(error);
1574
+            context.errorCallback(error);
1575 1575
         });
1576 1576
 }
1577 1577
 

Loading…
取消
儲存