@flashphoner/websdk 2.0.271 → 2.0.274
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/docTemplate/README.md +1 -1
- package/examples/demo/streaming/media_devices_manager/manager.js +83 -80
- package/flashphoner-no-flash.js +286 -73
- package/flashphoner-no-flash.min.js +2 -2
- package/flashphoner-no-webrtc.js +85 -33
- package/flashphoner-no-webrtc.min.js +2 -2
- package/flashphoner-no-wsplayer.js +286 -73
- package/flashphoner-no-wsplayer.min.js +2 -2
- package/flashphoner-room-api-webrtc-only.js +286 -73
- package/flashphoner-room-api-webrtc-only.min.js +1 -1
- package/flashphoner-room-api.js +221 -72
- package/flashphoner-room-api.min.js +2 -2
- package/flashphoner-temasys-flash-websocket-without-adapterjs.js +85 -33
- package/flashphoner-temasys-flash-websocket.js +85 -33
- package/flashphoner-temasys-flash-websocket.min.js +1 -1
- package/flashphoner-webrtc-only.js +286 -73
- package/flashphoner-webrtc-only.min.js +1 -1
- package/flashphoner.js +286 -73
- package/flashphoner.min.js +2 -2
- package/package.json +1 -1
- package/src/flashphoner-core.js +67 -27
- package/src/stats-collector.js +12 -1
- package/src/webrtc-media-provider.js +142 -44
package/flashphoner-no-flash.js
CHANGED
|
@@ -8999,6 +8999,34 @@ var getMediaDevices = function getMediaDevices(mediaProvider, labels, kind, devi
|
|
|
8999
8999
|
return MediaProvider[mediaProvider].listDevices(labels, kind, deviceConstraints);
|
|
9000
9000
|
};
|
|
9001
9001
|
|
|
9002
|
+
/**
|
|
9003
|
+
* Get mobile local media devices
|
|
9004
|
+
*
|
|
9005
|
+
* @param {String=} mediaProvider Media provider that will be asked for device list
|
|
9006
|
+
* @param {Flashphoner.constants.MEDIA_DEVICE_KIND} kind Media devices kind to access:
|
|
9007
|
+
* MEDIA_DEVICE_KIND.INPUT (default) get access to input devices only (camera, mic).
|
|
9008
|
+
* MEDIA_DEVICE_KIND.OUTPUT get access to output devices only (speaker, headphone).
|
|
9009
|
+
* MEDIA_DEVICE_KIND.ALL get access to all devices (cam, mic, speaker, headphone).
|
|
9010
|
+
* @param {Object=} deviceConstraints
|
|
9011
|
+
* If {audio: true, video: false}, then access to the camera will not be requested.
|
|
9012
|
+
* If {audio: false, video: true}, then access to the microphone will not be requested.
|
|
9013
|
+
* @returns {Promise.<Flashphoner.MediaDeviceList>} Promise with media device list on fulfill
|
|
9014
|
+
* @throws {Error} Error if API is not initialized
|
|
9015
|
+
* @memberof Flashphoner
|
|
9016
|
+
*/
|
|
9017
|
+
var getMobileDevices = function getMobileDevices(mediaProvider, kind, deviceConstraints) {
|
|
9018
|
+
if (!initialized) {
|
|
9019
|
+
throw new Error("Flashphoner API is not initialized");
|
|
9020
|
+
}
|
|
9021
|
+
if (!mediaProvider) {
|
|
9022
|
+
mediaProvider = getMediaProviders()[0];
|
|
9023
|
+
}
|
|
9024
|
+
if (MediaProvider[mediaProvider].getMobileDevices) {
|
|
9025
|
+
return MediaProvider[mediaProvider].getMobileDevices(kind, deviceConstraints);
|
|
9026
|
+
}
|
|
9027
|
+
return [];
|
|
9028
|
+
};
|
|
9029
|
+
|
|
9002
9030
|
/**
|
|
9003
9031
|
* Get access to local media
|
|
9004
9032
|
*
|
|
@@ -9436,36 +9464,19 @@ var createSession = function createSession(options) {
|
|
|
9436
9464
|
streamRefreshHandlers[obj.mediaSessionId](obj);
|
|
9437
9465
|
}
|
|
9438
9466
|
break;
|
|
9439
|
-
case
|
|
9440
|
-
|
|
9441
|
-
|
|
9442
|
-
|
|
9443
|
-
|
|
9444
|
-
|
|
9445
|
-
|
|
9446
|
-
}
|
|
9447
|
-
|
|
9448
|
-
|
|
9449
|
-
|
|
9450
|
-
|
|
9451
|
-
|
|
9452
|
-
}
|
|
9453
|
-
if (obj.sampling) {
|
|
9454
|
-
webRTCMetricsServerDescription.sampling = obj.sampling;
|
|
9455
|
-
}
|
|
9456
|
-
if (obj.types) {
|
|
9457
|
-
webRTCMetricsServerDescription.types = obj.types;
|
|
9458
|
-
}
|
|
9459
|
-
if (obj.collect) {
|
|
9460
|
-
webRTCMetricsServerDescription.collect = obj.collect;
|
|
9461
|
-
}
|
|
9462
|
-
for (var _i = 0, _Object$entries = Object.entries(streamRefreshHandlers); _i < _Object$entries.length; _i++) {
|
|
9463
|
-
var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
|
|
9464
|
-
_id = _Object$entries$_i[0],
|
|
9465
|
-
handler = _Object$entries$_i[1];
|
|
9466
|
-
handler(obj);
|
|
9467
|
-
}
|
|
9468
|
-
}
|
|
9467
|
+
case 'webRTCMetricsDescriptionUpdate':
|
|
9468
|
+
handleWebRTCMetricsUpdate(obj, {
|
|
9469
|
+
compression: "compression",
|
|
9470
|
+
batchSize: "batchSize",
|
|
9471
|
+
sampling: "sampling",
|
|
9472
|
+
types: "types",
|
|
9473
|
+
collect: "collect"
|
|
9474
|
+
});
|
|
9475
|
+
break;
|
|
9476
|
+
case 'webRTCMetricsTokenRefresh':
|
|
9477
|
+
handleWebRTCMetricsUpdate(obj, {
|
|
9478
|
+
authorization: "authorization"
|
|
9479
|
+
});
|
|
9469
9480
|
break;
|
|
9470
9481
|
default:
|
|
9471
9482
|
logger.info(LOG_PREFIX, "Unknown server message " + data.message);
|
|
@@ -9475,6 +9486,31 @@ var createSession = function createSession(options) {
|
|
|
9475
9486
|
wsPingReceiver.success();
|
|
9476
9487
|
};
|
|
9477
9488
|
}
|
|
9489
|
+
function handleWebRTCMetricsUpdate(obj) {
|
|
9490
|
+
var updateFields = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
9491
|
+
if (obj.ids) {
|
|
9492
|
+
obj.ids.forEach(function (id) {
|
|
9493
|
+
if (streamRefreshHandlers[id]) {
|
|
9494
|
+
streamRefreshHandlers[id](obj);
|
|
9495
|
+
}
|
|
9496
|
+
});
|
|
9497
|
+
} else {
|
|
9498
|
+
Object.entries(updateFields).forEach(function (_ref2) {
|
|
9499
|
+
var _ref3 = _slicedToArray(_ref2, 2),
|
|
9500
|
+
key = _ref3[0],
|
|
9501
|
+
value = _ref3[1];
|
|
9502
|
+
if (obj[value] !== undefined) {
|
|
9503
|
+
webRTCMetricsServerDescription[key] = obj[value];
|
|
9504
|
+
}
|
|
9505
|
+
});
|
|
9506
|
+
for (var _i = 0, _Object$entries = Object.entries(streamRefreshHandlers); _i < _Object$entries.length; _i++) {
|
|
9507
|
+
var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
|
|
9508
|
+
_id = _Object$entries$_i[0],
|
|
9509
|
+
handler = _Object$entries$_i[1];
|
|
9510
|
+
handler(obj);
|
|
9511
|
+
}
|
|
9512
|
+
}
|
|
9513
|
+
}
|
|
9478
9514
|
|
|
9479
9515
|
//WebSocket send helper
|
|
9480
9516
|
function send(message, data) {
|
|
@@ -10609,6 +10645,10 @@ var createSession = function createSession(options) {
|
|
|
10609
10645
|
statsCollector.start();
|
|
10610
10646
|
}
|
|
10611
10647
|
}
|
|
10648
|
+
if (streamInfo.authorization && statsCollector && statsCollector.description.ingestPoint) {
|
|
10649
|
+
statsCollector.description.authorization = streamInfo.authorization;
|
|
10650
|
+
statsCollector.updateHttpConnection(statsCollector.description.ingestPoint, statsCollector.description.authorization);
|
|
10651
|
+
}
|
|
10612
10652
|
|
|
10613
10653
|
// Pause or resume metrics collection
|
|
10614
10654
|
if (!streamInfo.status && streamInfo.collect !== undefined && statsCollector) {
|
|
@@ -11463,7 +11503,7 @@ var createSession = function createSession(options) {
|
|
|
11463
11503
|
* @memberof Stream
|
|
11464
11504
|
*/
|
|
11465
11505
|
var setZoom = /*#__PURE__*/function () {
|
|
11466
|
-
var
|
|
11506
|
+
var _ref4 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(value) {
|
|
11467
11507
|
return _regenerator().w(function (_context2) {
|
|
11468
11508
|
while (1) switch (_context2.n) {
|
|
11469
11509
|
case 0:
|
|
@@ -11483,7 +11523,7 @@ var createSession = function createSession(options) {
|
|
|
11483
11523
|
}, _callee2);
|
|
11484
11524
|
}));
|
|
11485
11525
|
return function setZoom(_x2) {
|
|
11486
|
-
return
|
|
11526
|
+
return _ref4.apply(this, arguments);
|
|
11487
11527
|
};
|
|
11488
11528
|
}();
|
|
11489
11529
|
stream.play = play;
|
|
@@ -11835,6 +11875,7 @@ module.exports = {
|
|
|
11835
11875
|
isUsingTemasys: isUsingTemasys,
|
|
11836
11876
|
getMediaProviders: getMediaProviders,
|
|
11837
11877
|
getMediaDevices: getMediaDevices,
|
|
11878
|
+
getMobileDevices: getMobileDevices,
|
|
11838
11879
|
getMediaAccess: getMediaAccess,
|
|
11839
11880
|
releaseLocalMedia: releaseLocalMedia,
|
|
11840
11881
|
getSessions: getSessions,
|
|
@@ -12202,6 +12243,11 @@ var StreamStatsCollector = function StreamStatsCollector(description, id, mediaC
|
|
|
12202
12243
|
}
|
|
12203
12244
|
return updateCompression;
|
|
12204
12245
|
}(),
|
|
12246
|
+
updateHttpConnection: function updateHttpConnection(url, authorization) {
|
|
12247
|
+
if (url.startsWith(CONNECTION_TYPE.HTTP) && authorization) {
|
|
12248
|
+
statCollector.connection.http.setAuthorization(authorization);
|
|
12249
|
+
}
|
|
12250
|
+
},
|
|
12205
12251
|
checkForCompression: function () {
|
|
12206
12252
|
var _checkForCompression = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(compression) {
|
|
12207
12253
|
var _t2;
|
|
@@ -12293,6 +12339,9 @@ var StreamStatsCollector = function StreamStatsCollector(description, id, mediaC
|
|
|
12293
12339
|
statCollector.metricsBatch = null;
|
|
12294
12340
|
}
|
|
12295
12341
|
},
|
|
12342
|
+
isMetricValid: function isMetricValid(value) {
|
|
12343
|
+
return value != null && value !== "" && value !== "undefined" && value !== "null";
|
|
12344
|
+
},
|
|
12296
12345
|
collectMetrics: function () {
|
|
12297
12346
|
var _collectMetrics = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee8() {
|
|
12298
12347
|
var stats, metrics, lostMetrics, headersUpdated;
|
|
@@ -12339,7 +12388,7 @@ var StreamStatsCollector = function StreamStatsCollector(description, id, mediaC
|
|
|
12339
12388
|
_iterator2.f();
|
|
12340
12389
|
}
|
|
12341
12390
|
}
|
|
12342
|
-
if (value) {
|
|
12391
|
+
if (statCollector.isMetricValid(value)) {
|
|
12343
12392
|
metrics.push(value);
|
|
12344
12393
|
} else {
|
|
12345
12394
|
lostMetrics.push(descriptor);
|
|
@@ -12593,6 +12642,9 @@ var HttpConnection = function HttpConnection(url, headers) {
|
|
|
12593
12642
|
var connection = {
|
|
12594
12643
|
url: addSlash(url),
|
|
12595
12644
|
headers: headers,
|
|
12645
|
+
setAuthorization: function setAuthorization(token) {
|
|
12646
|
+
this.headers.Authorization = token;
|
|
12647
|
+
},
|
|
12596
12648
|
send: function () {
|
|
12597
12649
|
var _send3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee1(message, data) {
|
|
12598
12650
|
var code, httpHeaders, _i2, _Object$entries, _Object$entries$_i, header, value, response, _t5;
|
|
@@ -14834,6 +14886,66 @@ var available = function available() {
|
|
|
14834
14886
|
//return (adapter.browserDetails.browser != "edge") ? navigator.getUserMedia && RTCPeerConnection : false;
|
|
14835
14887
|
return 'getUserMedia' in navigator && 'RTCPeerConnection' in window;
|
|
14836
14888
|
};
|
|
14889
|
+
|
|
14890
|
+
/**
|
|
14891
|
+
* Helper function to get media devices list in id, label, type form
|
|
14892
|
+
*
|
|
14893
|
+
* @param devices
|
|
14894
|
+
* @param kind
|
|
14895
|
+
* @param videoFilter
|
|
14896
|
+
* @returns {{audio: *[], video: *[]}}
|
|
14897
|
+
*/
|
|
14898
|
+
var getList = function getList(devices, kind) {
|
|
14899
|
+
var videoFilter = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
|
|
14900
|
+
var list = {
|
|
14901
|
+
audio: [],
|
|
14902
|
+
video: []
|
|
14903
|
+
};
|
|
14904
|
+
var micCount = 0;
|
|
14905
|
+
var outputCount = 0;
|
|
14906
|
+
var camCount = 0;
|
|
14907
|
+
for (var i = 0; i < devices.length; i++) {
|
|
14908
|
+
var device = devices[i];
|
|
14909
|
+
var ret = {
|
|
14910
|
+
id: device.deviceId,
|
|
14911
|
+
label: device.label
|
|
14912
|
+
};
|
|
14913
|
+
if (device.kind.indexOf("audio" + kind) === 0 && device.deviceId !== "communications") {
|
|
14914
|
+
ret.type = device.kind === "audioinput" ? "mic" : "speaker";
|
|
14915
|
+
if (ret.type === "mic" && ret.label === "") {
|
|
14916
|
+
ret.label = 'microphone' + ++micCount;
|
|
14917
|
+
}
|
|
14918
|
+
if (ret.type === "speaker" && ret.label === "") {
|
|
14919
|
+
ret.label = 'speaker' + ++outputCount;
|
|
14920
|
+
}
|
|
14921
|
+
list.audio.push(ret);
|
|
14922
|
+
} else if (device.kind.indexOf("video" + kind) === 0) {
|
|
14923
|
+
if (!videoFilter || videoFilter.find(function (id) {
|
|
14924
|
+
return id === device.deviceId;
|
|
14925
|
+
})) {
|
|
14926
|
+
if (ret.label === "") {
|
|
14927
|
+
ret.label = 'camera' + ++camCount;
|
|
14928
|
+
}
|
|
14929
|
+
ret.type = "camera";
|
|
14930
|
+
list.video.push(ret);
|
|
14931
|
+
} else {
|
|
14932
|
+
logger.debug(LOG_PREFIX, "Video device " + device.deviceId + "does not conform the filter " + JSON.stringify(videoFilter));
|
|
14933
|
+
}
|
|
14934
|
+
} else {
|
|
14935
|
+
logger.debug(LOG_PREFIX, "unknown device " + device.kind + " id " + device.deviceId);
|
|
14936
|
+
}
|
|
14937
|
+
}
|
|
14938
|
+
return list;
|
|
14939
|
+
};
|
|
14940
|
+
|
|
14941
|
+
/**
|
|
14942
|
+
* Get media devices list
|
|
14943
|
+
*
|
|
14944
|
+
* @param labels
|
|
14945
|
+
* @param kind
|
|
14946
|
+
* @param deviceConstraints
|
|
14947
|
+
* @returns {Promise<{audio: [], video: []}>}
|
|
14948
|
+
*/
|
|
14837
14949
|
var listDevices = function listDevices(labels, kind, deviceConstraints) {
|
|
14838
14950
|
//WCS-1963. added deviceConstraints.
|
|
14839
14951
|
if (!deviceConstraints) {
|
|
@@ -14844,7 +14956,7 @@ var listDevices = function listDevices(labels, kind, deviceConstraints) {
|
|
|
14844
14956
|
}
|
|
14845
14957
|
if (!kind) {
|
|
14846
14958
|
kind = constants.MEDIA_DEVICE_KIND.INPUT;
|
|
14847
|
-
} else if (kind
|
|
14959
|
+
} else if (kind === constants.MEDIA_DEVICE_KIND.ALL) {
|
|
14848
14960
|
kind = "";
|
|
14849
14961
|
}
|
|
14850
14962
|
var getConstraints = function getConstraints(devices) {
|
|
@@ -14852,50 +14964,15 @@ var listDevices = function listDevices(labels, kind, deviceConstraints) {
|
|
|
14852
14964
|
for (var i = 0; i < devices.length; i++) {
|
|
14853
14965
|
var device = devices[i];
|
|
14854
14966
|
if (device.kind.indexOf("audio" + kind) === 0 && deviceConstraints.audio) {
|
|
14855
|
-
constraints.audio =
|
|
14967
|
+
constraints.audio = deviceConstraints.audio;
|
|
14856
14968
|
} else if (device.kind.indexOf("video" + kind) === 0 && deviceConstraints.video) {
|
|
14857
|
-
constraints.video =
|
|
14969
|
+
constraints.video = deviceConstraints.video;
|
|
14858
14970
|
} else {
|
|
14859
14971
|
logger.debug(LOG_PREFIX, "unknown device " + device.kind + " id " + device.deviceId);
|
|
14860
14972
|
}
|
|
14861
14973
|
}
|
|
14862
14974
|
return constraints;
|
|
14863
14975
|
};
|
|
14864
|
-
var getList = function getList(devices) {
|
|
14865
|
-
var list = {
|
|
14866
|
-
audio: [],
|
|
14867
|
-
video: []
|
|
14868
|
-
};
|
|
14869
|
-
var micCount = 0;
|
|
14870
|
-
var outputCount = 0;
|
|
14871
|
-
var camCount = 0;
|
|
14872
|
-
for (var i = 0; i < devices.length; i++) {
|
|
14873
|
-
var device = devices[i];
|
|
14874
|
-
var ret = {
|
|
14875
|
-
id: device.deviceId,
|
|
14876
|
-
label: device.label
|
|
14877
|
-
};
|
|
14878
|
-
if (device.kind.indexOf("audio" + kind) === 0 && device.deviceId != "communications") {
|
|
14879
|
-
ret.type = device.kind == "audioinput" ? "mic" : "speaker";
|
|
14880
|
-
if (ret.type == "mic" && ret.label == "") {
|
|
14881
|
-
ret.label = 'microphone' + ++micCount;
|
|
14882
|
-
}
|
|
14883
|
-
if (ret.type == "speaker" && ret.label == "") {
|
|
14884
|
-
ret.label = 'speaker' + ++outputCount;
|
|
14885
|
-
}
|
|
14886
|
-
list.audio.push(ret);
|
|
14887
|
-
} else if (device.kind.indexOf("video" + kind) === 0) {
|
|
14888
|
-
if (ret.label == "") {
|
|
14889
|
-
ret.label = 'camera' + ++camCount;
|
|
14890
|
-
}
|
|
14891
|
-
ret.type = "camera";
|
|
14892
|
-
list.video.push(ret);
|
|
14893
|
-
} else {
|
|
14894
|
-
logger.debug(LOG_PREFIX, "unknown device " + device.kind + " id " + device.deviceId);
|
|
14895
|
-
}
|
|
14896
|
-
}
|
|
14897
|
-
return list;
|
|
14898
|
-
};
|
|
14899
14976
|
return new Promise(function (resolve, reject) {
|
|
14900
14977
|
navigator.mediaDevices.enumerateDevices().then(function (devices) {
|
|
14901
14978
|
if (labels) {
|
|
@@ -14907,18 +14984,153 @@ var listDevices = function listDevices(labels, kind, deviceConstraints) {
|
|
|
14907
14984
|
}
|
|
14908
14985
|
navigator.getUserMedia(constraints, function (stream) {
|
|
14909
14986
|
navigator.mediaDevices.enumerateDevices().then(function (devicesWithLabels) {
|
|
14910
|
-
resolve(getList(devicesWithLabels));
|
|
14987
|
+
resolve(getList(devicesWithLabels, kind));
|
|
14911
14988
|
stream.getTracks().forEach(function (track) {
|
|
14912
14989
|
track.stop();
|
|
14913
14990
|
});
|
|
14914
14991
|
}, reject);
|
|
14915
14992
|
}, reject);
|
|
14916
14993
|
} else {
|
|
14917
|
-
resolve(getList(devices));
|
|
14994
|
+
resolve(getList(devices, kind));
|
|
14918
14995
|
}
|
|
14919
14996
|
}, reject);
|
|
14920
14997
|
});
|
|
14921
14998
|
};
|
|
14999
|
+
var getMobileDevices = /*#__PURE__*/function () {
|
|
15000
|
+
var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(kind) {
|
|
15001
|
+
var deviceConstraints,
|
|
15002
|
+
constraints,
|
|
15003
|
+
videoFilter,
|
|
15004
|
+
list,
|
|
15005
|
+
getCamera,
|
|
15006
|
+
front,
|
|
15007
|
+
back,
|
|
15008
|
+
_stream,
|
|
15009
|
+
mediaDevices,
|
|
15010
|
+
_args4 = arguments,
|
|
15011
|
+
_t2;
|
|
15012
|
+
return _regenerator().w(function (_context4) {
|
|
15013
|
+
while (1) switch (_context4.p = _context4.n) {
|
|
15014
|
+
case 0:
|
|
15015
|
+
deviceConstraints = _args4.length > 1 && _args4[1] !== undefined ? _args4[1] : null;
|
|
15016
|
+
constraints = {};
|
|
15017
|
+
videoFilter = [];
|
|
15018
|
+
list = null;
|
|
15019
|
+
if (!kind) {
|
|
15020
|
+
kind = constants.MEDIA_DEVICE_KIND.INPUT;
|
|
15021
|
+
} else if (kind === constants.MEDIA_DEVICE_KIND.ALL) {
|
|
15022
|
+
kind = "";
|
|
15023
|
+
}
|
|
15024
|
+
if (deviceConstraints && deviceConstraints.audio) {
|
|
15025
|
+
constraints.audio = deviceConstraints.audio;
|
|
15026
|
+
} else {
|
|
15027
|
+
constraints.audio = true;
|
|
15028
|
+
}
|
|
15029
|
+
if (deviceConstraints && deviceConstraints.video) {
|
|
15030
|
+
if (_typeof(deviceConstraints.video) === 'object') {
|
|
15031
|
+
constraints.video = deviceConstraints.video;
|
|
15032
|
+
} else {
|
|
15033
|
+
constraints.video = {};
|
|
15034
|
+
}
|
|
15035
|
+
} else {
|
|
15036
|
+
constraints.video = {};
|
|
15037
|
+
}
|
|
15038
|
+
getCamera = /*#__PURE__*/function () {
|
|
15039
|
+
var _ref4 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(constraints, facingMode) {
|
|
15040
|
+
var deviceId, mediaConstraints, _t;
|
|
15041
|
+
return _regenerator().w(function (_context3) {
|
|
15042
|
+
while (1) switch (_context3.p = _context3.n) {
|
|
15043
|
+
case 0:
|
|
15044
|
+
deviceId = null;
|
|
15045
|
+
mediaConstraints = {
|
|
15046
|
+
audio: false,
|
|
15047
|
+
video: constraints.video
|
|
15048
|
+
};
|
|
15049
|
+
mediaConstraints.video.facingMode = facingMode;
|
|
15050
|
+
_context3.p = 1;
|
|
15051
|
+
_context3.n = 2;
|
|
15052
|
+
return navigator.mediaDevices.getUserMedia(mediaConstraints);
|
|
15053
|
+
case 2:
|
|
15054
|
+
stream = _context3.v;
|
|
15055
|
+
if (stream) {
|
|
15056
|
+
if (stream.getVideoTracks().length > 0) {
|
|
15057
|
+
deviceId = stream.getVideoTracks()[0].getSettings().deviceId;
|
|
15058
|
+
}
|
|
15059
|
+
stream.getTracks().forEach(function (track) {
|
|
15060
|
+
track.stop();
|
|
15061
|
+
});
|
|
15062
|
+
}
|
|
15063
|
+
_context3.n = 4;
|
|
15064
|
+
break;
|
|
15065
|
+
case 3:
|
|
15066
|
+
_context3.p = 3;
|
|
15067
|
+
_t = _context3.v;
|
|
15068
|
+
logger.error(LOG_PREFIX, "Can't get device access with video constraints " + JSON.stringify(constraints.video) + ", error " + _t);
|
|
15069
|
+
case 4:
|
|
15070
|
+
return _context3.a(2, deviceId);
|
|
15071
|
+
}
|
|
15072
|
+
}, _callee3, null, [[1, 3]]);
|
|
15073
|
+
}));
|
|
15074
|
+
return function getCamera(_x5, _x6) {
|
|
15075
|
+
return _ref4.apply(this, arguments);
|
|
15076
|
+
};
|
|
15077
|
+
}();
|
|
15078
|
+
_context4.n = 1;
|
|
15079
|
+
return getCamera(constraints, {
|
|
15080
|
+
ideal: 'user'
|
|
15081
|
+
});
|
|
15082
|
+
case 1:
|
|
15083
|
+
front = _context4.v;
|
|
15084
|
+
if (front && front !== "") {
|
|
15085
|
+
logger.debug(LOG_PREFIX, "Front camera id: " + front);
|
|
15086
|
+
videoFilter.push(front);
|
|
15087
|
+
}
|
|
15088
|
+
_context4.n = 2;
|
|
15089
|
+
return getCamera(constraints, {
|
|
15090
|
+
ideal: 'environment'
|
|
15091
|
+
});
|
|
15092
|
+
case 2:
|
|
15093
|
+
back = _context4.v;
|
|
15094
|
+
if (back && back !== "") {
|
|
15095
|
+
logger.debug(LOG_PREFIX, "Back camera id: " + back);
|
|
15096
|
+
videoFilter.push(back);
|
|
15097
|
+
}
|
|
15098
|
+
_context4.p = 3;
|
|
15099
|
+
_context4.n = 4;
|
|
15100
|
+
return navigator.mediaDevices.getUserMedia(constraints);
|
|
15101
|
+
case 4:
|
|
15102
|
+
_stream = _context4.v;
|
|
15103
|
+
if (!_stream) {
|
|
15104
|
+
_context4.n = 6;
|
|
15105
|
+
break;
|
|
15106
|
+
}
|
|
15107
|
+
_context4.n = 5;
|
|
15108
|
+
return navigator.mediaDevices.enumerateDevices();
|
|
15109
|
+
case 5:
|
|
15110
|
+
mediaDevices = _context4.v;
|
|
15111
|
+
if (mediaDevices) {
|
|
15112
|
+
logger.debug(LOG_PREFIX, "mediaDevices: " + JSON.stringify(mediaDevices));
|
|
15113
|
+
list = getList(mediaDevices, kind, videoFilter);
|
|
15114
|
+
}
|
|
15115
|
+
_stream.getTracks().forEach(function (track) {
|
|
15116
|
+
track.stop();
|
|
15117
|
+
});
|
|
15118
|
+
case 6:
|
|
15119
|
+
_context4.n = 8;
|
|
15120
|
+
break;
|
|
15121
|
+
case 7:
|
|
15122
|
+
_context4.p = 7;
|
|
15123
|
+
_t2 = _context4.v;
|
|
15124
|
+
logger.error(LOG_PREFIX, "Can't get device access with constraints " + JSON.stringify(constraints) + ", error " + _t2);
|
|
15125
|
+
case 8:
|
|
15126
|
+
return _context4.a(2, list);
|
|
15127
|
+
}
|
|
15128
|
+
}, _callee4, null, [[3, 7]]);
|
|
15129
|
+
}));
|
|
15130
|
+
return function getMobileDevices(_x4) {
|
|
15131
|
+
return _ref3.apply(this, arguments);
|
|
15132
|
+
};
|
|
15133
|
+
}();
|
|
14922
15134
|
function normalizeConstraints(constraints) {
|
|
14923
15135
|
//WCS-2010. fixed TypeError after publish->stop->publish
|
|
14924
15136
|
//WCS-2373. fixed customStream
|
|
@@ -15047,6 +15259,7 @@ module.exports = {
|
|
|
15047
15259
|
getMediaAccess: getMediaAccess,
|
|
15048
15260
|
releaseMedia: releaseMedia,
|
|
15049
15261
|
listDevices: listDevices,
|
|
15262
|
+
getMobileDevices: getMobileDevices,
|
|
15050
15263
|
playFirstSound: playFirstSound,
|
|
15051
15264
|
playFirstVideo: playFirstVideo,
|
|
15052
15265
|
available: available,
|