@webex/media-helpers 3.0.0-next.4 → 3.0.0-next.5

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/LICENSE CHANGED
@@ -1,2 +1,2 @@
1
- All contents are licensed under the Cisco EULA
1
+ All contents are licensed under the Cisco EULA
2
2
  (https://www.cisco.com/c/en/us/products/end-user-license-agreement.html)
package/README.md CHANGED
@@ -1,106 +1,106 @@
1
- # @webex/media-helpers
2
-
3
- [![standard-readme compliant](https://img.shields.io/badge/readme%20style-standard-brightgreen.svg?style=flat-square)](https://github.com/RichardLitt/standard-readme)
4
-
5
- > Media helpers
6
-
7
- This is an internal Cisco Webex plugin. As such, it does not strictly adhere to semantic versioning. Use at your own risk. If you're not working on one of our first party clients, please look at our [developer api](https://developer.webex.com/) and stick to our public plugins.
8
-
9
- - [@webex/media-helpers](#webexmedia-helpers)
10
- - [Install](#install)
11
- - [Usage](#usage)
12
- - [Maintainers](#maintainers)
13
- - [Contribute](#contribute)
14
- - [License](#license)
15
-
16
- ## Install
17
-
18
- ```bash
19
- npm install --save @webex/media-helpers
20
- ```
21
-
22
- ## Usage
23
-
24
- ### Effects
25
- There are two effects included in this package:
26
-
27
- Virtual background (e.g., blur, image replacement, video replacement)
28
- Noise reduction (e.g., background noise removal)
29
-
30
- #### Virtual background
31
- The virtual background effect provides a virtual background for video calling. The virtual background may be an image, an mp4 video, or the user's background with blur applied.
32
-
33
- **Applying the effect**
34
- 1. Create a new camera track instance by using LocalCameraTrack() method.
35
- 2. Create a VirtualBackgroundEffect instance by passing appropriate constraints.
36
- 3. Use addEffect() method on cameraTrack to apply effect on it.
37
- 4. Enable the effect after adding it to cameraTrack using enable() method available on effect. Effect will be enabled on cameraTrack.
38
-
39
- ```javascript
40
- import {LocalCameraTrack, VirtualBackgroundEffect} from '@webex/media-helpers';
41
-
42
- // Create a new video stream by a getting user's video media.
43
- const stream = await navigator.mediaDevices.getUserMedia({ video: { width, height } });
44
-
45
- const videoTrackFromLocalStream = stream.getVideoTracks()[0];
46
-
47
- const cameraTrack = new LocalCameraTrack(new MediaStream([videoTrackFromLocalStream]));
48
-
49
- // Create the effect.
50
- const effect = new VirtualBackgroundEffect({
51
- authToken: '<encoded-string>',
52
- mode: `BLUR`,
53
- blurStrength: `STRONG`,
54
- quality: `LOW`,
55
- });
56
-
57
- // add the effect on the input camera track.
58
- await cameraTrack.addEffect("background-blur", effect);
59
-
60
- //enable the effect once it is added to the track
61
- await effect.enable()
62
- ```
63
-
64
- #### Noise reduction
65
- The noise reduction effect removes background noise from an audio stream to provide clear audio for calling.
66
-
67
- **Applying the effect**
68
- 1. Create a new microphone track instance by using LocalMicrophoneTrack() method.
69
- 2. Create a NoiseReductionEffect instance by passing appropriate constraints.
70
- 3. Use addEffect() method on microphoneTrack to apply effect on it.
71
- 4. Enable the effect after adding it to microphoneTrack using enable() method available on effect. Effect will be enabled on microphoneTrack.
72
-
73
- ```javascript
74
- import {LocalMicrophoneTrack, NoiseReductionEffect} from '@webex/media-helpers';
75
-
76
- // Create a new audio stream by getting a user's audio media.
77
- const stream = await navigator.mediaDevices.getUserMedia({ audio: true });
78
-
79
- const audioTrackFromLocalStream = stream.getAudioTracks()[0];
80
-
81
- const microphoneTrack = new LocalMicrophoneTrack(new MediaStream([audioTrackFromLocalStream]));
82
-
83
- // Create the effect.
84
- const effect = new NoiseReductionEffect({
85
- authToken: '<encoded-string>',
86
- mode: 'WORKLET', // or 'LEGACY'
87
- });
88
-
89
- // add the effect on microphone track.
90
- await microphoneTrack.addEffect("background-noise-removal", effect);
91
-
92
- //enable the effect once it is added to the track
93
- await effect.enable()
94
- ```
95
-
96
- ## Maintainers
97
-
98
- This package is maintained by [Cisco Webex for Developers](https://developer.webex.com/).
99
-
100
- ## Contribute
101
-
102
- Pull requests welcome. Please see [CONTRIBUTING.md](https://github.com/webex/webex-js-sdk/blob/master/CONTRIBUTING.md) for more details.
103
-
104
- ## License
105
-
106
- © 2016-2022 Cisco and/or its affiliates. All Rights Reserved.
1
+ # @webex/media-helpers
2
+
3
+ [![standard-readme compliant](https://img.shields.io/badge/readme%20style-standard-brightgreen.svg?style=flat-square)](https://github.com/RichardLitt/standard-readme)
4
+
5
+ > Media helpers
6
+
7
+ This is an internal Cisco Webex plugin. As such, it does not strictly adhere to semantic versioning. Use at your own risk. If you're not working on one of our first party clients, please look at our [developer api](https://developer.webex.com/) and stick to our public plugins.
8
+
9
+ - [@webex/media-helpers](#webexmedia-helpers)
10
+ - [Install](#install)
11
+ - [Usage](#usage)
12
+ - [Maintainers](#maintainers)
13
+ - [Contribute](#contribute)
14
+ - [License](#license)
15
+
16
+ ## Install
17
+
18
+ ```bash
19
+ npm install --save @webex/media-helpers
20
+ ```
21
+
22
+ ## Usage
23
+
24
+ ### Effects
25
+ There are two effects included in this package:
26
+
27
+ Virtual background (e.g., blur, image replacement, video replacement)
28
+ Noise reduction (e.g., background noise removal)
29
+
30
+ #### Virtual background
31
+ The virtual background effect provides a virtual background for video calling. The virtual background may be an image, an mp4 video, or the user's background with blur applied.
32
+
33
+ **Applying the effect**
34
+ 1. Create a new camera track instance by using LocalCameraTrack() method.
35
+ 2. Create a VirtualBackgroundEffect instance by passing appropriate constraints.
36
+ 3. Use addEffect() method on cameraTrack to apply effect on it.
37
+ 4. Enable the effect after adding it to cameraTrack using enable() method available on effect. Effect will be enabled on cameraTrack.
38
+
39
+ ```javascript
40
+ import {LocalCameraTrack, VirtualBackgroundEffect} from '@webex/media-helpers';
41
+
42
+ // Create a new video stream by a getting user's video media.
43
+ const stream = await navigator.mediaDevices.getUserMedia({ video: { width, height } });
44
+
45
+ const videoTrackFromLocalStream = stream.getVideoTracks()[0];
46
+
47
+ const cameraTrack = new LocalCameraTrack(new MediaStream([videoTrackFromLocalStream]));
48
+
49
+ // Create the effect.
50
+ const effect = new VirtualBackgroundEffect({
51
+ authToken: '<encoded-string>',
52
+ mode: `BLUR`,
53
+ blurStrength: `STRONG`,
54
+ quality: `LOW`,
55
+ });
56
+
57
+ // add the effect on the input camera track.
58
+ await cameraTrack.addEffect("background-blur", effect);
59
+
60
+ //enable the effect once it is added to the track
61
+ await effect.enable()
62
+ ```
63
+
64
+ #### Noise reduction
65
+ The noise reduction effect removes background noise from an audio stream to provide clear audio for calling.
66
+
67
+ **Applying the effect**
68
+ 1. Create a new microphone track instance by using LocalMicrophoneTrack() method.
69
+ 2. Create a NoiseReductionEffect instance by passing appropriate constraints.
70
+ 3. Use addEffect() method on microphoneTrack to apply effect on it.
71
+ 4. Enable the effect after adding it to microphoneTrack using enable() method available on effect. Effect will be enabled on microphoneTrack.
72
+
73
+ ```javascript
74
+ import {LocalMicrophoneTrack, NoiseReductionEffect} from '@webex/media-helpers';
75
+
76
+ // Create a new audio stream by getting a user's audio media.
77
+ const stream = await navigator.mediaDevices.getUserMedia({ audio: true });
78
+
79
+ const audioTrackFromLocalStream = stream.getAudioTracks()[0];
80
+
81
+ const microphoneTrack = new LocalMicrophoneTrack(new MediaStream([audioTrackFromLocalStream]));
82
+
83
+ // Create the effect.
84
+ const effect = new NoiseReductionEffect({
85
+ authToken: '<encoded-string>',
86
+ mode: 'WORKLET', // or 'LEGACY'
87
+ });
88
+
89
+ // add the effect on microphone track.
90
+ await microphoneTrack.addEffect("background-noise-removal", effect);
91
+
92
+ //enable the effect once it is added to the track
93
+ await effect.enable()
94
+ ```
95
+
96
+ ## Maintainers
97
+
98
+ This package is maintained by [Cisco Webex for Developers](https://developer.webex.com/).
99
+
100
+ ## Contribute
101
+
102
+ Pull requests welcome. Please see [CONTRIBUTING.md](https://github.com/webex/webex-js-sdk/blob/master/CONTRIBUTING.md) for more details.
103
+
104
+ ## License
105
+
106
+ © 2016-2022 Cisco and/or its affiliates. All Rights Reserved.
package/babel.config.json CHANGED
@@ -1,13 +1,13 @@
1
- {
2
- "presets": [
3
- [
4
- "@babel/preset-env",
5
- {
6
- "targets": {
7
- "node": "current"
8
- }
9
- }
10
- ],
11
- "@babel/preset-typescript"
12
- ],
1
+ {
2
+ "presets": [
3
+ [
4
+ "@babel/preset-env",
5
+ {
6
+ "targets": {
7
+ "node": "current"
8
+ }
9
+ }
10
+ ],
11
+ "@babel/preset-typescript"
12
+ ],
13
13
  }
@@ -1,13 +1,13 @@
1
- import { VideoDeviceConstraints } from '@webex/internal-media-core';
2
- export declare enum FacingMode {
3
- user = "user",
4
- environment = "environment"
5
- }
6
- export declare enum DisplaySurface {
7
- browser = "browser",
8
- monitor = "monitor",
9
- window = "window"
10
- }
11
- export declare const PresetCameraConstraints: {
12
- [key: string]: VideoDeviceConstraints;
13
- };
1
+ import { VideoDeviceConstraints } from '@webex/internal-media-core';
2
+ export declare enum FacingMode {
3
+ user = "user",
4
+ environment = "environment"
5
+ }
6
+ export declare enum DisplaySurface {
7
+ browser = "browser",
8
+ monitor = "monitor",
9
+ window = "window"
10
+ }
11
+ export declare const PresetCameraConstraints: {
12
+ [key: string]: VideoDeviceConstraints;
13
+ };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { getDevices, LocalStream, LocalDisplayStream, LocalSystemAudioStream, LocalStreamEventNames, StreamEventNames, type ServerMuteReason, LocalMicrophoneStreamEventNames, LocalCameraStreamEventNames, LocalMicrophoneStream, LocalCameraStream, createMicrophoneStream, createCameraStream, createDisplayStream, createDisplayStreamWithAudio, } from './webrtc-core';
2
- export { NoiseReductionEffect, VirtualBackgroundEffect } from '@webex/web-media-effects';
3
- export type { NoiseReductionEffectOptions, VirtualBackgroundEffectOptions, } from '@webex/web-media-effects';
4
- export { FacingMode, DisplaySurface, PresetCameraConstraints } from './constants';
1
+ export { getDevices, LocalStream, LocalDisplayStream, LocalSystemAudioStream, LocalStreamEventNames, StreamEventNames, type ServerMuteReason, LocalMicrophoneStreamEventNames, LocalCameraStreamEventNames, LocalMicrophoneStream, LocalCameraStream, createMicrophoneStream, createCameraStream, createDisplayStream, createDisplayStreamWithAudio, } from './webrtc-core';
2
+ export { NoiseReductionEffect, VirtualBackgroundEffect } from '@webex/web-media-effects';
3
+ export type { NoiseReductionEffectOptions, VirtualBackgroundEffectOptions, } from '@webex/web-media-effects';
4
+ export { FacingMode, DisplaySurface, PresetCameraConstraints } from './constants';
@@ -1,48 +1,48 @@
1
- import { AudioDeviceConstraints, LocalDisplayStream, LocalSystemAudioStream, LocalMicrophoneStream as WcmeLocalMicrophoneStream, LocalCameraStream as WcmeLocalCameraStream, VideoDeviceConstraints } from '@webex/internal-media-core';
2
- import { TypedEvent } from '@webex/ts-events';
3
- export { getDevices, LocalStream, LocalDisplayStream, LocalSystemAudioStream, LocalStreamEventNames, StreamEventNames, RemoteStream, } from '@webex/internal-media-core';
4
- export type ServerMuteReason = 'remotelyMuted' | 'clientRequestFailed' | 'localUnmuteRequired';
5
- export declare enum LocalMicrophoneStreamEventNames {
6
- ServerMuted = "muted:byServer"
7
- }
8
- export declare enum LocalCameraStreamEventNames {
9
- ServerMuted = "muted:byServer"
10
- }
11
- export declare class LocalMicrophoneStream extends WcmeLocalMicrophoneStream {
12
- private unmuteAllowed;
13
- [LocalMicrophoneStreamEventNames.ServerMuted]: TypedEvent<(muted: boolean, reason: ServerMuteReason) => void>;
14
- /**
15
- * @internal
16
- */
17
- setUnmuteAllowed(allowed: any): void;
18
- /**
19
- * @returns true if user is allowed to unmute the Stream, false otherwise
20
- */
21
- isUnmuteAllowed(): boolean;
22
- setMuted(muted: boolean): void;
23
- /**
24
- * @internal
25
- */
26
- setServerMuted(muted: boolean, reason: ServerMuteReason): void;
27
- }
28
- export declare class LocalCameraStream extends WcmeLocalCameraStream {
29
- private unmuteAllowed;
30
- [LocalCameraStreamEventNames.ServerMuted]: TypedEvent<(muted: boolean, reason: ServerMuteReason) => void>;
31
- /**
32
- * @internal
33
- */
34
- setUnmuteAllowed(allowed: any): void;
35
- /**
36
- * @returns true if user is allowed to unmute the Stream, false otherwise
37
- */
38
- isUnmuteAllowed(): boolean;
39
- setMuted(muted: boolean): void;
40
- /**
41
- * @internal
42
- */
43
- setServerMuted(muted: boolean, reason: ServerMuteReason): void;
44
- }
45
- export declare const createMicrophoneStream: (constraints?: AudioDeviceConstraints) => Promise<LocalMicrophoneStream>;
46
- export declare const createCameraStream: (constraints?: VideoDeviceConstraints) => Promise<LocalCameraStream>;
47
- export declare const createDisplayStream: () => Promise<LocalDisplayStream>;
48
- export declare const createDisplayStreamWithAudio: () => Promise<[LocalDisplayStream, LocalSystemAudioStream]>;
1
+ import { AudioDeviceConstraints, LocalDisplayStream, LocalSystemAudioStream, LocalMicrophoneStream as WcmeLocalMicrophoneStream, LocalCameraStream as WcmeLocalCameraStream, VideoDeviceConstraints } from '@webex/internal-media-core';
2
+ import { TypedEvent } from '@webex/ts-events';
3
+ export { getDevices, LocalStream, LocalDisplayStream, LocalSystemAudioStream, LocalStreamEventNames, StreamEventNames, RemoteStream, } from '@webex/internal-media-core';
4
+ export type ServerMuteReason = 'remotelyMuted' | 'clientRequestFailed' | 'localUnmuteRequired';
5
+ export declare enum LocalMicrophoneStreamEventNames {
6
+ ServerMuted = "muted:byServer"
7
+ }
8
+ export declare enum LocalCameraStreamEventNames {
9
+ ServerMuted = "muted:byServer"
10
+ }
11
+ export declare class LocalMicrophoneStream extends WcmeLocalMicrophoneStream {
12
+ private unmuteAllowed;
13
+ [LocalMicrophoneStreamEventNames.ServerMuted]: TypedEvent<(muted: boolean, reason: ServerMuteReason) => void>;
14
+ /**
15
+ * @internal
16
+ */
17
+ setUnmuteAllowed(allowed: any): void;
18
+ /**
19
+ * @returns true if user is allowed to unmute the Stream, false otherwise
20
+ */
21
+ isUnmuteAllowed(): boolean;
22
+ setMuted(muted: boolean): void;
23
+ /**
24
+ * @internal
25
+ */
26
+ setServerMuted(muted: boolean, reason: ServerMuteReason): void;
27
+ }
28
+ export declare class LocalCameraStream extends WcmeLocalCameraStream {
29
+ private unmuteAllowed;
30
+ [LocalCameraStreamEventNames.ServerMuted]: TypedEvent<(muted: boolean, reason: ServerMuteReason) => void>;
31
+ /**
32
+ * @internal
33
+ */
34
+ setUnmuteAllowed(allowed: any): void;
35
+ /**
36
+ * @returns true if user is allowed to unmute the Stream, false otherwise
37
+ */
38
+ isUnmuteAllowed(): boolean;
39
+ setMuted(muted: boolean): void;
40
+ /**
41
+ * @internal
42
+ */
43
+ setServerMuted(muted: boolean, reason: ServerMuteReason): void;
44
+ }
45
+ export declare const createMicrophoneStream: (constraints?: AudioDeviceConstraints) => Promise<LocalMicrophoneStream>;
46
+ export declare const createCameraStream: (constraints?: VideoDeviceConstraints) => Promise<LocalCameraStream>;
47
+ export declare const createDisplayStream: () => Promise<LocalDisplayStream>;
48
+ export declare const createDisplayStreamWithAudio: () => Promise<[LocalDisplayStream, LocalSystemAudioStream]>;
package/package.json CHANGED
@@ -22,11 +22,7 @@
22
22
  "deploy:npm": "yarn npm publish"
23
23
  },
24
24
  "dependencies": {
25
- "@webex/babel-config-legacy": "^0.0.0",
26
- "@webex/eslint-config-legacy": "^0.0.0",
27
25
  "@webex/internal-media-core": "^2.0.0",
28
- "@webex/jest-config-legacy": "^0.0.0",
29
- "@webex/legacy-tools": "^0.0.0",
30
26
  "@webex/ts-events": "^1.1.0",
31
27
  "@webex/web-media-effects": "^2.12.0"
32
28
  },
@@ -38,10 +34,14 @@
38
34
  },
39
35
  "devDependencies": {
40
36
  "@babel/preset-typescript": "7.22.11",
37
+ "@webex/babel-config-legacy": "^0.0.0",
38
+ "@webex/eslint-config-legacy": "^0.0.0",
39
+ "@webex/jest-config-legacy": "^0.0.0",
40
+ "@webex/legacy-tools": "^0.0.0",
41
41
  "@webex/test-helper-chai": "^2.59.3-next.1",
42
42
  "@webex/test-helper-mock-webex": "^2.59.3-next.1",
43
43
  "eslint": "^8.24.0",
44
44
  "sinon": "^9.2.4"
45
45
  },
46
- "version": "3.0.0-next.4"
46
+ "version": "3.0.0-next.5"
47
47
  }
package/src/constants.ts CHANGED
@@ -1,29 +1,29 @@
1
- import {VideoDeviceConstraints} from '@webex/internal-media-core';
2
-
3
- export enum FacingMode {
4
- user = 'user',
5
- environment = 'environment',
6
- }
7
-
8
- // can be used later on when we add constraints in create display track
9
- export enum DisplaySurface {
10
- browser = 'browser',
11
- monitor = 'monitor',
12
- window = 'window',
13
- }
14
-
15
- export const PresetCameraConstraints: {[key: string]: VideoDeviceConstraints} = {
16
- '1080p': {frameRate: 30, width: 1920, height: 1080},
17
-
18
- '720p': {frameRate: 30, width: 1280, height: 720},
19
-
20
- '480p': {frameRate: 30, width: 640, height: 480},
21
-
22
- '360p': {frameRate: 30, width: 640, height: 360},
23
-
24
- '240p': {frameRate: 30, width: 320, height: 240},
25
-
26
- '180p': {frameRate: 30, width: 320, height: 180},
27
-
28
- '120p': {frameRate: 30, width: 160, height: 120},
29
- };
1
+ import {VideoDeviceConstraints} from '@webex/internal-media-core';
2
+
3
+ export enum FacingMode {
4
+ user = 'user',
5
+ environment = 'environment',
6
+ }
7
+
8
+ // can be used later on when we add constraints in create display track
9
+ export enum DisplaySurface {
10
+ browser = 'browser',
11
+ monitor = 'monitor',
12
+ window = 'window',
13
+ }
14
+
15
+ export const PresetCameraConstraints: {[key: string]: VideoDeviceConstraints} = {
16
+ '1080p': {frameRate: 30, width: 1920, height: 1080},
17
+
18
+ '720p': {frameRate: 30, width: 1280, height: 720},
19
+
20
+ '480p': {frameRate: 30, width: 640, height: 480},
21
+
22
+ '360p': {frameRate: 30, width: 640, height: 360},
23
+
24
+ '240p': {frameRate: 30, width: 320, height: 240},
25
+
26
+ '180p': {frameRate: 30, width: 320, height: 180},
27
+
28
+ '120p': {frameRate: 30, width: 160, height: 120},
29
+ };
package/src/index.ts CHANGED
@@ -1,25 +1,25 @@
1
- export {
2
- getDevices,
3
- LocalStream,
4
- LocalDisplayStream,
5
- LocalSystemAudioStream,
6
- LocalStreamEventNames,
7
- StreamEventNames,
8
- type ServerMuteReason,
9
- LocalMicrophoneStreamEventNames,
10
- LocalCameraStreamEventNames,
11
- LocalMicrophoneStream,
12
- LocalCameraStream,
13
- createMicrophoneStream,
14
- createCameraStream,
15
- createDisplayStream,
16
- createDisplayStreamWithAudio,
17
- } from './webrtc-core';
18
-
19
- export {NoiseReductionEffect, VirtualBackgroundEffect} from '@webex/web-media-effects';
20
- export type {
21
- NoiseReductionEffectOptions,
22
- VirtualBackgroundEffectOptions,
23
- } from '@webex/web-media-effects';
24
-
25
- export {FacingMode, DisplaySurface, PresetCameraConstraints} from './constants';
1
+ export {
2
+ getDevices,
3
+ LocalStream,
4
+ LocalDisplayStream,
5
+ LocalSystemAudioStream,
6
+ LocalStreamEventNames,
7
+ StreamEventNames,
8
+ type ServerMuteReason,
9
+ LocalMicrophoneStreamEventNames,
10
+ LocalCameraStreamEventNames,
11
+ LocalMicrophoneStream,
12
+ LocalCameraStream,
13
+ createMicrophoneStream,
14
+ createCameraStream,
15
+ createDisplayStream,
16
+ createDisplayStreamWithAudio,
17
+ } from './webrtc-core';
18
+
19
+ export {NoiseReductionEffect, VirtualBackgroundEffect} from '@webex/web-media-effects';
20
+ export type {
21
+ NoiseReductionEffectOptions,
22
+ VirtualBackgroundEffectOptions,
23
+ } from '@webex/web-media-effects';
24
+
25
+ export {FacingMode, DisplaySurface, PresetCameraConstraints} from './constants';