|
|
@@ -386,12 +386,24 @@ function onReady (options, GUM) {
|
|
386
|
386
|
eventEmitter.emit(RTCEvents.RTC_READY, true);
|
|
387
|
387
|
screenObtainer.init(options, GUM);
|
|
388
|
388
|
|
|
389
|
|
- if (isDeviceChangeEventSupported && RTCUtils.isDeviceListAvailable()) {
|
|
390
|
|
- navigator.mediaDevices.addEventListener('devicechange', function () {
|
|
391
|
|
- RTCUtils.enumerateDevices(onMediaDevicesListChanged);
|
|
|
389
|
+ if (RTCUtils.isDeviceListAvailable() && rawEnumerateDevicesWithCallback) {
|
|
|
390
|
+ rawEnumerateDevicesWithCallback(function (devices) {
|
|
|
391
|
+ currentlyAvailableMediaDevices = devices.splice(0);
|
|
|
392
|
+
|
|
|
393
|
+ eventEmitter.emit(RTCEvents.DEVICE_LIST_AVAILABLE,
|
|
|
394
|
+ currentlyAvailableMediaDevices);
|
|
|
395
|
+
|
|
|
396
|
+ if (isDeviceChangeEventSupported) {
|
|
|
397
|
+ navigator.mediaDevices.addEventListener(
|
|
|
398
|
+ 'devicechange',
|
|
|
399
|
+ function () {
|
|
|
400
|
+ RTCUtils.enumerateDevices(
|
|
|
401
|
+ onMediaDevicesListChanged);
|
|
|
402
|
+ });
|
|
|
403
|
+ } else {
|
|
|
404
|
+ pollForAvailableMediaDevices();
|
|
|
405
|
+ }
|
|
392
|
406
|
});
|
|
393
|
|
- } else if (RTCUtils.isDeviceListAvailable()) {
|
|
394
|
|
- pollForAvailableMediaDevices();
|
|
395
|
407
|
}
|
|
396
|
408
|
}
|
|
397
|
409
|
|
|
|
@@ -1207,6 +1219,31 @@ var RTCUtils = {
|
|
1207
|
1219
|
*/
|
|
1208
|
1220
|
getAudioOutputDevice: function () {
|
|
1209
|
1221
|
return audioOutputDeviceId;
|
|
|
1222
|
+ },
|
|
|
1223
|
+
|
|
|
1224
|
+ /**
|
|
|
1225
|
+ * Returns list of available media devices if its obtained, otherwise an
|
|
|
1226
|
+ * empty array is returned/
|
|
|
1227
|
+ * @returns {Array} list of available media devices.
|
|
|
1228
|
+ */
|
|
|
1229
|
+ getCurrentlyAvailableMediaDevices: function () {
|
|
|
1230
|
+ return currentlyAvailableMediaDevices;
|
|
|
1231
|
+ },
|
|
|
1232
|
+
|
|
|
1233
|
+ /**
|
|
|
1234
|
+ * Returns event data for device to be reported to stats.
|
|
|
1235
|
+ * @returns {MediaDeviceInfo} device.
|
|
|
1236
|
+ */
|
|
|
1237
|
+ getEventDataForActiveDevice: function (device) {
|
|
|
1238
|
+ var devices = [];
|
|
|
1239
|
+ var deviceData = {
|
|
|
1240
|
+ "deviceId": device.deviceId,
|
|
|
1241
|
+ "kind": device.kind,
|
|
|
1242
|
+ "label": device.label,
|
|
|
1243
|
+ "groupId": device.groupId
|
|
|
1244
|
+ };
|
|
|
1245
|
+ devices.push(deviceData);
|
|
|
1246
|
+ return { deviceList: devices };
|
|
1210
|
1247
|
}
|
|
1211
|
1248
|
};
|
|
1212
|
1249
|
|