@pexip/media-control 17.1.2 → 17.2.0

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/CHANGELOG.md CHANGED
@@ -1,5 +1,25 @@
1
1
  # Changelog
2
2
 
3
+ ## 17.2.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 244cb04c: Add screen capture constraints
8
+
9
+ - Add screen capture constraints
10
+ - Add fallback implementation of `mointorTypeSurfaces`
11
+ - Fix typo of `areMultipleFacingModeSupported`
12
+
13
+ - 26878b60: Add contentHint to InputConstraintSet
14
+ - 7e02391e9c: Changest to support FECC and PTZ capabilities
15
+
16
+ ### Patch Changes
17
+
18
+ - 4ea55a5205: Prettier and linting for new prettier version.
19
+ - Updated dependencies [244cb04c]
20
+ - Updated dependencies [4ea55a5205]
21
+ - @pexip/utils@16.8.0
22
+
3
23
  ## 17.1.2
4
24
 
5
25
  ## 17.1.1
package/dist/index.d.ts CHANGED
@@ -72,6 +72,16 @@ interface InputConstraintSet extends MediaTrackConstraints {
72
72
  * Image Url that is being used for video overlay effects
73
73
  */
74
74
  resizeMode?: ConstrainDOMString;
75
+ /**
76
+ * Current pan, tilt and zoom level for a PTZ controllable camera on web
77
+ */
78
+ pan?: boolean;
79
+ tilt?: boolean;
80
+ zoom?: boolean;
81
+ /**
82
+ * Content Hint for the track to apply
83
+ */
84
+ contentHint?: ConstrainDOMString;
75
85
  }
76
86
  type InputDeviceConstraint = DeviceConstraint | InputConstraintSet | boolean;
77
87
  /**
@@ -209,6 +219,35 @@ interface InputDevicePermission {
209
219
  audio: PermissionState;
210
220
  video: PermissionState;
211
221
  }
222
+ interface DisplayVideoTrackConstraint extends MediaTrackConstraintSet {
223
+ displaySurface?: ConstrainDOMString;
224
+ cursor?: ConstrainDOMString;
225
+ }
226
+ interface DisplayAudioTrackConstraint extends MediaTrackConstraintSet {
227
+ restrictOwnAudio?: ConstrainBoolean;
228
+ suppressLocalAudioPlayback?: ConstrainBoolean;
229
+ }
230
+ interface DisplayVideoTrackConstraints extends DisplayVideoTrackConstraint {
231
+ advanced?: DisplayVideoTrackConstraint[];
232
+ }
233
+ interface DisplayAudioTrackConstraints extends DisplayAudioTrackConstraint {
234
+ advanced?: DisplayAudioTrackConstraint[];
235
+ }
236
+ /**
237
+ * The `DisplayMediaStreamOptions` dictionary is used to instruct the user agent
238
+ * what sort of `MediaStreamTracks` may be included in the `MediaStream`
239
+ * returned by `getDisplayMedia`.
240
+ *
241
+ * @see {@link https://w3c.github.io/mediacapture-screen-share/#displaymediastreamoptions}
242
+ */
243
+ interface DisplayMediaOptions extends DisplayMediaStreamOptions {
244
+ audio?: boolean | DisplayAudioTrackConstraints;
245
+ video?: boolean | DisplayVideoTrackConstraints;
246
+ selfBrowserSurface?: ConstrainDOMString;
247
+ systemAudio?: ConstrainDOMString;
248
+ surfaceSwitching?: ConstrainDOMString;
249
+ monitorTypeSurfaces?: ConstrainDOMString;
250
+ }
212
251
 
213
252
  /**
214
253
  * DeviceChange Event
@@ -553,7 +592,7 @@ declare const hasChangedInput: (oldInput: MediaDeviceInfoLike | undefined, newIn
553
592
  * i.e. `navigator.mediaDevices.getSupportedConstraints()`
554
593
  * @param tracks - Current video input track
555
594
  */
