@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.
@@ -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 "webRTCMetricsDescriptionUpdate":
9440
- if (obj.ids) {
9441
- obj.ids.forEach(function (id) {
9442
- if (streamRefreshHandlers[id]) {
9443
- streamRefreshHandlers[id](obj);
9444
- }
9445
- });
9446
- } else {
9447
- if (obj.compression) {
9448
- webRTCMetricsServerDescription.compression = obj.compression;
9449
- }
9450
- if (obj.batchSize) {
9451
- webRTCMetricsServerDescription.batchSize = obj.batchSize;
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 _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(value) {
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 _ref2.apply(this, arguments);
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;