@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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flashphoner/websdk",
3
- "version": "2.0.259",
3
+ "version": "2.0.260",
4
4
  "description": "Official Flashphoner WebCallServer WebSDK package",
5
5
  "main": "./src/flashphoner-core.js",
6
6
  "types": "./src/flashphoner-core.d.ts",
@@ -2685,6 +2685,48 @@ var createSession = function (options) {
2685
2685
  }
2686
2686
  };
2687
2687
 
2688
+ /**
2689
+ * Get camera zoom capabilities
2690
+ *
2691
+ * @return {Object} zoom capabilities object: max, min, step or null if zoom is not supported
2692
+ * @memberof Stream
2693
+ */
2694
+ const getZoomCapabilities = function() {
2695
+ if (published() && mediaConnection) {
2696
+ return mediaConnection.getZoomCapabilities();
2697
+ } else {
2698
+ throw new Error("This function available for publishing stream only");
2699
+ }
2700
+ }
2701
+
2702
+ /**
2703
+ * Get current camera zoom value if supported
2704
+ *
2705
+ * @return {number} current camera zoom value
2706
+ * @memberof Stream
2707
+ */
2708
+ const getZoom = function() {
2709
+ if (published() && mediaConnection) {
2710
+ return mediaConnection.getZoom();
2711
+ } else {
2712
+ throw new Error("This function available for publishing stream only");
2713
+ }
2714
+ }
2715
+
2716
+ /**
2717
+ * Set camera zoom value if supported
2718
+ *
2719
+ * @param {number} desired camera zoom value
2720
+ * @memberof Stream
2721
+ */
2722
+ const setZoom = async function(value) {
2723
+ if (published() && mediaConnection) {
2724
+ return await mediaConnection.setZoom(value);
2725
+ } else {
2726
+ throw new Error("This function available for publishing stream only");
2727
+ }
2728
+ }
2729
+
2688
2730
  stream.play = play;
2689
2731
  stream.publish = publish;
2690
2732
  stream.stop = stop;
@@ -2726,6 +2768,9 @@ var createSession = function (options) {
2726
2768
  stream.getLogger = getLogger;
2727
2769
  stream.updateVideoSettings = updateVideoSettings;
2728
2770
  stream.updateVideoResolution = updateVideoResolution;
2771
+ stream.getZoomCapabilities = getZoomCapabilities;
2772
+ stream.getZoom = getZoom;
2773
+ stream.setZoom = setZoom;
2729
2774
 
2730
2775
  streams[id_] = stream;
2731
2776
  return stream;
@@ -66,6 +66,8 @@ var createConnection = function (options) {
66
66
  var useControls = options.useControls || false;
67
67
  // Stream event handler to rise an event #WCS-4097
68
68
  var unmuteRequiredEvent = options.unmuteRequiredEvent ? options.unmuteRequiredEvent : null;
69
+ // Current video capturer zoom #WCS-4579
70
+ let zoom = null;
69
71
 
70
72
  if (bidirectional) {
71
73
  localVideo = getCacheInstance(localDisplay);
@@ -896,6 +898,56 @@ var createConnection = function (options) {
896
898
  }
897
899
  };
898
900
 
901
+ const getZoomCapabilities = function() {
902
+ if (localVideo && localVideo.srcObject) {
903
+ if (constraints.video && constraints.video.zoom) {
904
+ const [track] = localVideo.srcObject.getVideoTracks();
905
+ const capabilities = track.getCapabilities();
906
+ const settings = track.getSettings();
907
+
908
+ if (!('zoom' in settings)) {
909
+ logger.info(LOG_PREFIX, "Zoom is not supported by " + track.label);
910
+ zoom = null;
911
+ } else {
912
+ zoom = {
913
+ min: capabilities.zoom.min,
914
+ max: capabilities.zoom.max,
915
+ step: capabilities.zoom.step,
916
+ value: settings.zoom
917
+ }
918
+ }
919
+ } else {
920
+ zoom = null;
921
+ }
922
+ }
923
+ return zoom;
924
+ };
925
+
926
+ const setZoom = async function(value) {
927
+ if (zoom) {
928
+ if (value >= zoom.min && value <= zoom.max) {
929
+ if (localVideo && localVideo.srcObject) {
930
+ const [track] = localVideo.srcObject.getVideoTracks();
931
+ await track.applyConstraints({advanced: [{zoom: value}]});
932
+ zoom.value = value;
933
+ } else {
934
+ logger.warn(LOG_PREFIX, "Can't set zoom value: no local video");
935
+ }
936
+ } else {
937
+ logger.info(LOG_PREFIX, "Zoom value " + value + "is out of range: " + zoom.min + "-" + zoom.max);
938
+ }
939
+ } else {
940
+ logger.info(LOG_PREFIX, "Zoom is not supported or zoom capabilities unknown yet");
941
+ }
942
+ }
943
+
944
+ const getZoom = function() {
945
+ if (zoom) {
946
+ return zoom.value;
947
+ }
948
+ return -1;
949
+ }
950
+
899
951
  var exports = {};
900
952
  exports.state = state;
901
953
  exports.createOffer = createOffer;
@@ -925,6 +977,9 @@ var createConnection = function (options) {
925
977
  exports.setPublishingBitrate = setPublishingBitrate;
926
978
  exports.updateVideoSettings = updateVideoSettings;
927
979
  exports.updateVideoResolution = updateVideoResolution;
980
+ exports.getZoomCapabilities = getZoomCapabilities;
981
+ exports.setZoom = setZoom;
982
+ exports.getZoom = getZoom;
928
983
  connections[id] = exports;
929
984
  resolve(exports);
930
985
  });