556
- declare const areMultipleFacingModeSupportted: (currentDevices: MediaDeviceInfoLike[], getSupportedConstraints?: () => MediaTrackSupportedConstraints) => boolean;
595
+ declare const areMultipleFacingModeSupported: (currentDevices: MediaDeviceInfoLike[], getSupportedConstraints?: () => MediaTrackSupportedConstraints) => boolean;
557
596
  /**
558
597
  * Interpret the current facing mode from the provided track, and try to get the
559
598
  * mode from settings, or use the label to guess the facing mode when facingMode
@@ -601,7 +640,7 @@ declare const findDevice: (deviceToFind: MediaDeviceInfoLike, useFallback?: bool
601
640
  * Reference https://w3c.github.io/mediacapture-main/#dom-mediatrackconstraintset
602
641
  */
603
642
  declare const CONSTRAIN_STRING_KEYS: readonly ["facingMode", "resizeMode", "deviceId", "groupId"];
604
- declare const EXTENDED_CONSTRAIN_STRING_KEYS: readonly ["videoSegmentation", "videoSegmentationModel", "bgImageUrl"];
643
+ declare const EXTENDED_CONSTRAIN_STRING_KEYS: readonly ["videoSegmentation", "videoSegmentationModel", "bgImageUrl", "contentHint"];
605
644
  type ExtendedConstrainStringKeys = (typeof EXTENDED_CONSTRAIN_STRING_KEYS)[number];
606
645
  type ConstrainStringKeys = (typeof CONSTRAIN_STRING_KEYS)[number];
607
646
  declare const CONSTRAIN_U_LONG_KEYS: readonly ["width", "height", "sampleRate", "sampleSize", "channelCount"];
