@pexip/media-control 22.0.0 → 22.1.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 +9 -0
- package/api-docs/functions/applyConstraints.mdx +2 -2
- package/api-docs/functions/areMultipleFacingModeSupported.mdx +1 -1
- package/api-docs/functions/areTracksEnabled.mdx +2 -2
- package/api-docs/functions/compareDevices.mdx +1 -1
- package/api-docs/functions/createTrackDevicesChanges.mdx +1 -1
- package/api-docs/functions/deviceChanged.mdx +1 -1
- package/api-docs/functions/extractConstrainDevice.mdx +4 -2
- package/api-docs/functions/extractConstraints.mdx +8 -8
- package/api-docs/functions/extractConstraintsWithKeys.mdx +3 -3
- package/api-docs/functions/findCurrentVideoInputDeviceIdFromStream.mdx +3 -1
- package/api-docs/functions/findDevice.mdx +6 -2
- package/api-docs/functions/findDeviceFromConstraints.mdx +9 -3
- package/api-docs/functions/findDeviceWithDeviceId.mdx +6 -2
- package/api-docs/functions/findMediaInputFromMediaStreamTrack.mdx +6 -2
- package/api-docs/functions/findMediaInputFromStream.mdx +1 -1
- package/api-docs/functions/getDevices.mdx +3 -1
- package/api-docs/functions/getFacingModeFromConstraintString.mdx +3 -1
- package/api-docs/functions/getInputDevicePermissionState.mdx +4 -2
- package/api-docs/functions/hasAnyInputs.mdx +3 -1
- package/api-docs/functions/interpretCurrentFacingMode.mdx +4 -2
- package/api-docs/functions/isRequestedResolution.mdx +1 -1
- package/api-docs/functions/isStreamingRequestedDevices.mdx +1 -1
- package/api-docs/functions/isStreamingRequestedDevicesBase.mdx +3 -3
- package/api-docs/functions/isStreamingRequestingDevice.mdx +1 -1
- package/api-docs/functions/mergeConstraints.mdx +9 -3
- package/api-docs/functions/muteStreamTrack.mdx +1 -1
- package/api-docs/functions/relaxInputConstraint.mdx +7 -3
- package/api-docs/functions/resolveMediaDeviceConstraints.mdx +4 -2
- package/api-docs/functions/stopMediaStream.mdx +2 -2
- package/api-docs/functions/toKey.mdx +3 -3
- package/api-docs/functions/toMediaDeviceInfoLike.mdx +6 -2
- package/api-docs/functions/toMediaDeviceInputKind.mdx +4 -2
- package/api-docs/interfaces/DisplayMediaOptions.mdx +2 -2
- package/api-docs/interfaces/IndexedDevices.mdx +9 -3
- package/api-docs/interfaces/InputConstraintSet.mdx +3 -3
- package/api-docs/interfaces/MediaControl.mdx +5 -5
- package/api-docs/type-aliases/MediaDeviceInfoLike.mdx +1 -1
- package/api-docs/variables/getUserMedia.mdx +1 -1
- package/api-docs/variables/subscribe.mdx +1 -1
- package/dist/devices.d.ts +6 -4
- package/dist/devices.js +0 -1
- package/dist/streamTrackMap.d.ts +3 -2
- package/dist/streamTrackMap.js +66 -15
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 22.1.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- a9456de: Increase performance when tracking tracks and device changes.
|
|
8
|
+
- Updated dependencies [44ad859]
|
|
9
|
+
- Updated dependencies [514c523]
|
|
10
|
+
- @pexip/utils@17.4.0
|
|
11
|
+
|
|
3
12
|
## 22.0.0
|
|
4
13
|
|
|
5
14
|
### Major Changes
|
|
@@ -8,9 +8,9 @@ Call applyConstraints foreach track accordingly
|
|
|
8
8
|
|
|
9
9
|
| Parameter | Type | Description |
|
|
10
10
|
| ------ | ------ | ------ |
|
|
11
|
-
| `tracks` | `MediaStreamTrack
|
|
11
|
+
| `tracks` | `MediaStreamTrack[] \| undefined` | Tracks to be applied |
|
|
12
12
|
| `constraints` | [`MediaDeviceRequest`](../interfaces/MediaDeviceRequest.mdx) | constraints to be applied |
|
|
13
13
|
|
|
14
14
|
## Returns
|
|
15
15
|
|
|
16
|
-
`Promise
|
|
16
|
+
`Promise<void>`
|
|
@@ -10,7 +10,7 @@ device label and the API `getSupportedConstraints`
|
|
|
10
10
|
| Parameter | Type | Description |
|
|
11
11
|
| ------ | ------ | ------ |
|
|
12
12
|
| `currentDevices` | [`MediaDeviceInfoLike`](../type-aliases/MediaDeviceInfoLike.mdx)[] | Current list of devices available |
|
|
13
|
-
| `getSupportedConstraints` | () =>
|
|
13
|
+
| `getSupportedConstraints` | `() => MediaTrackSupportedConstraints` | A function to get supported constraints, i.e. `navigator.mediaDevices.getSupportedConstraints()` |
|
|
14
14
|
|
|
15
15
|
## Returns
|
|
16
16
|
|
|
@@ -8,8 +8,8 @@ function areTracksEnabled(stream, type): boolean;
|
|
|
8
8
|
|
|
9
9
|
| Parameter | Type |
|
|
10
10
|
| ------ | ------ |
|
|
11
|
-
| `stream` | `MediaStream
|
|
12
|
-
| `type` | `"audio"
|
|
11
|
+
| `stream` | `MediaStream \| undefined` |
|
|
12
|
+
| `type` | `"audio" \| "video"` |
|
|
13
13
|
|
|
14
14
|
## Returns
|
|
15
15
|
|
|
@@ -9,7 +9,7 @@ function compareDevices(deviceInfo, key): (anotherDeviceInfo) => boolean;
|
|
|
9
9
|
| Parameter | Type | Default value |
|
|
10
10
|
| ------ | ------ | ------ |
|
|
11
11
|
| `deviceInfo` | [`MediaDeviceInfoLike`](../type-aliases/MediaDeviceInfoLike.mdx) | `undefined` |
|
|
12
|
-
| `key` | `"toJSON"
|
|
12
|
+
| `key` | `"toJSON" \| "deviceId" \| "groupId" \| "label"` | `'deviceId'` |
|
|
13
13
|
|
|
14
14
|
## Returns
|
|
15
15
|
|
|
@@ -6,7 +6,7 @@ function createTrackDevicesChanges(prevDevices): (devices) => object;
|
|
|
6
6
|
|
|
7
7
|
| Parameter | Type | Default value |
|
|
8
8
|
| ------ | ------ | ------ |
|
|
9
|
-
| `prevDevices` | [`MediaDeviceInfoLike`](../type-aliases/MediaDeviceInfoLike.mdx)[] |
|
|
9
|
+
| `prevDevices` | [`MediaDeviceInfoLike`](../type-aliases/MediaDeviceInfoLike.mdx)[] | []`` |
|
|
10
10
|
|
|
11
11
|
## Returns
|
|
12
12
|
|
|
@@ -7,8 +7,10 @@ function extractConstrainDevice(constraints, initialParam): ConstrainNoneTuple |
|
|
|
7
7
|
| Parameter | Type | Default value |
|
|
8
8
|
| ------ | ------ | ------ |
|
|
9
9
|
| `constraints` | \| [`InputDeviceConstraint`](../type-aliases/InputDeviceConstraint.mdx) \| `undefined` | `undefined` |
|
|
10
|
-
| `initialParam` | `"exact"
|
|
10
|
+
| `initialParam` | `"exact" \| "ideal"` | `'ideal'` |
|
|
11
11
|
|
|
12
12
|
## Returns
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
```ts
|
|
15
|
+
ConstrainNoneTuple | ConstrainDeviceTuple
|
|
16
|
+
```
|
|
@@ -8,7 +8,7 @@ function extractConstraints<T>(key): ExtractConstraintFn<ConstrainDeviceTuple>;
|
|
|
8
8
|
|
|
9
9
|
| Type Parameter |
|
|
10
10
|
| ------ |
|
|
11
|
-
| `T
|
|
11
|
+
| `T extends "device"` |
|
|
12
12
|
|
|
13
13
|
### Parameters
|
|
14
14
|
|
|
@@ -18,7 +18,7 @@ function extractConstraints<T>(key): ExtractConstraintFn<ConstrainDeviceTuple>;
|
|
|
18
18
|
|
|
19
19
|
### Returns
|
|
20
20
|
|
|
21
|
-
`ExtractConstraintFn
|
|
21
|
+
`ExtractConstraintFn<ConstrainDeviceTuple>`
|
|
22
22
|
|
|
23
23
|
## Call Signature
|
|
24
24
|
|
|
@@ -30,7 +30,7 @@ function extractConstraints<T>(key): ExtractConstraintFn<ConstrainStringTuple>;
|
|
|
30
30
|
|
|
31
31
|
| Type Parameter |
|
|
32
32
|
| ------ |
|
|
33
|
-
| `T
|
|
33
|
+
| `T extends \| "deviceId" \| "groupId" \| "videoSegmentation" \| "backgroundImageUrl" \| "resizeMode" \| "contentHint" \| "facingMode"` |
|
|
34
34
|
|
|
35
35
|
### Parameters
|
|
36
36
|
|
|
@@ -40,7 +40,7 @@ function extractConstraints<T>(key): ExtractConstraintFn<ConstrainStringTuple>;
|
|
|
40
40
|
|
|
41
41
|
### Returns
|
|
42
42
|
|
|
43
|
-
`ExtractConstraintFn
|
|
43
|
+
`ExtractConstraintFn<ConstrainStringTuple>`
|
|
44
44
|
|
|
45
45
|
## Call Signature
|
|
46
46
|
|
|
@@ -52,7 +52,7 @@ function extractConstraints<T>(key): ExtractConstraintFn<ConstrainNumberTuple>;
|
|
|
52
52
|
|
|
53
53
|
| Type Parameter |
|
|
54
54
|
| ------ |
|
|
55
|
-
| `T
|
|
55
|
+
| `T extends ConstrainNumberKeys` |
|
|
56
56
|
|
|
57
57
|
### Parameters
|
|
58
58
|
|
|
@@ -62,7 +62,7 @@ function extractConstraints<T>(key): ExtractConstraintFn<ConstrainNumberTuple>;
|
|
|
62
62
|
|
|
63
63
|
### Returns
|
|
64
64
|
|
|
65
|
-
`ExtractConstraintFn
|
|
65
|
+
`ExtractConstraintFn<ConstrainNumberTuple>`
|
|
66
66
|
|
|
67
67
|
## Call Signature
|
|
68
68
|
|
|
@@ -74,7 +74,7 @@ function extractConstraints<T>(key): ExtractConstraintFn<ConstrainBooleanTuple>;
|
|
|
74
74
|
|
|
75
75
|
| Type Parameter |
|
|
76
76
|
| ------ |
|
|
77
|
-
| `T
|
|
77
|
+
| `T extends \| "denoise" \| "vad" \| "asd" \| "mixWithAdditionalMedia" \| "excludeBystanders" \| "pan" \| "tilt" \| "zoom" \| "echoCancellation" \| "autoGainControl" \| "noiseSuppression"` |
|
|
78
78
|
|
|
79
79
|
### Parameters
|
|
80
80
|
|
|
@@ -84,4 +84,4 @@ function extractConstraints<T>(key): ExtractConstraintFn<ConstrainBooleanTuple>;
|
|
|
84
84
|
|
|
85
85
|
### Returns
|
|
86
86
|
|
|
87
|
-
`ExtractConstraintFn
|
|
87
|
+
`ExtractConstraintFn<ConstrainBooleanTuple>`
|
|
@@ -8,13 +8,13 @@ Extract the constraints with provided keys
|
|
|
8
8
|
|
|
9
9
|
| Type Parameter |
|
|
10
10
|
| ------ |
|
|
11
|
-
| `T
|
|
11
|
+
| `T extends \| "deviceId" \| "groupId" \| "device" \| "videoSegmentation" \| "denoise" \| "vad" \| "asd" \| "mixWithAdditionalMedia" \| "backgroundImageUrl" \| "excludeBystanders" \| "resizeMode" \| "pan" \| "tilt" \| "zoom" \| "contentHint" \| "facingMode" \| "echoCancellation" \| "autoGainControl" \| "noiseSuppression" \| ConstrainNumberKeys` |
|
|
12
12
|
|
|
13
13
|
## Parameters
|
|
14
14
|
|
|
15
15
|
| Parameter | Type | Description |
|
|
16
16
|
| ------ | ------ | ------ |
|
|
17
|
-
| `keys` | readonly `T
|
|
17
|
+
| `keys` | readonly `T[]` | The keys to be used for the extraction |
|
|
18
18
|
|
|
19
19
|
## Returns
|
|
20
20
|
|
|
@@ -32,7 +32,7 @@ an object with the provided key and the value-param tuple
|
|
|
32
32
|
|
|
33
33
|
### Returns
|
|
34
34
|
|
|
35
|
-
`Pick
|
|
35
|
+
`Pick<Constraints, T>`
|
|
36
36
|
|
|
37
37
|
## Example
|
|
38
38
|
|
|
@@ -16,9 +16,15 @@ Find device from the device list with provided constraints
|
|
|
16
16
|
|
|
17
17
|
## Returns
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
```ts
|
|
20
|
+
| boolean
|
|
21
|
+
```
|
|
22
|
+
```ts
|
|
23
|
+
| MediaDeviceInfoLike
|
|
24
|
+
```
|
|
25
|
+
```ts
|
|
26
|
+
| undefined
|
|
27
|
+
```
|
|
22
28
|
|
|
23
29
|
`true` means it can be any devices, `undefined` means not found,
|
|
24
30
|
otherwise, the matched device will be returned
|
|
@@ -14,8 +14,10 @@ A wrapper for `navigator.permissions.query` with fallback to use
|
|
|
14
14
|
| ------ | ------ | ------ | ------ |
|
|
15
15
|
| `anyActiveAudioTrack` | `boolean` | `false` | Has ever got an active audio to help the fallback to guess the state more accurately |
|
|
16
16
|
| `anyActiveVideoTrack` | `boolean` | `false` | Has ever got an active video to help the fallback to guess the state more accurately |
|
|
17
|
-
| `getDevices` | () =>
|
|
17
|
+
| `getDevices` | `() => Promise<MediaDeviceInfo[]>` | `...` | A function to get the list of devices, e.g. navigator.mediaDevices.enumerateDevices |
|
|
18
18
|
|
|
19
19
|
## Returns
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
```ts
|
|
22
|
+
Promise<InputDevicePermission>
|
|
23
|
+
```
|
|
@@ -13,7 +13,9 @@ Check if provided devices have any video and audio inputs
|
|
|
13
13
|
|
|
14
14
|
## Returns
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
```ts
|
|
17
|
+
[boolean, boolean]
|
|
18
|
+
```
|
|
17
19
|
|
|
18
20
|
A tuple of `[anyAudioInput, anyVideoInput]`, e.g. `[true, false]`
|
|
19
21
|
means there is audio input but no video input
|
|
@@ -10,8 +10,10 @@ is not supported from settings
|
|
|
10
10
|
|
|
11
11
|
| Parameter | Type | Description |
|
|
12
12
|
| ------ | ------ | ------ |
|
|
13
|
-
| `currentTrack` | `MediaStreamTrack
|
|
13
|
+
| `currentTrack` | `MediaStreamTrack \| undefined` | The current video input track |
|
|
14
14
|
|
|
15
15
|
## Returns
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
```ts
|
|
18
|
+
"user" | "environment" | "left" | "right" | undefined
|
|
19
|
+
```
|
|
@@ -7,7 +7,7 @@ function isRequestedResolution(request, response): boolean;
|
|
|
7
7
|
| Parameter | Type |
|
|
8
8
|
| ------ | ------ |
|
|
9
9
|
| `request` | \| [`InputDeviceConstraint`](../type-aliases/InputDeviceConstraint.mdx) \| `undefined` |
|
|
10
|
-
| `response` | `MediaTrackSettings
|
|
10
|
+
| `response` | `MediaTrackSettings \| undefined` |
|
|
11
11
|
|
|
12
12
|
## Returns
|
|
13
13
|
|
|
@@ -12,7 +12,7 @@ Check if provided request has already been fulfilled
|
|
|
12
12
|
| Parameter | Type | Description |
|
|
13
13
|
| ------ | ------ | ------ |
|
|
14
14
|
| `request` | [`MediaDeviceRequest`](../interfaces/MediaDeviceRequest.mdx) | A media request constraints |
|
|
15
|
-
| `stream` | `MediaStream
|
|
15
|
+
| `stream` | `MediaStream \| undefined` | Current media stream |
|
|
16
16
|
| `devices` | [`IndexedDevices`](../interfaces/IndexedDevices.mdx) | - |
|
|
17
17
|
|
|
18
18
|
## Returns
|
|
@@ -10,9 +10,9 @@ function isStreamingRequestedDevicesBase(
|
|
|
10
10
|
| Parameter | Type |
|
|
11
11
|
| ------ | ------ |
|
|
12
12
|
| `request` | [`MediaDeviceRequest`](../interfaces/MediaDeviceRequest.mdx) |
|
|
13
|
-
| `tracksOrDevices` | \{ `audio?`: \| [`MediaDeviceInfoLike`](../type-aliases/MediaDeviceInfoLike.mdx) \| `MediaStreamTrack
|
|
14
|
-
| `tracksOrDevices.audio?` | \| [`MediaDeviceInfoLike`](../type-aliases/MediaDeviceInfoLike.mdx) \| `MediaStreamTrack
|
|
15
|
-
| `tracksOrDevices.video?` | \| [`MediaDeviceInfoLike`](../type-aliases/MediaDeviceInfoLike.mdx) \| `MediaStreamTrack
|
|
13
|
+
| `tracksOrDevices` | \{ `audio?`: \| [`MediaDeviceInfoLike`](../type-aliases/MediaDeviceInfoLike.mdx) \| `MediaStreamTrack[]`; `video?`: \| [`MediaDeviceInfoLike`](../type-aliases/MediaDeviceInfoLike.mdx) \| `MediaStreamTrack[]`; \} |
|
|
14
|
+
| `tracksOrDevices.audio?` | \| [`MediaDeviceInfoLike`](../type-aliases/MediaDeviceInfoLike.mdx) \| `MediaStreamTrack[]` |
|
|
15
|
+
| `tracksOrDevices.video?` | \| [`MediaDeviceInfoLike`](../type-aliases/MediaDeviceInfoLike.mdx) \| `MediaStreamTrack[]` |
|
|
16
16
|
| `devices` | [`IndexedDevices`](../interfaces/IndexedDevices.mdx) |
|
|
17
17
|
|
|
18
18
|
## Returns
|
|
@@ -10,7 +10,7 @@ function isStreamingRequestingDevice(
|
|
|
10
10
|
| Parameter | Type |
|
|
11
11
|
| ------ | ------ |
|
|
12
12
|
| `request` | \| [`InputDeviceConstraint`](../type-aliases/InputDeviceConstraint.mdx) \| `undefined` |
|
|
13
|
-
| `trackOrDevice` | \| [`MediaDeviceInfoLike`](../type-aliases/MediaDeviceInfoLike.mdx) \| `MediaStreamTrack
|
|
13
|
+
| `trackOrDevice` | \| [`MediaDeviceInfoLike`](../type-aliases/MediaDeviceInfoLike.mdx) \| `MediaStreamTrack[]` \| `undefined` |
|
|
14
14
|
| `devices` | [`IndexedDevices`](../interfaces/IndexedDevices.mdx) |
|
|
15
15
|
|
|
16
16
|
## Returns
|
|
@@ -30,6 +30,12 @@ Merge base constraints with provided base constraints and another constraints
|
|
|
30
30
|
|
|
31
31
|
### Returns
|
|
32
32
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
```ts
|
|
34
|
+
| boolean
|
|
35
|
+
```
|
|
36
|
+
```ts
|
|
37
|
+
| InputConstraintSet
|
|
38
|
+
```
|
|
39
|
+
```ts
|
|
40
|
+
| undefined
|
|
41
|
+
```
|
|
@@ -21,7 +21,7 @@ function muteStreamTrack(stream?): (mute, mediaType) => void;
|
|
|
21
21
|
| Parameter | Type | Default value |
|
|
22
22
|
| ------ | ------ | ------ |
|
|
23
23
|
| `mute` | `boolean` | `undefined` |
|
|
24
|
-
| `mediaType` | `"audio"
|
|
24
|
+
| `mediaType` | `"audio" \| "video" \| "all"` | `'all'` |
|
|
25
25
|
|
|
26
26
|
### Returns
|
|
27
27
|
|
|
@@ -16,11 +16,15 @@ we will use the `ideal`.
|
|
|
16
16
|
|
|
17
17
|
| Parameter | Type | Description |
|
|
18
18
|
| ------ | ------ | ------ |
|
|
19
|
-
| `kind` | `"audioinput"
|
|
19
|
+
| `kind` | `"audioinput" \| "videoinput"` | - |
|
|
20
20
|
| `input` | \| [`InputDeviceConstraint`](../type-aliases/InputDeviceConstraint.mdx) \| `undefined` | The input constraints to be relaxed |
|
|
21
21
|
| `devices` | [`IndexedDevices`](../interfaces/IndexedDevices.mdx) | The current device list |
|
|
22
22
|
|
|
23
23
|
## Returns
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
```ts
|
|
26
|
+
| InputDeviceConstraint
|
|
27
|
+
```
|
|
28
|
+
```ts
|
|
29
|
+
| undefined
|
|
30
|
+
```
|
|
@@ -12,8 +12,10 @@ try to return the best possible from mediaTrackConstraints.
|
|
|
12
12
|
| Parameter | Type |
|
|
13
13
|
| ------ | ------ |
|
|
14
14
|
| `constraints?` | [`InputDeviceConstraint`](../type-aliases/InputDeviceConstraint.mdx) |
|
|
15
|
-
| `base?` | `boolean
|
|
15
|
+
| `base?` | `boolean \| MediaTrackConstraints` |
|
|
16
16
|
|
|
17
17
|
## Returns
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
```ts
|
|
20
|
+
boolean | MediaTrackConstraints | undefined
|
|
21
|
+
```
|
|
@@ -12,8 +12,8 @@ https://developer.mozilla.org/en-US/docs/Web/API/MediaStreamTrack/stop#descripti
|
|
|
12
12
|
|
|
13
13
|
| Parameter | Type | Description |
|
|
14
14
|
| ------ | ------ | ------ |
|
|
15
|
-
| `stream` | `MediaStream
|
|
16
|
-
| `onStopped?` | (
|
|
15
|
+
| `stream` | `MediaStream \| undefined` | `MediaStream` which we mutate |
|
|
16
|
+
| `onStopped?` | `(track) => void` | callback to be called when the track is stopped |
|
|
17
17
|
|
|
18
18
|
## Returns
|
|
19
19
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
```ts
|
|
2
|
-
function toKey(__namedParameters):
|
|
2
|
+
function toKey(__namedParameters): DeviceKey;
|
|
3
3
|
```
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Convert provided info to key for Map
|
|
6
6
|
|
|
7
7
|
## Parameters
|
|
8
8
|
|
|
@@ -12,4 +12,4 @@ function toKey(__namedParameters): string;
|
|
|
12
12
|
|
|
13
13
|
## Returns
|
|
14
14
|
|
|
15
|
-
`
|
|
15
|
+
`DeviceKey`
|
|
@@ -6,8 +6,10 @@ function toMediaDeviceInputKind(track): "audioinput" | "videoinput";
|
|
|
6
6
|
|
|
7
7
|
| Parameter | Type |
|
|
8
8
|
| ------ | ------ |
|
|
9
|
-
| `track` | `Pick
|
|
9
|
+
| `track` | `Pick<MediaStreamTrack, "kind">` |
|
|
10
10
|
|
|
11
11
|
## Returns
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
```ts
|
|
14
|
+
"audioinput" | "videoinput"
|
|
15
|
+
```
|
|
@@ -14,8 +14,8 @@ returned by `getDisplayMedia`.
|
|
|
14
14
|
|
|
15
15
|
| Property | Type | Overrides |
|
|
16
16
|
| ------ | ------ | ------ |
|
|
17
|
-
| <a id="audio"></a> `audio?` | `boolean
|
|
18
|
-
| <a id="video"></a> `video?` | `boolean
|
|
17
|
+
| <a id="audio"></a> `audio?` | `boolean \| DisplayAudioTrackConstraints` | `DisplayMediaStreamOptions.audio` |
|
|
18
|
+
| <a id="video"></a> `video?` | `boolean \| DisplayVideoTrackConstraints` | `DisplayMediaStreamOptions.video` |
|
|
19
19
|
| <a id="selfbrowsersurface"></a> `selfBrowserSurface?` | `ConstrainDOMString` | - |
|
|
20
20
|
| <a id="systemaudio"></a> `systemAudio?` | `ConstrainDOMString` | - |
|
|
21
21
|
| <a id="surfaceswitching"></a> `surfaceSwitching?` | `ConstrainDOMString` | - |
|
|
@@ -65,8 +65,12 @@ First device of the kind
|
|
|
65
65
|
|
|
66
66
|
#### Returns
|
|
67
67
|
|
|
68
|
-
|
|
69
|
-
|
|
68
|
+
```ts
|
|
69
|
+
| MediaDeviceInfoLike
|
|
70
|
+
```
|
|
71
|
+
```ts
|
|
72
|
+
| undefined
|
|
73
|
+
```
|
|
70
74
|
|
|
71
75
|
***
|
|
72
76
|
|
|
@@ -78,7 +82,9 @@ toJSON(): Record<MediaDeviceKind, MediaDeviceInfoLike[]>;
|
|
|
78
82
|
|
|
79
83
|
#### Returns
|
|
80
84
|
|
|
81
|
-
|
|
85
|
+
```ts
|
|
86
|
+
Record<MediaDeviceKind, MediaDeviceInfoLike[]>
|
|
87
|
+
```
|
|
82
88
|
|
|
83
89
|
***
|
|
84
90
|
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
| Property | Type | Description | Inherited from |
|
|
8
8
|
| ------ | ------ | ------ | ------ |
|
|
9
|
-
| <a id="device"></a> `device?` | `DeviceConstraint
|
|
9
|
+
| <a id="device"></a> `device?` | `DeviceConstraint \| ConstraintDeviceParameters` | Same purpose as `deviceId` but it gives more information about the device so that we can have extra tolerance on device selection | - |
|
|
10
10
|
| <a id="videosegmentation"></a> `videoSegmentation?` | `ConstrainDOMString` | Whether or not using video segmentation, e.g. background blur/replacement, to specify the effects, intended to be applied to the segment. Available effects are `none`, `blur`, `overlay` or `remove` | - |
|
|
11
11
|
| <a id="denoise"></a> `denoise?` | `ConstrainBoolean` | Whether or not using our own noise suppression | - |
|
|
12
12
|
| <a id="vad"></a> `vad?` | `ConstrainBoolean` | Voice Activity Detection | - |
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
| <a id="foregroundthreshold"></a> `foregroundThreshold?` | `ConstrainDouble` | Erode level for edge smoothing when using video segmentation | - |
|
|
18
18
|
| <a id="backgroundimageurl"></a> `backgroundImageUrl?` | `ConstrainDOMString` | Image Url that is being used for video overlay effects | - |
|
|
19
19
|
| <a id="maskcombineratio"></a> `maskCombineRatio?` | `ConstrainDouble` | The ratio to be used for smoothing segmentation mask. How much uncertainty enables temporal blend, [0,1]. Higher = more frame-to-frame blending, more stability but more trailing ghosts. Typical: 0.6–0.85. | - |
|
|
20
|
-
| <a id="backgroundthreshold"></a> `backgroundThreshold?` | `ConstrainDouble` | [0,1] Lower mask confidence: all mask pixels
|
|
20
|
+
| <a id="backgroundthreshold"></a> `backgroundThreshold?` | `ConstrainDouble` | [0,1] Lower mask confidence: all mask pixels \<= this are considered definite background. Adjust to make mask edges tighter or more permissive for background inclusion. Example: 0.3 ("mask \< 0.3 = sure background"). | - |
|
|
21
21
|
| <a id="sigmaspace"></a> `sigmaSpace?` | `ConstrainDouble` | Bilateral filter: sigma in pixel space for mask edge snapping. Controls the neighborhood/pixel distance—higher is larger window (5–10 typical). | - |
|
|
22
22
|
| <a id="sigmarangelo"></a> `sigmaRangeLo?` | `ConstrainDouble` | Bilateral filter: minimum sigma in color/luma (for mask interiors), [0,1]. Controls how little color difference is needed to cross-mask regions away from edge. Lower = sharper edge preservation in mask interiors. Example: 0.2 | - |
|
|
23
23
|
| <a id="sigmarangehi"></a> `sigmaRangeHi?` | `ConstrainDouble` | Bilateral filter: maximum sigma in color/luma (for mask uncertain zones), [0,1]. Controls how much color similarity is required at uncertain/edge mask locations. Higher = more mask smoothing at edges. Example: 0.8 | - |
|
|
@@ -52,4 +52,4 @@
|
|
|
52
52
|
| <a id="samplerate"></a> `sampleRate?` | `ConstrainULong` | - | `MediaTrackConstraints.sampleRate` |
|
|
53
53
|
| <a id="samplesize"></a> `sampleSize?` | `ConstrainULong` | - | `MediaTrackConstraints.sampleSize` |
|
|
54
54
|
| <a id="width"></a> `width?` | `ConstrainULong` | - | `MediaTrackConstraints.width` |
|
|
55
|
-
| <a id="advanced"></a> `advanced?` | `MediaTrackConstraintSet
|
|
55
|
+
| <a id="advanced"></a> `advanced?` | `MediaTrackConstraintSet[]` | - | `MediaTrackConstraints.advanced` |
|
|
@@ -6,9 +6,9 @@ MediaControl Interface
|
|
|
6
6
|
|
|
7
7
|
| Property | Type | Description |
|
|
8
8
|
| ------ | ------ | ------ |
|
|
9
|
-
| <a id="devicechanged"></a> `deviceChanged` | (
|
|
10
|
-
| <a id="getdevices"></a> `getDevices` | () =>
|
|
9
|
+
| <a id="devicechanged"></a> `deviceChanged` | `(fn) => () => void` | **`Beta`** Unified interface for subscribing [DeviceChangedChanges](../type-aliases/DeviceChangedChanges.mdx) Event |
|
|
10
|
+
| <a id="getdevices"></a> `getDevices` | `() => Promise<MediaDeviceInfo[]>` | **`Beta`** Future proofing: in case we want to alter the values or type returned by [enumerateDevices](https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/enumerateDevices) |
|
|
11
11
|
| <a id="mediaeventtype"></a> `MediaEventType` | *typeof* [`MediaEventType`](../enumerations/MediaEventType.mdx) | **`Beta`** MediaStreamTrack Events **Remarks** See MDN [Events](https://developer.mozilla.org/en-US/docs/Web/API/MediaStreamTrack#Events) |
|
|
12
|
-
| <a id="getusermedia"></a> `getUserMedia` | (
|
|
13
|
-
| <a id="setdefaultconstraints"></a> `setDefaultConstraints` | (
|
|
14
|
-
| <a id="subscribe"></a> `subscribe` | (
|
|
12
|
+
| <a id="getusermedia"></a> `getUserMedia` | `(__namedParameters) => Promise<MediaStream>` | **`Beta`** Get MediaStream with provided [input constraints](MediaDeviceRequest.mdx) |
|
|
13
|
+
| <a id="setdefaultconstraints"></a> `setDefaultConstraints` | `(newConstraints) => void` | **`Beta`** Set default media stream constraints A [MediaStreamConstraints](https://developer.mozilla.org/en-US/docs/Web/API/MediaStreamConstraints) object specifying the types of media to request, along with any requirements for each type. |
|
|
14
|
+
| <a id="subscribe"></a> `subscribe` | `(listener) => () => void` | **`Beta`** Subscribe media events |
|
package/dist/devices.d.ts
CHANGED
|
@@ -18,12 +18,14 @@ interface ToKeyOptions {
|
|
|
18
18
|
kind: string;
|
|
19
19
|
label: string;
|
|
20
20
|
}
|
|
21
|
+
export type DeviceKey = string & {
|
|
22
|
+
__type: 'track-key';
|
|
23
|
+
};
|
|
21
24
|
/**
|
|
22
25
|
* Convert provided info to key for Map
|
|
23
26
|
*
|
|
24
|
-
* @beta
|
|
25
27
|
*/
|
|
26
|
-
export declare const toKey: ({ id, kind, label }: ToKeyOptions) =>
|
|
28
|
+
export declare const toKey: ({ id, kind, label }: ToKeyOptions) => DeviceKey;
|
|
27
29
|
export declare const toMediaDeviceInputKind: (track: Pick<MediaStreamTrack, "kind">) => "audioinput" | "videoinput";
|
|
28
30
|
/**
|
|
29
31
|
* Future proofing: in case we want to alter the values or type returned
|
|
@@ -43,8 +45,8 @@ export declare const toMediaDeviceInputKind: (track: Pick<MediaStreamTrack, "kin
|
|
|
43
45
|
* @beta
|
|
44
46
|
*/
|
|
45
47
|
export declare const getDevices: () => Promise<MediaDeviceInfo[]>;
|
|
46
|
-
export declare const toDeviceKey: (device: MediaDeviceInfoLike) =>
|
|
47
|
-
export declare const toDeviceTuple: (device: MediaDeviceInfoLike) => readonly [
|
|
48
|
+
export declare const toDeviceKey: (device: MediaDeviceInfoLike) => DeviceKey;
|
|
49
|
+
export declare const toDeviceTuple: (device: MediaDeviceInfoLike) => readonly [DeviceKey, MediaDeviceInfoLike];
|
|
48
50
|
export declare const toDevicesMap: (devices: MediaDeviceInfoLike[]) => Map<string, MediaDeviceInfoLike>;
|
|
49
51
|
export declare const createTrackDevicesChanges: (prevDevices?: MediaDeviceInfoLike[]) => (devices: MediaDeviceInfoLike[]) => {
|
|
50
52
|
found: MediaDeviceInfoLike[];
|
package/dist/devices.js
CHANGED
package/dist/streamTrackMap.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { DeviceOrTrack, MediaStreamTrackLike } from './types';
|
|
2
|
+
import { type DeviceKey } from './devices';
|
|
2
3
|
export declare const createStreamTrackMap: (tracks?: MediaStreamTrackLike[]) => {
|
|
3
|
-
add: (track: MediaStreamTrackLike) => Map<
|
|
4
|
-
has: (deviceOrTrack: DeviceOrTrack) => boolean
|
|
4
|
+
add: (track: MediaStreamTrackLike) => Map<DeviceKey, MediaStreamTrackLike>;
|
|
5
|
+
has: (deviceOrTrack: DeviceOrTrack) => boolean;
|
|
5
6
|
clear: () => void;
|
|
6
7
|
remove: (track: MediaStreamTrackLike) => boolean;
|
|
7
8
|
size: () => number;
|
package/dist/streamTrackMap.js
CHANGED
|
@@ -3,33 +3,81 @@ import { toKey } from './devices';
|
|
|
3
3
|
import { isMediaStreamTrack } from './typeGuards';
|
|
4
4
|
export const createStreamTrackMap = (tracks) => {
|
|
5
5
|
const streamTrackMap = new Map(tracks?.map(track => [toKey(track), track]));
|
|
6
|
+
const toDeviceIndexKey = (track) => {
|
|
7
|
+
const { deviceId } = track.getSettings();
|
|
8
|
+
return deviceId
|
|
9
|
+
? `${track.kind}:${deviceId}`
|
|
10
|
+
: undefined;
|
|
11
|
+
};
|
|
12
|
+
const toDeviceQueryKey = (device) => {
|
|
13
|
+
switch (device.kind) {
|
|
14
|
+
case 'audioinput':
|
|
15
|
+
return `audio:${device.deviceId}`;
|
|
16
|
+
case 'videoinput':
|
|
17
|
+
return `video:${device.deviceId}`;
|
|
18
|
+
default:
|
|
19
|
+
return undefined;
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Secondary index: `${track.kind}:${deviceId}` → tracks for O(1) device lookups.
|
|
24
|
+
* Uses a Set per key so multiple tracks sharing a deviceId stay findable
|
|
25
|
+
* until every one of them is removed.
|
|
26
|
+
*/
|
|
27
|
+
const deviceIndex = new Map();
|
|
28
|
+
const addToDeviceIndex = (track) => {
|
|
29
|
+
const indexKey = toDeviceIndexKey(track);
|
|
30
|
+
if (!indexKey) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
const existing = deviceIndex.get(indexKey);
|
|
34
|
+
if (existing) {
|
|
35
|
+
existing.add(track);
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
deviceIndex.set(indexKey, new Set([track]));
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
const removeFromDeviceIndex = (track) => {
|
|
42
|
+
const indexKey = toDeviceIndexKey(track);
|
|
43
|
+
if (!indexKey) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
const existing = deviceIndex.get(indexKey);
|
|
47
|
+
if (!existing) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
existing.delete(track);
|
|
51
|
+
if (existing.size === 0) {
|
|
52
|
+
deviceIndex.delete(indexKey);
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
for (const track of streamTrackMap.values()) {
|
|
56
|
+
addToDeviceIndex(track);
|
|
57
|
+
}
|
|
6
58
|
/**
|
|
7
59
|
* Find track from the list of track in use.
|
|
8
60
|
*/
|
|
9
61
|
const findTrack = (device) => {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
return false;
|
|
17
|
-
}
|
|
18
|
-
return (device.kind.includes(kind) && device.deviceId === deviceId);
|
|
19
|
-
});
|
|
62
|
+
const queryKey = toDeviceQueryKey(device);
|
|
63
|
+
if (!queryKey) {
|
|
64
|
+
return undefined;
|
|
65
|
+
}
|
|
66
|
+
const tracks = deviceIndex.get(queryKey);
|
|
67
|
+
return tracks?.values().next().value;
|
|
20
68
|
};
|
|
21
69
|
/**
|
|
22
|
-
* Construct a `
|
|
70
|
+
* Construct a `DeviceKey` from `DeviceOrTrack`
|
|
23
71
|
*/
|
|
24
72
|
const toStreamTrackKey = (deviceOrTrack) => {
|
|
25
73
|
// Unify interfaces
|
|
26
74
|
const track = isMediaStreamTrack(deviceOrTrack)
|
|
27
75
|
? deviceOrTrack
|
|
28
76
|
: findTrack(deviceOrTrack);
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
return toKey(
|
|
77
|
+
const kind = track?.kind || 'unknown-kind';
|
|
78
|
+
const id = track?.id || 'unknown-id';
|
|
79
|
+
const label = track?.label || 'unknown-label';
|
|
80
|
+
return toKey({ kind, id, label });
|
|
33
81
|
};
|
|
34
82
|
/**
|
|
35
83
|
* Add the `MediaStreamTrack` to `streamTrackMap`
|
|
@@ -37,6 +85,7 @@ export const createStreamTrackMap = (tracks) => {
|
|
|
37
85
|
const add = (track) => {
|
|
38
86
|
const key = toStreamTrackKey(track);
|
|
39
87
|
if (key) {
|
|
88
|
+
addToDeviceIndex(track);
|
|
40
89
|
return streamTrackMap.set(key, track);
|
|
41
90
|
}
|
|
42
91
|
throw new Error(MediaDeviceFailure.StreamTrackNotFound);
|
|
@@ -56,12 +105,14 @@ export const createStreamTrackMap = (tracks) => {
|
|
|
56
105
|
track.stop();
|
|
57
106
|
}
|
|
58
107
|
streamTrackMap.clear();
|
|
108
|
+
deviceIndex.clear();
|
|
59
109
|
};
|
|
60
110
|
/**
|
|
61
111
|
* Stop the track and remove the track from `streamTrackMap`
|
|
62
112
|
*/
|
|
63
113
|
const remove = (track) => {
|
|
64
114
|
const key = toStreamTrackKey(track);
|
|
115
|
+
removeFromDeviceIndex(track);
|
|
65
116
|
track.stop();
|
|
66
117
|
return streamTrackMap.delete(key);
|
|
67
118
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pexip/media-control",
|
|
3
|
-
"version": "22.
|
|
3
|
+
"version": "22.1.0",
|
|
4
4
|
"homepage": "https://developer.pexip.com",
|
|
5
5
|
"bugs": "https://gitlab.com/pexip/zoo/issues",
|
|
6
6
|
"repository": {
|
|
@@ -48,12 +48,12 @@
|
|
|
48
48
|
"docs": "typedoc"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@pexip/utils": "17.
|
|
51
|
+
"@pexip/utils": "17.4.0"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
54
|
"@jest/globals": "^29.5.12",
|
|
55
55
|
"@pexip/bundler": "18.2.1",
|
|
56
|
-
"@swc/core": "^1.
|
|
56
|
+
"@swc/core": "^1.15.33",
|
|
57
57
|
"@swc/jest": "^0.2.39",
|
|
58
58
|
"@types/uuid": "^8.3.0",
|
|
59
59
|
"@types/webrtc": "^0.0.31",
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
"typedoc": "^0.28.18",
|
|
64
64
|
"typedoc-plugin-markdown": "^4.11.0",
|
|
65
65
|
"typescript": "~6.0.2",
|
|
66
|
-
"uuid": "^
|
|
66
|
+
"uuid": "^14.0.0"
|
|
67
67
|
},
|
|
68
68
|
"publishConfig": {
|
|
69
69
|
"access": "public"
|