@flashphoner/websdk 2.0.247 → 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
  }
@@ -11912,13 +11912,27 @@ var createConnection = function createConnection(options) {
11912
11912
  if (localVideo && localVideo.srcObject && videoCams.length > 1 && !customStream && !screenShare) {
11913
11913
  connection.getSenders().forEach(function (sender) {
11914
11914
  if (sender.track.kind === 'audio') return;
11915
- switchCamCount = (switchCamCount + 1) % videoCams.length;
11916
11915
  sender.track.stop();
11917
- 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
+ }
11918
11932
  //use the settings that were set during connection initiation
11919
11933
  var clonedConstraints = Object.assign({}, constraints);
11920
11934
  clonedConstraints.video.deviceId = {
11921
- exact: cam
11935
+ exact: cameraId
11922
11936
  };
11923
11937
  clonedConstraints.audio = false;
11924
11938
  navigator.mediaDevices.getUserMedia(clonedConstraints).then(function (newStream) {
@@ -11931,8 +11945,8 @@ var createConnection = function createConnection(options) {
11931
11945
  if (localVideo.srcObject.getAudioTracks().length == 0 && audioTrack) {
11932
11946
  localVideo.srcObject.addTrack(audioTrack);
11933
11947
  }
11934
- logger.info(LOG_PREFIX, "Switch camera to " + cam);
11935
- resolve(cam);
11948
+ logger.info(LOG_PREFIX, "Switch camera to " + cameraId);
11949
+ resolve(cameraId);
11936
11950
  })["catch"](function (reason) {
11937
11951
  logger.error(LOG_PREFIX, reason);
11938
11952
  reject(reason);