@webex/media-helpers 3.0.0-next.1 → 3.0.0-next.11
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/README.md +17 -25
- package/dist/constants.js +8 -12
- package/dist/constants.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +45 -40
- package/dist/index.js.map +1 -1
- package/dist/webrtc-core.d.ts +48 -24
- package/dist/webrtc-core.js +110 -157
- package/dist/webrtc-core.js.map +1 -1
- package/package.json +14 -13
- package/src/index.ts +2 -0
- package/src/webrtc-core.ts +52 -5
- package/test/unit/spec/webrtc-core.js +16 -11
package/README.md
CHANGED
|
@@ -31,20 +31,16 @@ Noise reduction (e.g., background noise removal)
|
|
|
31
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
32
|
|
|
33
33
|
**Applying the effect**
|
|
34
|
-
1. Create a new camera
|
|
34
|
+
1. Create a new camera stream instance by using createCameraStream() method.
|
|
35
35
|
2. Create a VirtualBackgroundEffect instance by passing appropriate constraints.
|
|
36
|
-
3. Use addEffect() method on
|
|
37
|
-
4. Enable the effect after adding it to
|
|
36
|
+
3. Use addEffect() method on cameraStream to apply effect on it.
|
|
37
|
+
4. Enable the effect after adding it to cameraStream using enable() method available on effect. Effect will be enabled on cameraStream.
|
|
38
38
|
|
|
39
39
|
```javascript
|
|
40
|
-
import {
|
|
40
|
+
import {createCameraStream, VirtualBackgroundEffect} from '@webex/media-helpers';
|
|
41
41
|
|
|
42
|
-
// Create a new video stream
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
const videoTrackFromLocalStream = stream.getVideoTracks()[0];
|
|
46
|
-
|
|
47
|
-
const cameraTrack = new LocalCameraTrack(new MediaStream([videoTrackFromLocalStream]));
|
|
42
|
+
// Create a new video stream.
|
|
43
|
+
const cameraStream = createCameraStream(optionalVideoConstraints);
|
|
48
44
|
|
|
49
45
|
// Create the effect.
|
|
50
46
|
const effect = new VirtualBackgroundEffect({
|
|
@@ -54,10 +50,10 @@ const effect = new VirtualBackgroundEffect({
|
|
|
54
50
|
quality: `LOW`,
|
|
55
51
|
});
|
|
56
52
|
|
|
57
|
-
// add the effect on the input camera
|
|
58
|
-
await
|
|
53
|
+
// add the effect on the input camera stream.
|
|
54
|
+
await cameraStream.addEffect("background-blur", effect);
|
|
59
55
|
|
|
60
|
-
//enable the effect once it is added to the
|
|
56
|
+
//enable the effect once it is added to the stream
|
|
61
57
|
await effect.enable()
|
|
62
58
|
```
|
|
63
59
|
|
|
@@ -65,20 +61,16 @@ await effect.enable()
|
|
|
65
61
|
The noise reduction effect removes background noise from an audio stream to provide clear audio for calling.
|
|
66
62
|
|
|
67
63
|
**Applying the effect**
|
|
68
|
-
1. Create a new microphone
|
|
64
|
+
1. Create a new microphone stream instance by using createMicrophoneStream() method.
|
|
69
65
|
2. Create a NoiseReductionEffect instance by passing appropriate constraints.
|
|
70
|
-
3. Use addEffect() method on
|
|
71
|
-
4. Enable the effect after adding it to
|
|
66
|
+
3. Use addEffect() method on microphoneStream to apply effect on it.
|
|
67
|
+
4. Enable the effect after adding it to microphoneStream using enable() method available on effect. Effect will be enabled on microphoneStream.
|
|
72
68
|
|
|
73
69
|
```javascript
|
|
74
|
-
import {
|
|
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];
|
|
70
|
+
import {createMicrophoneStream, NoiseReductionEffect} from '@webex/media-helpers';
|
|
80
71
|
|
|
81
|
-
|
|
72
|
+
// Create a new audio stream.
|
|
73
|
+
const microphoneStream = createMicrophoneStream(optionalAudioConstraints);
|
|
82
74
|
|
|
83
75
|
// Create the effect.
|
|
84
76
|
const effect = new NoiseReductionEffect({
|
|
@@ -86,8 +78,8 @@ const effect = new NoiseReductionEffect({
|
|
|
86
78
|
mode: 'WORKLET', // or 'LEGACY'
|
|
87
79
|
});
|
|
88
80
|
|
|
89
|
-
// add the effect on microphone
|
|
90
|
-
await
|
|
81
|
+
// add the effect on microphone stream.
|
|
82
|
+
await microphoneStream.addEffect("background-noise-removal", effect);
|
|
91
83
|
|
|
92
84
|
//enable the effect once it is added to the track
|
|
93
85
|
await effect.enable()
|
package/dist/constants.js
CHANGED
|
@@ -1,24 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
_Object$defineProperty(exports, "__esModule", {
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
6
5
|
});
|
|
7
6
|
exports.PresetCameraConstraints = exports.FacingMode = exports.DisplaySurface = void 0;
|
|
8
|
-
|
|
9
|
-
exports.FacingMode = FacingMode;
|
|
10
|
-
(function (FacingMode) {
|
|
7
|
+
let FacingMode = exports.FacingMode = /*#__PURE__*/function (FacingMode) {
|
|
11
8
|
FacingMode["user"] = "user";
|
|
12
9
|
FacingMode["environment"] = "environment";
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
exports.DisplaySurface = DisplaySurface
|
|
16
|
-
(function (DisplaySurface) {
|
|
10
|
+
return FacingMode;
|
|
11
|
+
}({}); // can be used later on when we add constraints in create display track
|
|
12
|
+
let DisplaySurface = exports.DisplaySurface = /*#__PURE__*/function (DisplaySurface) {
|
|
17
13
|
DisplaySurface["browser"] = "browser";
|
|
18
14
|
DisplaySurface["monitor"] = "monitor";
|
|
19
15
|
DisplaySurface["window"] = "window";
|
|
20
|
-
|
|
21
|
-
|
|
16
|
+
return DisplaySurface;
|
|
17
|
+
}({});
|
|
18
|
+
const PresetCameraConstraints = exports.PresetCameraConstraints = {
|
|
22
19
|
'1080p': {
|
|
23
20
|
frameRate: 30,
|
|
24
21
|
width: 1920,
|
|
@@ -55,5 +52,4 @@ var PresetCameraConstraints = {
|
|
|
55
52
|
height: 120
|
|
56
53
|
}
|
|
57
54
|
};
|
|
58
|
-
exports.PresetCameraConstraints = PresetCameraConstraints;
|
|
59
55
|
//# sourceMappingURL=constants.js.map
|
package/dist/constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
null
|
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';
|
|
1
|
+
export { getDevices, LocalStream, LocalDisplayStream, LocalSystemAudioStream, LocalStreamEventNames, StreamEventNames, RemoteStream, type ServerMuteReason, LocalMicrophoneStreamEventNames, LocalCameraStreamEventNames, LocalMicrophoneStream, LocalCameraStream, createMicrophoneStream, createCameraStream, createDisplayStream, createDisplayStreamWithAudio, type VideoContentHint, } from './webrtc-core';
|
|
2
2
|
export { NoiseReductionEffect, VirtualBackgroundEffect } from '@webex/web-media-effects';
|
|
3
3
|
export type { NoiseReductionEffectOptions, VirtualBackgroundEffectOptions, } from '@webex/web-media-effects';
|
|
4
4
|
export { FacingMode, DisplaySurface, PresetCameraConstraints } from './constants';
|
package/dist/index.js
CHANGED
|
@@ -1,120 +1,125 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
_Object$defineProperty(exports, "__esModule", {
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
6
5
|
});
|
|
7
|
-
|
|
6
|
+
Object.defineProperty(exports, "DisplaySurface", {
|
|
8
7
|
enumerable: true,
|
|
9
|
-
get: function
|
|
8
|
+
get: function () {
|
|
10
9
|
return _constants.DisplaySurface;
|
|
11
10
|
}
|
|
12
11
|
});
|
|
13
|
-
|
|
12
|
+
Object.defineProperty(exports, "FacingMode", {
|
|
14
13
|
enumerable: true,
|
|
15
|
-
get: function
|
|
14
|
+
get: function () {
|
|
16
15
|
return _constants.FacingMode;
|
|
17
16
|
}
|
|
18
17
|
});
|
|
19
|
-
|
|
18
|
+
Object.defineProperty(exports, "LocalCameraStream", {
|
|
20
19
|
enumerable: true,
|
|
21
|
-
get: function
|
|
20
|
+
get: function () {
|
|
22
21
|
return _webrtcCore.LocalCameraStream;
|
|
23
22
|
}
|
|
24
23
|
});
|
|
25
|
-
|
|
24
|
+
Object.defineProperty(exports, "LocalCameraStreamEventNames", {
|
|
26
25
|
enumerable: true,
|
|
27
|
-
get: function
|
|
26
|
+
get: function () {
|
|
28
27
|
return _webrtcCore.LocalCameraStreamEventNames;
|
|
29
28
|
}
|
|
30
29
|
});
|
|
31
|
-
|
|
30
|
+
Object.defineProperty(exports, "LocalDisplayStream", {
|
|
32
31
|
enumerable: true,
|
|
33
|
-
get: function
|
|
32
|
+
get: function () {
|
|
34
33
|
return _webrtcCore.LocalDisplayStream;
|
|
35
34
|
}
|
|
36
35
|
});
|
|
37
|
-
|
|
36
|
+
Object.defineProperty(exports, "LocalMicrophoneStream", {
|
|
38
37
|
enumerable: true,
|
|
39
|
-
get: function
|
|
38
|
+
get: function () {
|
|
40
39
|
return _webrtcCore.LocalMicrophoneStream;
|
|
41
40
|
}
|
|
42
41
|
});
|
|
43
|
-
|
|
42
|
+
Object.defineProperty(exports, "LocalMicrophoneStreamEventNames", {
|
|
44
43
|
enumerable: true,
|
|
45
|
-
get: function
|
|
44
|
+
get: function () {
|
|
46
45
|
return _webrtcCore.LocalMicrophoneStreamEventNames;
|
|
47
46
|
}
|
|
48
47
|
});
|
|
49
|
-
|
|
48
|
+
Object.defineProperty(exports, "LocalStream", {
|
|
50
49
|
enumerable: true,
|
|
51
|
-
get: function
|
|
50
|
+
get: function () {
|
|
52
51
|
return _webrtcCore.LocalStream;
|
|
53
52
|
}
|
|
54
53
|
});
|
|
55
|
-
|
|
54
|
+
Object.defineProperty(exports, "LocalStreamEventNames", {
|
|
56
55
|
enumerable: true,
|
|
57
|
-
get: function
|
|
56
|
+
get: function () {
|
|
58
57
|
return _webrtcCore.LocalStreamEventNames;
|
|
59
58
|
}
|
|
60
59
|
});
|
|
61
|
-
|
|
60
|
+
Object.defineProperty(exports, "LocalSystemAudioStream", {
|
|
62
61
|
enumerable: true,
|
|
63
|
-
get: function
|
|
62
|
+
get: function () {
|
|
64
63
|
return _webrtcCore.LocalSystemAudioStream;
|
|
65
64
|
}
|
|
66
65
|
});
|
|
67
|
-
|
|
66
|
+
Object.defineProperty(exports, "NoiseReductionEffect", {
|
|
68
67
|
enumerable: true,
|
|
69
|
-
get: function
|
|
68
|
+
get: function () {
|
|
70
69
|
return _webMediaEffects.NoiseReductionEffect;
|
|
71
70
|
}
|
|
72
71
|
});
|
|
73
|
-
|
|
72
|
+
Object.defineProperty(exports, "PresetCameraConstraints", {
|
|
74
73
|
enumerable: true,
|
|
75
|
-
get: function
|
|
74
|
+
get: function () {
|
|
76
75
|
return _constants.PresetCameraConstraints;
|
|
77
76
|
}
|
|
78
77
|
});
|
|
79
|
-
|
|
78
|
+
Object.defineProperty(exports, "RemoteStream", {
|
|
80
79
|
enumerable: true,
|
|
81
|
-
get: function
|
|
80
|
+
get: function () {
|
|
81
|
+
return _webrtcCore.RemoteStream;
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
Object.defineProperty(exports, "StreamEventNames", {
|
|
85
|
+
enumerable: true,
|
|
86
|
+
get: function () {
|
|
82
87
|
return _webrtcCore.StreamEventNames;
|
|
83
88
|
}
|
|
84
89
|
});
|
|
85
|
-
|
|
90
|
+
Object.defineProperty(exports, "VirtualBackgroundEffect", {
|
|
86
91
|
enumerable: true,
|
|
87
|
-
get: function
|
|
92
|
+
get: function () {
|
|
88
93
|
return _webMediaEffects.VirtualBackgroundEffect;
|
|
89
94
|
}
|
|
90
95
|
});
|
|
91
|
-
|
|
96
|
+
Object.defineProperty(exports, "createCameraStream", {
|
|
92
97
|
enumerable: true,
|
|
93
|
-
get: function
|
|
98
|
+
get: function () {
|
|
94
99
|
return _webrtcCore.createCameraStream;
|
|
95
100
|
}
|
|
96
101
|
});
|
|
97
|
-
|
|
102
|
+
Object.defineProperty(exports, "createDisplayStream", {
|
|
98
103
|
enumerable: true,
|
|
99
|
-
get: function
|
|
104
|
+
get: function () {
|
|
100
105
|
return _webrtcCore.createDisplayStream;
|
|
101
106
|
}
|
|
102
107
|
});
|
|
103
|
-
|
|
108
|
+
Object.defineProperty(exports, "createDisplayStreamWithAudio", {
|
|
104
109
|
enumerable: true,
|
|
105
|
-
get: function
|
|
110
|
+
get: function () {
|
|
106
111
|
return _webrtcCore.createDisplayStreamWithAudio;
|
|
107
112
|
}
|
|
108
113
|
});
|
|
109
|
-
|
|
114
|
+
Object.defineProperty(exports, "createMicrophoneStream", {
|
|
110
115
|
enumerable: true,
|
|
111
|
-
get: function
|
|
116
|
+
get: function () {
|
|
112
117
|
return _webrtcCore.createMicrophoneStream;
|
|
113
118
|
}
|
|
114
119
|
});
|
|
115
|
-
|
|
120
|
+
Object.defineProperty(exports, "getDevices", {
|
|
116
121
|
enumerable: true,
|
|
117
|
-
get: function
|
|
122
|
+
get: function () {
|
|
118
123
|
return _webrtcCore.getDevices;
|
|
119
124
|
}
|
|
120
125
|
});
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
null
|
package/dist/webrtc-core.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
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';
|
|
2
|
+
import { TypedEvent, WithEventsDummyType } from '@webex/ts-events';
|
|
3
|
+
export { getDevices, LocalStream, LocalDisplayStream, LocalSystemAudioStream, LocalStreamEventNames, StreamEventNames, RemoteStream, type VideoContentHint, } from '@webex/internal-media-core';
|
|
4
4
|
export type ServerMuteReason = 'remotelyMuted' | 'clientRequestFailed' | 'localUnmuteRequired';
|
|
5
5
|
export declare enum LocalMicrophoneStreamEventNames {
|
|
6
6
|
ServerMuted = "muted:byServer"
|
|
@@ -8,41 +8,65 @@ export declare enum LocalMicrophoneStreamEventNames {
|
|
|
8
8
|
export declare enum LocalCameraStreamEventNames {
|
|
9
9
|
ServerMuted = "muted:byServer"
|
|
10
10
|
}
|
|
11
|
-
|
|
11
|
+
interface LocalMicrophoneStreamEvents {
|
|
12
|
+
[LocalMicrophoneStreamEventNames.ServerMuted]: TypedEvent<(muted: boolean, reason: ServerMuteReason) => void>;
|
|
13
|
+
}
|
|
14
|
+
interface LocalCameraStreamEvents {
|
|
15
|
+
[LocalMicrophoneStreamEventNames.ServerMuted]: TypedEvent<(muted: boolean, reason: ServerMuteReason) => void>;
|
|
16
|
+
}
|
|
17
|
+
declare class _LocalMicrophoneStream extends WcmeLocalMicrophoneStream {
|
|
12
18
|
private unmuteAllowed;
|
|
13
19
|
[LocalMicrophoneStreamEventNames.ServerMuted]: TypedEvent<(muted: boolean, reason: ServerMuteReason) => void>;
|
|
14
20
|
/**
|
|
15
|
-
* @
|
|
16
|
-
*/
|
|
17
|
-
setUnmuteAllowed(allowed: any): void;
|
|
18
|
-
/**
|
|
19
|
-
* @returns true if user is allowed to unmute the Stream, false otherwise
|
|
21
|
+
* @returns true if user is allowed to unmute the track, false otherwise
|
|
20
22
|
*/
|
|
21
23
|
isUnmuteAllowed(): boolean;
|
|
22
24
|
setMuted(muted: boolean): void;
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
toJSON(): {
|
|
26
|
+
id: string;
|
|
27
|
+
enabled: boolean;
|
|
28
|
+
label: string;
|
|
29
|
+
readyState: string;
|
|
30
|
+
numEnabledEffects: number;
|
|
31
|
+
};
|
|
27
32
|
}
|
|
28
|
-
|
|
33
|
+
declare class _LocalCameraStream extends WcmeLocalCameraStream {
|
|
29
34
|
private unmuteAllowed;
|
|
30
35
|
[LocalCameraStreamEventNames.ServerMuted]: TypedEvent<(muted: boolean, reason: ServerMuteReason) => void>;
|
|
31
36
|
/**
|
|
32
|
-
* @
|
|
33
|
-
*/
|
|
34
|
-
setUnmuteAllowed(allowed: any): void;
|
|
35
|
-
/**
|
|
36
|
-
* @returns true if user is allowed to unmute the Stream, false otherwise
|
|
37
|
+
* @returns true if user is allowed to unmute the track, false otherwise
|
|
37
38
|
*/
|
|
38
39
|
isUnmuteAllowed(): boolean;
|
|
39
40
|
setMuted(muted: boolean): void;
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
41
|
+
toJSON(): {
|
|
42
|
+
id: string;
|
|
43
|
+
enabled: boolean;
|
|
44
|
+
label: string;
|
|
45
|
+
readyState: string;
|
|
46
|
+
numEnabledEffects: number;
|
|
47
|
+
};
|
|
44
48
|
}
|
|
45
|
-
export declare const createMicrophoneStream: (constraints?: AudioDeviceConstraints) => Promise<
|
|
46
|
-
|
|
49
|
+
export declare const createMicrophoneStream: (constraints?: AudioDeviceConstraints) => Promise<{
|
|
50
|
+
on<K extends LocalMicrophoneStreamEventNames.ServerMuted, E extends LocalMicrophoneStreamEvents[K] extends infer T ? T extends LocalMicrophoneStreamEvents[K] ? T extends TypedEvent<infer X extends (...args: any[]) => void> ? X : never : never : never>(eventName: K, handler: E): void;
|
|
51
|
+
once<K_1 extends LocalMicrophoneStreamEventNames.ServerMuted, E_1 extends LocalMicrophoneStreamEvents[K_1] extends infer T_1 ? T_1 extends LocalMicrophoneStreamEvents[K_1] ? T_1 extends TypedEvent<infer X extends (...args: any[]) => void> ? X : never : never : never>(eventName: K_1, handler: E_1): void;
|
|
52
|
+
off<K_2 extends LocalMicrophoneStreamEventNames.ServerMuted, E_2 extends LocalMicrophoneStreamEvents[K_2] extends infer T_2 ? T_2 extends LocalMicrophoneStreamEvents[K_2] ? T_2 extends TypedEvent<infer X extends (...args: any[]) => void> ? X : never : never : never>(eventName: K_2, handler: E_2): void;
|
|
53
|
+
} & _LocalMicrophoneStream>;
|
|
54
|
+
export declare const createCameraStream: (constraints?: VideoDeviceConstraints) => Promise<{
|
|
55
|
+
on<K extends LocalMicrophoneStreamEventNames.ServerMuted, E extends LocalCameraStreamEvents[K] extends infer T ? T extends LocalCameraStreamEvents[K] ? T extends TypedEvent<infer X extends (...args: any[]) => void> ? X : never : never : never>(eventName: K, handler: E): void;
|
|
56
|
+
once<K_1 extends LocalMicrophoneStreamEventNames.ServerMuted, E_1 extends LocalCameraStreamEvents[K_1] extends infer T_1 ? T_1 extends LocalCameraStreamEvents[K_1] ? T_1 extends TypedEvent<infer X extends (...args: any[]) => void> ? X : never : never : never>(eventName: K_1, handler: E_1): void;
|
|
57
|
+
off<K_2 extends LocalMicrophoneStreamEventNames.ServerMuted, E_2 extends LocalCameraStreamEvents[K_2] extends infer T_2 ? T_2 extends LocalCameraStreamEvents[K_2] ? T_2 extends TypedEvent<infer X extends (...args: any[]) => void> ? X : never : never : never>(eventName: K_2, handler: E_2): void;
|
|
58
|
+
} & _LocalCameraStream>;
|
|
47
59
|
export declare const createDisplayStream: () => Promise<LocalDisplayStream>;
|
|
48
60
|
export declare const createDisplayStreamWithAudio: () => Promise<[LocalDisplayStream, LocalSystemAudioStream]>;
|
|
61
|
+
export declare const LocalMicrophoneStream: (new (...args: any[]) => {
|
|
62
|
+
on<K extends LocalMicrophoneStreamEventNames.ServerMuted, E extends LocalMicrophoneStreamEvents[K] extends infer T ? T extends LocalMicrophoneStreamEvents[K] ? T extends TypedEvent<infer X extends (...args: any[]) => void> ? X : never : never : never>(eventName: K, handler: E): void;
|
|
63
|
+
once<K_1 extends LocalMicrophoneStreamEventNames.ServerMuted, E_1 extends LocalMicrophoneStreamEvents[K_1] extends infer T_1 ? T_1 extends LocalMicrophoneStreamEvents[K_1] ? T_1 extends TypedEvent<infer X extends (...args: any[]) => void> ? X : never : never : never>(eventName: K_1, handler: E_1): void;
|
|
64
|
+
off<K_2 extends LocalMicrophoneStreamEventNames.ServerMuted, E_2 extends LocalMicrophoneStreamEvents[K_2] extends infer T_2 ? T_2 extends LocalMicrophoneStreamEvents[K_2] ? T_2 extends TypedEvent<infer X extends (...args: any[]) => void> ? X : never : never : never>(eventName: K_2, handler: E_2): void;
|
|
65
|
+
}) & typeof _LocalMicrophoneStream;
|
|
66
|
+
export type LocalMicrophoneStream = _LocalMicrophoneStream & WithEventsDummyType<LocalMicrophoneStreamEvents>;
|
|
67
|
+
export declare const LocalCameraStream: (new (...args: any[]) => {
|
|
68
|
+
on<K extends LocalMicrophoneStreamEventNames.ServerMuted, E extends LocalCameraStreamEvents[K] extends infer T ? T extends LocalCameraStreamEvents[K] ? T extends TypedEvent<infer X extends (...args: any[]) => void> ? X : never : never : never>(eventName: K, handler: E): void;
|
|
69
|
+
once<K_1 extends LocalMicrophoneStreamEventNames.ServerMuted, E_1 extends LocalCameraStreamEvents[K_1] extends infer T_1 ? T_1 extends LocalCameraStreamEvents[K_1] ? T_1 extends TypedEvent<infer X extends (...args: any[]) => void> ? X : never : never : never>(eventName: K_1, handler: E_1): void;
|
|
70
|
+
off<K_2 extends LocalMicrophoneStreamEventNames.ServerMuted, E_2 extends LocalCameraStreamEvents[K_2] extends infer T_2 ? T_2 extends LocalCameraStreamEvents[K_2] ? T_2 extends TypedEvent<infer X extends (...args: any[]) => void> ? X : never : never : never>(eventName: K_2, handler: E_2): void;
|
|
71
|
+
}) & typeof _LocalCameraStream;
|
|
72
|
+
export type LocalCameraStream = _LocalCameraStream & WithEventsDummyType<LocalCameraStreamEvents>;
|
package/dist/webrtc-core.js
CHANGED
|
@@ -1,213 +1,166 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
var _Object$defineProperty = require("@babel/runtime-corejs2/core-js/object/define-property");
|
|
5
|
-
var _interopRequireDefault = require("@babel/runtime-corejs2/helpers/interopRequireDefault");
|
|
6
|
-
_Object$defineProperty(exports, "__esModule", {
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
7
4
|
value: true
|
|
8
5
|
});
|
|
9
6
|
exports.LocalCameraStreamEventNames = exports.LocalCameraStream = void 0;
|
|
10
|
-
|
|
7
|
+
Object.defineProperty(exports, "LocalDisplayStream", {
|
|
11
8
|
enumerable: true,
|
|
12
|
-
get: function
|
|
9
|
+
get: function () {
|
|
13
10
|
return _internalMediaCore.LocalDisplayStream;
|
|
14
11
|
}
|
|
15
12
|
});
|
|
16
13
|
exports.LocalMicrophoneStreamEventNames = exports.LocalMicrophoneStream = void 0;
|
|
17
|
-
|
|
14
|
+
Object.defineProperty(exports, "LocalStream", {
|
|
18
15
|
enumerable: true,
|
|
19
|
-
get: function
|
|
16
|
+
get: function () {
|
|
20
17
|
return _internalMediaCore.LocalStream;
|
|
21
18
|
}
|
|
22
19
|
});
|
|
23
|
-
|
|
20
|
+
Object.defineProperty(exports, "LocalStreamEventNames", {
|
|
24
21
|
enumerable: true,
|
|
25
|
-
get: function
|
|
22
|
+
get: function () {
|
|
26
23
|
return _internalMediaCore.LocalStreamEventNames;
|
|
27
24
|
}
|
|
28
25
|
});
|
|
29
|
-
|
|
26
|
+
Object.defineProperty(exports, "LocalSystemAudioStream", {
|
|
30
27
|
enumerable: true,
|
|
31
|
-
get: function
|
|
28
|
+
get: function () {
|
|
32
29
|
return _internalMediaCore.LocalSystemAudioStream;
|
|
33
30
|
}
|
|
34
31
|
});
|
|
35
|
-
|
|
32
|
+
Object.defineProperty(exports, "RemoteStream", {
|
|
36
33
|
enumerable: true,
|
|
37
|
-
get: function
|
|
34
|
+
get: function () {
|
|
38
35
|
return _internalMediaCore.RemoteStream;
|
|
39
36
|
}
|
|
40
37
|
});
|
|
41
|
-
|
|
38
|
+
Object.defineProperty(exports, "StreamEventNames", {
|
|
42
39
|
enumerable: true,
|
|
43
|
-
get: function
|
|
40
|
+
get: function () {
|
|
44
41
|
return _internalMediaCore.StreamEventNames;
|
|
45
42
|
}
|
|
46
43
|
});
|
|
47
44
|
exports.createMicrophoneStream = exports.createDisplayStreamWithAudio = exports.createDisplayStream = exports.createCameraStream = void 0;
|
|
48
|
-
|
|
45
|
+
Object.defineProperty(exports, "getDevices", {
|
|
49
46
|
enumerable: true,
|
|
50
|
-
get: function
|
|
47
|
+
get: function () {
|
|
51
48
|
return _internalMediaCore.getDevices;
|
|
52
49
|
}
|
|
53
50
|
});
|
|
54
|
-
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/classCallCheck"));
|
|
55
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/createClass"));
|
|
56
|
-
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/assertThisInitialized"));
|
|
57
|
-
var _get2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/get"));
|
|
58
|
-
var _inherits2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/inherits"));
|
|
59
|
-
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/possibleConstructorReturn"));
|
|
60
|
-
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/getPrototypeOf"));
|
|
61
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/defineProperty"));
|
|
62
51
|
var _internalMediaCore = require("@webex/internal-media-core");
|
|
63
52
|
var _tsEvents = require("@webex/ts-events");
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
53
|
+
/* eslint-disable @typescript-eslint/no-misused-new */
|
|
54
|
+
/* eslint-disable valid-jsdoc */
|
|
55
|
+
/* eslint-disable require-jsdoc */
|
|
67
56
|
// server forced the client to be unmuted
|
|
68
57
|
// these events are in addition to WCME events. This will be properly typed once webrtc-core event types inheritance is fixed
|
|
69
|
-
|
|
70
|
-
exports.LocalMicrophoneStreamEventNames = LocalMicrophoneStreamEventNames;
|
|
71
|
-
(function (LocalMicrophoneStreamEventNames) {
|
|
58
|
+
let LocalMicrophoneStreamEventNames = exports.LocalMicrophoneStreamEventNames = /*#__PURE__*/function (LocalMicrophoneStreamEventNames) {
|
|
72
59
|
LocalMicrophoneStreamEventNames["ServerMuted"] = "muted:byServer";
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
exports.LocalCameraStreamEventNames = LocalCameraStreamEventNames
|
|
76
|
-
(function (LocalCameraStreamEventNames) {
|
|
60
|
+
return LocalMicrophoneStreamEventNames;
|
|
61
|
+
}({}); // these events are in addition to WCME events. This will be properly typed once webrtc-core event types inheritance is fixed
|
|
62
|
+
let LocalCameraStreamEventNames = exports.LocalCameraStreamEventNames = /*#__PURE__*/function (LocalCameraStreamEventNames) {
|
|
77
63
|
LocalCameraStreamEventNames["ServerMuted"] = "muted:byServer";
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
function LocalMicrophoneStream() {
|
|
84
|
-
var _this;
|
|
85
|
-
(0, _classCallCheck2.default)(this, LocalMicrophoneStream);
|
|
86
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
87
|
-
args[_key] = arguments[_key];
|
|
88
|
-
}
|
|
89
|
-
_this = _super.call.apply(_super, [this].concat(args));
|
|
90
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "unmuteAllowed", true);
|
|
91
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), _LocalMicrophoneStrea, new _tsEvents.TypedEvent());
|
|
92
|
-
return _this;
|
|
93
|
-
}
|
|
94
|
-
(0, _createClass2.default)(LocalMicrophoneStream, [{
|
|
95
|
-
key: "setUnmuteAllowed",
|
|
96
|
-
value:
|
|
97
|
-
/**
|
|
98
|
-
* @internal
|
|
99
|
-
*/
|
|
100
|
-
function setUnmuteAllowed(allowed) {
|
|
101
|
-
this.unmuteAllowed = allowed;
|
|
102
|
-
}
|
|
64
|
+
return LocalCameraStreamEventNames;
|
|
65
|
+
}({});
|
|
66
|
+
class _LocalMicrophoneStream extends _internalMediaCore.LocalMicrophoneStream {
|
|
67
|
+
unmuteAllowed = true;
|
|
68
|
+
[LocalMicrophoneStreamEventNames.ServerMuted] = new _tsEvents.TypedEvent();
|
|
103
69
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
return this.unmuteAllowed;
|
|
111
|
-
}
|
|
112
|
-
}, {
|
|
113
|
-
key: "setMuted",
|
|
114
|
-
value: function setMuted(muted) {
|
|
115
|
-
if (!muted) {
|
|
116
|
-
if (!this.isUnmuteAllowed()) {
|
|
117
|
-
throw new Error('Unmute is not allowed');
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
return (0, _get2.default)((0, _getPrototypeOf2.default)(LocalMicrophoneStream.prototype), "setMuted", this).call(this, muted);
|
|
121
|
-
}
|
|
70
|
+
/**
|
|
71
|
+
* @internal
|
|
72
|
+
*/
|
|
73
|
+
setUnmuteAllowed(allowed) {
|
|
74
|
+
this.unmuteAllowed = allowed;
|
|
75
|
+
}
|
|
122
76
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
77
|
+
/**
|
|
78
|
+
* @returns true if user is allowed to unmute the track, false otherwise
|
|
79
|
+
*/
|
|
80
|
+
isUnmuteAllowed() {
|
|
81
|
+
return this.unmuteAllowed;
|
|
82
|
+
}
|
|
83
|
+
setMuted(muted) {
|
|
84
|
+
if (!muted) {
|
|
85
|
+
if (!this.isUnmuteAllowed()) {
|
|
86
|
+
throw new Error('Unmute is not allowed');
|
|
132
87
|
}
|
|
133
88
|
}
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
}(_internalMediaCore.LocalMicrophoneStream);
|
|
137
|
-
exports.LocalMicrophoneStream = LocalMicrophoneStream;
|
|
138
|
-
_LocalCameraStreamEve = LocalCameraStreamEventNames.ServerMuted;
|
|
139
|
-
var LocalCameraStream = /*#__PURE__*/function (_WcmeLocalCameraStrea) {
|
|
140
|
-
(0, _inherits2.default)(LocalCameraStream, _WcmeLocalCameraStrea);
|
|
141
|
-
var _super2 = _createSuper(LocalCameraStream);
|
|
142
|
-
function LocalCameraStream() {
|
|
143
|
-
var _this2;
|
|
144
|
-
(0, _classCallCheck2.default)(this, LocalCameraStream);
|
|
145
|
-
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
146
|
-
args[_key2] = arguments[_key2];
|
|
147
|
-
}
|
|
148
|
-
_this2 = _super2.call.apply(_super2, [this].concat(args));
|
|
149
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this2), "unmuteAllowed", true);
|
|
150
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this2), _LocalCameraStreamEve, new _tsEvents.TypedEvent());
|
|
151
|
-
return _this2;
|
|
152
|
-
}
|
|
153
|
-
(0, _createClass2.default)(LocalCameraStream, [{
|
|
154
|
-
key: "setUnmuteAllowed",
|
|
155
|
-
value:
|
|
156
|
-
/**
|
|
157
|
-
* @internal
|
|
158
|
-
*/
|
|
159
|
-
function setUnmuteAllowed(allowed) {
|
|
160
|
-
this.unmuteAllowed = allowed;
|
|
161
|
-
}
|
|
89
|
+
return super.setMuted(muted);
|
|
90
|
+
}
|
|
162
91
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
92
|
+
/**
|
|
93
|
+
* @internal
|
|
94
|
+
*/
|
|
95
|
+
setServerMuted(muted, reason) {
|
|
96
|
+
if (muted !== this.muted) {
|
|
97
|
+
this.setMuted(muted);
|
|
98
|
+
this[LocalMicrophoneStreamEventNames.ServerMuted].emit(muted, reason);
|
|
170
99
|
}
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
100
|
+
}
|
|
101
|
+
toJSON() {
|
|
102
|
+
return {
|
|
103
|
+
id: this.id,
|
|
104
|
+
enabled: this.inputTrack?.enabled,
|
|
105
|
+
label: this.label,
|
|
106
|
+
readyState: this.readyState,
|
|
107
|
+
numEnabledEffects: this.getAllEffects().filter(item => item.effect.isEnabled).length
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
class _LocalCameraStream extends _internalMediaCore.LocalCameraStream {
|
|
112
|
+
unmuteAllowed = true;
|
|
113
|
+
[LocalCameraStreamEventNames.ServerMuted] = new _tsEvents.TypedEvent();
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* @internal
|
|
117
|
+
*/
|
|
118
|
+
setUnmuteAllowed(allowed) {
|
|
119
|
+
this.unmuteAllowed = allowed;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* @returns true if user is allowed to unmute the track, false otherwise
|
|
124
|
+
*/
|
|
125
|
+
isUnmuteAllowed() {
|
|
126
|
+
return this.unmuteAllowed;
|
|
127
|
+
}
|
|
128
|
+
setMuted(muted) {
|
|
129
|
+
if (!muted) {
|
|
130
|
+
if (!this.isUnmuteAllowed()) {
|
|
131
|
+
throw new Error('Unmute is not allowed');
|
|
178
132
|
}
|
|
179
|
-
return (0, _get2.default)((0, _getPrototypeOf2.default)(LocalCameraStream.prototype), "setMuted", this).call(this, muted);
|
|
180
133
|
}
|
|
134
|
+
return super.setMuted(muted);
|
|
135
|
+
}
|
|
181
136
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
this.setMuted(muted);
|
|
190
|
-
this[LocalCameraStreamEventNames.ServerMuted].emit(muted, reason);
|
|
191
|
-
}
|
|
137
|
+
/**
|
|
138
|
+
* @internal
|
|
139
|
+
*/
|
|
140
|
+
setServerMuted(muted, reason) {
|
|
141
|
+
if (muted !== this.muted) {
|
|
142
|
+
this.setMuted(muted);
|
|
143
|
+
this[LocalCameraStreamEventNames.ServerMuted].emit(muted, reason);
|
|
192
144
|
}
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
145
|
+
}
|
|
146
|
+
toJSON() {
|
|
147
|
+
return {
|
|
148
|
+
id: this.id,
|
|
149
|
+
enabled: this.inputTrack?.enabled,
|
|
150
|
+
label: this.label,
|
|
151
|
+
readyState: this.readyState,
|
|
152
|
+
numEnabledEffects: this.getAllEffects().filter(item => item.effect.isEnabled).length
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
const createMicrophoneStream = constraints => (0, _internalMediaCore.createMicrophoneStream)(LocalMicrophoneStream, constraints);
|
|
200
157
|
exports.createMicrophoneStream = createMicrophoneStream;
|
|
201
|
-
|
|
202
|
-
return (0, _internalMediaCore.createCameraStream)(LocalCameraStream, constraints);
|
|
203
|
-
};
|
|
158
|
+
const createCameraStream = constraints => (0, _internalMediaCore.createCameraStream)(LocalCameraStream, constraints);
|
|
204
159
|
exports.createCameraStream = createCameraStream;
|
|
205
|
-
|
|
206
|
-
return (0, _internalMediaCore.createDisplayStream)(_internalMediaCore.LocalDisplayStream);
|
|
207
|
-
};
|
|
160
|
+
const createDisplayStream = () => (0, _internalMediaCore.createDisplayStream)(_internalMediaCore.LocalDisplayStream);
|
|
208
161
|
exports.createDisplayStream = createDisplayStream;
|
|
209
|
-
|
|
210
|
-
return (0, _internalMediaCore.createDisplayStreamWithAudio)(_internalMediaCore.LocalDisplayStream, _internalMediaCore.LocalSystemAudioStream);
|
|
211
|
-
};
|
|
162
|
+
const createDisplayStreamWithAudio = () => (0, _internalMediaCore.createDisplayStreamWithAudio)(_internalMediaCore.LocalDisplayStream, _internalMediaCore.LocalSystemAudioStream);
|
|
212
163
|
exports.createDisplayStreamWithAudio = createDisplayStreamWithAudio;
|
|
164
|
+
const LocalMicrophoneStream = exports.LocalMicrophoneStream = (0, _tsEvents.AddEvents)(_LocalMicrophoneStream);
|
|
165
|
+
const LocalCameraStream = exports.LocalCameraStream = (0, _tsEvents.AddEvents)(_LocalCameraStream);
|
|
213
166
|
//# sourceMappingURL=webrtc-core.js.map
|
package/dist/webrtc-core.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
null
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webex/media-helpers",
|
|
3
|
-
"description": "",
|
|
3
|
+
"description": "Package that provides helper functions for media related activities.",
|
|
4
4
|
"license": "Cisco EULA (https://www.cisco.com/c/en/us/products/end-user-license-agreement.html)",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"devMain": "src/index.ts",
|
|
@@ -13,22 +13,19 @@
|
|
|
13
13
|
"node": ">=16"
|
|
14
14
|
},
|
|
15
15
|
"scripts": {
|
|
16
|
-
"build
|
|
16
|
+
"build": "yarn run -T tsc --declaration true --declarationDir ./dist",
|
|
17
|
+
"build:src": "webex-legacy-tools build -dest \"./dist\" -src \"./src\" -js -ts -maps && yarn run -T tsc --declaration true --declarationDir ./dist",
|
|
17
18
|
"test:broken": "yarn test:style && yarn test:unit && yarn test:integration && yarn test:browser",
|
|
18
19
|
"test:browser:broken": "webex-legacy-tools test --integration --unit --runner karma",
|
|
19
20
|
"test:integration:broken": "webex-legacy-tools test --integration --runner mocha",
|
|
20
21
|
"test:style": "eslint 'src/**/*.ts' --fix",
|
|
21
22
|
"test:unit:broken": "webex-legacy-tools test --unit --runner mocha",
|
|
22
|
-
"deploy:npm": "npm publish"
|
|
23
|
+
"deploy:npm": "yarn npm publish"
|
|
23
24
|
},
|
|
24
25
|
"dependencies": {
|
|
25
|
-
"@webex/
|
|
26
|
-
"@webex/eslint-config-legacy": "workspace:^",
|
|
27
|
-
"@webex/internal-media-core": "^2.0.0",
|
|
28
|
-
"@webex/jest-config-legacy": "workspace:^",
|
|
29
|
-
"@webex/legacy-tools": "workspace:^",
|
|
26
|
+
"@webex/internal-media-core": "2.2.1",
|
|
30
27
|
"@webex/ts-events": "^1.1.0",
|
|
31
|
-
"@webex/web-media-effects": "^2.
|
|
28
|
+
"@webex/web-media-effects": "^2.13.6"
|
|
32
29
|
},
|
|
33
30
|
"browserify": {
|
|
34
31
|
"transform": [
|
|
@@ -38,10 +35,14 @@
|
|
|
38
35
|
},
|
|
39
36
|
"devDependencies": {
|
|
40
37
|
"@babel/preset-typescript": "7.22.11",
|
|
41
|
-
"@webex/
|
|
42
|
-
"@webex/
|
|
38
|
+
"@webex/babel-config-legacy": "^0.0.0",
|
|
39
|
+
"@webex/eslint-config-legacy": "^0.0.0",
|
|
40
|
+
"@webex/jest-config-legacy": "^0.0.0",
|
|
41
|
+
"@webex/legacy-tools": "^0.0.0",
|
|
42
|
+
"@webex/test-helper-chai": "^2.60.0-next.1",
|
|
43
|
+
"@webex/test-helper-mock-webex": "^2.60.0-next.1",
|
|
43
44
|
"eslint": "^8.24.0",
|
|
44
45
|
"sinon": "^9.2.4"
|
|
45
46
|
},
|
|
46
|
-
"version": "3.0.0-next.
|
|
47
|
-
}
|
|
47
|
+
"version": "3.0.0-next.11"
|
|
48
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -5,6 +5,7 @@ export {
|
|
|
5
5
|
LocalSystemAudioStream,
|
|
6
6
|
LocalStreamEventNames,
|
|
7
7
|
StreamEventNames,
|
|
8
|
+
RemoteStream,
|
|
8
9
|
type ServerMuteReason,
|
|
9
10
|
LocalMicrophoneStreamEventNames,
|
|
10
11
|
LocalCameraStreamEventNames,
|
|
@@ -14,6 +15,7 @@ export {
|
|
|
14
15
|
createCameraStream,
|
|
15
16
|
createDisplayStream,
|
|
16
17
|
createDisplayStreamWithAudio,
|
|
18
|
+
type VideoContentHint,
|
|
17
19
|
} from './webrtc-core';
|
|
18
20
|
|
|
19
21
|
export {NoiseReductionEffect, VirtualBackgroundEffect} from '@webex/web-media-effects';
|
package/src/webrtc-core.ts
CHANGED
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
LocalCameraStream as WcmeLocalCameraStream,
|
|
14
14
|
VideoDeviceConstraints,
|
|
15
15
|
} from '@webex/internal-media-core';
|
|
16
|
-
import {TypedEvent} from '@webex/ts-events';
|
|
16
|
+
import {AddEvents, TypedEvent, WithEventsDummyType} from '@webex/ts-events';
|
|
17
17
|
|
|
18
18
|
export {
|
|
19
19
|
getDevices,
|
|
@@ -23,6 +23,7 @@ export {
|
|
|
23
23
|
LocalStreamEventNames,
|
|
24
24
|
StreamEventNames,
|
|
25
25
|
RemoteStream,
|
|
26
|
+
type VideoContentHint,
|
|
26
27
|
} from '@webex/internal-media-core';
|
|
27
28
|
|
|
28
29
|
export type ServerMuteReason =
|
|
@@ -40,7 +41,19 @@ export enum LocalCameraStreamEventNames {
|
|
|
40
41
|
ServerMuted = 'muted:byServer',
|
|
41
42
|
}
|
|
42
43
|
|
|
43
|
-
|
|
44
|
+
interface LocalMicrophoneStreamEvents {
|
|
45
|
+
[LocalMicrophoneStreamEventNames.ServerMuted]: TypedEvent<
|
|
46
|
+
(muted: boolean, reason: ServerMuteReason) => void
|
|
47
|
+
>;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
interface LocalCameraStreamEvents {
|
|
51
|
+
[LocalMicrophoneStreamEventNames.ServerMuted]: TypedEvent<
|
|
52
|
+
(muted: boolean, reason: ServerMuteReason) => void
|
|
53
|
+
>;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
class _LocalMicrophoneStream extends WcmeLocalMicrophoneStream {
|
|
44
57
|
private unmuteAllowed = true;
|
|
45
58
|
|
|
46
59
|
[LocalMicrophoneStreamEventNames.ServerMuted] = new TypedEvent<
|
|
@@ -55,7 +68,7 @@ export class LocalMicrophoneStream extends WcmeLocalMicrophoneStream {
|
|
|
55
68
|
}
|
|
56
69
|
|
|
57
70
|
/**
|
|
58
|
-
* @returns true if user is allowed to unmute the
|
|
71
|
+
* @returns true if user is allowed to unmute the track, false otherwise
|
|
59
72
|
*/
|
|
60
73
|
isUnmuteAllowed() {
|
|
61
74
|
return this.unmuteAllowed;
|
|
@@ -80,9 +93,19 @@ export class LocalMicrophoneStream extends WcmeLocalMicrophoneStream {
|
|
|
80
93
|
this[LocalMicrophoneStreamEventNames.ServerMuted].emit(muted, reason);
|
|
81
94
|
}
|
|
82
95
|
}
|
|
96
|
+
|
|
97
|
+
toJSON() {
|
|
98
|
+
return {
|
|
99
|
+
id: this.id,
|
|
100
|
+
enabled: this.inputTrack?.enabled,
|
|
101
|
+
label: this.label,
|
|
102
|
+
readyState: this.readyState,
|
|
103
|
+
numEnabledEffects: this.getAllEffects().filter((item) => item.effect.isEnabled).length,
|
|
104
|
+
};
|
|
105
|
+
}
|
|
83
106
|
}
|
|
84
107
|
|
|
85
|
-
|
|
108
|
+
class _LocalCameraStream extends WcmeLocalCameraStream {
|
|
86
109
|
private unmuteAllowed = true;
|
|
87
110
|
|
|
88
111
|
[LocalCameraStreamEventNames.ServerMuted] = new TypedEvent<
|
|
@@ -97,7 +120,7 @@ export class LocalCameraStream extends WcmeLocalCameraStream {
|
|
|
97
120
|
}
|
|
98
121
|
|
|
99
122
|
/**
|
|
100
|
-
* @returns true if user is allowed to unmute the
|
|
123
|
+
* @returns true if user is allowed to unmute the track, false otherwise
|
|
101
124
|
*/
|
|
102
125
|
isUnmuteAllowed() {
|
|
103
126
|
return this.unmuteAllowed;
|
|
@@ -122,6 +145,16 @@ export class LocalCameraStream extends WcmeLocalCameraStream {
|
|
|
122
145
|
this[LocalCameraStreamEventNames.ServerMuted].emit(muted, reason);
|
|
123
146
|
}
|
|
124
147
|
}
|
|
148
|
+
|
|
149
|
+
toJSON() {
|
|
150
|
+
return {
|
|
151
|
+
id: this.id,
|
|
152
|
+
enabled: this.inputTrack?.enabled,
|
|
153
|
+
label: this.label,
|
|
154
|
+
readyState: this.readyState,
|
|
155
|
+
numEnabledEffects: this.getAllEffects().filter((item) => item.effect.isEnabled).length,
|
|
156
|
+
};
|
|
157
|
+
}
|
|
125
158
|
}
|
|
126
159
|
|
|
127
160
|
export const createMicrophoneStream = (constraints?: AudioDeviceConstraints) =>
|
|
@@ -134,3 +167,17 @@ export const createDisplayStream = () => wcmeCreateDisplayStream(LocalDisplayStr
|
|
|
134
167
|
|
|
135
168
|
export const createDisplayStreamWithAudio = () =>
|
|
136
169
|
wcmeCreateDisplayStreamWithAudio(LocalDisplayStream, LocalSystemAudioStream);
|
|
170
|
+
|
|
171
|
+
export const LocalMicrophoneStream = AddEvents<
|
|
172
|
+
typeof _LocalMicrophoneStream,
|
|
173
|
+
LocalMicrophoneStreamEvents
|
|
174
|
+
>(_LocalMicrophoneStream);
|
|
175
|
+
|
|
176
|
+
export type LocalMicrophoneStream = _LocalMicrophoneStream &
|
|
177
|
+
WithEventsDummyType<LocalMicrophoneStreamEvents>;
|
|
178
|
+
|
|
179
|
+
export const LocalCameraStream = AddEvents<typeof _LocalCameraStream, LocalCameraStreamEvents>(
|
|
180
|
+
_LocalCameraStream
|
|
181
|
+
);
|
|
182
|
+
|
|
183
|
+
export type LocalCameraStream = _LocalCameraStream & WithEventsDummyType<LocalCameraStreamEvents>;
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
createDisplayStream,
|
|
13
13
|
createDisplayStreamWithAudio,
|
|
14
14
|
} from '../../../src/webrtc-core';
|
|
15
|
-
import * as
|
|
15
|
+
import * as wcmestreams from '@webex/internal-media-core';
|
|
16
16
|
|
|
17
17
|
describe('media-helpers', () => {
|
|
18
18
|
describe('webrtc-core', () => {
|
|
@@ -36,11 +36,12 @@ describe('media-helpers', () => {
|
|
|
36
36
|
classesToTest.forEach(({className, title, event, createFn, spyFn}) =>
|
|
37
37
|
describe(title, () => {
|
|
38
38
|
const fakeStream = {
|
|
39
|
-
|
|
39
|
+
getTracks: sinon.stub().returns([
|
|
40
40
|
{
|
|
41
|
-
label: 'fake
|
|
42
|
-
id: 'fake
|
|
41
|
+
label: 'fake track',
|
|
42
|
+
id: 'fake track id',
|
|
43
43
|
enabled: true,
|
|
44
|
+
addEventListener: sinon.stub(),
|
|
44
45
|
},
|
|
45
46
|
]),
|
|
46
47
|
};
|
|
@@ -70,6 +71,10 @@ describe('media-helpers', () => {
|
|
|
70
71
|
await stream.setMuted(false);
|
|
71
72
|
});
|
|
72
73
|
|
|
74
|
+
it('returns a reasonable length string from JSON.stringify()', () => {
|
|
75
|
+
assert.isBelow(JSON.stringify(stream).length, 200);
|
|
76
|
+
})
|
|
77
|
+
|
|
73
78
|
describe('#setServerMuted', () => {
|
|
74
79
|
afterEach(() => {
|
|
75
80
|
sinon.restore();
|
|
@@ -87,7 +92,7 @@ describe('media-helpers', () => {
|
|
|
87
92
|
|
|
88
93
|
assert.equal(stream.muted, setMute);
|
|
89
94
|
if (expectedCalled) {
|
|
90
|
-
assert.calledOnceWithExactly(handler,
|
|
95
|
+
assert.calledOnceWithExactly(handler, setMute, 'remotelyMuted');
|
|
91
96
|
} else {
|
|
92
97
|
assert.notCalled(handler);
|
|
93
98
|
}
|
|
@@ -111,10 +116,10 @@ describe('media-helpers', () => {
|
|
|
111
116
|
});
|
|
112
117
|
|
|
113
118
|
describe('#wcmeCreateMicrophoneStream, #wcmeCreateCameraStream', () => {
|
|
114
|
-
it('checks creating
|
|
115
|
-
const constraints = {
|
|
119
|
+
it('checks creating tracks', async () => {
|
|
120
|
+
const constraints = {deviceId: 'abc'};
|
|
116
121
|
|
|
117
|
-
const spy = sinon.stub(
|
|
122
|
+
const spy = sinon.stub(wcmestreams, spyFn).returns('something');
|
|
118
123
|
const result = createFn(constraints);
|
|
119
124
|
|
|
120
125
|
assert.equal(result, 'something');
|
|
@@ -126,16 +131,16 @@ describe('media-helpers', () => {
|
|
|
126
131
|
|
|
127
132
|
describe('createDisplayStream', () => {
|
|
128
133
|
it('checks createDisplayStream', async () => {
|
|
129
|
-
const spy = sinon.stub(
|
|
134
|
+
const spy = sinon.stub(wcmestreams, 'createDisplayStream').returns('something');
|
|
130
135
|
const result = createDisplayStream();
|
|
131
136
|
assert.equal(result, 'something');
|
|
132
137
|
assert.calledOnceWithExactly(spy, LocalDisplayStream);
|
|
133
138
|
});
|
|
134
139
|
});
|
|
135
|
-
|
|
140
|
+
|
|
136
141
|
describe('createDisplayStreamWithAudio', () => {
|
|
137
142
|
it('checks createDisplayStreamWithAudio', async () => {
|
|
138
|
-
const spy = sinon.stub(
|
|
143
|
+
const spy = sinon.stub(wcmestreams, 'createDisplayStreamWithAudio').returns('something');
|
|
139
144
|
const result = createDisplayStreamWithAudio();
|
|
140
145
|
assert.equal(result, 'something');
|
|
141
146
|
assert.calledOnceWithExactly(spy, LocalDisplayStream, LocalSystemAudioStream);
|