@flashphoner/websdk 2.0.245 → 2.0.247

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.
@@ -19,6 +19,8 @@ var validBrowsers = ["firefox", "chrome", "safari"];
19
19
  var videoCams = [];
20
20
  // list of presented audio input devices
21
21
  var mics = [];
22
+ // current audio source device label
23
+ let audioSourceDevice = "";
22
24
 
23
25
  var createConnection = function (options) {
24
26
  return new Promise(function (resolve, reject) {
@@ -461,18 +463,25 @@ var createConnection = function (options) {
461
463
  stat.forEach(function (report) {
462
464
  if (!report.isRemote) {
463
465
  let mediaType = "";
464
- if (report.type == 'outbound-rtp') {
466
+ if (report.type === 'outbound-rtp') {
465
467
  mediaType = getReportMediaType(report);
466
468
  fillStatObject(result.outboundStream, report, mediaType);
467
- if (mediaType == 'video') {
469
+ if (mediaType === 'video') {
468
470
  getVideoSize(result.outboundStream[mediaType], report);
469
471
  }
470
- } else if (report.type == 'inbound-rtp') {
472
+ } else if (report.type === 'inbound-rtp') {
471
473
  mediaType = getReportMediaType(report);
472
474
  fillStatObject(result.inboundStream, report, mediaType);
473
- if (mediaType == 'video') {
475
+ if (mediaType === 'video') {
474
476
  getVideoSize(result.inboundStream[mediaType], report);
475
477
  }
478
+ } else if (report.type === 'candidate-pair' && report.state === 'succeeded' && report.nominated) {
479
+ if (report.availableIncomingBitrate) {
480
+ result.otherStats.availableIncomingBitrate = report.availableIncomingBitrate;
481
+ } else if (localVideo && report.availableOutgoingBitrate) {
482
+ // availableOutgoingBitrate is defined for incoming stream too #WCS-4175
483
+ result.otherStats.availableOutgoingBitrate = report.availableOutgoingBitrate;
484
+ }
476
485
  }
477
486
  }
478
487
  });
@@ -530,19 +539,27 @@ var createConnection = function (options) {
530
539
  } else {
531
540
  logger.debug(LOG_PREFIX, "Can't parse current SDP to detect codec and sampleRate");
532
541
  }
533
- var codec = util.getCurrentCodecAndSampleRate(sdp, mediaType);
542
+ let codec = util.getCurrentCodecAndSampleRate(sdp, mediaType);
534
543
  obj[mediaType]["codec"] = codec.name;
535
544
  obj[mediaType]["codecRate"] = codec.sampleRate;
545
+ let qualityLimitationDurations;
536
546
  Object.keys(report).forEach(function (key) {
537
547
  // Add audioLevel parameter parsing #WCS-3290
538
548
  if (key.startsWith("bytes") ||
539
549
  key.startsWith("packets") ||
540
550
  key.indexOf("Count") != -1 ||
541
551
  key.indexOf("audioLevel") != -1 ||
542
- key == "framesPerSecond") {
552
+ key === "framesPerSecond" ||
553
+ key === "qualityLimitationReason" ) {
543
554
  obj[mediaType][key] = report[key];
544
555
  }
556
+ if (key === "qualityLimitationDurations") {
557
+ qualityLimitationDurations = report[key];
558
+ }
545
559
  });
560
+ if (qualityLimitationDurations) {
561
+ obj[mediaType]["qualityLimitationDurations"] = qualityLimitationDurations[obj[mediaType]["qualityLimitationReason"]];
562
+ }
546
563
  };
547
564
 
548
565
  var fullScreen = function () {
@@ -955,10 +972,14 @@ var getMediaAccess = function (constraints, display, disableConstraintsNormaliza
955
972
  // WCS-2933, fix mobile streaming issues, gather info about available devices before streaming, but not during
956
973
  listDevices(false).then((devices) => {
957
974
  devices.video.forEach(function (device) {
958
- videoCams.push(device);
975
+ if (!videoCams.find((cam) => device.id === cam.id)) {
976
+ videoCams.push(device);
977
+ }
959
978
  })
960
979
  devices.audio.forEach(function (device) {
961
- mics.push(device);
980
+ if (!mics.find((mic) => device.id === mic.id)) {
981
+ mics.push(device);
982
+ }
962
983
  })
963
984
  navigator.getUserMedia(constraints, function (stream) {
964
985
  loadVideo(display, stream, screenShare, requestAudioConstraints, resolve, constraints, useCanvas);
@@ -1188,6 +1209,7 @@ var createGainNode = function (stream) {
1188
1209
  source.connect(gainNode);
1189
1210
  gainNode.connect(destination);
1190
1211
  var sourceAudioTrack = stream.getAudioTracks()[0];
1212
+ audioSourceDevice = sourceAudioTrack.label;
1191
1213
  gainNode.sourceAudioTrack = sourceAudioTrack;
1192
1214
  gainNode.release = function () {
1193
1215
  this.sourceAudioTrack.stop();
@@ -1198,6 +1220,10 @@ var createGainNode = function (stream) {
1198
1220
  return gainNode;
1199
1221
  };
1200
1222
 
1223
+ const getAudioSourceDevice = function () {
1224
+ return audioSourceDevice;
1225
+ }
1226
+
1201
1227
  //Fix to set screen resolution for screen sharing in Firefox
1202
1228
  var setScreenResolution = function (video, stream, constraints) {
1203
1229
  var newHeight;
@@ -1314,6 +1340,22 @@ function getCacheInstance(display) {
1314
1340
  }
1315
1341
  }
1316
1342
 
1343
+ function getVideoElement(display) {
1344
+ if (display) {
1345
+ for (const child of display.children) {
1346
+ if (child.tagName.toLowerCase() === "video") {
1347
+ return child;
1348
+ } else {
1349
+ let grandchild = getVideoElement(child);
1350
+ if (grandchild) {
1351
+ return grandchild;
1352
+ }
1353
+ }
1354
+ }
1355
+ }
1356
+ return null;
1357
+ }
1358
+
1317
1359
  function createVideoElement(useControls = false) {
1318
1360
  let video = document.createElement('video');
1319
1361
  // Prepare video tag to auto play and add specific Safari tweaks #WCS-2425
@@ -1440,8 +1482,8 @@ var listDevices = function (labels, kind, deviceConstraints) {
1440
1482
  return;
1441
1483
  }
1442
1484
  navigator.getUserMedia(constraints, function (stream) {
1443
- navigator.mediaDevices.enumerateDevices().then(function (devicesWithLabales) {
1444
- resolve(getList(devicesWithLabales));
1485
+ navigator.mediaDevices.enumerateDevices().then(function (devicesWithLabels) {
1486
+ resolve(getList(devicesWithLabels));
1445
1487
  stream.getTracks().forEach(function (track) {
1446
1488
  track.stop();
1447
1489
  });
@@ -1581,5 +1623,10 @@ module.exports = {
1581
1623
  logger = configuration.logger;
1582
1624
  createMicGainNode = (typeof configuration.createMicGainNode !== 'undefined') ? configuration.createMicGainNode : true;
1583
1625
  logger.info(LOG_PREFIX, "Initialized");
1584
- }
1626
+ },
1627
+ videoCams: videoCams,
1628
+ mics: mics,
1629
+ getAudioSourceDevice: getAudioSourceDevice,
1630
+ getCacheInstance: getCacheInstance,
1631
+ getVideoElement: getVideoElement
1585
1632
  };