@flashphoner/websdk 2.0.259 → 2.0.260

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.
@@ -12065,6 +12065,48 @@ var createSession = function (options) {
12065
12065
  }
12066
12066
  };
12067
12067
 
12068
+ /**
12069
+ * Get camera zoom capabilities
12070
+ *
12071
+ * @return {Object} zoom capabilities object: max, min, step or null if zoom is not supported
12072
+ * @memberof Stream
12073
+ */
12074
+ const getZoomCapabilities = function() {
12075
+ if (published() && mediaConnection) {
12076
+ return mediaConnection.getZoomCapabilities();
12077
+ } else {
12078
+ throw new Error("This function available for publishing stream only");
12079
+ }
12080
+ }
12081
+
12082
+ /**
12083
+ * Get current camera zoom value if supported
12084
+ *
12085
+ * @return {number} current camera zoom value
12086
+ * @memberof Stream
12087
+ */
12088
+ const getZoom = function() {
12089
+ if (published() && mediaConnection) {
12090
+ return mediaConnection.getZoom();
12091
+ } else {
12092
+ throw new Error("This function available for publishing stream only");
12093
+ }
12094
+ }
12095
+
12096
+ /**
12097
+ * Set camera zoom value if supported
12098
+ *
12099
+ * @param {number} desired camera zoom value
12100
+ * @memberof Stream
12101
+ */
12102
+ const setZoom = async function(value) {
12103
+ if (published() && mediaConnection) {
12104
+ return await mediaConnection.setZoom(value);
12105
+ } else {
12106
+ throw new Error("This function available for publishing stream only");
12107
+ }
12108
+ }
12109
+
12068
12110
  stream.play = play;
12069
12111
  stream.publish = publish;
12070
12112
  stream.stop = stop;
@@ -12106,6 +12148,9 @@ var createSession = function (options) {
12106
12148
  stream.getLogger = getLogger;
12107
12149
  stream.updateVideoSettings = updateVideoSettings;
12108
12150
  stream.updateVideoResolution = updateVideoResolution;
12151
+ stream.getZoomCapabilities = getZoomCapabilities;
12152
+ stream.getZoom = getZoom;
12153
+ stream.setZoom = setZoom;
12109
12154
 
12110
12155
  streams[id_] = stream;
12111
12156
  return stream;
@@ -14169,6 +14214,8 @@ var createConnection = function (options) {
14169
14214
  var useControls = options.useControls || false;
14170
14215
  // Stream event handler to rise an event #WCS-4097
14171
14216
  var unmuteRequiredEvent = options.unmuteRequiredEvent ? options.unmuteRequiredEvent : null;
14217
+ // Current video capturer zoom #WCS-4579
14218
+ let zoom = null;
14172
14219
 
14173
14220
  if (bidirectional) {
14174
14221
  localVideo = getCacheInstance(localDisplay);
@@ -14999,6 +15046,56 @@ var createConnection = function (options) {
14999
15046
  }
15000
15047
  };
15001
15048
 
15049
+ const getZoomCapabilities = function() {
15050
+ if (localVideo && localVideo.srcObject) {
15051
+ if (constraints.video && constraints.video.zoom) {
15052
+ const [track] = localVideo.srcObject.getVideoTracks();
15053
+ const capabilities = track.getCapabilities();
15054
+ const settings = track.getSettings();
15055
+
15056
+ if (!('zoom' in settings)) {
15057
+ logger.info(LOG_PREFIX, "Zoom is not supported by " + track.label);
15058
+ zoom = null;
15059
+ } else {
15060
+ zoom = {
15061
+ min: capabilities.zoom.min,
15062
+ max: capabilities.zoom.max,
15063
+ step: capabilities.zoom.step,
15064
+ value: settings.zoom
15065
+ }
15066
+ }
15067
+ } else {
15068
+ zoom = null;
15069
+ }
15070
+ }
15071
+ return zoom;
15072
+ };
15073
+
15074
+ const setZoom = async function(value) {
15075
+ if (zoom) {
15076
+ if (value >= zoom.min && value <= zoom.max) {
15077
+ if (localVideo && localVideo.srcObject) {
15078
+ const [track] = localVideo.srcObject.getVideoTracks();
15079
+ await track.applyConstraints({advanced: [{zoom: value}]});
15080
+ zoom.value = value;
15081
+ } else {
15082
+ logger.warn(LOG_PREFIX, "Can't set zoom value: no local video");
15083
+ }
15084
+ } else {
15085
+ logger.info(LOG_PREFIX, "Zoom value " + value + "is out of range: " + zoom.min + "-" + zoom.max);
15086
+ }
15087
+ } else {
15088
+ logger.info(LOG_PREFIX, "Zoom is not supported or zoom capabilities unknown yet");
15089
+ }
15090
+ }
15091
+
15092
+ const getZoom = function() {
15093
+ if (zoom) {
15094
+ return zoom.value;
15095
+ }
15096
+ return -1;
15097
+ }
15098
+
15002
15099
  var exports = {};
15003
15100
  exports.state = state;
15004
15101
  exports.createOffer = createOffer;
@@ -15028,6 +15125,9 @@ var createConnection = function (options) {
15028
15125
  exports.setPublishingBitrate = setPublishingBitrate;
15029
15126
  exports.updateVideoSettings = updateVideoSettings;
15030
15127
  exports.updateVideoResolution = updateVideoResolution;
15128
+ exports.getZoomCapabilities = getZoomCapabilities;
15129
+ exports.setZoom = setZoom;
15130
+ exports.getZoom = getZoom;
15031
15131
  connections[id] = exports;
15032
15132
  resolve(exports);
15033
15133
  });