Browse Source

fix(RTC) fix device selection not being available

RTCUtils.enumerateDevices was being called earlier than the RTCUtils.init which assigned that function
tags/v0.0.2
Tudor-Ovidiu Avram 4 years ago
parent
commit
e6ef4e7ae9
1 changed files with 18 additions and 25 deletions
  1. 18
    25
      modules/RTC/RTCUtils.js

+ 18
- 25
modules/RTC/RTCUtils.js View File

107
     // no-op
107
     // no-op
108
 }
108
 }
109
 
109
 
110
-/**
111
- * Initialize wrapper function for enumerating devices.
112
- * TODO: remove this, it should no longer be needed.
113
- *
114
- * @returns {?Function}
115
- */
116
-function initEnumerateDevicesWithCallback() {
117
-    if (navigator.mediaDevices && navigator.mediaDevices.enumerateDevices) {
118
-        return callback => {
119
-            navigator.mediaDevices.enumerateDevices()
120
-                .then(devices => {
121
-                    updateKnownDevices(devices);
122
-                    callback(devices);
123
-                })
124
-                .catch(error => {
125
-                    logger.warn(`Failed to  enumerate devices. ${error}`);
126
-                    updateKnownDevices([]);
127
-                    callback([]);
128
-                });
129
-        };
130
-    }
131
-}
132
-
133
 /**
110
 /**
134
  *
111
  *
135
  * @param constraints
112
  * @param constraints
804
         window.clearInterval(availableDevicesPollTimer);
781
         window.clearInterval(availableDevicesPollTimer);
805
         availableDevicesPollTimer = undefined;
782
         availableDevicesPollTimer = undefined;
806
 
783
 
807
-        this.enumerateDevices = initEnumerateDevicesWithCallback();
808
-
809
         if (browser.usesNewGumFlow()) {
784
         if (browser.usesNewGumFlow()) {
810
             this.RTCPeerConnectionType = RTCPeerConnection;
785
             this.RTCPeerConnectionType = RTCPeerConnection;
811
 
786
 
898
         this.p2pPcConstraints = this.p2pPcConstraints || this.pcConstraints;
873
         this.p2pPcConstraints = this.p2pPcConstraints || this.pcConstraints;
899
     }
874
     }
900
 
875
 
876
+
877
+    /**
878
+     *
879
+     * @param {Function} callback
880
+     */
881
+    enumerateDevices(callback) {
882
+        navigator.mediaDevices.enumerateDevices()
883
+            .then(devices => {
884
+                updateKnownDevices(devices);
885
+                callback(devices);
886
+            })
887
+            .catch(error => {
888
+                logger.warn(`Failed to  enumerate devices. ${error}`);
889
+                updateKnownDevices([]);
890
+                callback([]);
891
+            });
892
+    }
893
+
901
     /* eslint-disable max-params */
894
     /* eslint-disable max-params */
902
 
895
 
903
     /**
896
     /**

Loading…
Cancel
Save