@webex/media-helpers 3.0.0-stream-classes.5 → 3.0.0-test.2
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 +2 -2
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -1
- package/dist/webrtc-core.js +16 -38
- package/dist/webrtc-core.js.map +1 -1
- package/package.json +7 -3
- package/src/index.ts +1 -0
- package/src/webrtc-core.ts +12 -31
- package/test/unit/spec/webrtc-core.js +19 -17
- package/tsconfig.json +6 -0
package/README.md
CHANGED
|
@@ -51,7 +51,7 @@ const effect = new VirtualBackgroundEffect({
|
|
|
51
51
|
});
|
|
52
52
|
|
|
53
53
|
// add the effect on the input camera stream.
|
|
54
|
-
await cameraStream.addEffect(
|
|
54
|
+
await cameraStream.addEffect(effect);
|
|
55
55
|
|
|
56
56
|
//enable the effect once it is added to the stream
|
|
57
57
|
await effect.enable()
|
|
@@ -79,7 +79,7 @@ const effect = new NoiseReductionEffect({
|
|
|
79
79
|
});
|
|
80
80
|
|
|
81
81
|
// add the effect on microphone stream.
|
|
82
|
-
await microphoneStream.addEffect(
|
|
82
|
+
await microphoneStream.addEffect(effect);
|
|
83
83
|
|
|
84
84
|
//enable the effect once it is added to the track
|
|
85
85
|
await effect.enable()
|
package/dist/index.js
CHANGED
|
@@ -82,6 +82,12 @@ _Object$defineProperty(exports, "RemoteStream", {
|
|
|
82
82
|
return _webrtcCore.RemoteStream;
|
|
83
83
|
}
|
|
84
84
|
});
|
|
85
|
+
_Object$defineProperty(exports, "RemoteStreamEventNames", {
|
|
86
|
+
enumerable: true,
|
|
87
|
+
get: function get() {
|
|
88
|
+
return _webrtcCore.RemoteStreamEventNames;
|
|
89
|
+
}
|
|
90
|
+
});
|
|
85
91
|
_Object$defineProperty(exports, "StreamEventNames", {
|
|
86
92
|
enumerable: true,
|
|
87
93
|
get: function get() {
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export {\n getDevices,\n LocalStream,\n LocalDisplayStream,\n LocalSystemAudioStream,\n LocalStreamEventNames,\n StreamEventNames,\n RemoteStream,\n type ServerMuteReason,\n LocalMicrophoneStreamEventNames,\n LocalCameraStreamEventNames,\n LocalMicrophoneStream,\n LocalCameraStream,\n createMicrophoneStream,\n createCameraStream,\n createDisplayStream,\n createDisplayStreamWithAudio,\n type VideoContentHint,\n} from './webrtc-core';\n\nexport {NoiseReductionEffect, VirtualBackgroundEffect} from '@webex/web-media-effects';\nexport type {\n NoiseReductionEffectOptions,\n VirtualBackgroundEffectOptions,\n} from '@webex/web-media-effects';\n\nexport {FacingMode, DisplaySurface, PresetCameraConstraints} from './constants';\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export {\n getDevices,\n LocalStream,\n LocalDisplayStream,\n LocalSystemAudioStream,\n LocalStreamEventNames,\n StreamEventNames,\n RemoteStream,\n RemoteStreamEventNames,\n type ServerMuteReason,\n LocalMicrophoneStreamEventNames,\n LocalCameraStreamEventNames,\n LocalMicrophoneStream,\n LocalCameraStream,\n createMicrophoneStream,\n createCameraStream,\n createDisplayStream,\n createDisplayStreamWithAudio,\n type VideoContentHint,\n} from './webrtc-core';\n\nexport {NoiseReductionEffect, VirtualBackgroundEffect} from '@webex/web-media-effects';\nexport type {\n NoiseReductionEffectOptions,\n VirtualBackgroundEffectOptions,\n} from '@webex/web-media-effects';\n\nexport {FacingMode, DisplaySurface, PresetCameraConstraints} from './constants';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAqBA;AAMA"}
|
package/dist/webrtc-core.js
CHANGED
|
@@ -38,6 +38,12 @@ _Object$defineProperty(exports, "RemoteStream", {
|
|
|
38
38
|
return _internalMediaCore.RemoteStream;
|
|
39
39
|
}
|
|
40
40
|
});
|
|
41
|
+
_Object$defineProperty(exports, "RemoteStreamEventNames", {
|
|
42
|
+
enumerable: true,
|
|
43
|
+
get: function get() {
|
|
44
|
+
return _internalMediaCore.RemoteStreamEventNames;
|
|
45
|
+
}
|
|
46
|
+
});
|
|
41
47
|
_Object$defineProperty(exports, "StreamEventNames", {
|
|
42
48
|
enumerable: true,
|
|
43
49
|
get: function get() {
|
|
@@ -110,14 +116,14 @@ var _LocalMicrophoneStream = /*#__PURE__*/function (_WcmeLocalMicrophoneS) {
|
|
|
110
116
|
return this.unmuteAllowed;
|
|
111
117
|
}
|
|
112
118
|
}, {
|
|
113
|
-
key: "
|
|
114
|
-
value: function
|
|
119
|
+
key: "setUserMuted",
|
|
120
|
+
value: function setUserMuted(muted) {
|
|
115
121
|
if (!muted) {
|
|
116
122
|
if (!this.isUnmuteAllowed()) {
|
|
117
123
|
throw new Error('Unmute is not allowed');
|
|
118
124
|
}
|
|
119
125
|
}
|
|
120
|
-
return (0, _get2.default)((0, _getPrototypeOf2.default)(_LocalMicrophoneStream.prototype), "
|
|
126
|
+
return (0, _get2.default)((0, _getPrototypeOf2.default)(_LocalMicrophoneStream.prototype), "setUserMuted", this).call(this, muted);
|
|
121
127
|
}
|
|
122
128
|
|
|
123
129
|
/**
|
|
@@ -126,25 +132,11 @@ var _LocalMicrophoneStream = /*#__PURE__*/function (_WcmeLocalMicrophoneS) {
|
|
|
126
132
|
}, {
|
|
127
133
|
key: "setServerMuted",
|
|
128
134
|
value: function setServerMuted(muted, reason) {
|
|
129
|
-
if (muted !== this.
|
|
130
|
-
this.
|
|
135
|
+
if (muted !== this.userMuted) {
|
|
136
|
+
this.setUserMuted(muted);
|
|
131
137
|
this[LocalMicrophoneStreamEventNames.ServerMuted].emit(muted, reason);
|
|
132
138
|
}
|
|
133
139
|
}
|
|
134
|
-
}, {
|
|
135
|
-
key: "toJSON",
|
|
136
|
-
value: function toJSON() {
|
|
137
|
-
var _this$inputTrack;
|
|
138
|
-
return {
|
|
139
|
-
id: this.id,
|
|
140
|
-
enabled: (_this$inputTrack = this.inputTrack) === null || _this$inputTrack === void 0 ? void 0 : _this$inputTrack.enabled,
|
|
141
|
-
label: this.label,
|
|
142
|
-
readyState: this.readyState,
|
|
143
|
-
numEnabledEffects: this.getAllEffects().filter(function (item) {
|
|
144
|
-
return item.effect.isEnabled;
|
|
145
|
-
}).length
|
|
146
|
-
};
|
|
147
|
-
}
|
|
148
140
|
}]);
|
|
149
141
|
return _LocalMicrophoneStream;
|
|
150
142
|
}(_internalMediaCore.LocalMicrophoneStream);
|
|
@@ -182,14 +174,14 @@ var _LocalCameraStream = /*#__PURE__*/function (_WcmeLocalCameraStrea) {
|
|
|
182
174
|
return this.unmuteAllowed;
|
|
183
175
|
}
|
|
184
176
|
}, {
|
|
185
|
-
key: "
|
|
186
|
-
value: function
|
|
177
|
+
key: "setUserMuted",
|
|
178
|
+
value: function setUserMuted(muted) {
|
|
187
179
|
if (!muted) {
|
|
188
180
|
if (!this.isUnmuteAllowed()) {
|
|
189
181
|
throw new Error('Unmute is not allowed');
|
|
190
182
|
}
|
|
191
183
|
}
|
|
192
|
-
return (0, _get2.default)((0, _getPrototypeOf2.default)(_LocalCameraStream.prototype), "
|
|
184
|
+
return (0, _get2.default)((0, _getPrototypeOf2.default)(_LocalCameraStream.prototype), "setUserMuted", this).call(this, muted);
|
|
193
185
|
}
|
|
194
186
|
|
|
195
187
|
/**
|
|
@@ -198,25 +190,11 @@ var _LocalCameraStream = /*#__PURE__*/function (_WcmeLocalCameraStrea) {
|
|
|
198
190
|
}, {
|
|
199
191
|
key: "setServerMuted",
|
|
200
192
|
value: function setServerMuted(muted, reason) {
|
|
201
|
-
if (muted !== this.
|
|
202
|
-
this.
|
|
193
|
+
if (muted !== this.userMuted) {
|
|
194
|
+
this.setUserMuted(muted);
|
|
203
195
|
this[LocalCameraStreamEventNames.ServerMuted].emit(muted, reason);
|
|
204
196
|
}
|
|
205
197
|
}
|
|
206
|
-
}, {
|
|
207
|
-
key: "toJSON",
|
|
208
|
-
value: function toJSON() {
|
|
209
|
-
var _this$inputTrack2;
|
|
210
|
-
return {
|
|
211
|
-
id: this.id,
|
|
212
|
-
enabled: (_this$inputTrack2 = this.inputTrack) === null || _this$inputTrack2 === void 0 ? void 0 : _this$inputTrack2.enabled,
|
|
213
|
-
label: this.label,
|
|
214
|
-
readyState: this.readyState,
|
|
215
|
-
numEnabledEffects: this.getAllEffects().filter(function (item) {
|
|
216
|
-
return item.effect.isEnabled;
|
|
217
|
-
}).length
|
|
218
|
-
};
|
|
219
|
-
}
|
|
220
198
|
}]);
|
|
221
199
|
return _LocalCameraStream;
|
|
222
200
|
}(_internalMediaCore.LocalCameraStream);
|
package/dist/webrtc-core.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["LocalMicrophoneStreamEventNames","LocalCameraStreamEventNames","ServerMuted","_LocalMicrophoneStream","TypedEvent","allowed","unmuteAllowed","muted","isUnmuteAllowed","Error","reason","
|
|
1
|
+
{"version":3,"names":["LocalMicrophoneStreamEventNames","LocalCameraStreamEventNames","ServerMuted","_LocalMicrophoneStream","TypedEvent","allowed","unmuteAllowed","muted","isUnmuteAllowed","Error","reason","userMuted","setUserMuted","emit","WcmeLocalMicrophoneStream","_LocalCameraStream","WcmeLocalCameraStream","createMicrophoneStream","constraints","wcmeCreateMicrophoneStream","LocalMicrophoneStream","createCameraStream","wcmeCreateCameraStream","LocalCameraStream","createDisplayStream","wcmeCreateDisplayStream","LocalDisplayStream","createDisplayStreamWithAudio","wcmeCreateDisplayStreamWithAudio","LocalSystemAudioStream","AddEvents"],"sources":["webrtc-core.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-misused-new */\n/* eslint-disable valid-jsdoc */\n/* eslint-disable require-jsdoc */\nimport {\n AudioDeviceConstraints,\n createCameraStream as wcmeCreateCameraStream,\n createDisplayStream as wcmeCreateDisplayStream,\n createDisplayStreamWithAudio as wcmeCreateDisplayStreamWithAudio,\n createMicrophoneStream as wcmeCreateMicrophoneStream,\n LocalDisplayStream,\n LocalSystemAudioStream,\n LocalMicrophoneStream as WcmeLocalMicrophoneStream,\n LocalCameraStream as WcmeLocalCameraStream,\n VideoDeviceConstraints,\n} from '@webex/internal-media-core';\nimport {AddEvents, TypedEvent, WithEventsDummyType} from '@webex/ts-events';\n\nexport {\n getDevices,\n LocalStream,\n LocalDisplayStream,\n LocalSystemAudioStream,\n LocalStreamEventNames,\n StreamEventNames,\n RemoteStream,\n RemoteStreamEventNames,\n type VideoContentHint,\n} from '@webex/internal-media-core';\n\nexport type ServerMuteReason =\n | 'remotelyMuted' // other user has remotely muted us\n | 'clientRequestFailed' // client called setUserMuted() but server request failed\n | 'localUnmuteRequired'; // server forced the client to be unmuted\n\n// these events are in addition to WCME events. This will be properly typed once webrtc-core event types inheritance is fixed\nexport enum LocalMicrophoneStreamEventNames {\n ServerMuted = 'muted:byServer',\n}\n\n// these events are in addition to WCME events. This will be properly typed once webrtc-core event types inheritance is fixed\nexport enum LocalCameraStreamEventNames {\n ServerMuted = 'muted:byServer',\n}\n\ninterface LocalMicrophoneStreamEvents {\n [LocalMicrophoneStreamEventNames.ServerMuted]: TypedEvent<\n (muted: boolean, reason: ServerMuteReason) => void\n >;\n}\n\ninterface LocalCameraStreamEvents {\n [LocalMicrophoneStreamEventNames.ServerMuted]: TypedEvent<\n (muted: boolean, reason: ServerMuteReason) => void\n >;\n}\n\nclass _LocalMicrophoneStream extends WcmeLocalMicrophoneStream {\n private unmuteAllowed = true;\n\n [LocalMicrophoneStreamEventNames.ServerMuted] = new TypedEvent<\n (muted: boolean, reason: ServerMuteReason) => void\n >();\n\n /**\n * @internal\n */\n setUnmuteAllowed(allowed: boolean) {\n this.unmuteAllowed = allowed;\n }\n\n /**\n * @returns true if user is allowed to unmute the track, false otherwise\n */\n isUnmuteAllowed() {\n return this.unmuteAllowed;\n }\n\n setUserMuted(muted: boolean): void {\n if (!muted) {\n if (!this.isUnmuteAllowed()) {\n throw new Error('Unmute is not allowed');\n }\n }\n\n return super.setUserMuted(muted);\n }\n\n /**\n * @internal\n */\n setServerMuted(muted: boolean, reason: ServerMuteReason) {\n if (muted !== this.userMuted) {\n this.setUserMuted(muted);\n this[LocalMicrophoneStreamEventNames.ServerMuted].emit(muted, reason);\n }\n }\n}\n\nclass _LocalCameraStream extends WcmeLocalCameraStream {\n private unmuteAllowed = true;\n\n [LocalCameraStreamEventNames.ServerMuted] = new TypedEvent<\n (muted: boolean, reason: ServerMuteReason) => void\n >();\n\n /**\n * @internal\n */\n setUnmuteAllowed(allowed: boolean) {\n this.unmuteAllowed = allowed;\n }\n\n /**\n * @returns true if user is allowed to unmute the track, false otherwise\n */\n isUnmuteAllowed() {\n return this.unmuteAllowed;\n }\n\n setUserMuted(muted: boolean): void {\n if (!muted) {\n if (!this.isUnmuteAllowed()) {\n throw new Error('Unmute is not allowed');\n }\n }\n\n return super.setUserMuted(muted);\n }\n\n /**\n * @internal\n */\n setServerMuted(muted: boolean, reason: ServerMuteReason) {\n if (muted !== this.userMuted) {\n this.setUserMuted(muted);\n this[LocalCameraStreamEventNames.ServerMuted].emit(muted, reason);\n }\n }\n}\n\nexport const createMicrophoneStream = (constraints?: AudioDeviceConstraints) =>\n wcmeCreateMicrophoneStream(LocalMicrophoneStream, constraints);\n\nexport const createCameraStream = (constraints?: VideoDeviceConstraints) =>\n wcmeCreateCameraStream(LocalCameraStream, constraints);\n\nexport const createDisplayStream = () => wcmeCreateDisplayStream(LocalDisplayStream);\n\nexport const createDisplayStreamWithAudio = () =>\n wcmeCreateDisplayStreamWithAudio(LocalDisplayStream, LocalSystemAudioStream);\n\nexport const LocalMicrophoneStream = AddEvents<\n typeof _LocalMicrophoneStream,\n LocalMicrophoneStreamEvents\n>(_LocalMicrophoneStream);\n\nexport type LocalMicrophoneStream = _LocalMicrophoneStream &\n WithEventsDummyType<LocalMicrophoneStreamEvents>;\n\nexport const LocalCameraStream = AddEvents<typeof _LocalCameraStream, LocalCameraStreamEvents>(\n _LocalCameraStream\n);\n\nexport type LocalCameraStream = _LocalCameraStream & WithEventsDummyType<LocalCameraStreamEvents>;\n"],"mappings":"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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webex/media-helpers",
|
|
3
|
-
"version": "3.0.0-
|
|
3
|
+
"version": "3.0.0-test.2",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "Cisco EULA (https://www.cisco.com/c/en/us/products/end-user-license-agreement.html)",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -10,13 +10,16 @@
|
|
|
10
10
|
"url": "https://github.com/webex/webex-js-sdk.git",
|
|
11
11
|
"directory": "packages/@webex/media-helpers"
|
|
12
12
|
},
|
|
13
|
+
"scripts": {
|
|
14
|
+
"build:src": "yarn run -T tsc --declaration true --declarationDir ./dist"
|
|
15
|
+
},
|
|
13
16
|
"engines": {
|
|
14
17
|
"node": ">=16"
|
|
15
18
|
},
|
|
16
19
|
"dependencies": {
|
|
17
|
-
"@webex/internal-media-core": "2.0
|
|
20
|
+
"@webex/internal-media-core": "2.3.0",
|
|
18
21
|
"@webex/ts-events": "^1.1.0",
|
|
19
|
-
"@webex/web-media-effects": "^2.
|
|
22
|
+
"@webex/web-media-effects": "^2.15.6"
|
|
20
23
|
},
|
|
21
24
|
"browserify": {
|
|
22
25
|
"transform": [
|
|
@@ -27,6 +30,7 @@
|
|
|
27
30
|
"devDependencies": {
|
|
28
31
|
"@webex/test-helper-chai": "workspace:^",
|
|
29
32
|
"@webex/test-helper-mock-webex": "workspace:^",
|
|
33
|
+
"jsdom-global": "3.0.2",
|
|
30
34
|
"sinon": "^9.2.4"
|
|
31
35
|
}
|
|
32
36
|
}
|
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
|
|
@@ -63,7 +64,7 @@ class _LocalMicrophoneStream extends WcmeLocalMicrophoneStream {
|
|
|
63
64
|
/**
|
|
64
65
|
* @internal
|
|
65
66
|
*/
|
|
66
|
-
setUnmuteAllowed(allowed) {
|
|
67
|
+
setUnmuteAllowed(allowed: boolean) {
|
|
67
68
|
this.unmuteAllowed = allowed;
|
|
68
69
|
}
|
|
69
70
|
|
|
@@ -74,35 +75,25 @@ 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
|
}
|
|
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
|
-
}
|
|
106
97
|
}
|
|
107
98
|
|
|
108
99
|
class _LocalCameraStream extends WcmeLocalCameraStream {
|
|
@@ -115,7 +106,7 @@ class _LocalCameraStream extends WcmeLocalCameraStream {
|
|
|
115
106
|
/**
|
|
116
107
|
* @internal
|
|
117
108
|
*/
|
|
118
|
-
setUnmuteAllowed(allowed) {
|
|
109
|
+
setUnmuteAllowed(allowed: boolean) {
|
|
119
110
|
this.unmuteAllowed = allowed;
|
|
120
111
|
}
|
|
121
112
|
|
|
@@ -126,35 +117,25 @@ class _LocalCameraStream extends WcmeLocalCameraStream {
|
|
|
126
117
|
return this.unmuteAllowed;
|
|
127
118
|
}
|
|
128
119
|
|
|
129
|
-
|
|
120
|
+
setUserMuted(muted: boolean): void {
|
|
130
121
|
if (!muted) {
|
|
131
122
|
if (!this.isUnmuteAllowed()) {
|
|
132
123
|
throw new Error('Unmute is not allowed');
|
|
133
124
|
}
|
|
134
125
|
}
|
|
135
126
|
|
|
136
|
-
return super.
|
|
127
|
+
return super.setUserMuted(muted);
|
|
137
128
|
}
|
|
138
129
|
|
|
139
130
|
/**
|
|
140
131
|
* @internal
|
|
141
132
|
*/
|
|
142
133
|
setServerMuted(muted: boolean, reason: ServerMuteReason) {
|
|
143
|
-
if (muted !== this.
|
|
144
|
-
this.
|
|
134
|
+
if (muted !== this.userMuted) {
|
|
135
|
+
this.setUserMuted(muted);
|
|
145
136
|
this[LocalCameraStreamEventNames.ServerMuted].emit(muted, reason);
|
|
146
137
|
}
|
|
147
138
|
}
|
|
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
|
-
}
|
|
158
139
|
}
|
|
159
140
|
|
|
160
141
|
export const createMicrophoneStream = (constraints?: AudioDeviceConstraints) =>
|
|
@@ -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 {
|
|
@@ -11,7 +12,7 @@ import {
|
|
|
11
12
|
createMicrophoneStream,
|
|
12
13
|
createDisplayStream,
|
|
13
14
|
createDisplayStreamWithAudio,
|
|
14
|
-
} from '
|
|
15
|
+
} from '@webex/media-helpers';
|
|
15
16
|
import * as wcmestreams from '@webex/internal-media-core';
|
|
16
17
|
|
|
17
18
|
describe('media-helpers', () => {
|
|
@@ -41,6 +42,7 @@ describe('media-helpers', () => {
|
|
|
41
42
|
label: 'fake track',
|
|
42
43
|
id: 'fake track id',
|
|
43
44
|
enabled: true,
|
|
45
|
+
muted: false,
|
|
44
46
|
addEventListener: sinon.stub(),
|
|
45
47
|
},
|
|
46
48
|
]),
|
|
@@ -53,44 +55,44 @@ describe('media-helpers', () => {
|
|
|
53
55
|
|
|
54
56
|
it('by default allows unmuting', async () => {
|
|
55
57
|
assert.equal(stream.isUnmuteAllowed(), true);
|
|
56
|
-
await stream.
|
|
58
|
+
await stream.setUserMuted(false);
|
|
57
59
|
});
|
|
58
60
|
|
|
59
|
-
it('rejects
|
|
61
|
+
it('rejects setUserMuted(false) if unmute is not allowed', async () => {
|
|
60
62
|
stream.setUnmuteAllowed(false);
|
|
61
63
|
|
|
62
64
|
assert.equal(stream.isUnmuteAllowed(), false);
|
|
63
|
-
const fn = () => stream.
|
|
65
|
+
const fn = () => stream.setUserMuted(false);
|
|
64
66
|
expect(fn).to.throw(/Unmute is not allowed/);
|
|
65
67
|
});
|
|
66
68
|
|
|
67
|
-
it('resolves
|
|
69
|
+
it('resolves setUserMuted(false) if unmute is allowed', async () => {
|
|
68
70
|
stream.setUnmuteAllowed(true);
|
|
69
71
|
|
|
70
72
|
assert.equal(stream.isUnmuteAllowed(), true);
|
|
71
|
-
await stream.
|
|
73
|
+
await stream.setUserMuted(false);
|
|
72
74
|
});
|
|
73
75
|
|
|
74
76
|
it('returns a reasonable length string from JSON.stringify()', () => {
|
|
75
77
|
assert.isBelow(JSON.stringify(stream).length, 200);
|
|
76
|
-
})
|
|
78
|
+
});
|
|
77
79
|
|
|
78
80
|
describe('#setServerMuted', () => {
|
|
79
81
|
afterEach(() => {
|
|
80
82
|
sinon.restore();
|
|
81
83
|
});
|
|
82
84
|
|
|
83
|
-
const checkSetServerMuted =
|
|
84
|
-
|
|
85
|
+
const checkSetServerMuted = (startMute, setMute, expectedCalled) => {
|
|
86
|
+
stream.setUserMuted(startMute);
|
|
85
87
|
|
|
86
|
-
assert.equal(stream.
|
|
88
|
+
assert.equal(stream.userMuted, startMute);
|
|
87
89
|
|
|
88
90
|
const handler = sinon.fake();
|
|
89
91
|
stream.on(event.ServerMuted, handler);
|
|
90
92
|
|
|
91
|
-
|
|
93
|
+
stream.setServerMuted(setMute, 'remotelyMuted');
|
|
92
94
|
|
|
93
|
-
assert.equal(stream.
|
|
95
|
+
assert.equal(stream.userMuted, setMute);
|
|
94
96
|
if (expectedCalled) {
|
|
95
97
|
assert.calledOnceWithExactly(handler, setMute, 'remotelyMuted');
|
|
96
98
|
} else {
|
|
@@ -99,19 +101,19 @@ describe('media-helpers', () => {
|
|
|
99
101
|
};
|
|
100
102
|
|
|
101
103
|
it('tests true to false', async () => {
|
|
102
|
-
|
|
104
|
+
checkSetServerMuted(true, false, true);
|
|
103
105
|
});
|
|
104
106
|
|
|
105
107
|
it('tests false to true', async () => {
|
|
106
|
-
|
|
108
|
+
checkSetServerMuted(false, true, true);
|
|
107
109
|
});
|
|
108
110
|
|
|
109
111
|
it('tests true to true', async () => {
|
|
110
|
-
|
|
112
|
+
checkSetServerMuted(true, true, false);
|
|
111
113
|
});
|
|
112
114
|
|
|
113
115
|
it('tests false to false', async () => {
|
|
114
|
-
|
|
116
|
+
checkSetServerMuted(false, false, false);
|
|
115
117
|
});
|
|
116
118
|
});
|
|
117
119
|
|
|
@@ -137,7 +139,7 @@ describe('media-helpers', () => {
|
|
|
137
139
|
assert.calledOnceWithExactly(spy, LocalDisplayStream);
|
|
138
140
|
});
|
|
139
141
|
});
|
|
140
|
-
|
|
142
|
+
|
|
141
143
|
describe('createDisplayStreamWithAudio', () => {
|
|
142
144
|
it('checks createDisplayStreamWithAudio', async () => {
|
|
143
145
|
const spy = sinon.stub(wcmestreams, 'createDisplayStreamWithAudio').returns('something');
|