@webex/media-helpers 3.0.0-next.7 → 3.0.0-stream-classes.1
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/constants.js.map +1 -1
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -1
- package/dist/webrtc-core.js +50 -20
- package/dist/webrtc-core.js.map +1 -1
- package/package.json +8 -23
- package/src/index.ts +2 -0
- package/src/webrtc-core.ts +52 -5
- package/test/unit/spec/webrtc-core.js +16 -11
- package/babel.config.json +0 -13
- package/tsconfig.json +0 -6
package/dist/constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["FacingMode","
|
|
1
|
+
{"version":3,"names":["FacingMode","DisplaySurface","PresetCameraConstraints","frameRate","width","height"],"sources":["constants.ts"],"sourcesContent":["import {VideoDeviceConstraints} from '@webex/internal-media-core';\n\nexport enum FacingMode {\n user = 'user',\n environment = 'environment',\n}\n\n// can be used later on when we add constraints in create display track\nexport enum DisplaySurface {\n browser = 'browser',\n monitor = 'monitor',\n window = 'window',\n}\n\nexport const PresetCameraConstraints: {[key: string]: VideoDeviceConstraints} = {\n '1080p': {frameRate: 30, width: 1920, height: 1080},\n\n '720p': {frameRate: 30, width: 1280, height: 720},\n\n '480p': {frameRate: 30, width: 640, height: 480},\n\n '360p': {frameRate: 30, width: 640, height: 360},\n\n '240p': {frameRate: 30, width: 320, height: 240},\n\n '180p': {frameRate: 30, width: 320, height: 180},\n\n '120p': {frameRate: 30, width: 160, height: 120},\n};\n"],"mappings":";;;;;;;IAEYA,UAAU,EAKtB;AAAA;AAAA,WALYA,UAAU;EAAVA,UAAU;EAAVA,UAAU;AAAA,GAAVA,UAAU,0BAAVA,UAAU;AAAA,IAMVC,cAAc;AAAA;AAAA,WAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;AAAA,GAAdA,cAAc,8BAAdA,cAAc;AAMnB,IAAMC,uBAAgE,GAAG;EAC9E,OAAO,EAAE;IAACC,SAAS,EAAE,EAAE;IAAEC,KAAK,EAAE,IAAI;IAAEC,MAAM,EAAE;EAAI,CAAC;EAEnD,MAAM,EAAE;IAACF,SAAS,EAAE,EAAE;IAAEC,KAAK,EAAE,IAAI;IAAEC,MAAM,EAAE;EAAG,CAAC;EAEjD,MAAM,EAAE;IAACF,SAAS,EAAE,EAAE;IAAEC,KAAK,EAAE,GAAG;IAAEC,MAAM,EAAE;EAAG,CAAC;EAEhD,MAAM,EAAE;IAACF,SAAS,EAAE,EAAE;IAAEC,KAAK,EAAE,GAAG;IAAEC,MAAM,EAAE;EAAG,CAAC;EAEhD,MAAM,EAAE;IAACF,SAAS,EAAE,EAAE;IAAEC,KAAK,EAAE,GAAG;IAAEC,MAAM,EAAE;EAAG,CAAC;EAEhD,MAAM,EAAE;IAACF,SAAS,EAAE,EAAE;IAAEC,KAAK,EAAE,GAAG;IAAEC,MAAM,EAAE;EAAG,CAAC;EAEhD,MAAM,EAAE;IAACF,SAAS,EAAE,EAAE;IAAEC,KAAK,EAAE,GAAG;IAAEC,MAAM,EAAE;EAAG;AACjD,CAAC;AAAC"}
|
package/dist/index.js
CHANGED
|
@@ -76,6 +76,12 @@ _Object$defineProperty(exports, "PresetCameraConstraints", {
|
|
|
76
76
|
return _constants.PresetCameraConstraints;
|
|
77
77
|
}
|
|
78
78
|
});
|
|
79
|
+
_Object$defineProperty(exports, "RemoteStream", {
|
|
80
|
+
enumerable: true,
|
|
81
|
+
get: function get() {
|
|
82
|
+
return _webrtcCore.RemoteStream;
|
|
83
|
+
}
|
|
84
|
+
});
|
|
79
85
|
_Object$defineProperty(exports, "StreamEventNames", {
|
|
80
86
|
enumerable: true,
|
|
81
87
|
get: function get() {
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[
|
|
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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAoBA;AAMA"}
|
package/dist/webrtc-core.js
CHANGED
|
@@ -77,12 +77,12 @@ exports.LocalCameraStreamEventNames = LocalCameraStreamEventNames;
|
|
|
77
77
|
LocalCameraStreamEventNames["ServerMuted"] = "muted:byServer";
|
|
78
78
|
})(LocalCameraStreamEventNames || (exports.LocalCameraStreamEventNames = LocalCameraStreamEventNames = {}));
|
|
79
79
|
_LocalMicrophoneStrea = LocalMicrophoneStreamEventNames.ServerMuted;
|
|
80
|
-
var
|
|
81
|
-
(0, _inherits2.default)(
|
|
82
|
-
var _super = _createSuper(
|
|
83
|
-
function
|
|
80
|
+
var _LocalMicrophoneStream = /*#__PURE__*/function (_WcmeLocalMicrophoneS) {
|
|
81
|
+
(0, _inherits2.default)(_LocalMicrophoneStream, _WcmeLocalMicrophoneS);
|
|
82
|
+
var _super = _createSuper(_LocalMicrophoneStream);
|
|
83
|
+
function _LocalMicrophoneStream() {
|
|
84
84
|
var _this;
|
|
85
|
-
(0, _classCallCheck2.default)(this,
|
|
85
|
+
(0, _classCallCheck2.default)(this, _LocalMicrophoneStream);
|
|
86
86
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
87
87
|
args[_key] = arguments[_key];
|
|
88
88
|
}
|
|
@@ -91,7 +91,7 @@ var LocalMicrophoneStream = /*#__PURE__*/function (_WcmeLocalMicrophoneS) {
|
|
|
91
91
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), _LocalMicrophoneStrea, new _tsEvents.TypedEvent());
|
|
92
92
|
return _this;
|
|
93
93
|
}
|
|
94
|
-
(0, _createClass2.default)(
|
|
94
|
+
(0, _createClass2.default)(_LocalMicrophoneStream, [{
|
|
95
95
|
key: "setUnmuteAllowed",
|
|
96
96
|
value:
|
|
97
97
|
/**
|
|
@@ -102,7 +102,7 @@ var LocalMicrophoneStream = /*#__PURE__*/function (_WcmeLocalMicrophoneS) {
|
|
|
102
102
|
}
|
|
103
103
|
|
|
104
104
|
/**
|
|
105
|
-
* @returns true if user is allowed to unmute the
|
|
105
|
+
* @returns true if user is allowed to unmute the track, false otherwise
|
|
106
106
|
*/
|
|
107
107
|
}, {
|
|
108
108
|
key: "isUnmuteAllowed",
|
|
@@ -117,7 +117,7 @@ var LocalMicrophoneStream = /*#__PURE__*/function (_WcmeLocalMicrophoneS) {
|
|
|
117
117
|
throw new Error('Unmute is not allowed');
|
|
118
118
|
}
|
|
119
119
|
}
|
|
120
|
-
return (0, _get2.default)((0, _getPrototypeOf2.default)(
|
|
120
|
+
return (0, _get2.default)((0, _getPrototypeOf2.default)(_LocalMicrophoneStream.prototype), "setMuted", this).call(this, muted);
|
|
121
121
|
}
|
|
122
122
|
|
|
123
123
|
/**
|
|
@@ -131,17 +131,30 @@ var LocalMicrophoneStream = /*#__PURE__*/function (_WcmeLocalMicrophoneS) {
|
|
|
131
131
|
this[LocalMicrophoneStreamEventNames.ServerMuted].emit(muted, reason);
|
|
132
132
|
}
|
|
133
133
|
}
|
|
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
|
+
}
|
|
134
148
|
}]);
|
|
135
|
-
return
|
|
149
|
+
return _LocalMicrophoneStream;
|
|
136
150
|
}(_internalMediaCore.LocalMicrophoneStream);
|
|
137
|
-
exports.LocalMicrophoneStream = LocalMicrophoneStream;
|
|
138
151
|
_LocalCameraStreamEve = LocalCameraStreamEventNames.ServerMuted;
|
|
139
|
-
var
|
|
140
|
-
(0, _inherits2.default)(
|
|
141
|
-
var _super2 = _createSuper(
|
|
142
|
-
function
|
|
152
|
+
var _LocalCameraStream = /*#__PURE__*/function (_WcmeLocalCameraStrea) {
|
|
153
|
+
(0, _inherits2.default)(_LocalCameraStream, _WcmeLocalCameraStrea);
|
|
154
|
+
var _super2 = _createSuper(_LocalCameraStream);
|
|
155
|
+
function _LocalCameraStream() {
|
|
143
156
|
var _this2;
|
|
144
|
-
(0, _classCallCheck2.default)(this,
|
|
157
|
+
(0, _classCallCheck2.default)(this, _LocalCameraStream);
|
|
145
158
|
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
146
159
|
args[_key2] = arguments[_key2];
|
|
147
160
|
}
|
|
@@ -150,7 +163,7 @@ var LocalCameraStream = /*#__PURE__*/function (_WcmeLocalCameraStrea) {
|
|
|
150
163
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this2), _LocalCameraStreamEve, new _tsEvents.TypedEvent());
|
|
151
164
|
return _this2;
|
|
152
165
|
}
|
|
153
|
-
(0, _createClass2.default)(
|
|
166
|
+
(0, _createClass2.default)(_LocalCameraStream, [{
|
|
154
167
|
key: "setUnmuteAllowed",
|
|
155
168
|
value:
|
|
156
169
|
/**
|
|
@@ -161,7 +174,7 @@ var LocalCameraStream = /*#__PURE__*/function (_WcmeLocalCameraStrea) {
|
|
|
161
174
|
}
|
|
162
175
|
|
|
163
176
|
/**
|
|
164
|
-
* @returns true if user is allowed to unmute the
|
|
177
|
+
* @returns true if user is allowed to unmute the track, false otherwise
|
|
165
178
|
*/
|
|
166
179
|
}, {
|
|
167
180
|
key: "isUnmuteAllowed",
|
|
@@ -176,7 +189,7 @@ var LocalCameraStream = /*#__PURE__*/function (_WcmeLocalCameraStrea) {
|
|
|
176
189
|
throw new Error('Unmute is not allowed');
|
|
177
190
|
}
|
|
178
191
|
}
|
|
179
|
-
return (0, _get2.default)((0, _getPrototypeOf2.default)(
|
|
192
|
+
return (0, _get2.default)((0, _getPrototypeOf2.default)(_LocalCameraStream.prototype), "setMuted", this).call(this, muted);
|
|
180
193
|
}
|
|
181
194
|
|
|
182
195
|
/**
|
|
@@ -190,10 +203,23 @@ var LocalCameraStream = /*#__PURE__*/function (_WcmeLocalCameraStrea) {
|
|
|
190
203
|
this[LocalCameraStreamEventNames.ServerMuted].emit(muted, reason);
|
|
191
204
|
}
|
|
192
205
|
}
|
|
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
|
+
}
|
|
193
220
|
}]);
|
|
194
|
-
return
|
|
221
|
+
return _LocalCameraStream;
|
|
195
222
|
}(_internalMediaCore.LocalCameraStream);
|
|
196
|
-
exports.LocalCameraStream = LocalCameraStream;
|
|
197
223
|
var createMicrophoneStream = function createMicrophoneStream(constraints) {
|
|
198
224
|
return (0, _internalMediaCore.createMicrophoneStream)(LocalMicrophoneStream, constraints);
|
|
199
225
|
};
|
|
@@ -210,4 +236,8 @@ var createDisplayStreamWithAudio = function createDisplayStreamWithAudio() {
|
|
|
210
236
|
return (0, _internalMediaCore.createDisplayStreamWithAudio)(_internalMediaCore.LocalDisplayStream, _internalMediaCore.LocalSystemAudioStream);
|
|
211
237
|
};
|
|
212
238
|
exports.createDisplayStreamWithAudio = createDisplayStreamWithAudio;
|
|
239
|
+
var LocalMicrophoneStream = (0, _tsEvents.AddEvents)(_LocalMicrophoneStream);
|
|
240
|
+
exports.LocalMicrophoneStream = LocalMicrophoneStream;
|
|
241
|
+
var LocalCameraStream = (0, _tsEvents.AddEvents)(_LocalCameraStream);
|
|
242
|
+
exports.LocalCameraStream = LocalCameraStream;
|
|
213
243
|
//# sourceMappingURL=webrtc-core.js.map
|
package/dist/webrtc-core.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["LocalMicrophoneStreamEventNames","LocalCameraStreamEventNames","ServerMuted","_LocalMicrophoneStream","TypedEvent","allowed","unmuteAllowed","muted","isUnmuteAllowed","Error","reason","setMuted","emit","id","enabled","inputTrack","label","readyState","numEnabledEffects","getAllEffects","filter","item","effect","isEnabled","length","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 type VideoContentHint,\n} from '@webex/internal-media-core';\n\nexport type ServerMuteReason =\n | 'remotelyMuted' // other user has remotely muted us\n | 'clientRequestFailed' // client called setMuted() 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) {\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 setMuted(muted: boolean): void {\n if (!muted) {\n if (!this.isUnmuteAllowed()) {\n throw new Error('Unmute is not allowed');\n }\n }\n\n return super.setMuted(muted);\n }\n\n /**\n * @internal\n */\n setServerMuted(muted: boolean, reason: ServerMuteReason) {\n if (muted !== this.muted) {\n this.setMuted(muted);\n this[LocalMicrophoneStreamEventNames.ServerMuted].emit(muted, reason);\n }\n }\n\n toJSON() {\n return {\n id: this.id,\n enabled: this.inputTrack?.enabled,\n label: this.label,\n readyState: this.readyState,\n numEnabledEffects: this.getAllEffects().filter((item) => item.effect.isEnabled).length,\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) {\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 setMuted(muted: boolean): void {\n if (!muted) {\n if (!this.isUnmuteAllowed()) {\n throw new Error('Unmute is not allowed');\n }\n }\n\n return super.setMuted(muted);\n }\n\n /**\n * @internal\n */\n setServerMuted(muted: boolean, reason: ServerMuteReason) {\n if (muted !== this.muted) {\n this.setMuted(muted);\n this[LocalCameraStreamEventNames.ServerMuted].emit(muted, reason);\n }\n }\n\n toJSON() {\n return {\n id: this.id,\n enabled: this.inputTrack?.enabled,\n label: this.label,\n readyState: this.readyState,\n numEnabledEffects: this.getAllEffects().filter((item) => item.effect.isEnabled).length,\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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA;AAYA;AAA4E;AAAA;AAAA;AAgBjD;AAE3B;AAAA,IACYA,+BAA+B,EAI3C;AAAA;AAAA,WAJYA,+BAA+B;EAA/BA,+BAA+B;AAAA,GAA/BA,+BAA+B,+CAA/BA,+BAA+B;AAAA,IAK/BC,2BAA2B;AAAA;AAAA,WAA3BA,2BAA2B;EAA3BA,2BAA2B;AAAA,GAA3BA,2BAA2B,2CAA3BA,2BAA2B;AAAA,wBAmBpCD,+BAA+B,CAACE,WAAW;AAAA,IAHxCC,sBAAsB;EAAA;EAAA;EAAA;IAAA;IAAA;IAAA;MAAA;IAAA;IAAA;IAAA,4FACF,IAAI;IAAA,kGAEoB,IAAIC,oBAAU,EAE3D;IAAA;EAAA;EAAA;IAAA;IAAA;IAEH;AACF;AACA;IACE,0BAAiBC,OAAO,EAAE;MACxB,IAAI,CAACC,aAAa,GAAGD,OAAO;IAC9B;;IAEA;AACF;AACA;EAFE;IAAA;IAAA,OAGA,2BAAkB;MAChB,OAAO,IAAI,CAACC,aAAa;IAC3B;EAAC;IAAA;IAAA,OAED,kBAASC,KAAc,EAAQ;MAC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A;AAAC;AAE9E,IAAMC,4BAA4B,GAAG,SAA/BA,4BAA4B;EAAA,OACvC,IAAAC,+CAAgC,EAACF,qCAAkB,EAAEG,yCAAsB,CAAC;AAAA;AAAC;AAExE,IAAMT,qBAAqB,GAAG,IAAAU,mBAAS,EAG5CtC,sBAAsB,CAAC;AAAC;AAKnB,IAAM+B,iBAAiB,GAAG,IAAAO,mBAAS,EACxCf,kBAAkB,CACnB;AAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webex/media-helpers",
|
|
3
|
-
"
|
|
3
|
+
"version": "3.0.0-stream-classes.01",
|
|
4
|
+
"description": "",
|
|
4
5
|
"license": "Cisco EULA (https://www.cisco.com/c/en/us/products/end-user-license-agreement.html)",
|
|
5
6
|
"main": "dist/index.js",
|
|
6
7
|
"devMain": "src/index.ts",
|
|
@@ -12,19 +13,10 @@
|
|
|
12
13
|
"engines": {
|
|
13
14
|
"node": ">=16"
|
|
14
15
|
},
|
|
15
|
-
"scripts": {
|
|
16
|
-
"build:src": "yarn run -T tsc --declaration true --declarationDir ./dist",
|
|
17
|
-
"test:broken": "yarn test:style && yarn test:unit && yarn test:integration && yarn test:browser",
|
|
18
|
-
"test:browser:broken": "webex-legacy-tools test --integration --unit --runner karma",
|
|
19
|
-
"test:integration:broken": "webex-legacy-tools test --integration --runner mocha",
|
|
20
|
-
"test:style": "eslint 'src/**/*.ts' --fix",
|
|
21
|
-
"test:unit:broken": "webex-legacy-tools test --unit --runner mocha",
|
|
22
|
-
"deploy:npm": "yarn npm publish"
|
|
23
|
-
},
|
|
24
16
|
"dependencies": {
|
|
25
|
-
"@webex/internal-media-core": "
|
|
17
|
+
"@webex/internal-media-core": "2.0.3",
|
|
26
18
|
"@webex/ts-events": "^1.1.0",
|
|
27
|
-
"@webex/web-media-effects": "^2.
|
|
19
|
+
"@webex/web-media-effects": "^2.8.0"
|
|
28
20
|
},
|
|
29
21
|
"browserify": {
|
|
30
22
|
"transform": [
|
|
@@ -33,15 +25,8 @@
|
|
|
33
25
|
]
|
|
34
26
|
},
|
|
35
27
|
"devDependencies": {
|
|
36
|
-
"@
|
|
37
|
-
"@webex/
|
|
38
|
-
"@webex/eslint-config-legacy": "^0.0.0",
|
|
39
|
-
"@webex/jest-config-legacy": "^0.0.0",
|
|
40
|
-
"@webex/legacy-tools": "^0.0.0",
|
|
41
|
-
"@webex/test-helper-chai": "^2.59.3-next.1",
|
|
42
|
-
"@webex/test-helper-mock-webex": "^2.59.3-next.1",
|
|
43
|
-
"eslint": "^8.24.0",
|
|
28
|
+
"@webex/test-helper-chai": "workspace:^",
|
|
29
|
+
"@webex/test-helper-mock-webex": "workspace:^",
|
|
44
30
|
"sinon": "^9.2.4"
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
}
|
|
31
|
+
}
|
|
32
|
+
}
|
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);
|
package/babel.config.json
DELETED