@flashphoner/websdk 2.0.246 → 2.0.248

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.
@@ -6933,7 +6933,7 @@ function getClientInfo(_x, _x2) {
6933
6933
  return _getClientInfo.apply(this, arguments);
6934
6934
  }
6935
6935
  function _getClientInfo() {
6936
- _getClientInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(navigator, keys) {
6936
+ _getClientInfo = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(navigator, keys) {
6937
6937
  var info, customUAData;
6938
6938
  return _regeneratorRuntime().wrap(function _callee$(_context) {
6939
6939
  while (1) switch (_context.prev = _context.next) {
@@ -7900,7 +7900,7 @@ var disableConnectionQualityCalculation;
7900
7900
  * @memberof Flashphoner
7901
7901
  */
7902
7902
  var init = /*#__PURE__*/function () {
7903
- var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(options) {
7903
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(options) {
7904
7904
  var waitingTemasys, audioContext, webRtcProvider, enableGainNode, webRtcConf, flashProvider, flashConf, mediaSourceMediaProvider, mseConf, websocketProvider, wsConf, _MediaProvider, p, newMediaProvider, i, pMP;
7905
7905
  return _regeneratorRuntime().wrap(function _callee$(_context) {
7906
7906
  while (1) switch (_context.prev = _context.next) {
@@ -10052,7 +10052,7 @@ var createSession = function createSession(options) {
10052
10052
  * @memberof Stream
10053
10053
  * @inner
10054
10054
  */
10055
- var stop = function stop() {
10055
+ var _stop = function stop() {
10056
10056
  logger.debug(LOG_PREFIX, "Stop stream " + name_);
10057
10057
  if (status_ == STREAM_STATUS.NEW) {
10058
10058
  //trigger FAILED status
@@ -10062,7 +10062,7 @@ var createSession = function createSession(options) {
10062
10062
  return;
10063
10063
  } else if (status_ == STREAM_STATUS.PENDING) {
10064
10064
  logger.warn(LOG_PREFIX, "Stopping stream before server response " + id_);
10065
- setTimeout(stop, 200);
10065
+ setTimeout(_stop, 200);
10066
10066
  return;
10067
10067
  } else if (status_ == STREAM_STATUS.FAILED) {
10068
10068
  logger.warn(LOG_PREFIX, "Stream status FAILED");
@@ -10473,7 +10473,7 @@ var createSession = function createSession(options) {
10473
10473
  };
10474
10474
  stream.play = play;
10475
10475
  stream.publish = publish;
10476
- stream.stop = stop;
10476
+ stream.stop = _stop;
10477
10477
  stream.id = id;
10478
10478
  stream.status = status;
10479
10479
  stream.name = name;
@@ -11365,7 +11365,7 @@ var createConnection = function createConnection(options) {
11365
11365
  var localVideo;
11366
11366
  //tweak for custom video players #WCS-1511
11367
11367
  var remoteVideo = options.remoteVideo;
11368
- var switchCamCount = 0;
11368
+ var switchCamIndex = 0;
11369
11369
  var switchMicCount = 0;
11370
11370
  var customStream = options.customStream;
11371
11371
  var currentAudioTrack;
@@ -11451,7 +11451,7 @@ var createConnection = function createConnection(options) {
11451
11451
  if (videoTrack) {
11452
11452
  videoCams.forEach(function (cam, index) {
11453
11453
  if (videoTrack.label === cam.label) {
11454
- switchCamCount = index;
11454
+ switchCamIndex = index;
11455
11455
  }
11456
11456
  });
11457
11457
  }
@@ -11772,18 +11772,25 @@ var createConnection = function createConnection(options) {
11772
11772
  stat.forEach(function (report) {
11773
11773
  if (!report.isRemote) {
11774
11774
  var mediaType = "";
11775
- if (report.type == 'outbound-rtp') {
11775
+ if (report.type === 'outbound-rtp') {
11776
11776
  mediaType = getReportMediaType(report);
11777
11777
  fillStatObject(result.outboundStream, report, mediaType);
11778
- if (mediaType == 'video') {
11778
+ if (mediaType === 'video') {
11779
11779
  getVideoSize(result.outboundStream[mediaType], report);
11780
11780
  }
11781
- } else if (report.type == 'inbound-rtp') {
11781
+ } else if (report.type === 'inbound-rtp') {
11782
11782
  mediaType = getReportMediaType(report);
11783
11783
  fillStatObject(result.inboundStream, report, mediaType);
11784
- if (mediaType == 'video') {
11784
+ if (mediaType === 'video') {
11785
11785
  getVideoSize(result.inboundStream[mediaType], report);
11786
11786
  }
11787
+ } else if (report.type === 'candidate-pair' && report.state === 'succeeded' && report.nominated) {
11788
+ if (report.availableIncomingBitrate) {
11789
+ result.otherStats.availableIncomingBitrate = report.availableIncomingBitrate;
11790
+ } else if (localVideo && report.availableOutgoingBitrate) {
11791
+ // availableOutgoingBitrate is defined for incoming stream too #WCS-4175
11792
+ result.otherStats.availableOutgoingBitrate = report.availableOutgoingBitrate;
11793
+ }
11787
11794
  }
11788
11795
  }
11789
11796
  });
@@ -11840,12 +11847,19 @@ var createConnection = function createConnection(options) {
11840
11847
  var codec = util.getCurrentCodecAndSampleRate(sdp, mediaType);
11841
11848
  obj[mediaType]["codec"] = codec.name;
11842
11849
  obj[mediaType]["codecRate"] = codec.sampleRate;
11850
+ var qualityLimitationDurations;
11843
11851
  Object.keys(report).forEach(function (key) {
11844
11852
  // Add audioLevel parameter parsing #WCS-3290
11845
- if (key.startsWith("bytes") || key.startsWith("packets") || key.indexOf("Count") != -1 || key.indexOf("audioLevel") != -1 || key == "framesPerSecond") {
11853
+ if (key.startsWith("bytes") || key.startsWith("packets") || key.indexOf("Count") != -1 || key.indexOf("audioLevel") != -1 || key === "framesPerSecond" || key === "qualityLimitationReason") {
11846
11854
  obj[mediaType][key] = report[key];
11847
11855
  }
11856
+ if (key === "qualityLimitationDurations") {
11857
+ qualityLimitationDurations = report[key];
11858
+ }
11848
11859
  });
11860
+ if (qualityLimitationDurations) {
11861
+ obj[mediaType]["qualityLimitationDurations"] = qualityLimitationDurations[obj[mediaType]["qualityLimitationReason"]];
11862
+ }
11849
11863
  };
11850
11864
  var fullScreen = function fullScreen() {
11851
11865
  var video = document.getElementById(id);
@@ -11898,13 +11912,27 @@ var createConnection = function createConnection(options) {
11898
11912
  if (localVideo && localVideo.srcObject && videoCams.length > 1 && !customStream && !screenShare) {
11899
11913
  connection.getSenders().forEach(function (sender) {
11900
11914
  if (sender.track.kind === 'audio') return;
11901
- switchCamCount = (switchCamCount + 1) % videoCams.length;
11902
11915
  sender.track.stop();
11903
- var cam = typeof deviceId !== "undefined" ? deviceId : videoCams[switchCamCount].id;
11916
+ var cameraId;
11917
+ if (typeof deviceId !== "undefined") {
11918
+ videoCams.forEach(function (cam, index) {
11919
+ if (deviceId === cam.id) {
11920
+ switchCamIndex = index;
11921
+ }
11922
+ });
11923
+ cameraId = deviceId;
11924
+ } else {
11925
+ switchCamIndex = (switchCamIndex + 1) % videoCams.length;
11926
+ cameraId = videoCams[switchCamIndex].id;
11927
+ }
11928
+ if (!cameraId) {
11929
+ logger.error(LOG_PREFIX, "Can't detect camera to switch to");
11930
+ reject(constants.ERROR_INFO.CAN_NOT_SWITCH_CAM);
11931
+ }
11904
11932
  //use the settings that were set during connection initiation
11905
11933
  var clonedConstraints = Object.assign({}, constraints);
11906
11934
  clonedConstraints.video.deviceId = {
11907
- exact: cam
11935
+ exact: cameraId
11908
11936
  };
11909
11937
  clonedConstraints.audio = false;
11910
11938
  navigator.mediaDevices.getUserMedia(clonedConstraints).then(function (newStream) {
@@ -11917,8 +11945,8 @@ var createConnection = function createConnection(options) {
11917
11945
  if (localVideo.srcObject.getAudioTracks().length == 0 && audioTrack) {
11918
11946
  localVideo.srcObject.addTrack(audioTrack);
11919
11947
  }
11920
- logger.info(LOG_PREFIX, "Switch camera to " + cam);
11921
- resolve(cam);
11948
+ logger.info(LOG_PREFIX, "Switch camera to " + cameraId);
11949
+ resolve(cameraId);
11922
11950
  })["catch"](function (reason) {
11923
11951
  logger.error(LOG_PREFIX, reason);
11924
11952
  reject(reason);