@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
|
@@ -8171,6 +8171,34 @@ var getMediaDevices = function getMediaDevices(mediaProvider, labels, kind, devi
|
|
|
8171
8171
|
return MediaProvider[mediaProvider].listDevices(labels, kind, deviceConstraints);
|
|
8172
8172
|
};
|
|
8173
8173
|
|
|
8174
|
+
/**
|
|
8175
|
+
* Get mobile local media devices
|
|
8176
|
+
*
|
|
8177
|
+
* @param {String=} mediaProvider Media provider that will be asked for device list
|
|
8178
|
+
* @param {Flashphoner.constants.MEDIA_DEVICE_KIND} kind Media devices kind to access:
|
|
8179
|
+
* MEDIA_DEVICE_KIND.INPUT (default) get access to input devices only (camera, mic).
|
|
8180
|
+
* MEDIA_DEVICE_KIND.OUTPUT get access to output devices only (speaker, headphone).
|
|
8181
|
+
* MEDIA_DEVICE_KIND.ALL get access to all devices (cam, mic, speaker, headphone).
|
|
8182
|
+
* @param {Object=} deviceConstraints
|
|
8183
|
+
* If {audio: true, video: false}, then access to the camera will not be requested.
|
|
8184
|
+
* If {audio: false, video: true}, then access to the microphone will not be requested.
|
|
8185
|
+
* @returns {Promise.<Flashphoner.MediaDeviceList>} Promise with media device list on fulfill
|
|
8186
|
+
* @throws {Error} Error if API is not initialized
|
|
8187
|
+
* @memberof Flashphoner
|
|
8188
|
+
*/
|
|
8189
|
+
var getMobileDevices = function getMobileDevices(mediaProvider, kind, deviceConstraints) {
|
|
8190
|
+
if (!initialized) {
|
|
8191
|
+
throw new Error("Flashphoner API is not initialized");
|
|
8192
|
+
}
|
|
8193
|
+
if (!mediaProvider) {
|
|
8194
|
+
mediaProvider = getMediaProviders()[0];
|
|
8195
|
+
}
|
|
8196
|
+
if (MediaProvider[mediaProvider].getMobileDevices) {
|
|
8197
|
+
return MediaProvider[mediaProvider].getMobileDevices(kind, deviceConstraints);
|
|
8198
|
+
}
|
|
8199
|
+
return [];
|
|
8200
|
+
};
|
|
8201
|
+
|
|
8174
8202
|
/**
|
|
8175
8203
|
* Get access to local media
|
|
8176
8204
|
*
|
|
@@ -8608,36 +8636,19 @@ var createSession = function createSession(options) {
|
|
|
8608
8636
|
streamRefreshHandlers[obj.mediaSessionId](obj);
|
|
8609
8637
|
}
|
|
8610
8638
|
break;
|
|
8611
|
-
case
|
|
8612
|
-
|
|
8613
|
-
|
|
8614
|
-
|
|
8615
|
-
|
|
8616
|
-
|
|
8617
|
-
|
|
8618
|
-
}
|
|
8619
|
-
|
|
8620
|
-
|
|
8621
|
-
|
|
8622
|
-
|
|
8623
|
-
|
|
8624
|
-
}
|
|
8625
|
-
if (obj.sampling) {
|
|
8626
|
-
webRTCMetricsServerDescription.sampling = obj.sampling;
|
|
8627
|
-
}
|
|
8628
|
-
if (obj.types) {
|
|
8629
|
-
webRTCMetricsServerDescription.types = obj.types;
|
|
8630
|
-
}
|
|
8631
|
-
if (obj.collect) {
|
|
8632
|
-
webRTCMetricsServerDescription.collect = obj.collect;
|
|
8633
|
-
}
|
|
8634
|
-
for (var _i = 0, _Object$entries = Object.entries(streamRefreshHandlers); _i < _Object$entries.length; _i++) {
|
|
8635
|
-
var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
|
|
8636
|
-
_id = _Object$entries$_i[0],
|
|
8637
|
-
handler = _Object$entries$_i[1];
|
|
8638
|
-
handler(obj);
|
|
8639
|
-
}
|
|
8640
|
-
}
|
|
8639
|
+
case 'webRTCMetricsDescriptionUpdate':
|
|
8640
|
+
handleWebRTCMetricsUpdate(obj, {
|
|
8641
|
+
compression: "compression",
|
|
8642
|
+
batchSize: "batchSize",
|
|
8643
|
+
sampling: "sampling",
|
|
8644
|
+
types: "types",
|
|
8645
|
+
collect: "collect"
|
|
8646
|
+
});
|
|
8647
|
+
break;
|
|
8648
|
+
case 'webRTCMetricsTokenRefresh':
|
|
8649
|
+
handleWebRTCMetricsUpdate(obj, {
|
|
8650
|
+
authorization: "authorization"
|
|
8651
|
+
});
|
|
8641
8652
|
break;
|
|
8642
8653
|
default:
|
|
8643
8654
|
logger.info(LOG_PREFIX, "Unknown server message " + data.message);
|
|
@@ -8647,6 +8658,31 @@ var createSession = function createSession(options) {
|
|
|
8647
8658
|
wsPingReceiver.success();
|
|
8648
8659
|
};
|
|
8649
8660
|
}
|
|
8661
|
+
function handleWebRTCMetricsUpdate(obj) {
|
|
8662
|
+
var updateFields = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
8663
|
+
if (obj.ids) {
|
|
8664
|
+
obj.ids.forEach(function (id) {
|
|
8665
|
+
if (streamRefreshHandlers[id]) {
|
|
8666
|
+
streamRefreshHandlers[id](obj);
|
|
8667
|
+
}
|
|
8668
|
+
});
|
|
8669
|
+
} else {
|
|
8670
|
+
Object.entries(updateFields).forEach(function (_ref2) {
|
|
8671
|
+
var _ref3 = _slicedToArray(_ref2, 2),
|
|
8672
|
+
key = _ref3[0],
|
|
8673
|
+
value = _ref3[1];
|
|
8674
|
+
if (obj[value] !== undefined) {
|
|
8675
|
+
webRTCMetricsServerDescription[key] = obj[value];
|
|
8676
|
+
}
|
|
8677
|
+
});
|
|
8678
|
+
for (var _i = 0, _Object$entries = Object.entries(streamRefreshHandlers); _i < _Object$entries.length; _i++) {
|
|
8679
|
+
var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
|
|
8680
|
+
_id = _Object$entries$_i[0],
|
|
8681
|
+
handler = _Object$entries$_i[1];
|
|
8682
|
+
handler(obj);
|
|
8683
|
+
}
|
|
8684
|
+
}
|
|
8685
|
+
}
|
|
8650
8686
|
|
|
8651
8687
|
//WebSocket send helper
|
|
8652
8688
|
function send(message, data) {
|
|
@@ -9781,6 +9817,10 @@ var createSession = function createSession(options) {
|
|
|
9781
9817
|
statsCollector.start();
|
|
9782
9818
|
}
|
|
9783
9819
|
}
|
|
9820
|
+
if (streamInfo.authorization && statsCollector && statsCollector.description.ingestPoint) {
|
|
9821
|
+
statsCollector.description.authorization = streamInfo.authorization;
|
|
9822
|
+
statsCollector.updateHttpConnection(statsCollector.description.ingestPoint, statsCollector.description.authorization);
|
|
9823
|
+
}
|
|
9784
9824
|
|
|
9785
9825
|
// Pause or resume metrics collection
|
|
9786
9826
|
if (!streamInfo.status && streamInfo.collect !== undefined && statsCollector) {
|
|
@@ -10635,7 +10675,7 @@ var createSession = function createSession(options) {
|
|
|
10635
10675
|
* @memberof Stream
|
|
10636
10676
|
*/
|
|
10637
10677
|
var setZoom = /*#__PURE__*/function () {
|
|
10638
|
-
var
|
|
10678
|
+
var _ref4 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(value) {
|
|
10639
10679
|
return _regenerator().w(function (_context2) {
|
|
10640
10680
|
while (1) switch (_context2.n) {
|
|
10641
10681
|
case 0:
|
|
@@ -10655,7 +10695,7 @@ var createSession = function createSession(options) {
|
|
|
10655
10695
|
}, _callee2);
|
|
10656
10696
|
}));
|
|
10657
10697
|
return function setZoom(_x2) {
|
|
10658
|
-
return
|
|
10698
|
+
return _ref4.apply(this, arguments);
|
|
10659
10699
|
};
|
|
10660
10700
|
}();
|
|
10661
10701
|
stream.play = play;
|
|
@@ -11007,6 +11047,7 @@ module.exports = {
|
|
|
11007
11047
|
isUsingTemasys: isUsingTemasys,
|
|
11008
11048
|
getMediaProviders: getMediaProviders,
|
|
11009
11049
|
getMediaDevices: getMediaDevices,
|
|
11050
|
+
getMobileDevices: getMobileDevices,
|
|
11010
11051
|
getMediaAccess: getMediaAccess,
|
|
11011
11052
|
releaseLocalMedia: releaseLocalMedia,
|
|
11012
11053
|
getSessions: getSessions,
|
|
@@ -11374,6 +11415,11 @@ var StreamStatsCollector = function StreamStatsCollector(description, id, mediaC
|
|
|
11374
11415
|
}
|
|
11375
11416
|
return updateCompression;
|
|
11376
11417
|
}(),
|
|
11418
|
+
updateHttpConnection: function updateHttpConnection(url, authorization) {
|
|
11419
|
+
if (url.startsWith(CONNECTION_TYPE.HTTP) && authorization) {
|
|
11420
|
+
statCollector.connection.http.setAuthorization(authorization);
|
|
11421
|
+
}
|
|
11422
|
+
},
|
|
11377
11423
|
checkForCompression: function () {
|
|
11378
11424
|
var _checkForCompression = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(compression) {
|
|
11379
11425
|
var _t2;
|
|
@@ -11465,6 +11511,9 @@ var StreamStatsCollector = function StreamStatsCollector(description, id, mediaC
|
|
|
11465
11511
|
statCollector.metricsBatch = null;
|
|
11466
11512
|
}
|
|
11467
11513
|
},
|
|
11514
|
+
isMetricValid: function isMetricValid(value) {
|
|
11515
|
+
return value != null && value !== "" && value !== "undefined" && value !== "null";
|
|
11516
|
+
},
|
|
11468
11517
|
collectMetrics: function () {
|
|
11469
11518
|
var _collectMetrics = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee8() {
|
|
11470
11519
|
var stats, metrics, lostMetrics, headersUpdated;
|
|
@@ -11511,7 +11560,7 @@ var StreamStatsCollector = function StreamStatsCollector(description, id, mediaC
|
|
|
11511
11560
|
_iterator2.f();
|
|
11512
11561
|
}
|
|
11513
11562
|
}
|
|
11514
|
-
if (value) {
|
|
11563
|
+
if (statCollector.isMetricValid(value)) {
|
|
11515
11564
|
metrics.push(value);
|
|
11516
11565
|
} else {
|
|
11517
11566
|
lostMetrics.push(descriptor);
|
|
@@ -11765,6 +11814,9 @@ var HttpConnection = function HttpConnection(url, headers) {
|
|
|
11765
11814
|
var connection = {
|
|
11766
11815
|
url: addSlash(url),
|
|
11767
11816
|
headers: headers,
|
|
11817
|
+
setAuthorization: function setAuthorization(token) {
|
|
11818
|
+
this.headers.Authorization = token;
|
|
11819
|
+
},
|
|
11768
11820
|
send: function () {
|
|
11769
11821
|
var _send3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee1(message, data) {
|
|
11770
11822
|
var code, httpHeaders, _i2, _Object$entries, _Object$entries$_i, header, value, response, _t5;
|
|
@@ -14006,6 +14058,66 @@ var available = function available() {
|
|
|
14006
14058
|
//return (adapter.browserDetails.browser != "edge") ? navigator.getUserMedia && RTCPeerConnection : false;
|
|
14007
14059
|
return 'getUserMedia' in navigator && 'RTCPeerConnection' in window;
|
|
14008
14060
|
};
|
|
14061
|
+
|
|
14062
|
+
/**
|
|
14063
|
+
* Helper function to get media devices list in id, label, type form
|
|
14064
|
+
*
|
|
14065
|
+
* @param devices
|
|
14066
|
+
* @param kind
|
|
14067
|
+
* @param videoFilter
|
|
14068
|
+
* @returns {{audio: *[], video: *[]}}
|
|
14069
|
+
*/
|
|
14070
|
+
var getList = function getList(devices, kind) {
|
|
14071
|
+
var videoFilter = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
|
|
14072
|
+
var list = {
|
|
14073
|
+
audio: [],
|
|
14074
|
+
video: []
|
|
14075
|
+
};
|
|
14076
|
+
var micCount = 0;
|
|
14077
|
+
var outputCount = 0;
|
|
14078
|
+
var camCount = 0;
|
|
14079
|
+
for (var i = 0; i < devices.length; i++) {
|
|
14080
|
+
var device = devices[i];
|
|
14081
|
+
var ret = {
|
|
14082
|
+
id: device.deviceId,
|
|
14083
|
+
label: device.label
|
|
14084
|
+
};
|
|
14085
|
+
if (device.kind.indexOf("audio" + kind) === 0 && device.deviceId !== "communications") {
|
|
14086
|
+
ret.type = device.kind === "audioinput" ? "mic" : "speaker";
|
|
14087
|
+
if (ret.type === "mic" && ret.label === "") {
|
|
14088
|
+
ret.label = 'microphone' + ++micCount;
|
|
14089
|
+
}
|
|
14090
|
+
if (ret.type === "speaker" && ret.label === "") {
|
|
14091
|
+
ret.label = 'speaker' + ++outputCount;
|
|
14092
|
+
}
|
|
14093
|
+
list.audio.push(ret);
|
|
14094
|
+
} else if (device.kind.indexOf("video" + kind) === 0) {
|
|
14095
|
+
if (!videoFilter || videoFilter.find(function (id) {
|
|
14096
|
+
return id === device.deviceId;
|
|
14097
|
+
})) {
|
|
14098
|
+
if (ret.label === "") {
|
|
14099
|
+
ret.label = 'camera' + ++camCount;
|
|
14100
|
+
}
|
|
14101
|
+
ret.type = "camera";
|
|
14102
|
+
list.video.push(ret);
|
|
14103
|
+
} else {
|
|
14104
|
+
logger.debug(LOG_PREFIX, "Video device " + device.deviceId + "does not conform the filter " + JSON.stringify(videoFilter));
|
|
14105
|
+
}
|
|
14106
|
+
} else {
|
|
14107
|
+
logger.debug(LOG_PREFIX, "unknown device " + device.kind + " id " + device.deviceId);
|
|
14108
|
+
}
|
|
14109
|
+
}
|
|
14110
|
+
return list;
|
|
14111
|
+
};
|
|
14112
|
+
|
|
14113
|
+
/**
|
|
14114
|
+
* Get media devices list
|
|
14115
|
+
*
|
|
14116
|
+
* @param labels
|
|
14117
|
+
* @param kind
|
|
14118
|
+
* @param deviceConstraints
|
|
14119
|
+
* @returns {Promise<{audio: [], video: []}>}
|
|
14120
|
+
*/
|
|
14009
14121
|
var listDevices = function listDevices(labels, kind, deviceConstraints) {
|
|
14010
14122
|
//WCS-1963. added deviceConstraints.
|
|
14011
14123
|
if (!deviceConstraints) {
|
|
@@ -14016,7 +14128,7 @@ var listDevices = function listDevices(labels, kind, deviceConstraints) {
|
|
|
14016
14128
|
}
|
|
14017
14129
|
if (!kind) {
|
|
14018
14130
|
kind = constants.MEDIA_DEVICE_KIND.INPUT;
|
|
14019
|
-
} else if (kind
|
|
14131
|
+
} else if (kind === constants.MEDIA_DEVICE_KIND.ALL) {
|
|
14020
14132
|
kind = "";
|
|
14021
14133
|
}
|
|
14022
14134
|
var getConstraints = function getConstraints(devices) {
|
|
@@ -14024,50 +14136,15 @@ var listDevices = function listDevices(labels, kind, deviceConstraints) {
|
|
|
14024
14136
|
for (var i = 0; i < devices.length; i++) {
|
|
14025
14137
|
var device = devices[i];
|
|
14026
14138
|
if (device.kind.indexOf("audio" + kind) === 0 && deviceConstraints.audio) {
|
|
14027
|
-
constraints.audio =
|
|
14139
|
+
constraints.audio = deviceConstraints.audio;
|
|
14028
14140
|
} else if (device.kind.indexOf("video" + kind) === 0 && deviceConstraints.video) {
|
|
14029
|
-
constraints.video =
|
|
14141
|
+
constraints.video = deviceConstraints.video;
|
|
14030
14142
|
} else {
|
|
14031
14143
|
logger.debug(LOG_PREFIX, "unknown device " + device.kind + " id " + device.deviceId);
|
|
14032
14144
|
}
|
|
14033
14145
|
}
|
|
14034
14146
|
return constraints;
|
|
14035
14147
|
};
|
|
14036
|
-
var getList = function getList(devices) {
|
|
14037
|
-
var list = {
|
|
14038
|
-
audio: [],
|
|
14039
|
-
video: []
|
|
14040
|
-
};
|
|
14041
|
-
var micCount = 0;
|
|
14042
|
-
var outputCount = 0;
|
|
14043
|
-
var camCount = 0;
|
|
14044
|
-
for (var i = 0; i < devices.length; i++) {
|
|
14045
|
-
var device = devices[i];
|
|
14046
|
-
var ret = {
|
|
14047
|
-
id: device.deviceId,
|
|
14048
|
-
label: device.label
|
|
14049
|
-
};
|
|
14050
|
-
if (device.kind.indexOf("audio" + kind) === 0 && device.deviceId != "communications") {
|
|
14051
|
-
ret.type = device.kind == "audioinput" ? "mic" : "speaker";
|
|
14052
|
-
if (ret.type == "mic" && ret.label == "") {
|
|
14053
|
-
ret.label = 'microphone' + ++micCount;
|
|
14054
|
-
}
|
|
14055
|
-
if (ret.type == "speaker" && ret.label == "") {
|
|
14056
|
-
ret.label = 'speaker' + ++outputCount;
|
|
14057
|
-
}
|
|
14058
|
-
list.audio.push(ret);
|
|
14059
|
-
} else if (device.kind.indexOf("video" + kind) === 0) {
|
|
14060
|
-
if (ret.label == "") {
|
|
14061
|
-
ret.label = 'camera' + ++camCount;
|
|
14062
|
-
}
|
|
14063
|
-
ret.type = "camera";
|
|
14064
|
-
list.video.push(ret);
|
|
14065
|
-
} else {
|
|
14066
|
-
logger.debug(LOG_PREFIX, "unknown device " + device.kind + " id " + device.deviceId);
|
|
14067
|
-
}
|
|
14068
|
-
}
|
|
14069
|
-
return list;
|
|
14070
|
-
};
|
|
14071
14148
|
return new Promise(function (resolve, reject) {
|
|
14072
14149
|
navigator.mediaDevices.enumerateDevices().then(function (devices) {
|
|
14073
14150
|
if (labels) {
|
|
@@ -14079,18 +14156,153 @@ var listDevices = function listDevices(labels, kind, deviceConstraints) {
|
|
|
14079
14156
|
}
|
|
14080
14157
|
navigator.getUserMedia(constraints, function (stream) {
|
|
14081
14158
|
navigator.mediaDevices.enumerateDevices().then(function (devicesWithLabels) {
|
|
14082
|
-
resolve(getList(devicesWithLabels));
|
|
14159
|
+
resolve(getList(devicesWithLabels, kind));
|
|
14083
14160
|
stream.getTracks().forEach(function (track) {
|
|
14084
14161
|
track.stop();
|
|
14085
14162
|
});
|
|
14086
14163
|
}, reject);
|
|
14087
14164
|
}, reject);
|
|
14088
14165
|
} else {
|
|
14089
|
-
resolve(getList(devices));
|
|
14166
|
+
resolve(getList(devices, kind));
|
|
14090
14167
|
}
|
|
14091
14168
|
}, reject);
|
|
14092
14169
|
});
|
|
14093
14170
|
};
|
|
14171
|
+
var getMobileDevices = /*#__PURE__*/function () {
|
|
14172
|
+
var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(kind) {
|
|
14173
|
+
var deviceConstraints,
|
|
14174
|
+
constraints,
|
|
14175
|
+
videoFilter,
|
|
14176
|
+
list,
|
|
14177
|
+
getCamera,
|
|
14178
|
+
front,
|
|
14179
|
+
back,
|
|
14180
|
+
_stream,
|
|
14181
|
+
mediaDevices,
|
|
14182
|
+
_args4 = arguments,
|
|
14183
|
+
_t2;
|
|
14184
|
+
return _regenerator().w(function (_context4) {
|
|
14185
|
+
while (1) switch (_context4.p = _context4.n) {
|
|
14186
|
+
case 0:
|
|
14187
|
+
deviceConstraints = _args4.length > 1 && _args4[1] !== undefined ? _args4[1] : null;
|
|
14188
|
+
constraints = {};
|
|
14189
|
+
videoFilter = [];
|
|
14190
|
+
list = null;
|
|
14191
|
+
if (!kind) {
|
|
14192
|
+
kind = constants.MEDIA_DEVICE_KIND.INPUT;
|
|
14193
|
+
} else if (kind === constants.MEDIA_DEVICE_KIND.ALL) {
|
|
14194
|
+
kind = "";
|
|
14195
|
+
}
|
|
14196
|
+
if (deviceConstraints && deviceConstraints.audio) {
|
|
14197
|
+
constraints.audio = deviceConstraints.audio;
|
|
14198
|
+
} else {
|
|
14199
|
+
constraints.audio = true;
|
|
14200
|
+
}
|
|
14201
|
+
if (deviceConstraints && deviceConstraints.video) {
|
|
14202
|
+
if (_typeof(deviceConstraints.video) === 'object') {
|
|
14203
|
+
constraints.video = deviceConstraints.video;
|
|
14204
|
+
} else {
|
|
14205
|
+
constraints.video = {};
|
|
14206
|
+
}
|
|
14207
|
+
} else {
|
|
14208
|
+
constraints.video = {};
|
|
14209
|
+
}
|
|
14210
|
+
getCamera = /*#__PURE__*/function () {
|
|
14211
|
+
var _ref4 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(constraints, facingMode) {
|
|
14212
|
+
var deviceId, mediaConstraints, _t;
|
|
14213
|
+
return _regenerator().w(function (_context3) {
|
|
14214
|
+
while (1) switch (_context3.p = _context3.n) {
|
|
14215
|
+
case 0:
|
|
14216
|
+
deviceId = null;
|
|
14217
|
+
mediaConstraints = {
|
|
14218
|
+
audio: false,
|
|
14219
|
+
video: constraints.video
|
|
14220
|
+
};
|
|
14221
|
+
mediaConstraints.video.facingMode = facingMode;
|
|
14222
|
+
_context3.p = 1;
|
|
14223
|
+
_context3.n = 2;
|
|
14224
|
+
return navigator.mediaDevices.getUserMedia(mediaConstraints);
|
|
14225
|
+
case 2:
|
|
14226
|
+
stream = _context3.v;
|
|
14227
|
+
if (stream) {
|
|
14228
|
+
if (stream.getVideoTracks().length > 0) {
|
|
14229
|
+
deviceId = stream.getVideoTracks()[0].getSettings().deviceId;
|
|
14230
|
+
}
|
|
14231
|
+
stream.getTracks().forEach(function (track) {
|
|
14232
|
+
track.stop();
|
|
14233
|
+
});
|
|
14234
|
+
}
|
|
14235
|
+
_context3.n = 4;
|
|
14236
|
+
break;
|
|
14237
|
+
case 3:
|
|
14238
|
+
_context3.p = 3;
|
|
14239
|
+
_t = _context3.v;
|
|
14240
|
+
logger.error(LOG_PREFIX, "Can't get device access with video constraints " + JSON.stringify(constraints.video) + ", error " + _t);
|
|
14241
|
+
case 4:
|
|
14242
|
+
return _context3.a(2, deviceId);
|
|
14243
|
+
}
|
|
14244
|
+
}, _callee3, null, [[1, 3]]);
|
|
14245
|
+
}));
|
|
14246
|
+
return function getCamera(_x5, _x6) {
|
|
14247
|
+
return _ref4.apply(this, arguments);
|
|
14248
|
+
};
|
|
14249
|
+
}();
|
|
14250
|
+
_context4.n = 1;
|
|
14251
|
+
return getCamera(constraints, {
|
|
14252
|
+
ideal: 'user'
|
|
14253
|
+
});
|
|
14254
|
+
case 1:
|
|
14255
|
+
front = _context4.v;
|
|
14256
|
+
if (front && front !== "") {
|
|
14257
|
+
logger.debug(LOG_PREFIX, "Front camera id: " + front);
|
|
14258
|
+
videoFilter.push(front);
|
|
14259
|
+
}
|
|
14260
|
+
_context4.n = 2;
|
|
14261
|
+
return getCamera(constraints, {
|
|
14262
|
+
ideal: 'environment'
|
|
14263
|
+
});
|
|
14264
|
+
case 2:
|
|
14265
|
+
back = _context4.v;
|
|
14266
|
+
if (back && back !== "") {
|
|
14267
|
+
logger.debug(LOG_PREFIX, "Back camera id: " + back);
|
|
14268
|
+
videoFilter.push(back);
|
|
14269
|
+
}
|
|
14270
|
+
_context4.p = 3;
|
|
14271
|
+
_context4.n = 4;
|
|
14272
|
+
return navigator.mediaDevices.getUserMedia(constraints);
|
|
14273
|
+
case 4:
|
|
14274
|
+
_stream = _context4.v;
|
|
14275
|
+
if (!_stream) {
|
|
14276
|
+
_context4.n = 6;
|
|
14277
|
+
break;
|
|
14278
|
+
}
|
|
14279
|
+
_context4.n = 5;
|
|
14280
|
+
return navigator.mediaDevices.enumerateDevices();
|
|
14281
|
+
case 5:
|
|
14282
|
+
mediaDevices = _context4.v;
|
|
14283
|
+
if (mediaDevices) {
|
|
14284
|
+
logger.debug(LOG_PREFIX, "mediaDevices: " + JSON.stringify(mediaDevices));
|
|
14285
|
+
list = getList(mediaDevices, kind, videoFilter);
|
|
14286
|
+
}
|
|
14287
|
+
_stream.getTracks().forEach(function (track) {
|
|
14288
|
+
track.stop();
|
|
14289
|
+
});
|
|
14290
|
+
case 6:
|
|
14291
|
+
_context4.n = 8;
|
|
14292
|
+
break;
|
|
14293
|
+
case 7:
|
|
14294
|
+
_context4.p = 7;
|
|
14295
|
+
_t2 = _context4.v;
|
|
14296
|
+
logger.error(LOG_PREFIX, "Can't get device access with constraints " + JSON.stringify(constraints) + ", error " + _t2);
|
|
14297
|
+
case 8:
|
|
14298
|
+
return _context4.a(2, list);
|
|
14299
|
+
}
|
|
14300
|
+
}, _callee4, null, [[3, 7]]);
|
|
14301
|
+
}));
|
|
14302
|
+
return function getMobileDevices(_x4) {
|
|
14303
|
+
return _ref3.apply(this, arguments);
|
|
14304
|
+
};
|
|
14305
|
+
}();
|
|
14094
14306
|
function normalizeConstraints(constraints) {
|
|
14095
14307
|
//WCS-2010. fixed TypeError after publish->stop->publish
|
|
14096
14308
|
//WCS-2373. fixed customStream
|
|
@@ -14219,6 +14431,7 @@ module.exports = {
|
|
|
14219
14431
|
getMediaAccess: getMediaAccess,
|
|
14220
14432
|
releaseMedia: releaseMedia,
|
|
14221
14433
|
listDevices: listDevices,
|
|
14434
|
+
getMobileDevices: getMobileDevices,
|
|
14222
14435
|
playFirstSound: playFirstSound,
|
|
14223
14436
|
playFirstVideo: playFirstVideo,
|
|
14224
14437
|
available: available,
|