@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.
@@ -10060,6 +10060,34 @@ var getMediaDevices = function getMediaDevices(mediaProvider, labels, kind, devi
10060
10060
  return MediaProvider[mediaProvider].listDevices(labels, kind, deviceConstraints);
10061
10061
  };
10062
10062
 
10063
+ /**
10064
+ * Get mobile local media devices
10065
+ *
10066
+ * @param {String=} mediaProvider Media provider that will be asked for device list
10067
+ * @param {Flashphoner.constants.MEDIA_DEVICE_KIND} kind Media devices kind to access:
10068
+ * MEDIA_DEVICE_KIND.INPUT (default) get access to input devices only (camera, mic).
10069
+ * MEDIA_DEVICE_KIND.OUTPUT get access to output devices only (speaker, headphone).
10070
+ * MEDIA_DEVICE_KIND.ALL get access to all devices (cam, mic, speaker, headphone).
10071
+ * @param {Object=} deviceConstraints
10072
+ * If {audio: true, video: false}, then access to the camera will not be requested.
10073
+ * If {audio: false, video: true}, then access to the microphone will not be requested.
10074
+ * @returns {Promise.<Flashphoner.MediaDeviceList>} Promise with media device list on fulfill
10075
+ * @throws {Error} Error if API is not initialized
10076
+ * @memberof Flashphoner
10077
+ */
10078
+ var getMobileDevices = function getMobileDevices(mediaProvider, kind, deviceConstraints) {
10079
+ if (!initialized) {
10080
+ throw new Error("Flashphoner API is not initialized");
10081
+ }
10082
+ if (!mediaProvider) {
10083
+ mediaProvider = getMediaProviders()[0];
10084
+ }
10085
+ if (MediaProvider[mediaProvider].getMobileDevices) {
10086
+ return MediaProvider[mediaProvider].getMobileDevices(kind, deviceConstraints);
10087
+ }
10088
+ return [];
10089
+ };
10090
+
10063
10091
  /**
10064
10092
  * Get access to local media
10065
10093
  *
@@ -10497,36 +10525,19 @@ var createSession = function createSession(options) {
10497
10525
  streamRefreshHandlers[obj.mediaSessionId](obj);
10498
10526
  }
10499
10527
  break;
10500
- case "webRTCMetricsDescriptionUpdate":
10501
- if (obj.ids) {
10502
- obj.ids.forEach(function (id) {
10503
- if (streamRefreshHandlers[id]) {
10504
- streamRefreshHandlers[id](obj);
10505
- }
10506
- });
10507
- } else {
10508
- if (obj.compression) {
10509
- webRTCMetricsServerDescription.compression = obj.compression;
10510
- }
10511
- if (obj.batchSize) {
10512
- webRTCMetricsServerDescription.batchSize = obj.batchSize;
10513
- }
10514
- if (obj.sampling) {
10515
- webRTCMetricsServerDescription.sampling = obj.sampling;
10516
- }
10517
- if (obj.types) {
10518
- webRTCMetricsServerDescription.types = obj.types;
10519
- }
10520
- if (obj.collect) {
10521
- webRTCMetricsServerDescription.collect = obj.collect;
10522
- }
10523
- for (var _i = 0, _Object$entries = Object.entries(streamRefreshHandlers); _i < _Object$entries.length; _i++) {
10524
- var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
10525
- _id = _Object$entries$_i[0],
10526
- handler = _Object$entries$_i[1];
10527
- handler(obj);
10528
- }
10529
- }
10528
+ case 'webRTCMetricsDescriptionUpdate':
10529
+ handleWebRTCMetricsUpdate(obj, {
10530
+ compression: "compression",
10531
+ batchSize: "batchSize",
10532
+ sampling: "sampling",
10533
+ types: "types",
10534
+ collect: "collect"
10535
+ });
10536
+ break;
10537
+ case 'webRTCMetricsTokenRefresh':
10538
+ handleWebRTCMetricsUpdate(obj, {
10539
+ authorization: "authorization"
10540
+ });
10530
10541
  break;
10531
10542
  default:
10532
10543
  logger.info(LOG_PREFIX, "Unknown server message " + data.message);
@@ -10536,6 +10547,31 @@ var createSession = function createSession(options) {
10536
10547
  wsPingReceiver.success();
10537
10548
  };
10538
10549
  }
10550
+ function handleWebRTCMetricsUpdate(obj) {
10551
+ var updateFields = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
10552
+ if (obj.ids) {
10553
+ obj.ids.forEach(function (id) {
10554
+ if (streamRefreshHandlers[id]) {
10555
+ streamRefreshHandlers[id](obj);
10556
+ }
10557
+ });
10558
+ } else {
10559
+ Object.entries(updateFields).forEach(function (_ref2) {
10560
+ var _ref3 = _slicedToArray(_ref2, 2),
10561
+ key = _ref3[0],
10562
+ value = _ref3[1];
10563
+ if (obj[value] !== undefined) {
10564
+ webRTCMetricsServerDescription[key] = obj[value];
10565
+ }
10566
+ });
10567
+ for (var _i = 0, _Object$entries = Object.entries(streamRefreshHandlers); _i < _Object$entries.length; _i++) {
10568
+ var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
10569
+ _id = _Object$entries$_i[0],
10570
+ handler = _Object$entries$_i[1];
10571
+ handler(obj);
10572
+ }
10573
+ }
10574
+ }
10539
10575
 
10540
10576
  //WebSocket send helper
10541
10577
  function send(message, data) {
@@ -11670,6 +11706,10 @@ var createSession = function createSession(options) {
11670
11706
  statsCollector.start();
11671
11707
  }
11672
11708
  }
11709
+ if (streamInfo.authorization && statsCollector && statsCollector.description.ingestPoint) {
11710
+ statsCollector.description.authorization = streamInfo.authorization;
11711
+ statsCollector.updateHttpConnection(statsCollector.description.ingestPoint, statsCollector.description.authorization);
11712
+ }
11673
11713
 
11674
11714
  // Pause or resume metrics collection
11675
11715
  if (!streamInfo.status && streamInfo.collect !== undefined && statsCollector) {
@@ -12524,7 +12564,7 @@ var createSession = function createSession(options) {
12524
12564
  * @memberof Stream
12525
12565
  */
