@webex/media-helpers 3.0.1-next.4 → 3.0.1-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/dist/index.d.ts +1 -1
- package/dist/index.js +6 -0
- package/dist/webrtc-core.d.ts +3 -3
- package/dist/webrtc-core.js +14 -8
- package/jest.config.js +1 -4
- package/package.json +5 -4
- package/src/index.ts +1 -0
- package/src/webrtc-core.ts +10 -9
- package/test/unit/spec/webrtc-core.js +11 -10
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { getDevices, LocalStream, LocalDisplayStream, LocalSystemAudioStream, LocalStreamEventNames, StreamEventNames, RemoteStream, type ServerMuteReason, LocalMicrophoneStreamEventNames, LocalCameraStreamEventNames, LocalMicrophoneStream, LocalCameraStream, createMicrophoneStream, createCameraStream, createDisplayStream, createDisplayStreamWithAudio, type VideoContentHint, } from './webrtc-core';
|
|
1
|
+
export { getDevices, LocalStream, LocalDisplayStream, LocalSystemAudioStream, LocalStreamEventNames, StreamEventNames, RemoteStream, RemoteStreamEventNames, 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
|
@@ -81,6 +81,12 @@ Object.defineProperty(exports, "RemoteStream", {
|
|
|
81
81
|
return _webrtcCore.RemoteStream;
|
|
82
82
|
}
|
|
83
83
|
});
|
|
84
|
+
Object.defineProperty(exports, "RemoteStreamEventNames", {
|
|
85
|
+
enumerable: true,
|
|
86
|
+
get: function () {
|
|
87
|
+
return _webrtcCore.RemoteStreamEventNames;
|
|
88
|
+
}
|
|
89
|
+
});
|
|
84
90
|
Object.defineProperty(exports, "StreamEventNames", {
|
|
85
91
|
enumerable: true,
|
|
86
92
|
get: function () {
|
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
2
|
import { TypedEvent, WithEventsDummyType } from '@webex/ts-events';
|
|
3
|
-
export { getDevices, LocalStream, LocalDisplayStream, LocalSystemAudioStream, LocalStreamEventNames, StreamEventNames, RemoteStream, type VideoContentHint, } from '@webex/internal-media-core';
|
|
3
|
+
export { getDevices, LocalStream, LocalDisplayStream, LocalSystemAudioStream, LocalStreamEventNames, StreamEventNames, RemoteStream, RemoteStreamEventNames, 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"
|
|
@@ -21,7 +21,7 @@ declare class _LocalMicrophoneStream extends WcmeLocalMicrophoneStream {
|
|
|
21
21
|
* @returns true if user is allowed to unmute the track, false otherwise
|
|
22
22
|
*/
|
|
23
23
|
isUnmuteAllowed(): boolean;
|
|
24
|
-
|
|
24
|
+
setUserMuted(muted: boolean): void;
|
|
25
25
|
}
|
|
26
26
|
declare class _LocalCameraStream extends WcmeLocalCameraStream {
|
|
27
27
|
private unmuteAllowed;
|
|
@@ -30,7 +30,7 @@ declare class _LocalCameraStream extends WcmeLocalCameraStream {
|
|
|
30
30
|
* @returns true if user is allowed to unmute the track, false otherwise
|
|
31
31
|
*/
|
|
32
32
|
isUnmuteAllowed(): boolean;
|
|
33
|
-
|
|
33
|
+
setUserMuted(muted: boolean): void;
|
|
34
34
|
}
|
|
35
35
|
export declare const createMicrophoneStream: (constraints?: AudioDeviceConstraints) => Promise<{
|
|
36
36
|
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;
|
package/dist/webrtc-core.js
CHANGED
|
@@ -35,6 +35,12 @@ Object.defineProperty(exports, "RemoteStream", {
|
|
|
35
35
|
return _internalMediaCore.RemoteStream;
|
|
36
36
|
}
|
|
37
37
|
});
|
|
38
|
+
Object.defineProperty(exports, "RemoteStreamEventNames", {
|
|
39
|
+
enumerable: true,
|
|
40
|
+
get: function () {
|
|
41
|
+
return _internalMediaCore.RemoteStreamEventNames;
|
|
42
|
+
}
|
|
43
|
+
});
|
|
38
44
|
Object.defineProperty(exports, "StreamEventNames", {
|
|
39
45
|
enumerable: true,
|
|
40
46
|
get: function () {
|
|
@@ -80,21 +86,21 @@ class _LocalMicrophoneStream extends _internalMediaCore.LocalMicrophoneStream {
|
|
|
80
86
|
isUnmuteAllowed() {
|
|
81
87
|
return this.unmuteAllowed;
|
|
82
88
|
}
|
|
83
|
-
|
|
89
|
+
setUserMuted(muted) {
|
|
84
90
|
if (!muted) {
|
|
85
91
|
if (!this.isUnmuteAllowed()) {
|
|
86
92
|
throw new Error('Unmute is not allowed');
|
|
87
93
|
}
|
|
88
94
|
}
|
|
89
|
-
return super.
|
|
95
|
+
return super.setUserMuted(muted);
|
|
90
96
|
}
|
|
91
97
|
|
|
92
98
|
/**
|
|
93
99
|
* @internal
|
|
94
100
|
*/
|
|
95
101
|
setServerMuted(muted, reason) {
|
|
96
|
-
if (muted !== this.
|
|
97
|
-
this.
|
|
102
|
+
if (muted !== this.userMuted) {
|
|
103
|
+
this.setUserMuted(muted);
|
|
98
104
|
this[LocalMicrophoneStreamEventNames.ServerMuted].emit(muted, reason);
|
|
99
105
|
}
|
|
100
106
|
}
|
|
@@ -116,21 +122,21 @@ class _LocalCameraStream extends _internalMediaCore.LocalCameraStream {
|
|
|
116
122
|
isUnmuteAllowed() {
|
|
117
123
|
return this.unmuteAllowed;
|
|
118
124
|
}
|
|
119
|
-
|
|
125
|
+
setUserMuted(muted) {
|
|
120
126
|
if (!muted) {
|
|
121
127
|
if (!this.isUnmuteAllowed()) {
|
|
122
128
|
throw new Error('Unmute is not allowed');
|
|
123
129
|
}
|
|
124
130
|
}
|
|
125
|
-
return super.
|
|
131
|
+
return super.setUserMuted(muted);
|
|
126
132
|
}
|
|
127
133
|
|
|
128
134
|
/**
|
|
129
135
|
* @internal
|
|
130
136
|
*/
|
|
131
137
|
setServerMuted(muted, reason) {
|
|
132
|
-
if (muted !== this.
|
|
133
|
-
this.
|
|
138
|
+
if (muted !== this.userMuted) {
|
|
139
|
+
this.setUserMuted(muted);
|
|
134
140
|
this[LocalCameraStreamEventNames.ServerMuted].emit(muted, reason);
|
|
135
141
|
}
|
|
136
142
|
}
|
package/jest.config.js
CHANGED
package/package.json
CHANGED
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"deploy:npm": "yarn npm publish"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@webex/internal-media-core": "2.
|
|
25
|
+
"@webex/internal-media-core": "2.3.0",
|
|
26
26
|
"@webex/ts-events": "^1.1.0",
|
|
27
27
|
"@webex/web-media-effects": "^2.15.6"
|
|
28
28
|
},
|
|
@@ -38,10 +38,11 @@
|
|
|
38
38
|
"@webex/eslint-config-legacy": "0.0.0",
|
|
39
39
|
"@webex/jest-config-legacy": "0.0.0",
|
|
40
40
|
"@webex/legacy-tools": "0.0.0",
|
|
41
|
-
"@webex/test-helper-chai": "3.0.0-next.
|
|
42
|
-
"@webex/test-helper-mock-webex": "3.0.0-next.
|
|
41
|
+
"@webex/test-helper-chai": "3.0.0-next.5",
|
|
42
|
+
"@webex/test-helper-mock-webex": "3.0.0-next.5",
|
|
43
43
|
"eslint": "^8.24.0",
|
|
44
|
+
"jsdom-global": "3.0.2",
|
|
44
45
|
"sinon": "^9.2.4"
|
|
45
46
|
},
|
|
46
|
-
"version": "3.0.1-next.
|
|
47
|
+
"version": "3.0.1-next.5"
|
|
47
48
|
}
|
package/src/index.ts
CHANGED
package/src/webrtc-core.ts
CHANGED
|
@@ -23,12 +23,13 @@ export {
|
|
|
23
23
|
LocalStreamEventNames,
|
|
24
24
|
StreamEventNames,
|
|
25
25
|
RemoteStream,
|
|
26
|
+
RemoteStreamEventNames,
|
|
26
27
|
type VideoContentHint,
|
|
27
28
|
} from '@webex/internal-media-core';
|
|
28
29
|
|
|
29
30
|
export type ServerMuteReason =
|
|
30
31
|
| 'remotelyMuted' // other user has remotely muted us
|
|
31
|
-
| 'clientRequestFailed' // client called
|
|
32
|
+
| 'clientRequestFailed' // client called setUserMuted() but server request failed
|
|
32
33
|
| 'localUnmuteRequired'; // server forced the client to be unmuted
|
|
33
34
|
|
|
34
35
|
// these events are in addition to WCME events. This will be properly typed once webrtc-core event types inheritance is fixed
|
|
@@ -74,22 +75,22 @@ class _LocalMicrophoneStream extends WcmeLocalMicrophoneStream {
|
|
|
74
75
|
return this.unmuteAllowed;
|
|
75
76
|
}
|
|
76
77
|
|
|
77
|
-
|
|
78
|
+
setUserMuted(muted: boolean): void {
|
|
78
79
|
if (!muted) {
|
|
79
80
|
if (!this.isUnmuteAllowed()) {
|
|
80
81
|
throw new Error('Unmute is not allowed');
|
|
81
82
|
}
|
|
82
83
|
}
|
|
83
84
|
|
|
84
|
-
return super.
|
|
85
|
+
return super.setUserMuted(muted);
|
|
85
86
|
}
|
|
86
87
|
|
|
87
88
|
/**
|
|
88
89
|
* @internal
|
|
89
90
|
*/
|
|
90
91
|
setServerMuted(muted: boolean, reason: ServerMuteReason) {
|
|
91
|
-
if (muted !== this.
|
|
92
|
-
this.
|
|
92
|
+
if (muted !== this.userMuted) {
|
|
93
|
+
this.setUserMuted(muted);
|
|
93
94
|
this[LocalMicrophoneStreamEventNames.ServerMuted].emit(muted, reason);
|
|
94
95
|
}
|
|
95
96
|
}
|
|
@@ -116,22 +117,22 @@ class _LocalCameraStream extends WcmeLocalCameraStream {
|
|
|
116
117
|
return this.unmuteAllowed;
|
|
117
118
|
}
|
|
118
119
|
|
|
119
|
-
|
|
120
|
+
setUserMuted(muted: boolean): void {
|
|
120
121
|
if (!muted) {
|
|
121
122
|
if (!this.isUnmuteAllowed()) {
|
|
122
123
|
throw new Error('Unmute is not allowed');
|
|
123
124
|
}
|
|
124
125
|
}
|
|
125
126
|
|
|
126
|
-
return super.
|
|
127
|
+
return super.setUserMuted(muted);
|
|
127
128
|
}
|
|
128
129
|
|
|
129
130
|
/**
|
|
130
131
|
* @internal
|
|
131
132
|
*/
|
|
132
133
|
setServerMuted(muted: boolean, reason: ServerMuteReason) {
|
|
133
|
-
if (muted !== this.
|
|
134
|
-
this.
|
|
134
|
+
if (muted !== this.userMuted) {
|
|
135
|
+
this.setUserMuted(muted);
|
|
135
136
|
this[LocalCameraStreamEventNames.ServerMuted].emit(muted, reason);
|
|
136
137
|
}
|
|
137
138
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import 'jsdom-global/register';
|
|
1
2
|
import {assert, expect} from '@webex/test-helper-chai';
|
|
2
3
|
import sinon from 'sinon';
|
|
3
4
|
import {
|
|
@@ -53,22 +54,22 @@ describe('media-helpers', () => {
|
|
|
53
54
|
|
|
54
55
|
it('by default allows unmuting', async () => {
|
|
55
56
|
assert.equal(stream.isUnmuteAllowed(), true);
|
|
56
|
-
await stream.
|
|
57
|
+
await stream.setUserMuted(false);
|
|
57
58
|
});
|
|
58
59
|
|
|
59
|
-
it('rejects
|
|
60
|
-
|
|
60
|
+
it('rejects setUserMuted(false) if unmute is not allowed', async () => {
|
|
61
|
+
stream.setUnmuteAllowed(false);
|
|
61
62
|
|
|
62
63
|
assert.equal(stream.isUnmuteAllowed(), false);
|
|
63
|
-
const fn = () => stream.
|
|
64
|
+
const fn = () => stream.setUserMuted(false);
|
|
64
65
|
expect(fn).to.throw(/Unmute is not allowed/);
|
|
65
66
|
});
|
|
66
67
|
|
|
67
|
-
it('resolves
|
|
68
|
-
|
|
68
|
+
it('resolves setUserMuted(false) if unmute is allowed', async () => {
|
|
69
|
+
stream.setUnmuteAllowed(true);
|
|
69
70
|
|
|
70
71
|
assert.equal(stream.isUnmuteAllowed(), true);
|
|
71
|
-
await stream.
|
|
72
|
+
await stream.setUserMuted(false);
|
|
72
73
|
});
|
|
73
74
|
|
|
74
75
|
it('returns a reasonable length string from JSON.stringify()', () => {
|
|
@@ -81,16 +82,16 @@ describe('media-helpers', () => {
|
|
|
81
82
|
});
|
|
82
83
|
|
|
83
84
|
const checkSetServerMuted = async (startMute, setMute, expectedCalled) => {
|
|
84
|
-
await stream.
|
|
85
|
+
await stream.setUserMuted(startMute);
|
|
85
86
|
|
|
86
|
-
assert.equal(stream.
|
|
87
|
+
assert.equal(stream.userMuted, startMute);
|
|
87
88
|
|
|
88
89
|
const handler = sinon.fake();
|
|
89
90
|
stream.on(event.ServerMuted, handler);
|
|
90
91
|
|
|
91
92
|
await stream.setServerMuted(setMute, 'remotelyMuted');
|
|
92
93
|
|
|
93
|
-
assert.equal(stream.
|
|
94
|
+
assert.equal(stream.userMuted, setMute);
|
|
94
95
|
if (expectedCalled) {
|
|
95
96
|
assert.calledOnceWithExactly(handler, setMute, 'remotelyMuted');
|
|
96
97
|
} else {
|