@webex/media-helpers 3.0.0-beta.250 → 3.0.0-beta.252
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/index.js +36 -24
- package/dist/index.js.map +1 -1
- package/dist/webrtc-core.js +103 -61
- package/dist/webrtc-core.js.map +1 -1
- package/package.json +6 -5
- package/src/index.ts +15 -13
- package/src/webrtc-core.ts +83 -26
- package/test/unit/spec/webrtc-core.js +54 -49
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/index.js
CHANGED
|
@@ -16,52 +16,52 @@ _Object$defineProperty(exports, "FacingMode", {
|
|
|
16
16
|
return _constants.FacingMode;
|
|
17
17
|
}
|
|
18
18
|
});
|
|
19
|
-
_Object$defineProperty(exports, "
|
|
19
|
+
_Object$defineProperty(exports, "LocalCameraStream", {
|
|
20
20
|
enumerable: true,
|
|
21
21
|
get: function get() {
|
|
22
|
-
return _webrtcCore.
|
|
22
|
+
return _webrtcCore.LocalCameraStream;
|
|
23
23
|
}
|
|
24
24
|
});
|
|
25
|
-
_Object$defineProperty(exports, "
|
|
25
|
+
_Object$defineProperty(exports, "LocalCameraStreamEventNames", {
|
|
26
26
|
enumerable: true,
|
|
27
27
|
get: function get() {
|
|
28
|
-
return _webrtcCore.
|
|
28
|
+
return _webrtcCore.LocalCameraStreamEventNames;
|
|
29
29
|
}
|
|
30
30
|
});
|
|
31
|
-
_Object$defineProperty(exports, "
|
|
31
|
+
_Object$defineProperty(exports, "LocalDisplayStream", {
|
|
32
32
|
enumerable: true,
|
|
33
33
|
get: function get() {
|
|
34
|
-
return _webrtcCore.
|
|
34
|
+
return _webrtcCore.LocalDisplayStream;
|
|
35
35
|
}
|
|
36
36
|
});
|
|
37
|
-
_Object$defineProperty(exports, "
|
|
37
|
+
_Object$defineProperty(exports, "LocalMicrophoneStream", {
|
|
38
38
|
enumerable: true,
|
|
39
39
|
get: function get() {
|
|
40
|
-
return _webrtcCore.
|
|
40
|
+
return _webrtcCore.LocalMicrophoneStream;
|
|
41
41
|
}
|
|
42
42
|
});
|
|
43
|
-
_Object$defineProperty(exports, "
|
|
43
|
+
_Object$defineProperty(exports, "LocalMicrophoneStreamEventNames", {
|
|
44
44
|
enumerable: true,
|
|
45
45
|
get: function get() {
|
|
46
|
-
return _webrtcCore.
|
|
46
|
+
return _webrtcCore.LocalMicrophoneStreamEventNames;
|
|
47
47
|
}
|
|
48
48
|
});
|
|
49
|
-
_Object$defineProperty(exports, "
|
|
49
|
+
_Object$defineProperty(exports, "LocalStream", {
|
|
50
50
|
enumerable: true,
|
|
51
51
|
get: function get() {
|
|
52
|
-
return _webrtcCore.
|
|
52
|
+
return _webrtcCore.LocalStream;
|
|
53
53
|
}
|
|
54
54
|
});
|
|
55
|
-
_Object$defineProperty(exports, "
|
|
55
|
+
_Object$defineProperty(exports, "LocalStreamEventNames", {
|
|
56
56
|
enumerable: true,
|
|
57
57
|
get: function get() {
|
|
58
|
-
return _webrtcCore.
|
|
58
|
+
return _webrtcCore.LocalStreamEventNames;
|
|
59
59
|
}
|
|
60
60
|
});
|
|
61
|
-
_Object$defineProperty(exports, "
|
|
61
|
+
_Object$defineProperty(exports, "LocalSystemAudioStream", {
|
|
62
62
|
enumerable: true,
|
|
63
63
|
get: function get() {
|
|
64
|
-
return _webrtcCore.
|
|
64
|
+
return _webrtcCore.LocalSystemAudioStream;
|
|
65
65
|
}
|
|
66
66
|
});
|
|
67
67
|
_Object$defineProperty(exports, "NoiseReductionEffect", {
|
|
@@ -76,34 +76,46 @@ _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
|
+
});
|
|
85
|
+
_Object$defineProperty(exports, "StreamEventNames", {
|
|
86
|
+
enumerable: true,
|
|
87
|
+
get: function get() {
|
|
88
|
+
return _webrtcCore.StreamEventNames;
|
|
89
|
+
}
|
|
90
|
+
});
|
|
79
91
|
_Object$defineProperty(exports, "VirtualBackgroundEffect", {
|
|
80
92
|
enumerable: true,
|
|
81
93
|
get: function get() {
|
|
82
94
|
return _webMediaEffects.VirtualBackgroundEffect;
|
|
83
95
|
}
|
|
84
96
|
});
|
|
85
|
-
_Object$defineProperty(exports, "
|
|
97
|
+
_Object$defineProperty(exports, "createCameraStream", {
|
|
86
98
|
enumerable: true,
|
|
87
99
|
get: function get() {
|
|
88
|
-
return _webrtcCore.
|
|
100
|
+
return _webrtcCore.createCameraStream;
|
|
89
101
|
}
|
|
90
102
|
});
|
|
91
|
-
_Object$defineProperty(exports, "
|
|
103
|
+
_Object$defineProperty(exports, "createDisplayStream", {
|
|
92
104
|
enumerable: true,
|
|
93
105
|
get: function get() {
|
|
94
|
-
return _webrtcCore.
|
|
106
|
+
return _webrtcCore.createDisplayStream;
|
|
95
107
|
}
|
|
96
108
|
});
|
|
97
|
-
_Object$defineProperty(exports, "
|
|
109
|
+
_Object$defineProperty(exports, "createDisplayStreamWithAudio", {
|
|
98
110
|
enumerable: true,
|
|
99
111
|
get: function get() {
|
|
100
|
-
return _webrtcCore.
|
|
112
|
+
return _webrtcCore.createDisplayStreamWithAudio;
|
|
101
113
|
}
|
|
102
114
|
});
|
|
103
|
-
_Object$defineProperty(exports, "
|
|
115
|
+
_Object$defineProperty(exports, "createMicrophoneStream", {
|
|
104
116
|
enumerable: true,
|
|
105
117
|
get: function get() {
|
|
106
|
-
return _webrtcCore.
|
|
118
|
+
return _webrtcCore.createMicrophoneStream;
|
|
107
119
|
}
|
|
108
120
|
});
|
|
109
121
|
_Object$defineProperty(exports, "getDevices", {
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export {\n getDevices,\n
|
|
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
|
@@ -6,33 +6,45 @@ var _interopRequireDefault = require("@babel/runtime-corejs2/helpers/interopRequ
|
|
|
6
6
|
_Object$defineProperty(exports, "__esModule", {
|
|
7
7
|
value: true
|
|
8
8
|
});
|
|
9
|
-
exports.
|
|
10
|
-
_Object$defineProperty(exports, "
|
|
9
|
+
exports.LocalCameraStreamEventNames = exports.LocalCameraStream = void 0;
|
|
10
|
+
_Object$defineProperty(exports, "LocalDisplayStream", {
|
|
11
11
|
enumerable: true,
|
|
12
12
|
get: function get() {
|
|
13
|
-
return _internalMediaCore.
|
|
13
|
+
return _internalMediaCore.LocalDisplayStream;
|
|
14
14
|
}
|
|
15
15
|
});
|
|
16
|
-
exports.
|
|
17
|
-
_Object$defineProperty(exports, "
|
|
16
|
+
exports.LocalMicrophoneStreamEventNames = exports.LocalMicrophoneStream = void 0;
|
|
17
|
+
_Object$defineProperty(exports, "LocalStream", {
|
|
18
18
|
enumerable: true,
|
|
19
19
|
get: function get() {
|
|
20
|
-
return _internalMediaCore.
|
|
20
|
+
return _internalMediaCore.LocalStream;
|
|
21
21
|
}
|
|
22
22
|
});
|
|
23
|
-
_Object$defineProperty(exports, "
|
|
23
|
+
_Object$defineProperty(exports, "LocalStreamEventNames", {
|
|
24
24
|
enumerable: true,
|
|
25
25
|
get: function get() {
|
|
26
|
-
return _internalMediaCore.
|
|
26
|
+
return _internalMediaCore.LocalStreamEventNames;
|
|
27
27
|
}
|
|
28
28
|
});
|
|
29
|
-
_Object$defineProperty(exports, "
|
|
29
|
+
_Object$defineProperty(exports, "LocalSystemAudioStream", {
|
|
30
30
|
enumerable: true,
|
|
31
31
|
get: function get() {
|
|
32
|
-
return _internalMediaCore.
|
|
32
|
+
return _internalMediaCore.LocalSystemAudioStream;
|
|
33
33
|
}
|
|
34
34
|
});
|
|
35
|
-
exports
|
|
35
|
+
_Object$defineProperty(exports, "RemoteStream", {
|
|
36
|
+
enumerable: true,
|
|
37
|
+
get: function get() {
|
|
38
|
+
return _internalMediaCore.RemoteStream;
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
_Object$defineProperty(exports, "StreamEventNames", {
|
|
42
|
+
enumerable: true,
|
|
43
|
+
get: function get() {
|
|
44
|
+
return _internalMediaCore.StreamEventNames;
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
exports.createMicrophoneStream = exports.createDisplayStreamWithAudio = exports.createDisplayStream = exports.createCameraStream = void 0;
|
|
36
48
|
_Object$defineProperty(exports, "getDevices", {
|
|
37
49
|
enumerable: true,
|
|
38
50
|
get: function get() {
|
|
@@ -48,34 +60,38 @@ var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime
|
|
|
48
60
|
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/getPrototypeOf"));
|
|
49
61
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/defineProperty"));
|
|
50
62
|
var _internalMediaCore = require("@webex/internal-media-core");
|
|
63
|
+
var _tsEvents = require("@webex/ts-events");
|
|
64
|
+
var _LocalMicrophoneStrea, _LocalCameraStreamEve;
|
|
51
65
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = _Reflect$construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
|
|
52
66
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !_Reflect$construct) return false; if (_Reflect$construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
53
67
|
// server forced the client to be unmuted
|
|
54
68
|
// these events are in addition to WCME events. This will be properly typed once webrtc-core event types inheritance is fixed
|
|
55
|
-
var
|
|
56
|
-
exports.
|
|
57
|
-
(function (
|
|
58
|
-
|
|
59
|
-
})(
|
|
60
|
-
var
|
|
61
|
-
exports.
|
|
62
|
-
(function (
|
|
63
|
-
|
|
64
|
-
})(
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
+
var LocalMicrophoneStreamEventNames; // these events are in addition to WCME events. This will be properly typed once webrtc-core event types inheritance is fixed
|
|
70
|
+
exports.LocalMicrophoneStreamEventNames = LocalMicrophoneStreamEventNames;
|
|
71
|
+
(function (LocalMicrophoneStreamEventNames) {
|
|
72
|
+
LocalMicrophoneStreamEventNames["ServerMuted"] = "muted:byServer";
|
|
73
|
+
})(LocalMicrophoneStreamEventNames || (exports.LocalMicrophoneStreamEventNames = LocalMicrophoneStreamEventNames = {}));
|
|
74
|
+
var LocalCameraStreamEventNames;
|
|
75
|
+
exports.LocalCameraStreamEventNames = LocalCameraStreamEventNames;
|
|
76
|
+
(function (LocalCameraStreamEventNames) {
|
|
77
|
+
LocalCameraStreamEventNames["ServerMuted"] = "muted:byServer";
|
|
78
|
+
})(LocalCameraStreamEventNames || (exports.LocalCameraStreamEventNames = LocalCameraStreamEventNames = {}));
|
|
79
|
+
_LocalMicrophoneStrea = LocalMicrophoneStreamEventNames.ServerMuted;
|
|
80
|
+
var _LocalMicrophoneStream = /*#__PURE__*/function (_WcmeLocalMicrophoneS) {
|
|
81
|
+
(0, _inherits2.default)(_LocalMicrophoneStream, _WcmeLocalMicrophoneS);
|
|
82
|
+
var _super = _createSuper(_LocalMicrophoneStream);
|
|
83
|
+
function _LocalMicrophoneStream() {
|
|
69
84
|
var _this;
|
|
70
|
-
(0, _classCallCheck2.default)(this,
|
|
85
|
+
(0, _classCallCheck2.default)(this, _LocalMicrophoneStream);
|
|
71
86
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
72
87
|
args[_key] = arguments[_key];
|
|
73
88
|
}
|
|
74
89
|
_this = _super.call.apply(_super, [this].concat(args));
|
|
75
90
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "unmuteAllowed", true);
|
|
91
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), _LocalMicrophoneStrea, new _tsEvents.TypedEvent());
|
|
76
92
|
return _this;
|
|
77
93
|
}
|
|
78
|
-
(0, _createClass2.default)(
|
|
94
|
+
(0, _createClass2.default)(_LocalMicrophoneStream, [{
|
|
79
95
|
key: "setUnmuteAllowed",
|
|
80
96
|
value:
|
|
81
97
|
/**
|
|
@@ -101,7 +117,7 @@ var LocalMicrophoneTrack = /*#__PURE__*/function (_WcmeLocalMicrophoneT) {
|
|
|
101
117
|
throw new Error('Unmute is not allowed');
|
|
102
118
|
}
|
|
103
119
|
}
|
|
104
|
-
return (0, _get2.default)((0, _getPrototypeOf2.default)(
|
|
120
|
+
return (0, _get2.default)((0, _getPrototypeOf2.default)(_LocalMicrophoneStream.prototype), "setMuted", this).call(this, muted);
|
|
105
121
|
}
|
|
106
122
|
|
|
107
123
|
/**
|
|
@@ -112,30 +128,42 @@ var LocalMicrophoneTrack = /*#__PURE__*/function (_WcmeLocalMicrophoneT) {
|
|
|
112
128
|
value: function setServerMuted(muted, reason) {
|
|
113
129
|
if (muted !== this.muted) {
|
|
114
130
|
this.setMuted(muted);
|
|
115
|
-
this.emit(
|
|
116
|
-
muted: muted,
|
|
117
|
-
reason: reason
|
|
118
|
-
});
|
|
131
|
+
this[LocalMicrophoneStreamEventNames.ServerMuted].emit(muted, reason);
|
|
119
132
|
}
|
|
120
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
|
+
}
|
|
121
148
|
}]);
|
|
122
|
-
return
|
|
123
|
-
}(_internalMediaCore.
|
|
124
|
-
|
|
125
|
-
var
|
|
126
|
-
(0, _inherits2.default)(
|
|
127
|
-
var _super2 = _createSuper(
|
|
128
|
-
function
|
|
149
|
+
return _LocalMicrophoneStream;
|
|
150
|
+
}(_internalMediaCore.LocalMicrophoneStream);
|
|
151
|
+
_LocalCameraStreamEve = LocalCameraStreamEventNames.ServerMuted;
|
|
152
|
+
var _LocalCameraStream = /*#__PURE__*/function (_WcmeLocalCameraStrea) {
|
|
153
|
+
(0, _inherits2.default)(_LocalCameraStream, _WcmeLocalCameraStrea);
|
|
154
|
+
var _super2 = _createSuper(_LocalCameraStream);
|
|
155
|
+
function _LocalCameraStream() {
|
|
129
156
|
var _this2;
|
|
130
|
-
(0, _classCallCheck2.default)(this,
|
|
157
|
+
(0, _classCallCheck2.default)(this, _LocalCameraStream);
|
|
131
158
|
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
132
159
|
args[_key2] = arguments[_key2];
|
|
133
160
|
}
|
|
134
161
|
_this2 = _super2.call.apply(_super2, [this].concat(args));
|
|
135
162
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this2), "unmuteAllowed", true);
|
|
163
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this2), _LocalCameraStreamEve, new _tsEvents.TypedEvent());
|
|
136
164
|
return _this2;
|
|
137
165
|
}
|
|
138
|
-
(0, _createClass2.default)(
|
|
166
|
+
(0, _createClass2.default)(_LocalCameraStream, [{
|
|
139
167
|
key: "setUnmuteAllowed",
|
|
140
168
|
value:
|
|
141
169
|
/**
|
|
@@ -161,7 +189,7 @@ var LocalCameraTrack = /*#__PURE__*/function (_WcmeLocalCameraTrack) {
|
|
|
161
189
|
throw new Error('Unmute is not allowed');
|
|
162
190
|
}
|
|
163
191
|
}
|
|
164
|
-
return (0, _get2.default)((0, _getPrototypeOf2.default)(
|
|
192
|
+
return (0, _get2.default)((0, _getPrototypeOf2.default)(_LocalCameraStream.prototype), "setMuted", this).call(this, muted);
|
|
165
193
|
}
|
|
166
194
|
|
|
167
195
|
/**
|
|
@@ -172,30 +200,44 @@ var LocalCameraTrack = /*#__PURE__*/function (_WcmeLocalCameraTrack) {
|
|
|
172
200
|
value: function setServerMuted(muted, reason) {
|
|
173
201
|
if (muted !== this.muted) {
|
|
174
202
|
this.setMuted(muted);
|
|
175
|
-
this.emit(
|
|
176
|
-
muted: muted,
|
|
177
|
-
reason: reason
|
|
178
|
-
});
|
|
203
|
+
this[LocalCameraStreamEventNames.ServerMuted].emit(muted, reason);
|
|
179
204
|
}
|
|
180
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
|
+
}
|
|
181
220
|
}]);
|
|
182
|
-
return
|
|
183
|
-
}(_internalMediaCore.
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
return (0, _internalMediaCore.createMicrophoneTrack)(LocalMicrophoneTrack, constraints);
|
|
221
|
+
return _LocalCameraStream;
|
|
222
|
+
}(_internalMediaCore.LocalCameraStream);
|
|
223
|
+
var createMicrophoneStream = function createMicrophoneStream(constraints) {
|
|
224
|
+
return (0, _internalMediaCore.createMicrophoneStream)(LocalMicrophoneStream, constraints);
|
|
187
225
|
};
|
|
188
|
-
exports.
|
|
189
|
-
var
|
|
190
|
-
return (0, _internalMediaCore.
|
|
226
|
+
exports.createMicrophoneStream = createMicrophoneStream;
|
|
227
|
+
var createCameraStream = function createCameraStream(constraints) {
|
|
228
|
+
return (0, _internalMediaCore.createCameraStream)(LocalCameraStream, constraints);
|
|
191
229
|
};
|
|
192
|
-
exports.
|
|
193
|
-
var
|
|
194
|
-
return (0, _internalMediaCore.
|
|
230
|
+
exports.createCameraStream = createCameraStream;
|
|
231
|
+
var createDisplayStream = function createDisplayStream() {
|
|
232
|
+
return (0, _internalMediaCore.createDisplayStream)(_internalMediaCore.LocalDisplayStream);
|
|
195
233
|
};
|
|
196
|
-
exports.
|
|
197
|
-
var
|
|
198
|
-
return (0, _internalMediaCore.
|
|
234
|
+
exports.createDisplayStream = createDisplayStream;
|
|
235
|
+
var createDisplayStreamWithAudio = function createDisplayStreamWithAudio() {
|
|
236
|
+
return (0, _internalMediaCore.createDisplayStreamWithAudio)(_internalMediaCore.LocalDisplayStream, _internalMediaCore.LocalSystemAudioStream);
|
|
199
237
|
};
|
|
200
|
-
exports.
|
|
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;
|
|
201
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 & WithEventsDumm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",
|
|
5
5
|
"license": "Cisco EULA (https://www.cisco.com/c/en/us/products/end-user-license-agreement.html)",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -14,8 +14,9 @@
|
|
|
14
14
|
"node": ">=16"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@webex/internal-media-core": "
|
|
18
|
-
"@webex/
|
|
17
|
+
"@webex/internal-media-core": "2.0.3",
|
|
18
|
+
"@webex/ts-events": "^1.1.0",
|
|
19
|
+
"@webex/web-media-effects": "^2.13.6"
|
|
19
20
|
},
|
|
20
21
|
"browserify": {
|
|
21
22
|
"transform": [
|
|
@@ -24,8 +25,8 @@
|
|
|
24
25
|
]
|
|
25
26
|
},
|
|
26
27
|
"devDependencies": {
|
|
27
|
-
"@webex/test-helper-chai": "3.0.0-beta.
|
|
28
|
-
"@webex/test-helper-mock-webex": "3.0.0-beta.
|
|
28
|
+
"@webex/test-helper-chai": "3.0.0-beta.252",
|
|
29
|
+
"@webex/test-helper-mock-webex": "3.0.0-beta.252",
|
|
29
30
|
"sinon": "^9.2.4"
|
|
30
31
|
}
|
|
31
32
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
export {
|
|
2
2
|
getDevices,
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
LocalStream,
|
|
4
|
+
LocalDisplayStream,
|
|
5
|
+
LocalSystemAudioStream,
|
|
6
|
+
LocalStreamEventNames,
|
|
7
|
+
StreamEventNames,
|
|
8
|
+
RemoteStream,
|
|
8
9
|
type ServerMuteReason,
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
10
|
+
LocalMicrophoneStreamEventNames,
|
|
11
|
+
LocalCameraStreamEventNames,
|
|
12
|
+
LocalMicrophoneStream,
|
|
13
|
+
LocalCameraStream,
|
|
14
|
+
createMicrophoneStream,
|
|
15
|
+
createCameraStream,
|
|
16
|
+
createDisplayStream,
|
|
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
|
@@ -3,24 +3,27 @@
|
|
|
3
3
|
/* eslint-disable require-jsdoc */
|
|
4
4
|
import {
|
|
5
5
|
AudioDeviceConstraints,
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
6
|
+
createCameraStream as wcmeCreateCameraStream,
|
|
7
|
+
createDisplayStream as wcmeCreateDisplayStream,
|
|
8
|
+
createDisplayStreamWithAudio as wcmeCreateDisplayStreamWithAudio,
|
|
9
|
+
createMicrophoneStream as wcmeCreateMicrophoneStream,
|
|
10
|
+
LocalDisplayStream,
|
|
11
|
+
LocalSystemAudioStream,
|
|
12
|
+
LocalMicrophoneStream as WcmeLocalMicrophoneStream,
|
|
13
|
+
LocalCameraStream as WcmeLocalCameraStream,
|
|
14
14
|
VideoDeviceConstraints,
|
|
15
15
|
} from '@webex/internal-media-core';
|
|
16
|
+
import {AddEvents, TypedEvent, WithEventsDummyType} from '@webex/ts-events';
|
|
16
17
|
|
|
17
18
|
export {
|
|
18
19
|
getDevices,
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
LocalStream,
|
|
21
|
+
LocalDisplayStream,
|
|
22
|
+
LocalSystemAudioStream,
|
|
23
|
+
LocalStreamEventNames,
|
|
24
|
+
StreamEventNames,
|
|
25
|
+
RemoteStream,
|
|
26
|
+
type VideoContentHint,
|
|
24
27
|
} from '@webex/internal-media-core';
|
|
25
28
|
|
|
26
29
|
export type ServerMuteReason =
|
|
@@ -29,18 +32,34 @@ export type ServerMuteReason =
|
|
|
29
32
|
| 'localUnmuteRequired'; // server forced the client to be unmuted
|
|
30
33
|
|
|
31
34
|
// these events are in addition to WCME events. This will be properly typed once webrtc-core event types inheritance is fixed
|
|
32
|
-
export enum
|
|
35
|
+
export enum LocalMicrophoneStreamEventNames {
|
|
33
36
|
ServerMuted = 'muted:byServer',
|
|
34
37
|
}
|
|
35
38
|
|
|
36
39
|
// these events are in addition to WCME events. This will be properly typed once webrtc-core event types inheritance is fixed
|
|
37
|
-
export enum
|
|
40
|
+
export enum LocalCameraStreamEventNames {
|
|
38
41
|
ServerMuted = 'muted:byServer',
|
|
39
42
|
}
|
|
40
43
|
|
|
41
|
-
|
|
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 {
|
|
42
57
|
private unmuteAllowed = true;
|
|
43
58
|
|
|
59
|
+
[LocalMicrophoneStreamEventNames.ServerMuted] = new TypedEvent<
|
|
60
|
+
(muted: boolean, reason: ServerMuteReason) => void
|
|
61
|
+
>();
|
|
62
|
+
|
|
44
63
|
/**
|
|
45
64
|
* @internal
|
|
46
65
|
*/
|
|
@@ -71,14 +90,28 @@ export class LocalMicrophoneTrack extends WcmeLocalMicrophoneTrack {
|
|
|
71
90
|
setServerMuted(muted: boolean, reason: ServerMuteReason) {
|
|
72
91
|
if (muted !== this.muted) {
|
|
73
92
|
this.setMuted(muted);
|
|
74
|
-
this.emit(
|
|
93
|
+
this[LocalMicrophoneStreamEventNames.ServerMuted].emit(muted, reason);
|
|
75
94
|
}
|
|
76
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
|
+
}
|
|
77
106
|
}
|
|
78
107
|
|
|
79
|
-
|
|
108
|
+
class _LocalCameraStream extends WcmeLocalCameraStream {
|
|
80
109
|
private unmuteAllowed = true;
|
|
81
110
|
|
|
111
|
+
[LocalCameraStreamEventNames.ServerMuted] = new TypedEvent<
|
|
112
|
+
(muted: boolean, reason: ServerMuteReason) => void
|
|
113
|
+
>();
|
|
114
|
+
|
|
82
115
|
/**
|
|
83
116
|
* @internal
|
|
84
117
|
*/
|
|
@@ -109,18 +142,42 @@ export class LocalCameraTrack extends WcmeLocalCameraTrack {
|
|
|
109
142
|
setServerMuted(muted: boolean, reason: ServerMuteReason) {
|
|
110
143
|
if (muted !== this.muted) {
|
|
111
144
|
this.setMuted(muted);
|
|
112
|
-
this.emit(
|
|
145
|
+
this[LocalCameraStreamEventNames.ServerMuted].emit(muted, reason);
|
|
113
146
|
}
|
|
114
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
|
+
}
|
|
115
158
|
}
|
|
116
159
|
|
|
117
|
-
export const
|
|
118
|
-
|
|
160
|
+
export const createMicrophoneStream = (constraints?: AudioDeviceConstraints) =>
|
|
161
|
+
wcmeCreateMicrophoneStream(LocalMicrophoneStream, constraints);
|
|
162
|
+
|
|
163
|
+
export const createCameraStream = (constraints?: VideoDeviceConstraints) =>
|
|
164
|
+
wcmeCreateCameraStream(LocalCameraStream, constraints);
|
|
165
|
+
|
|
166
|
+
export const createDisplayStream = () => wcmeCreateDisplayStream(LocalDisplayStream);
|
|
167
|
+
|
|
168
|
+
export const createDisplayStreamWithAudio = () =>
|
|
169
|
+
wcmeCreateDisplayStreamWithAudio(LocalDisplayStream, LocalSystemAudioStream);
|
|
170
|
+
|
|
171
|
+
export const LocalMicrophoneStream = AddEvents<
|
|
172
|
+
typeof _LocalMicrophoneStream,
|
|
173
|
+
LocalMicrophoneStreamEvents
|
|
174
|
+
>(_LocalMicrophoneStream);
|
|
119
175
|
|
|
120
|
-
export
|
|
121
|
-
|
|
176
|
+
export type LocalMicrophoneStream = _LocalMicrophoneStream &
|
|
177
|
+
WithEventsDummyType<LocalMicrophoneStreamEvents>;
|
|
122
178
|
|
|
123
|
-
export const
|
|
179
|
+
export const LocalCameraStream = AddEvents<typeof _LocalCameraStream, LocalCameraStreamEvents>(
|
|
180
|
+
_LocalCameraStream
|
|
181
|
+
);
|
|
124
182
|
|
|
125
|
-
export
|
|
126
|
-
wcmeCreateDisplayTrackWithAudio(LocalDisplayTrack, LocalSystemAudioTrack);
|
|
183
|
+
export type LocalCameraStream = _LocalCameraStream & WithEventsDummyType<LocalCameraStreamEvents>;
|
|
@@ -1,35 +1,35 @@
|
|
|
1
1
|
import {assert, expect} from '@webex/test-helper-chai';
|
|
2
2
|
import sinon from 'sinon';
|
|
3
3
|
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
4
|
+
LocalCameraStream,
|
|
5
|
+
LocalMicrophoneStream,
|
|
6
|
+
LocalMicrophoneStreamEventNames,
|
|
7
|
+
LocalCameraStreamEventNames,
|
|
8
|
+
LocalDisplayStream,
|
|
9
|
+
LocalSystemAudioStream,
|
|
10
|
+
createCameraStream,
|
|
11
|
+
createMicrophoneStream,
|
|
12
|
+
createDisplayStream,
|
|
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', () => {
|
|
19
19
|
const classesToTest = [
|
|
20
20
|
{
|
|
21
|
-
className:
|
|
22
|
-
title: '
|
|
23
|
-
event:
|
|
24
|
-
createFn:
|
|
25
|
-
spyFn: '
|
|
21
|
+
className: LocalCameraStream,
|
|
22
|
+
title: 'LocalCameraStream',
|
|
23
|
+
event: LocalCameraStreamEventNames,
|
|
24
|
+
createFn: createCameraStream,
|
|
25
|
+
spyFn: 'createCameraStream',
|
|
26
26
|
},
|
|
27
27
|
{
|
|
28
|
-
className:
|
|
29
|
-
title: '
|
|
30
|
-
event:
|
|
31
|
-
createFn:
|
|
32
|
-
spyFn: '
|
|
28
|
+
className: LocalMicrophoneStream,
|
|
29
|
+
title: 'LocalMicrophoneStream',
|
|
30
|
+
event: LocalMicrophoneStreamEventNames,
|
|
31
|
+
createFn: createMicrophoneStream,
|
|
32
|
+
spyFn: 'createMicrophoneStream',
|
|
33
33
|
},
|
|
34
34
|
];
|
|
35
35
|
|
|
@@ -41,53 +41,58 @@ describe('media-helpers', () => {
|
|
|
41
41
|
label: 'fake track',
|
|
42
42
|
id: 'fake track id',
|
|
43
43
|
enabled: true,
|
|
44
|
+
addEventListener: sinon.stub(),
|
|
44
45
|
},
|
|
45
46
|
]),
|
|
46
47
|
};
|
|
47
|
-
const
|
|
48
|
+
const stream = new className(fakeStream);
|
|
48
49
|
|
|
49
50
|
afterEach(() => {
|
|
50
51
|
sinon.restore();
|
|
51
52
|
});
|
|
52
53
|
|
|
53
54
|
it('by default allows unmuting', async () => {
|
|
54
|
-
assert.equal(
|
|
55
|
-
await
|
|
55
|
+
assert.equal(stream.isUnmuteAllowed(), true);
|
|
56
|
+
await stream.setMuted(false);
|
|
56
57
|
});
|
|
57
58
|
|
|
58
59
|
it('rejects setMute(false) if unmute is not allowed', async () => {
|
|
59
|
-
|
|
60
|
+
stream.setUnmuteAllowed(false);
|
|
60
61
|
|
|
61
|
-
assert.equal(
|
|
62
|
-
const fn = () =>
|
|
62
|
+
assert.equal(stream.isUnmuteAllowed(), false);
|
|
63
|
+
const fn = () => stream.setMuted(false);
|
|
63
64
|
expect(fn).to.throw(/Unmute is not allowed/);
|
|
64
65
|
});
|
|
65
66
|
|
|
66
67
|
it('resolves setMute(false) if unmute is allowed', async () => {
|
|
67
|
-
|
|
68
|
+
stream.setUnmuteAllowed(true);
|
|
68
69
|
|
|
69
|
-
assert.equal(
|
|
70
|
-
await
|
|
70
|
+
assert.equal(stream.isUnmuteAllowed(), true);
|
|
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();
|
|
76
81
|
});
|
|
77
82
|
|
|
78
83
|
const checkSetServerMuted = async (startMute, setMute, expectedCalled) => {
|
|
79
|
-
await
|
|
84
|
+
await stream.setMuted(startMute);
|
|
80
85
|
|
|
81
|
-
assert.equal(
|
|
86
|
+
assert.equal(stream.muted, startMute);
|
|
82
87
|
|
|
83
88
|
const handler = sinon.fake();
|
|
84
|
-
|
|
89
|
+
stream.on(event.ServerMuted, handler);
|
|
85
90
|
|
|
86
|
-
await
|
|
91
|
+
await stream.setServerMuted(setMute, 'remotelyMuted');
|
|
87
92
|
|
|
88
|
-
assert.equal(
|
|
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
|
}
|
|
@@ -110,11 +115,11 @@ describe('media-helpers', () => {
|
|
|
110
115
|
});
|
|
111
116
|
});
|
|
112
117
|
|
|
113
|
-
describe('#
|
|
118
|
+
describe('#wcmeCreateMicrophoneStream, #wcmeCreateCameraStream', () => {
|
|
114
119
|
it('checks creating tracks', async () => {
|
|
115
|
-
const constraints = {
|
|
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');
|
|
@@ -124,21 +129,21 @@ describe('media-helpers', () => {
|
|
|
124
129
|
})
|
|
125
130
|
);
|
|
126
131
|
|
|
127
|
-
describe('
|
|
128
|
-
it('checks
|
|
129
|
-
const spy = sinon.stub(
|
|
130
|
-
const result =
|
|
132
|
+
describe('createDisplayStream', () => {
|
|
133
|
+
it('checks createDisplayStream', async () => {
|
|
134
|
+
const spy = sinon.stub(wcmestreams, 'createDisplayStream').returns('something');
|
|
135
|
+
const result = createDisplayStream();
|
|
131
136
|
assert.equal(result, 'something');
|
|
132
|
-
assert.calledOnceWithExactly(spy,
|
|
137
|
+
assert.calledOnceWithExactly(spy, LocalDisplayStream);
|
|
133
138
|
});
|
|
134
139
|
});
|
|
135
140
|
|
|
136
|
-
describe('
|
|
137
|
-
it('checks
|
|
138
|
-
const spy = sinon.stub(
|
|
139
|
-
const result =
|
|
141
|
+
describe('createDisplayStreamWithAudio', () => {
|
|
142
|
+
it('checks createDisplayStreamWithAudio', async () => {
|
|
143
|
+
const spy = sinon.stub(wcmestreams, 'createDisplayStreamWithAudio').returns('something');
|
|
144
|
+
const result = createDisplayStreamWithAudio();
|
|
140
145
|
assert.equal(result, 'something');
|
|
141
|
-
assert.calledOnceWithExactly(spy,
|
|
146
|
+
assert.calledOnceWithExactly(spy, LocalDisplayStream, LocalSystemAudioStream);
|
|
142
147
|
});
|
|
143
148
|
});
|
|
144
149
|
});
|