12526
12566
  var setZoom = /*#__PURE__*/function () {
12527
- var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(value) {
12567
+ var _ref4 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(value) {
12528
12568
  return _regenerator().w(function (_context2) {
12529
12569
  while (1) switch (_context2.n) {
12530
12570
  case 0:
@@ -12544,7 +12584,7 @@ var createSession = function createSession(options) {
12544
12584
  }, _callee2);
12545
12585
  }));
12546
12586
  return function setZoom(_x2) {
12547
- return _ref2.apply(this, arguments);
12587
+ return _ref4.apply(this, arguments);
12548
12588
  };
12549
12589
  }();
12550
12590
  stream.play = play;
@@ -12896,6 +12936,7 @@ module.exports = {
12896
12936
  isUsingTemasys: isUsingTemasys,
12897
12937
  getMediaProviders: getMediaProviders,
12898
12938
  getMediaDevices: getMediaDevices,
12939
+ getMobileDevices: getMobileDevices,
12899
12940
  getMediaAccess: getMediaAccess,
12900
12941
  releaseLocalMedia: releaseLocalMedia,
12901
12942
  getSessions: getSessions,
@@ -13263,6 +13304,11 @@ var StreamStatsCollector = function StreamStatsCollector(description, id, mediaC
13263
13304
  }
13264
13305
  return updateCompression;
13265
13306
  }(),
13307
+ updateHttpConnection: function updateHttpConnection(url, authorization) {
13308
+ if (url.startsWith(CONNECTION_TYPE.HTTP) && authorization) {
13309
+ statCollector.connection.http.setAuthorization(authorization);
13310
+ }
13311
+ },
13266
13312
  checkForCompression: function () {
13267
13313
  var _checkForCompression = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(compression) {
13268
13314
  var _t2;
@@ -13354,6 +13400,9 @@ var StreamStatsCollector = function StreamStatsCollector(description, id, mediaC
13354
13400
  statCollector.metricsBatch = null;
13355
13401
  }
13356
13402
  },
13403
+ isMetricValid: function isMetricValid(value) {
13404
+ return value != null && value !== "" && value !== "undefined" && value !== "null";
13405
+ },
13357
13406
  collectMetrics: function () {
13358
13407
  var _collectMetrics = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee8() {
13359
13408
  var stats, metrics, lostMetrics, headersUpdated;
@@ -13400,7 +13449,7 @@ var StreamStatsCollector = function StreamStatsCollector(description, id, mediaC
13400
13449
  _iterator2.f();
13401
13450
  }
13402
13451
  }
13403
- if (value) {
13452
+ if (statCollector.isMetricValid(value)) {
13404
13453
  metrics.push(value);
13405
13454
  } else {
13406
13455
  lostMetrics.push(descriptor);
@@ -13654,6 +13703,9 @@ var HttpConnection = function HttpConnection(url, headers) {
13654
13703
  var connection = {
13655
13704
  url: addSlash(url),
13656
13705
  headers: headers,
13706
+ setAuthorization: function setAuthorization(token) {
13707
+ this.headers.Authorization = token;
13708
+ },
13657
13709
  send: function () {
13658
13710
  var _send3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee1(message, data) {
13659
13711
  var code, httpHeaders, _i2, _Object$entries, _Object$entries$_i, header, value, response, _t5;
@@ -16815,6 +16815,34 @@ var getMediaDevices = function getMediaDevices(mediaProvider, labels, kind, devi
16815
16815
  return MediaProvider[mediaProvider].listDevices(labels, kind, deviceConstraints);
16816
16816
  };
16817
16817
 
16818
+ /**
16819
+ * Get mobile local media devices
16820
+ *
16821
+ * @param {String=} mediaProvider Media provider that will be asked for device list
16822
+ * @param {Flashphoner.constants.MEDIA_DEVICE_KIND} kind Media devices kind to access:
16823
+ * MEDIA_DEVICE_KIND.INPUT (default) get access to input devices only (camera, mic).
16824
+ * MEDIA_DEVICE_KIND.OUTPUT get access to output devices only (speaker, headphone).
16825
+ * MEDIA_DEVICE_KIND.ALL get access to all devices (cam, mic, speaker, headphone).
16826
+ * @param {Object=} deviceConstraints
16827
+ * If {audio: true, video: false}, then access to the camera will not be requested.
16828
+ * If {audio: false, video: true}, then access to the microphone will not be requested.
16829
+ * @returns {Promise.<Flashphoner.MediaDeviceList>} Promise with media device list on fulfill
16830
+ * @throws {Error} Error if API is not initialized
16831
+ * @memberof Flashphoner
16832
+ */
16833
+ var getMobileDevices = function getMobileDevices(mediaProvider, kind, deviceConstraints) {
16834
+ if (!initialized) {
16835
+ throw new Error("Flashphoner API is not initialized");
16836
+ }
16837
+ if (!mediaProvider) {
16838
+ mediaProvider = getMediaProviders()[0];
16839
+ }
16840
+ if (MediaProvider[mediaProvider].getMobileDevices) {
16841
+ return MediaProvider[mediaProvider].getMobileDevices(kind, deviceConstraints);
16842
+ }
16843
+ return [];
16844
+ };
16845
+
16818
16846
  /**
16819
16847
  * Get access to local media
16820
16848
  *
@@ -17252,36 +17280,19 @@ var createSession = function createSession(options) {
17252
17280
  streamRefreshHandlers[obj.mediaSessionId](obj);
17253
17281
  }
17254
17282
  break;
17255
- case "webRTCMetricsDescriptionUpdate":
17256
- if (obj.ids) {
17257
- obj.ids.forEach(function (id) {
17258
- if (streamRefreshHandlers[id]) {
17259
- streamRefreshHandlers[id](obj);
17260
- }
17261
- });
17262
- } else {
17263
- if (obj.compression) {
17264
- webRTCMetricsServerDescription.compression = obj.compression;
17265
- }
17266
- if (obj.batchSize) {
17267
- webRTCMetricsServerDescription.batchSize = obj.batchSize;
17268
- }
17269
- if (obj.sampling) {
17270
- webRTCMetricsServerDescription.sampling = obj.sampling;
17271
- }
17272
- if (obj.types) {
17273
- webRTCMetricsServerDescription.types = obj.types;
17274
- }
17275
- if (obj.collect) {
17276
- webRTCMetricsServerDescription.collect = obj.collect;
17277
- }
17278
- for (var _i = 0, _Object$entries = Object.entries(streamRefreshHandlers); _i < _Object$entries.length; _i++) {
17279
- var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
17280
- _id = _Object$entries$_i[0],
17281
- handler = _Object$entries$_i[1];
17282
- handler(obj);
17283
- }
17284
- }
17283
+ case 'webRTCMetricsDescriptionUpdate':
17284
+ handleWebRTCMetricsUpdate(obj, {
17285
+ compression: "compression",
17286
+ batchSize: "batchSize",
17287
+ sampling: "sampling",
17288
+ types: "types",
17289
+ collect: "collect"
17290
+ });
17291
+ break;
17292
+ case 'webRTCMetricsTokenRefresh':
17293
+ handleWebRTCMetricsUpdate(obj, {
17294
+ authorization: "authorization"
17295
+ });
17285
17296
  break;
17286
17297
  default:
17287
17298
  logger.info(LOG_PREFIX, "Unknown server message " + data.message);
@@ -17291,6 +17302,31 @@ var createSession = function createSession(options) {
17291
17302
  wsPingReceiver.success();
17292
17303
  };
17293
17304
  }
17305
+ function handleWebRTCMetricsUpdate(obj) {
17306
+ var updateFields = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
17307
+ if (obj.ids) {
17308
+ obj.ids.forEach(function (id) {
17309
+ if (streamRefreshHandlers[id]) {
17310
+ streamRefreshHandlers[id](obj);
17311
+ }
17312
+ });
17313
+ } else {
17314
+ Object.entries(updateFields).forEach(function (_ref2) {
17315
+ var _ref3 = _slicedToArray(_ref2, 2),
17316
+ key = _ref3[0],
17317
+ value = _ref3[1];
17318
+ if (obj[value] !== undefined) {
17319
+ webRTCMetricsServerDescription[key] = obj[value];
17320
+ }
17321
+ });
17322
+ for (var _i = 0, _Object$entries = Object.entries(streamRefreshHandlers); _i < _Object$entries.length; _i++) {
17323
+ var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
17324
+ _id = _Object$entries$_i[0],
17325
+ handler = _Object$entries$_i[1];
17326
+ handler(obj);
17327
+ }
17328
+ }
17329
+ }
17294
17330
 
17295
17331
  //WebSocket send helper
17296
17332
  function send(message, data) {
@@ -18425,6 +18461,10 @@ var createSession = function createSession(options) {
18425
18461
  statsCollector.start();
18426
18462
  }
18427
18463
  }
18464
+ if (streamInfo.authorization && statsCollector && statsCollector.description.ingestPoint) {
18465
+ statsCollector.description.authorization = streamInfo.authorization;
18466
+ statsCollector.updateHttpConnection(statsCollector.description.ingestPoint, statsCollector.description.authorization);
18467
+ }
18428
18468
 
18429
18469
  // Pause or resume metrics collection
18430
18470
  if (!streamInfo.status && streamInfo.collect !== undefined && statsCollector) {
@@ -19279,7 +19319,7 @@ var createSession = function createSession(options) {
19279
19319
  * @memberof Stream
19280
19320
  */
19281
19321
  var setZoom = /*#__PURE__*/function () {
19282
- var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(value) {
19322
+ var _ref4 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(value) {
19283
19323
  return _regenerator().w(function (_context2) {
19284
19324
  while (1) switch (_context2.n) {
19285
19325
  case 0:
@@ -19299,7 +19339,7 @@ var createSession = function createSession(options) {
19299
19339
  }, _callee2);
19300
19340
  }));
19301
19341
  return function setZoom(_x2) {
19302
- return _ref2.apply(this, arguments);
19342
+ return _ref4.apply(this, arguments);
19303
19343
  };
19304
19344
  }();
19305
19345
  stream.play = play;
@@ -19651,6 +19691,7 @@ module.exports = {
19651
19691
  isUsingTemasys: isUsingTemasys,
19652
19692
  getMediaProviders: getMediaProviders,
19653
19693
  getMediaDevices: getMediaDevices,
19694
+ getMobileDevices: getMobileDevices,
19654
19695
  getMediaAccess: getMediaAccess,
19655
19696
  releaseLocalMedia: releaseLocalMedia,
19656
19697
  getSessions: getSessions,
@@ -20018,6 +20059,11 @@ var StreamStatsCollector = function StreamStatsCollector(description, id, mediaC
20018
20059
  }
20019
20060
  return updateCompression;
20020
20061
  }(),
20062
+ updateHttpConnection: function updateHttpConnection(url, authorization) {
20063
+ if (url.startsWith(CONNECTION_TYPE.HTTP) && authorization) {
20064
+ statCollector.connection.http.setAuthorization(authorization);
20065
+ }
20066
+ },
20021
20067
  checkForCompression: function () {
20022
20068
  var _checkForCompression = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(compression) {
20023
20069
  var _t2;
@@ -20109,6 +20155,9 @@ var StreamStatsCollector = function StreamStatsCollector(description, id, mediaC
20109
20155
  statCollector.metricsBatch = null;
20110
20156
  }
20111
20157
  },
20158
+ isMetricValid: function isMetricValid(value) {
20159
+ return value != null && value !== "" && value !== "undefined" && value !== "null";
20160
+ },
20112
20161
  collectMetrics: function () {
20113
20162
  var _collectMetrics = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee8() {
20114
20163
  var stats, metrics, lostMetrics, headersUpdated;
@@ -20155,7 +20204,7 @@ var StreamStatsCollector = function StreamStatsCollector(description, id, mediaC
20155
20204
  _iterator2.f();
20156
20205
  }
20157
20206
  }
20158
- if (value) {
20207
+ if (statCollector.isMetricValid(value)) {
20159
20208
  metrics.push(value);
20160
20209
  } else {
20161
20210
  lostMetrics.push(descriptor);
@@ -20409,6 +20458,9 @@ var HttpConnection = function HttpConnection(url, headers) {
20409
20458
  var connection = {
20410
20459
  url: addSlash(url),
20411
20460
  headers: headers,
20461
+ setAuthorization: function setAuthorization(token) {
20462
+ this.headers.Authorization = token;
20463
+ },
20412
20464
  send: function () {
20413
20465
  var _send3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee1(message, data) {
20414
20466
  var code, httpHeaders, _i2, _Object$entries, _Object$entries$_i, header, value, response, _t5;