@@ -612,7 +651,7 @@ declare const CONSTRAIN_DOUBLE_KEYS: readonly ["aspectRatio", "frameRate", "late
612
651
  declare const EXTENDED_CONSTRAIN_DOUBLE_KEYS: readonly ["foregroundThreshold"];
613
652
  type ExtendedConstrainDoubleKeys = (typeof EXTENDED_CONSTRAIN_DOUBLE_KEYS)[number];
614
653
  type ConstrainDoubleKeys = (typeof CONSTRAIN_DOUBLE_KEYS)[number];
615
- declare const CONSTRAIN_BOOLEAN_KEYS: readonly ["echoCancellation", "autoGainControl", "noiseSuppression"];
654
+ declare const CONSTRAIN_BOOLEAN_KEYS: readonly ["echoCancellation", "autoGainControl", "noiseSuppression", "pan", "tilt", "zoom"];
616
655
  /**
617
656
  * Extends boolean constraint keys for our own implementation of the media
618
657
  * feature
@@ -696,7 +735,7 @@ type Constraints = ConstrainStrings & ConstrainNumbers & ConstrainBooleans & Con
696
735
  * expect(noiseSuppressionParam).toEqual('ideal');
697
736
  * ```
698
737
  */
699
- declare const extractConstraintsWithKeys: <T extends "deviceId" | "groupId" | "facingMode" | "resizeMode" | "videoSegmentation" | "videoSegmentationModel" | "bgImageUrl" | ConstrainNumberKeys | "echoCancellation" | "autoGainControl" | "noiseSuppression" | "vad" | "asd" | "mixWithAdditionalMedia" | "denoise" | "flipHorizontal" | "device">(keys: T[]) => (constraints: InputDeviceConstraint | undefined) => Pick<Constraints, T>;
738
+ declare const extractConstraintsWithKeys: <T extends "deviceId" | "groupId" | "facingMode" | "resizeMode" | "videoSegmentation" | "videoSegmentationModel" | "bgImageUrl" | "contentHint" | ConstrainNumberKeys | "echoCancellation" | "autoGainControl" | "noiseSuppression" | "pan" | "tilt" | "zoom" | "vad" | "asd" | "mixWithAdditionalMedia" | "denoise" | "flipHorizontal" | "device">(keys: T[]) => (constraints: InputDeviceConstraint | undefined) => Pick<Constraints, T>;
700
739
  /**
701
740
  * Find device from the device list with provided constraints
702
741
  *
@@ -876,6 +915,59 @@ interface Logger extends LogMethods {
876
915
 
877
916
  declare function setLogger(newLogger: Logger): void;
878
917
 
918
+ type ExtractObjectValueTypes<T extends object> = T[keyof T];
919
+ /**
920
+ * The `DisplayCaptureSurfaceType` enumeration describes the different types of
921
+ * display surface
922
+ *
923
+ * @see {@link https://w3c.github.io/mediacapture-screen-share/#displaycapturesurfacetype}
924
+ */
925
+ declare const DISPLAY_CAPTURE_SURFACE_TYPE: {
926
+ readonly Monitor: "monitor";
927
+ readonly Window: "window";
928
+ readonly Browser: "browser";
929
+ };
930
+ /**
931
+ * The `DisplayCaptureSurfaceType` enumeration describes the different types of
932
+ * display surface
933
+ *
934
+ * @see {@link https://w3c.github.io/mediacapture-screen-share/#displaycapturesurfacetype}
935
+ */
936
+ type DisplayCaptureSurfaceType = ExtractObjectValueTypes<typeof DISPLAY_CAPTURE_SURFACE_TYPE>;
937
+ /**
938
+ * The `CursorCaptureConstraint` enumerates the conditions under which the
939
+ * cursor is captured.
940
+ *
941
+ * @see {@link https://w3c.github.io/mediacapture-screen-share/#cursorcaptureconstraint}
942
+ */
943
+ declare const CURSOR_CAPTURE_CONSTRAINT: {
944
+ readonly Never: "never";
945
+ readonly Always: "always";
946
+ readonly Motion: "motion";
947
+ };
948
+ /**
949
+ * The `CursorCaptureConstraint` enumerates the conditions under which the
950
+ * cursor is captured.
951
+ *
952
+ * @see {@link https://w3c.github.io/mediacapture-screen-share/#cursorcaptureconstraint}
953
+ */
954
+ type CursorCaptureConstraint = ExtractObjectValueTypes<typeof CURSOR_CAPTURE_CONSTRAINT>;
955
+ declare const INCLUDE_EXCLUDE_CONSTRAINT: {
956
+ readonly Include: "include";
957
+ readonly Exclude: "exclude";
958
+ };
959
+ type IncludeExcludeConstraint = ExtractObjectValueTypes<typeof INCLUDE_EXCLUDE_CONSTRAINT>;
960
+
961
+ /**
962
+ * A fallback implementation of `monitorTypeSurfaces` limitation when it is not
963
+ * supported by the current browser and the source of the `displaySurface` is
964
+ * available.
965
+ *
966
+ * @param constraints - The constraints used to request display media.
967
+ * @param stream - The MediaStream returned from the requesting display media.
968
+ */
969
+ declare const limitSharingMonitorInterface: (constraints: DisplayMediaOptions, stream: MediaStream) => MediaStream;
970
+
879
971
  /**
880
972
  * media-control is meant to extend the mediaDevices api methods such as
881
973
  * `getUserMedia`, `enumerateDevices` and events on media streams and tracks.
@@ -924,4 +1016,4 @@ interface MediaControl {
924
1016
  subscribe: typeof subscribe;
925
1017
  }
926
1018
 
927
- export { DeviceChangedChanges, Events, FacingMode, InputConstraintSet, InputDevicePermission, MediaControl, MediaDeviceFailure, MediaDeviceInfoLike, MediaDeviceKinds, MediaDeviceRequest, MediaEvent, MediaEventType, MediaInput, MediaStreamTrackLike, StreamTrackEventHandlers, Unsubscribe, applyConstraints, areMultipleFacingModeSupportted, areTracksEnabled, compareDevices, createStreamTrackEventSubscriptions, createTrackDevicesChanges, deviceChanged, extractConstraintsWithKeys, findAudioInputDevices, findAudioOutputDevices, findCurrentAudioOutputId, findCurrentVideoInputDeviceIdFromStream, findDevice, findDeviceFromConstraints, findDeviceWithDeviceId, findDevicesByKind, findMediaInputFromMediaStreamTrack, findMediaInputFromStream, findPermissionGrantedDevices, findVideoInputDevices, getDevices, getFacingModeFromConstraintString, getInputDevicePermissionState, getUserMedia, getValueFromConstrainNumber, hasAnyGrantedInput, hasAnyInputs, hasAudioInputs, hasAudioOrVideoInputs, hasChangedInput, hasRequestingDevice, hasVideoInputs, interpretCurrentFacingMode, isAudioInput, isAudioOutput, isDeviceGranted, isExactDeviceConstraint, isFacingMode, isMediaDeviceInfo, isMediaDeviceInfoArray, isMediaStreamTrack, isRequestedInputDevice, isRequestedInputTrack, isRequestedResolution, isStreamingRequestedDevices, isStreamingRequestedDevicesBase, isVideoInput, mergeConstraints, muteStreamTrack, relaxInputConstraint, setDefaultConstraints, setLogger, shouldRequestDevice, stopMediaStream, subscribe, toKey, toMediaDeviceInfoLike };
1019
+ export { CURSOR_CAPTURE_CONSTRAINT, CursorCaptureConstraint, DISPLAY_CAPTURE_SURFACE_TYPE, DeviceChangedChanges, DisplayCaptureSurfaceType, DisplayMediaOptions, Events, FacingMode, INCLUDE_EXCLUDE_CONSTRAINT, IncludeExcludeConstraint, InputConstraintSet, InputDevicePermission, MediaControl, MediaDeviceFailure, MediaDeviceInfoLike, MediaDeviceKinds, MediaDeviceRequest, MediaEvent, MediaEventType, MediaInput, MediaStreamTrackLike, StreamTrackEventHandlers, Unsubscribe, applyConstraints, areMultipleFacingModeSupported, areTracksEnabled, compareDevices, createStreamTrackEventSubscriptions, createTrackDevicesChanges, deviceChanged, extractConstraintsWithKeys, findAudioInputDevices, findAudioOutputDevices, findCurrentAudioOutputId, findCurrentVideoInputDeviceIdFromStream, findDevice, findDeviceFromConstraints, findDeviceWithDeviceId, findDevicesByKind, findMediaInputFromMediaStreamTrack, findMediaInputFromStream, findPermissionGrantedDevices, findVideoInputDevices, getDevices, getFacingModeFromConstraintString, getInputDevicePermissionState, getUserMedia, getValueFromConstrainNumber, hasAnyGrantedInput, hasAnyInputs, hasAudioInputs, hasAudioOrVideoInputs, hasChangedInput, hasRequestingDevice, hasVideoInputs, interpretCurrentFacingMode, isAudioInput, isAudioOutput, isDeviceGranted, isExactDeviceConstraint, isFacingMode, isMediaDeviceInfo, isMediaDeviceInfoArray, isMediaStreamTrack, isRequestedInputDevice, isRequestedInputTrack, isRequestedResolution, isStreamingRequestedDevices, isStreamingRequestedDevicesBase, isVideoInput, limitSharingMonitorInterface, mergeConstraints, muteStreamTrack, relaxInputConstraint, setDefaultConstraints, setLogger, shouldRequestDevice, stopMediaStream, subscribe, toKey, toMediaDeviceInfoLike };
package/dist/index.mjs CHANGED
@@ -41,7 +41,8 @@ var CONSTRAIN_STRING_KEYS = [
41
41
  var EXTENDED_CONSTRAIN_STRING_KEYS = [
42
42
  "videoSegmentation",
43
43
  "videoSegmentationModel",
44
- "bgImageUrl"
44
+ "bgImageUrl",
45
+ "contentHint"
45
46
  ];
46
47
  var CONSTRAIN_U_LONG_KEYS = [
47
48
  "width",
@@ -63,7 +64,10 @@ var EXTENDED_CONSTRAIN_DOUBLE_KEYS = ["foregroundThreshold"];
63
64
  var CONSTRAIN_BOOLEAN_KEYS = [
64
65
  "echoCancellation",
65
66
  "autoGainControl",
66
- "noiseSuppression"
67
+ "noiseSuppression",
68
+ "pan",
69
+ "tilt",
70
+ "zoom"
67
71
  ];
68
72
  var EXTENDED_CONSTRAIN_BOOLEAN_KEYS = [
69
73
  // Voice Activity Detection
@@ -348,15 +352,18 @@ var normalizeDeviceConstraint = (constraints) => {
348
352
  return void 0;
349
353
  }
350
354
  if (isConstraintDeviceParameters(constraints)) {
351
- return Object.keys(constraints).filter((k) => ["ideal", "exact"].includes(k)).reduce((cs, k) => {
352
- const key = k;
353
- const value = constraints[key];
354
- const devices = normalizeDevice(value);
355
- if (devices) {
356
- return { ...cs ?? {}, [key]: devices };
357
- }
358
- return cs;
359
- }, void 0);
355
+ return Object.keys(constraints).filter((k) => ["ideal", "exact"].includes(k)).reduce(
356
+ (cs, k) => {
357
+ const key = k;
358
+ const value = constraints[key];
359
+ const devices = normalizeDevice(value);
360
+ if (devices) {
361
+ return { ...cs ?? {}, [key]: devices };
362
+ }
363
+ return cs;
364
+ },
365
+ void 0
366
+ );
360
367
  }
361
368
  const normalized = normalizeDevice(constraints);
362
369
  return normalized && { ideal: normalized };
@@ -655,21 +662,36 @@ function extractConstraints(key) {
655
662
  return [void 0, "ideal"];
656
663
  };
657
664
  }
658
- var extractConstraintsWithKeys = (keys) => (constraints) => keys.reduce((result, key) => {
659
- if (key === "device") {
660
- return { ...result, [key]: extractConstraints(key)(constraints) };
661
- }
662
- if (isConstrainULongKeys(key) || isConstrainDoubleKeys(key) || isExtendedConstrainULongKeys(key) || isExtendedConstrainDoubleKeys(key)) {
663
- return { ...result, [key]: extractConstraints(key)(constraints) };
664
- }
665
- if (isConstrainStringKeys(key) || isExtendedConstrainStringKeys(key)) {
666
- return { ...result, [key]: extractConstraints(key)(constraints) };
667
- }
668
- if (isConstrainBooleanKeys(key) || isExtendedConstrainBooleanKeys(key)) {
669
- return { ...result, [key]: extractConstraints(key)(constraints) };
670
- }
671
- return result;
672
- }, {});
665
+ var extractConstraintsWithKeys = (keys) => (constraints) => keys.reduce(
666
+ (result, key) => {
667
+ if (key === "device") {
668
+ return {
669
+ ...result,
670
+ [key]: extractConstraints(key)(constraints)
671
+ };
672
+ }
673
+ if (isConstrainULongKeys(key) || isConstrainDoubleKeys(key) || isExtendedConstrainULongKeys(key) || isExtendedConstrainDoubleKeys(key)) {
674
+ return {
675
+ ...result,
676
+ [key]: extractConstraints(key)(constraints)
677
+ };
678
+ }
679
+ if (isConstrainStringKeys(key) || isExtendedConstrainStringKeys(key)) {
680
+ return {
681
+ ...result,
682
+ [key]: extractConstraints(key)(constraints)
683
+ };
684
+ }
685
+ if (isConstrainBooleanKeys(key) || isExtendedConstrainBooleanKeys(key)) {
686
+ return {
687
+ ...result,
688
+ [key]: extractConstraints(key)(constraints)
689
+ };
690
+ }
691
+ return result;
692
+ },
693
+ {}
694
+ );
673
695
  var extractDeviceId = extractConstrainString("deviceId");
674
696
  var findDeviceFromConstraints = (constraints, devices) => {
675
697
  if (typeof constraints === "boolean") {
@@ -1142,7 +1164,7 @@ var hasChangedInput = (oldInput, newInput) => {
1142
1164
  }
1143
1165
  return false;
1144
1166
  };
1145
- var areMultipleFacingModeSupportted = (currentDevices, getSupportedConstraints = () => navigator.mediaDevices.getSupportedConstraints()) => {
1167
+ var areMultipleFacingModeSupported = (currentDevices, getSupportedConstraints = () => navigator.mediaDevices.getSupportedConstraints()) => {
1146
1168
  if (!getSupportedConstraints().facingMode) {
1147
1169
  return false;
1148
1170
  }
@@ -1492,6 +1514,44 @@ var createStreamTrackMap = (tracks) => {
1492
1514
  };
1493
1515
  };
1494
1516
 
1517
+ // src/constants.ts
1518
+ var DISPLAY_CAPTURE_SURFACE_TYPE = {
1519
+ Monitor: "monitor",
1520
+ Window: "window",
1521
+ Browser: "browser"
1522
+ };
1523
+ var CURSOR_CAPTURE_CONSTRAINT = {
1524
+ Never: "never",
1525
+ Always: "always",
1526
+ Motion: "motion"
1527
+ };
1528
+ var INCLUDE_EXCLUDE_CONSTRAINT = {
1529
+ Include: "include",
1530
+ Exclude: "exclude"
1531
+ };
1532
+
1533
+ // src/displayMedia.ts
1534
+ var limitSharingMonitorInterface = (constraints, stream) => {
1535
+ if (!constraints.monitorTypeSurfaces || constraints.monitorTypeSurfaces !== "exclude") {
1536
+ return stream;
1537
+ }
1538
+ for (const track of stream.getTracks()) {
1539
+ const { displaySurface } = track.getSettings();
1540
+ if (!displaySurface || displaySurface !== "monitor") {
1541
+ continue;
1542
+ }
1543
+ stopMediaStream(stream);
1544
+ throw new TypeError("MonitorSharingNotAllowed", {
1545
+ cause: {
1546
+ monitorTypeSurfaces: constraints.monitorTypeSurfaces,
1547
+ track,
1548
+ displaySurface
1549
+ }
1550
+ });
1551
+ }
1552
+ return stream;
1553
+ };
1554
+
1495
1555
  // src/index.ts
1496
1556
  var state = () => {
1497
1557
  const { dispatch, subscriber } = eventEmitter();
@@ -1572,11 +1632,14 @@ var {
1572
1632
  subscribe
1573
1633
  } = state();
1574
1634
  export {
1635
+ CURSOR_CAPTURE_CONSTRAINT,
1636
+ DISPLAY_CAPTURE_SURFACE_TYPE,
1637
+ INCLUDE_EXCLUDE_CONSTRAINT,
1575
1638
  MediaDeviceFailure,
1576
1639
  MediaDeviceKinds,
1577
1640
  MediaEventType,
1578
1641
  applyConstraints,
1579
- areMultipleFacingModeSupportted,
1642
+ areMultipleFacingModeSupported,
1580
1643
  areTracksEnabled,
1581
1644
  compareDevices,
1582
1645
  createStreamTrackEventSubscriptions,
@@ -1622,6 +1685,7 @@ export {
1622
1685
  isStreamingRequestedDevices,
1623
1686
  isStreamingRequestedDevicesBase,
1624
1687
  isVideoInput,
1688
+ limitSharingMonitorInterface,
1625
1689
  mergeConstraints,
1626
1690
  muteStreamTrack,
1627
1691
  relaxInputConstraint,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pexip/media-control",
3
- "version": "17.1.2",
3
+ "version": "17.2.0",
4
4
  "homepage": "https://gitlab.com/pexip/zoo",
5
5
  "bugs": "https://gitlab.com/pexip/zoo/issues",
6
6
  "repository": {
@@ -26,17 +26,17 @@
26
26
  "typecheck": "yarn tsc --noEmit -p tsconfig.build.json"
27
27
  },
28
28
  "dependencies": {
29
- "@pexip/utils": "16.7.0"
29
+ "@pexip/utils": "16.8.0"
30
30
  },
31
31
  "devDependencies": {
32
32
  "@jest/globals": "^29.5.0",
33
- "@pexip/bundler": "16.4.0",
33
+ "@pexip/bundler": "16.4.1",
34
34
  "@types/core-js": "^2.5.3",
35
35
  "@types/prettier": "^2.0.2",
36
36
  "@types/uuid": "^8.3.0",
37
37
  "@types/webrtc": "^0.0.31",
38
38
  "core-js": "^3.6.5",
39
- "prettier": "2.8.8",
39
+ "prettier": "^3.0.3",
40
40
  "typescript": "~5.0.0",
41
41
  "uuid": "^9.0.0"
42
42
  },