@webex/media-helpers 3.0.0-bnr.5 → 3.0.0-next.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/README.md +72 -0
- package/babel.config.json +13 -0
- package/dist/constants.d.ts +13 -0
- package/dist/constants.js +59 -0
- package/dist/constants.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +76 -20
- package/dist/index.js.map +1 -1
- package/dist/webrtc-core.d.ts +48 -0
- package/dist/webrtc-core.js +86 -58
- package/dist/webrtc-core.js.map +1 -1
- package/package.json +22 -5
- package/src/constants.ts +29 -0
- package/src/index.ts +22 -11
- package/src/webrtc-core.ts +40 -23
- package/test/unit/spec/webrtc-core.js +116 -86
- package/tsconfig.json +6 -0
package/README.md
CHANGED
|
@@ -21,6 +21,78 @@ npm install --save @webex/media-helpers
|
|
|
21
21
|
|
|
22
22
|
## Usage
|
|
23
23
|
|
|
24
|
+
### Effects
|
|
25
|
+
There are two effects included in this package:
|
|
26
|
+
|
|
27
|
+
Virtual background (e.g., blur, image replacement, video replacement)
|
|
28
|
+
Noise reduction (e.g., background noise removal)
|
|
29
|
+
|
|
30
|
+
#### Virtual background
|
|
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
|
+
|
|
33
|
+
**Applying the effect**
|
|
34
|
+
1. Create a new camera track instance by using LocalCameraTrack() method.
|
|
35
|
+
2. Create a VirtualBackgroundEffect instance by passing appropriate constraints.
|
|
36
|
+
3. Use addEffect() method on cameraTrack to apply effect on it.
|
|
37
|
+
4. Enable the effect after adding it to cameraTrack using enable() method available on effect. Effect will be enabled on cameraTrack.
|
|
38
|
+
|
|
39
|
+
```javascript
|
|
40
|
+
import {LocalCameraTrack, VirtualBackgroundEffect} from '@webex/media-helpers';
|
|
41
|
+
|
|
42
|
+
// Create a new video stream by a getting user's video media.
|
|
43
|
+
const stream = await navigator.mediaDevices.getUserMedia({ video: { width, height } });
|
|
44
|
+
|
|
45
|
+
const videoTrackFromLocalStream = stream.getVideoTracks()[0];
|
|
46
|
+
|
|
47
|
+
const cameraTrack = new LocalCameraTrack(new MediaStream([videoTrackFromLocalStream]));
|
|
48
|
+
|
|
49
|
+
// Create the effect.
|
|
50
|
+
const effect = new VirtualBackgroundEffect({
|
|
51
|
+
authToken: '<encoded-string>',
|
|
52
|
+
mode: `BLUR`,
|
|
53
|
+
blurStrength: `STRONG`,
|
|
54
|
+
quality: `LOW`,
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
// add the effect on the input camera track.
|
|
58
|
+
await cameraTrack.addEffect("background-blur", effect);
|
|
59
|
+
|
|
60
|
+
//enable the effect once it is added to the track
|
|
61
|
+
await effect.enable()
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
#### Noise reduction
|
|
65
|
+
The noise reduction effect removes background noise from an audio stream to provide clear audio for calling.
|
|
66
|
+
|
|
67
|
+
**Applying the effect**
|
|
68
|
+
1. Create a new microphone track instance by using LocalMicrophoneTrack() method.
|
|
69
|
+
2. Create a NoiseReductionEffect instance by passing appropriate constraints.
|
|
70
|
+
3. Use addEffect() method on microphoneTrack to apply effect on it.
|
|
71
|
+
4. Enable the effect after adding it to microphoneTrack using enable() method available on effect. Effect will be enabled on microphoneTrack.
|
|
72
|
+
|
|
73
|
+
```javascript
|
|
74
|
+
import {LocalMicrophoneTrack, NoiseReductionEffect} from '@webex/media-helpers';
|
|
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];
|
|
80
|
+
|
|
81
|
+
const microphoneTrack = new LocalMicrophoneTrack(new MediaStream([audioTrackFromLocalStream]));
|
|
82
|
+
|
|
83
|
+
// Create the effect.
|
|
84
|
+
const effect = new NoiseReductionEffect({
|
|
85
|
+
authToken: '<encoded-string>',
|
|
86
|
+
mode: 'WORKLET', // or 'LEGACY'
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
// add the effect on microphone track.
|
|
90
|
+
await microphoneTrack.addEffect("background-noise-removal", effect);
|
|
91
|
+
|
|
92
|
+
//enable the effect once it is added to the track
|
|
93
|
+
await effect.enable()
|
|
94
|
+
```
|
|
95
|
+
|
|
24
96
|
## Maintainers
|
|
25
97
|
|
|
26
98
|
This package is maintained by [Cisco Webex for Developers](https://developer.webex.com/).
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { VideoDeviceConstraints } from '@webex/internal-media-core';
|
|
2
|
+
export declare enum FacingMode {
|
|
3
|
+
user = "user",
|
|
4
|
+
environment = "environment"
|
|
5
|
+
}
|
|
6
|
+
export declare enum DisplaySurface {
|
|
7
|
+
browser = "browser",
|
|
8
|
+
monitor = "monitor",
|
|
9
|
+
window = "window"
|
|
10
|
+
}
|
|
11
|
+
export declare const PresetCameraConstraints: {
|
|
12
|
+
[key: string]: VideoDeviceConstraints;
|
|
13
|
+
};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _Object$defineProperty = require("@babel/runtime-corejs2/core-js/object/define-property");
|
|
4
|
+
_Object$defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.PresetCameraConstraints = exports.FacingMode = exports.DisplaySurface = void 0;
|
|
8
|
+
var FacingMode; // can be used later on when we add constraints in create display track
|
|
9
|
+
exports.FacingMode = FacingMode;
|
|
10
|
+
(function (FacingMode) {
|
|
11
|
+
FacingMode["user"] = "user";
|
|
12
|
+
FacingMode["environment"] = "environment";
|
|
13
|
+
})(FacingMode || (exports.FacingMode = FacingMode = {}));
|
|
14
|
+
var DisplaySurface;
|
|
15
|
+
exports.DisplaySurface = DisplaySurface;
|
|
16
|
+
(function (DisplaySurface) {
|
|
17
|
+
DisplaySurface["browser"] = "browser";
|
|
18
|
+
DisplaySurface["monitor"] = "monitor";
|
|
19
|
+
DisplaySurface["window"] = "window";
|
|
20
|
+
})(DisplaySurface || (exports.DisplaySurface = DisplaySurface = {}));
|
|
21
|
+
var PresetCameraConstraints = {
|
|
22
|
+
'1080p': {
|
|
23
|
+
frameRate: 30,
|
|
24
|
+
width: 1920,
|
|
25
|
+
height: 1080
|
|
26
|
+
},
|
|
27
|
+
'720p': {
|
|
28
|
+
frameRate: 30,
|
|
29
|
+
width: 1280,
|
|
30
|
+
height: 720
|
|
31
|
+
},
|
|
32
|
+
'480p': {
|
|
33
|
+
frameRate: 30,
|
|
34
|
+
width: 640,
|
|
35
|
+
height: 480
|
|
36
|
+
},
|
|
37
|
+
'360p': {
|
|
38
|
+
frameRate: 30,
|
|
39
|
+
width: 640,
|
|
40
|
+
height: 360
|
|
41
|
+
},
|
|
42
|
+
'240p': {
|
|
43
|
+
frameRate: 30,
|
|
44
|
+
width: 320,
|
|
45
|
+
height: 240
|
|
46
|
+
},
|
|
47
|
+
'180p': {
|
|
48
|
+
frameRate: 30,
|
|
49
|
+
width: 320,
|
|
50
|
+
height: 180
|
|
51
|
+
},
|
|
52
|
+
'120p': {
|
|
53
|
+
frameRate: 30,
|
|
54
|
+
width: 160,
|
|
55
|
+
height: 120
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
exports.PresetCameraConstraints = PresetCameraConstraints;
|
|
59
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["FacingMode","exports","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;AAAAC,OAAA,CAAAD,UAAA,GAAAA,UAAA;AAAA,WALYA,UAAU;EAAVA,UAAU;EAAVA,UAAU;AAAA,GAAVA,UAAU,KAAAC,OAAA,CAAAD,UAAA,GAAVA,UAAU;AAAA,IAMVE,cAAc;AAAAD,OAAA,CAAAC,cAAA,GAAAA,cAAA;AAAA,WAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;AAAA,GAAdA,cAAc,KAAAD,OAAA,CAAAC,cAAA,GAAdA,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;AAACL,OAAA,CAAAE,uBAAA,GAAAA,uBAAA"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { getDevices, LocalStream, LocalDisplayStream, LocalSystemAudioStream, LocalStreamEventNames, StreamEventNames, type ServerMuteReason, LocalMicrophoneStreamEventNames, LocalCameraStreamEventNames, LocalMicrophoneStream, LocalCameraStream, createMicrophoneStream, createCameraStream, createDisplayStream, createDisplayStreamWithAudio, } from './webrtc-core';
|
|
2
|
+
export { NoiseReductionEffect, VirtualBackgroundEffect } from '@webex/web-media-effects';
|
|
3
|
+
export type { NoiseReductionEffectOptions, VirtualBackgroundEffectOptions, } from '@webex/web-media-effects';
|
|
4
|
+
export { FacingMode, DisplaySurface, PresetCameraConstraints } from './constants';
|
package/dist/index.js
CHANGED
|
@@ -4,65 +4,121 @@ var _Object$defineProperty = require("@babel/runtime-corejs2/core-js/object/defi
|
|
|
4
4
|
_Object$defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
_Object$defineProperty(exports, "
|
|
7
|
+
_Object$defineProperty(exports, "DisplaySurface", {
|
|
8
8
|
enumerable: true,
|
|
9
9
|
get: function get() {
|
|
10
|
-
return
|
|
10
|
+
return _constants.DisplaySurface;
|
|
11
11
|
}
|
|
12
12
|
});
|
|
13
|
-
_Object$defineProperty(exports, "
|
|
13
|
+
_Object$defineProperty(exports, "FacingMode", {
|
|
14
14
|
enumerable: true,
|
|
15
15
|
get: function get() {
|
|
16
|
-
return
|
|
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
|
+
}
|
|
66
|
+
});
|
|
67
|
+
_Object$defineProperty(exports, "NoiseReductionEffect", {
|
|
68
|
+
enumerable: true,
|
|
69
|
+
get: function get() {
|
|
70
|
+
return _webMediaEffects.NoiseReductionEffect;
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
_Object$defineProperty(exports, "PresetCameraConstraints", {
|
|
74
|
+
enumerable: true,
|
|
75
|
+
get: function get() {
|
|
76
|
+
return _constants.PresetCameraConstraints;
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
_Object$defineProperty(exports, "StreamEventNames", {
|
|
80
|
+
enumerable: true,
|
|
81
|
+
get: function get() {
|
|
82
|
+
return _webrtcCore.StreamEventNames;
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
_Object$defineProperty(exports, "VirtualBackgroundEffect", {
|
|
86
|
+
enumerable: true,
|
|
87
|
+
get: function get() {
|
|
88
|
+
return _webMediaEffects.VirtualBackgroundEffect;
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
_Object$defineProperty(exports, "createCameraStream", {
|
|
92
|
+
enumerable: true,
|
|
93
|
+
get: function get() {
|
|
94
|
+
return _webrtcCore.createCameraStream;
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
_Object$defineProperty(exports, "createDisplayStream", {
|
|
98
|
+
enumerable: true,
|
|
99
|
+
get: function get() {
|
|
100
|
+
return _webrtcCore.createDisplayStream;
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
_Object$defineProperty(exports, "createDisplayStreamWithAudio", {
|
|
104
|
+
enumerable: true,
|
|
105
|
+
get: function get() {
|
|
106
|
+
return _webrtcCore.createDisplayStreamWithAudio;
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
_Object$defineProperty(exports, "createMicrophoneStream", {
|
|
110
|
+
enumerable: true,
|
|
111
|
+
get: function get() {
|
|
112
|
+
return _webrtcCore.createMicrophoneStream;
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
_Object$defineProperty(exports, "getDevices", {
|
|
116
|
+
enumerable: true,
|
|
117
|
+
get: function get() {
|
|
118
|
+
return _webrtcCore.getDevices;
|
|
65
119
|
}
|
|
66
120
|
});
|
|
67
121
|
var _webrtcCore = require("./webrtc-core");
|
|
122
|
+
var _webMediaEffects = require("@webex/web-media-effects");
|
|
123
|
+
var _constants = require("./constants");
|
|
68
124
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export {\n
|
|
1
|
+
{"version":3,"names":["_webrtcCore","require","_webMediaEffects","_constants"],"sources":["index.ts"],"sourcesContent":["export {\n getDevices,\n LocalStream,\n LocalDisplayStream,\n LocalSystemAudioStream,\n LocalStreamEventNames,\n StreamEventNames,\n type ServerMuteReason,\n LocalMicrophoneStreamEventNames,\n LocalCameraStreamEventNames,\n LocalMicrophoneStream,\n LocalCameraStream,\n createMicrophoneStream,\n createCameraStream,\n createDisplayStream,\n createDisplayStreamWithAudio,\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,IAAAA,WAAA,GAAAC,OAAA;AAkBA,IAAAC,gBAAA,GAAAD,OAAA;AAMA,IAAAE,UAAA,GAAAF,OAAA"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { AudioDeviceConstraints, LocalDisplayStream, LocalSystemAudioStream, LocalMicrophoneStream as WcmeLocalMicrophoneStream, LocalCameraStream as WcmeLocalCameraStream, VideoDeviceConstraints } from '@webex/internal-media-core';
|
|
2
|
+
import { TypedEvent } from '@webex/ts-events';
|
|
3
|
+
export { getDevices, LocalStream, LocalDisplayStream, LocalSystemAudioStream, LocalStreamEventNames, StreamEventNames, RemoteStream, } from '@webex/internal-media-core';
|
|
4
|
+
export type ServerMuteReason = 'remotelyMuted' | 'clientRequestFailed' | 'localUnmuteRequired';
|
|
5
|
+
export declare enum LocalMicrophoneStreamEventNames {
|
|
6
|
+
ServerMuted = "muted:byServer"
|
|
7
|
+
}
|
|
8
|
+
export declare enum LocalCameraStreamEventNames {
|
|
9
|
+
ServerMuted = "muted:byServer"
|
|
10
|
+
}
|
|
11
|
+
export declare class LocalMicrophoneStream extends WcmeLocalMicrophoneStream {
|
|
12
|
+
private unmuteAllowed;
|
|
13
|
+
[LocalMicrophoneStreamEventNames.ServerMuted]: TypedEvent<(muted: boolean, reason: ServerMuteReason) => void>;
|
|
14
|
+
/**
|
|
15
|
+
* @internal
|
|
16
|
+
*/
|
|
17
|
+
setUnmuteAllowed(allowed: any): void;
|
|
18
|
+
/**
|
|
19
|
+
* @returns true if user is allowed to unmute the Stream, false otherwise
|
|
20
|
+
*/
|
|
21
|
+
isUnmuteAllowed(): boolean;
|
|
22
|
+
setMuted(muted: boolean): void;
|
|
23
|
+
/**
|
|
24
|
+
* @internal
|
|
25
|
+
*/
|
|
26
|
+
setServerMuted(muted: boolean, reason: ServerMuteReason): void;
|
|
27
|
+
}
|
|
28
|
+
export declare class LocalCameraStream extends WcmeLocalCameraStream {
|
|
29
|
+
private unmuteAllowed;
|
|
30
|
+
[LocalCameraStreamEventNames.ServerMuted]: TypedEvent<(muted: boolean, reason: ServerMuteReason) => void>;
|
|
31
|
+
/**
|
|
32
|
+
* @internal
|
|
33
|
+
*/
|
|
34
|
+
setUnmuteAllowed(allowed: any): void;
|
|
35
|
+
/**
|
|
36
|
+
* @returns true if user is allowed to unmute the Stream, false otherwise
|
|
37
|
+
*/
|
|
38
|
+
isUnmuteAllowed(): boolean;
|
|
39
|
+
setMuted(muted: boolean): void;
|
|
40
|
+
/**
|
|
41
|
+
* @internal
|
|
42
|
+
*/
|
|
43
|
+
setServerMuted(muted: boolean, reason: ServerMuteReason): void;
|
|
44
|
+
}
|
|
45
|
+
export declare const createMicrophoneStream: (constraints?: AudioDeviceConstraints) => Promise<LocalMicrophoneStream>;
|
|
46
|
+
export declare const createCameraStream: (constraints?: VideoDeviceConstraints) => Promise<LocalCameraStream>;
|
|
47
|
+
export declare const createDisplayStream: () => Promise<LocalDisplayStream>;
|
|
48
|
+
export declare const createDisplayStreamWithAudio: () => Promise<[LocalDisplayStream, LocalSystemAudioStream]>;
|
package/dist/webrtc-core.js
CHANGED
|
@@ -6,27 +6,51 @@ 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
|
+
}
|
|
28
|
+
});
|
|
29
|
+
_Object$defineProperty(exports, "LocalSystemAudioStream", {
|
|
30
|
+
enumerable: true,
|
|
31
|
+
get: function get() {
|
|
32
|
+
return _internalMediaCore.LocalSystemAudioStream;
|
|
33
|
+
}
|
|
34
|
+
});
|
|
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;
|
|
48
|
+
_Object$defineProperty(exports, "getDevices", {
|
|
49
|
+
enumerable: true,
|
|
50
|
+
get: function get() {
|
|
51
|
+
return _internalMediaCore.getDevices;
|
|
27
52
|
}
|
|
28
53
|
});
|
|
29
|
-
exports.createMicrophoneTrack = exports.createDisplayTrack = exports.createCameraTrack = void 0;
|
|
30
54
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/classCallCheck"));
|
|
31
55
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/createClass"));
|
|
32
56
|
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/assertThisInitialized"));
|
|
@@ -36,34 +60,38 @@ var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime
|
|
|
36
60
|
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/getPrototypeOf"));
|
|
37
61
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/defineProperty"));
|
|
38
62
|
var _internalMediaCore = require("@webex/internal-media-core");
|
|
63
|
+
var _tsEvents = require("@webex/ts-events");
|
|
64
|
+
var _LocalMicrophoneStrea, _LocalCameraStreamEve;
|
|
39
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); }; }
|
|
40
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; } }
|
|
41
67
|
// server forced the client to be unmuted
|
|
42
68
|
// these events are in addition to WCME events. This will be properly typed once webrtc-core event types inheritance is fixed
|
|
43
|
-
var
|
|
44
|
-
exports.
|
|
45
|
-
(function (
|
|
46
|
-
|
|
47
|
-
})(
|
|
48
|
-
var
|
|
49
|
-
exports.
|
|
50
|
-
(function (
|
|
51
|
-
|
|
52
|
-
})(
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
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() {
|
|
57
84
|
var _this;
|
|
58
|
-
(0, _classCallCheck2.default)(this,
|
|
85
|
+
(0, _classCallCheck2.default)(this, LocalMicrophoneStream);
|
|
59
86
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
60
87
|
args[_key] = arguments[_key];
|
|
61
88
|
}
|
|
62
89
|
_this = _super.call.apply(_super, [this].concat(args));
|
|
63
90
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "unmuteAllowed", true);
|
|
91
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), _LocalMicrophoneStrea, new _tsEvents.TypedEvent());
|
|
64
92
|
return _this;
|
|
65
93
|
}
|
|
66
|
-
(0, _createClass2.default)(
|
|
94
|
+
(0, _createClass2.default)(LocalMicrophoneStream, [{
|
|
67
95
|
key: "setUnmuteAllowed",
|
|
68
96
|
value:
|
|
69
97
|
/**
|
|
@@ -74,7 +102,7 @@ var LocalMicrophoneTrack = /*#__PURE__*/function (_WcmeLocalMicrophoneT) {
|
|
|
74
102
|
}
|
|
75
103
|
|
|
76
104
|
/**
|
|
77
|
-
* @returns true if user is allowed to unmute the
|
|
105
|
+
* @returns true if user is allowed to unmute the Stream, false otherwise
|
|
78
106
|
*/
|
|
79
107
|
}, {
|
|
80
108
|
key: "isUnmuteAllowed",
|
|
@@ -89,7 +117,7 @@ var LocalMicrophoneTrack = /*#__PURE__*/function (_WcmeLocalMicrophoneT) {
|
|
|
89
117
|
throw new Error('Unmute is not allowed');
|
|
90
118
|
}
|
|
91
119
|
}
|
|
92
|
-
return (0, _get2.default)((0, _getPrototypeOf2.default)(
|
|
120
|
+
return (0, _get2.default)((0, _getPrototypeOf2.default)(LocalMicrophoneStream.prototype), "setMuted", this).call(this, muted);
|
|
93
121
|
}
|
|
94
122
|
|
|
95
123
|
/**
|
|
@@ -100,30 +128,29 @@ var LocalMicrophoneTrack = /*#__PURE__*/function (_WcmeLocalMicrophoneT) {
|
|
|
100
128
|
value: function setServerMuted(muted, reason) {
|
|
101
129
|
if (muted !== this.muted) {
|
|
102
130
|
this.setMuted(muted);
|
|
103
|
-
this.emit(
|
|
104
|
-
muted: muted,
|
|
105
|
-
reason: reason
|
|
106
|
-
});
|
|
131
|
+
this[LocalMicrophoneStreamEventNames.ServerMuted].emit(muted, reason);
|
|
107
132
|
}
|
|
108
133
|
}
|
|
109
134
|
}]);
|
|
110
|
-
return
|
|
111
|
-
}(_internalMediaCore.
|
|
112
|
-
exports.
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
135
|
+
return LocalMicrophoneStream;
|
|
136
|
+
}(_internalMediaCore.LocalMicrophoneStream);
|
|
137
|
+
exports.LocalMicrophoneStream = LocalMicrophoneStream;
|
|
138
|
+
_LocalCameraStreamEve = LocalCameraStreamEventNames.ServerMuted;
|
|
139
|
+
var LocalCameraStream = /*#__PURE__*/function (_WcmeLocalCameraStrea) {
|
|
140
|
+
(0, _inherits2.default)(LocalCameraStream, _WcmeLocalCameraStrea);
|
|
141
|
+
var _super2 = _createSuper(LocalCameraStream);
|
|
142
|
+
function LocalCameraStream() {
|
|
117
143
|
var _this2;
|
|
118
|
-
(0, _classCallCheck2.default)(this,
|
|
144
|
+
(0, _classCallCheck2.default)(this, LocalCameraStream);
|
|
119
145
|
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
120
146
|
args[_key2] = arguments[_key2];
|
|
121
147
|
}
|
|
122
148
|
_this2 = _super2.call.apply(_super2, [this].concat(args));
|
|
123
149
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this2), "unmuteAllowed", true);
|
|
150
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this2), _LocalCameraStreamEve, new _tsEvents.TypedEvent());
|
|
124
151
|
return _this2;
|
|
125
152
|
}
|
|
126
|
-
(0, _createClass2.default)(
|
|
153
|
+
(0, _createClass2.default)(LocalCameraStream, [{
|
|
127
154
|
key: "setUnmuteAllowed",
|
|
128
155
|
value:
|
|
129
156
|
/**
|
|
@@ -134,7 +161,7 @@ var LocalCameraTrack = /*#__PURE__*/function (_WcmeLocalCameraTrack) {
|
|
|
134
161
|
}
|
|
135
162
|
|
|
136
163
|
/**
|
|
137
|
-
* @returns true if user is allowed to unmute the
|
|
164
|
+
* @returns true if user is allowed to unmute the Stream, false otherwise
|
|
138
165
|
*/
|
|
139
166
|
}, {
|
|
140
167
|
key: "isUnmuteAllowed",
|
|
@@ -149,7 +176,7 @@ var LocalCameraTrack = /*#__PURE__*/function (_WcmeLocalCameraTrack) {
|
|
|
149
176
|
throw new Error('Unmute is not allowed');
|
|
150
177
|
}
|
|
151
178
|
}
|
|
152
|
-
return (0, _get2.default)((0, _getPrototypeOf2.default)(
|
|
179
|
+
return (0, _get2.default)((0, _getPrototypeOf2.default)(LocalCameraStream.prototype), "setMuted", this).call(this, muted);
|
|
153
180
|
}
|
|
154
181
|
|
|
155
182
|
/**
|
|
@@ -160,26 +187,27 @@ var LocalCameraTrack = /*#__PURE__*/function (_WcmeLocalCameraTrack) {
|
|
|
160
187
|
value: function setServerMuted(muted, reason) {
|
|
161
188
|
if (muted !== this.muted) {
|
|
162
189
|
this.setMuted(muted);
|
|
163
|
-
this.emit(
|
|
164
|
-
muted: muted,
|
|
165
|
-
reason: reason
|
|
166
|
-
});
|
|
190
|
+
this[LocalCameraStreamEventNames.ServerMuted].emit(muted, reason);
|
|
167
191
|
}
|
|
168
192
|
}
|
|
169
193
|
}]);
|
|
170
|
-
return
|
|
171
|
-
}(_internalMediaCore.
|
|
172
|
-
exports.
|
|
173
|
-
var
|
|
174
|
-
return (0, _internalMediaCore.
|
|
194
|
+
return LocalCameraStream;
|
|
195
|
+
}(_internalMediaCore.LocalCameraStream);
|
|
196
|
+
exports.LocalCameraStream = LocalCameraStream;
|
|
197
|
+
var createMicrophoneStream = function createMicrophoneStream(constraints) {
|
|
198
|
+
return (0, _internalMediaCore.createMicrophoneStream)(LocalMicrophoneStream, constraints);
|
|
199
|
+
};
|
|
200
|
+
exports.createMicrophoneStream = createMicrophoneStream;
|
|
201
|
+
var createCameraStream = function createCameraStream(constraints) {
|
|
202
|
+
return (0, _internalMediaCore.createCameraStream)(LocalCameraStream, constraints);
|
|
175
203
|
};
|
|
176
|
-
exports.
|
|
177
|
-
var
|
|
178
|
-
return (0, _internalMediaCore.
|
|
204
|
+
exports.createCameraStream = createCameraStream;
|
|
205
|
+
var createDisplayStream = function createDisplayStream() {
|
|
206
|
+
return (0, _internalMediaCore.createDisplayStream)(_internalMediaCore.LocalDisplayStream);
|
|
179
207
|
};
|
|
180
|
-
exports.
|
|
181
|
-
var
|
|
182
|
-
return (0, _internalMediaCore.
|
|
208
|
+
exports.createDisplayStream = createDisplayStream;
|
|
209
|
+
var createDisplayStreamWithAudio = function createDisplayStreamWithAudio() {
|
|
210
|
+
return (0, _internalMediaCore.createDisplayStreamWithAudio)(_internalMediaCore.LocalDisplayStream, _internalMediaCore.LocalSystemAudioStream);
|
|
183
211
|
};
|
|
184
|
-
exports.
|
|
212
|
+
exports.createDisplayStreamWithAudio = createDisplayStreamWithAudio;
|
|
185
213
|
//# sourceMappingURL=webrtc-core.js.map
|
package/dist/webrtc-core.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["_internalMediaCore","require","_tsEvents","_LocalMicrophoneStrea","_LocalCameraStreamEve","_createSuper","Derived","hasNativeReflectConstruct","_isNativeReflectConstruct","_createSuperInternal","Super","_getPrototypeOf2","default","result","NewTarget","constructor","_Reflect$construct","arguments","apply","_possibleConstructorReturn2","Reflect","sham","Proxy","Boolean","prototype","valueOf","call","e","LocalMicrophoneStreamEventNames","exports","LocalCameraStreamEventNames","ServerMuted","LocalMicrophoneStream","_WcmeLocalMicrophoneS","_inherits2","_super","_this","_classCallCheck2","_len","length","args","Array","_key","concat","_defineProperty2","_assertThisInitialized2","TypedEvent","_createClass2","key","value","setUnmuteAllowed","allowed","unmuteAllowed","isUnmuteAllowed","setMuted","muted","Error","_get2","setServerMuted","reason","emit","WcmeLocalMicrophoneStream","LocalCameraStream","_WcmeLocalCameraStrea","_super2","_this2","_len2","_key2","WcmeLocalCameraStream","createMicrophoneStream","constraints","wcmeCreateMicrophoneStream","createCameraStream","wcmeCreateCameraStream","createDisplayStream","wcmeCreateDisplayStream","LocalDisplayStream","createDisplayStreamWithAudio","wcmeCreateDisplayStreamWithAudio","LocalSystemAudioStream"],"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 {TypedEvent} from '@webex/ts-events';\n\nexport {\n getDevices,\n LocalStream,\n LocalDisplayStream,\n LocalSystemAudioStream,\n LocalStreamEventNames,\n StreamEventNames,\n RemoteStream,\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\nexport class 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 Stream, 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\nexport class 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 Stream, 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\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"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,IAAAA,kBAAA,GAAAC,OAAA;AAYA,IAAAC,SAAA,GAAAD,OAAA;AAA4C,IAAAE,qBAAA,EAAAC,qBAAA;AAAA,SAAAC,aAAAC,OAAA,QAAAC,yBAAA,GAAAC,yBAAA,oBAAAC,qBAAA,QAAAC,KAAA,OAAAC,gBAAA,CAAAC,OAAA,EAAAN,OAAA,GAAAO,MAAA,MAAAN,yBAAA,QAAAO,SAAA,OAAAH,gBAAA,CAAAC,OAAA,QAAAG,WAAA,EAAAF,MAAA,GAAAG,kBAAA,CAAAN,KAAA,EAAAO,SAAA,EAAAH,SAAA,YAAAD,MAAA,GAAAH,KAAA,CAAAQ,KAAA,OAAAD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,4BAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webex/media-helpers",
|
|
3
|
-
"version": "3.0.0-bnr.5",
|
|
4
3
|
"description": "",
|
|
5
4
|
"license": "Cisco EULA (https://www.cisco.com/c/en/us/products/end-user-license-agreement.html)",
|
|
6
5
|
"main": "dist/index.js",
|
|
@@ -13,8 +12,23 @@
|
|
|
13
12
|
"engines": {
|
|
14
13
|
"node": ">=16"
|
|
15
14
|
},
|
|
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": "npm publish"
|
|
23
|
+
},
|
|
16
24
|
"dependencies": {
|
|
17
|
-
"@webex/
|
|
25
|
+
"@webex/babel-config-legacy": "workspace:^",
|
|
26
|
+
"@webex/eslint-config-legacy": "workspace:^",
|
|
27
|
+
"@webex/internal-media-core": "^2.0.0",
|
|
28
|
+
"@webex/jest-config-legacy": "workspace:^",
|
|
29
|
+
"@webex/legacy-tools": "workspace:^",
|
|
30
|
+
"@webex/ts-events": "^1.1.0",
|
|
31
|
+
"@webex/web-media-effects": "^2.12.0"
|
|
18
32
|
},
|
|
19
33
|
"browserify": {
|
|
20
34
|
"transform": [
|
|
@@ -23,8 +37,11 @@
|
|
|
23
37
|
]
|
|
24
38
|
},
|
|
25
39
|
"devDependencies": {
|
|
26
|
-
"@
|
|
27
|
-
"@webex/test-helper-
|
|
40
|
+
"@babel/preset-typescript": "7.22.11",
|
|
41
|
+
"@webex/test-helper-chai": "workspace:^",
|
|
42
|
+
"@webex/test-helper-mock-webex": "workspace:^",
|
|
43
|
+
"eslint": "^8.24.0",
|
|
28
44
|
"sinon": "^9.2.4"
|
|
29
|
-
}
|
|
45
|
+
},
|
|
46
|
+
"version": "3.0.0-next.1"
|
|
30
47
|
}
|
package/src/constants.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import {VideoDeviceConstraints} from '@webex/internal-media-core';
|
|
2
|
+
|
|
3
|
+
export enum FacingMode {
|
|
4
|
+
user = 'user',
|
|
5
|
+
environment = 'environment',
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
// can be used later on when we add constraints in create display track
|
|
9
|
+
export enum DisplaySurface {
|
|
10
|
+
browser = 'browser',
|
|
11
|
+
monitor = 'monitor',
|
|
12
|
+
window = 'window',
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export const PresetCameraConstraints: {[key: string]: VideoDeviceConstraints} = {
|
|
16
|
+
'1080p': {frameRate: 30, width: 1920, height: 1080},
|
|
17
|
+
|
|
18
|
+
'720p': {frameRate: 30, width: 1280, height: 720},
|
|
19
|
+
|
|
20
|
+
'480p': {frameRate: 30, width: 640, height: 480},
|
|
21
|
+
|
|
22
|
+
'360p': {frameRate: 30, width: 640, height: 360},
|
|
23
|
+
|
|
24
|
+
'240p': {frameRate: 30, width: 320, height: 240},
|
|
25
|
+
|
|
26
|
+
'180p': {frameRate: 30, width: 320, height: 180},
|
|
27
|
+
|
|
28
|
+
'120p': {frameRate: 30, width: 160, height: 120},
|
|
29
|
+
};
|
package/src/index.ts
CHANGED
|
@@ -1,14 +1,25 @@
|
|
|
1
1
|
export {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
getDevices,
|
|
3
|
+
LocalStream,
|
|
4
|
+
LocalDisplayStream,
|
|
5
|
+
LocalSystemAudioStream,
|
|
6
|
+
LocalStreamEventNames,
|
|
7
|
+
StreamEventNames,
|
|
6
8
|
type ServerMuteReason,
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
LocalMicrophoneStreamEventNames,
|
|
10
|
+
LocalCameraStreamEventNames,
|
|
11
|
+
LocalMicrophoneStream,
|
|
12
|
+
LocalCameraStream,
|
|
13
|
+
createMicrophoneStream,
|
|
14
|
+
createCameraStream,
|
|
15
|
+
createDisplayStream,
|
|
16
|
+
createDisplayStreamWithAudio,
|
|
14
17
|
} from './webrtc-core';
|
|
18
|
+
|
|
19
|
+
export {NoiseReductionEffect, VirtualBackgroundEffect} from '@webex/web-media-effects';
|
|
20
|
+
export type {
|
|
21
|
+
NoiseReductionEffectOptions,
|
|
22
|
+
VirtualBackgroundEffectOptions,
|
|
23
|
+
} from '@webex/web-media-effects';
|
|
24
|
+
|
|
25
|
+
export {FacingMode, DisplaySurface, PresetCameraConstraints} from './constants';
|
package/src/webrtc-core.ts
CHANGED
|
@@ -3,20 +3,26 @@
|
|
|
3
3
|
/* eslint-disable require-jsdoc */
|
|
4
4
|
import {
|
|
5
5
|
AudioDeviceConstraints,
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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,
|
|
12
14
|
VideoDeviceConstraints,
|
|
13
15
|
} from '@webex/internal-media-core';
|
|
16
|
+
import {TypedEvent} from '@webex/ts-events';
|
|
14
17
|
|
|
15
18
|
export {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
getDevices,
|
|
20
|
+
LocalStream,
|
|
21
|
+
LocalDisplayStream,
|
|
22
|
+
LocalSystemAudioStream,
|
|
23
|
+
LocalStreamEventNames,
|
|
24
|
+
StreamEventNames,
|
|
25
|
+
RemoteStream,
|
|
20
26
|
} from '@webex/internal-media-core';
|
|
21
27
|
|
|
22
28
|
export type ServerMuteReason =
|
|
@@ -25,18 +31,22 @@ export type ServerMuteReason =
|
|
|
25
31
|
| 'localUnmuteRequired'; // server forced the client to be unmuted
|
|
26
32
|
|
|
27
33
|
// these events are in addition to WCME events. This will be properly typed once webrtc-core event types inheritance is fixed
|
|
28
|
-
export enum
|
|
34
|
+
export enum LocalMicrophoneStreamEventNames {
|
|
29
35
|
ServerMuted = 'muted:byServer',
|
|
30
36
|
}
|
|
31
37
|
|
|
32
38
|
// these events are in addition to WCME events. This will be properly typed once webrtc-core event types inheritance is fixed
|
|
33
|
-
export enum
|
|
39
|
+
export enum LocalCameraStreamEventNames {
|
|
34
40
|
ServerMuted = 'muted:byServer',
|
|
35
41
|
}
|
|
36
42
|
|
|
37
|
-
export class
|
|
43
|
+
export class LocalMicrophoneStream extends WcmeLocalMicrophoneStream {
|
|
38
44
|
private unmuteAllowed = true;
|
|
39
45
|
|
|
46
|
+
[LocalMicrophoneStreamEventNames.ServerMuted] = new TypedEvent<
|
|
47
|
+
(muted: boolean, reason: ServerMuteReason) => void
|
|
48
|
+
>();
|
|
49
|
+
|
|
40
50
|
/**
|
|
41
51
|
* @internal
|
|
42
52
|
*/
|
|
@@ -45,7 +55,7 @@ export class LocalMicrophoneTrack extends WcmeLocalMicrophoneTrack {
|
|
|
45
55
|
}
|
|
46
56
|
|
|
47
57
|
/**
|
|
48
|
-
* @returns true if user is allowed to unmute the
|
|
58
|
+
* @returns true if user is allowed to unmute the Stream, false otherwise
|
|
49
59
|
*/
|
|
50
60
|
isUnmuteAllowed() {
|
|
51
61
|
return this.unmuteAllowed;
|
|
@@ -67,14 +77,18 @@ export class LocalMicrophoneTrack extends WcmeLocalMicrophoneTrack {
|
|
|
67
77
|
setServerMuted(muted: boolean, reason: ServerMuteReason) {
|
|
68
78
|
if (muted !== this.muted) {
|
|
69
79
|
this.setMuted(muted);
|
|
70
|
-
this.emit(
|
|
80
|
+
this[LocalMicrophoneStreamEventNames.ServerMuted].emit(muted, reason);
|
|
71
81
|
}
|
|
72
82
|
}
|
|
73
83
|
}
|
|
74
84
|
|
|
75
|
-
export class
|
|
85
|
+
export class LocalCameraStream extends WcmeLocalCameraStream {
|
|
76
86
|
private unmuteAllowed = true;
|
|
77
87
|
|
|
88
|
+
[LocalCameraStreamEventNames.ServerMuted] = new TypedEvent<
|
|
89
|
+
(muted: boolean, reason: ServerMuteReason) => void
|
|
90
|
+
>();
|
|
91
|
+
|
|
78
92
|
/**
|
|
79
93
|
* @internal
|
|
80
94
|
*/
|
|
@@ -83,7 +97,7 @@ export class LocalCameraTrack extends WcmeLocalCameraTrack {
|
|
|
83
97
|
}
|
|
84
98
|
|
|
85
99
|
/**
|
|
86
|
-
* @returns true if user is allowed to unmute the
|
|
100
|
+
* @returns true if user is allowed to unmute the Stream, false otherwise
|
|
87
101
|
*/
|
|
88
102
|
isUnmuteAllowed() {
|
|
89
103
|
return this.unmuteAllowed;
|
|
@@ -105,15 +119,18 @@ export class LocalCameraTrack extends WcmeLocalCameraTrack {
|
|
|
105
119
|
setServerMuted(muted: boolean, reason: ServerMuteReason) {
|
|
106
120
|
if (muted !== this.muted) {
|
|
107
121
|
this.setMuted(muted);
|
|
108
|
-
this.emit(
|
|
122
|
+
this[LocalCameraStreamEventNames.ServerMuted].emit(muted, reason);
|
|
109
123
|
}
|
|
110
124
|
}
|
|
111
125
|
}
|
|
112
126
|
|
|
113
|
-
export const
|
|
114
|
-
|
|
127
|
+
export const createMicrophoneStream = (constraints?: AudioDeviceConstraints) =>
|
|
128
|
+
wcmeCreateMicrophoneStream(LocalMicrophoneStream, constraints);
|
|
129
|
+
|
|
130
|
+
export const createCameraStream = (constraints?: VideoDeviceConstraints) =>
|
|
131
|
+
wcmeCreateCameraStream(LocalCameraStream, constraints);
|
|
115
132
|
|
|
116
|
-
export const
|
|
117
|
-
wcmeCreateCameraTrack(LocalCameraTrack, constraints);
|
|
133
|
+
export const createDisplayStream = () => wcmeCreateDisplayStream(LocalDisplayStream);
|
|
118
134
|
|
|
119
|
-
export const
|
|
135
|
+
export const createDisplayStreamWithAudio = () =>
|
|
136
|
+
wcmeCreateDisplayStreamWithAudio(LocalDisplayStream, LocalSystemAudioStream);
|
|
@@ -1,115 +1,145 @@
|
|
|
1
1
|
import {assert, expect} from '@webex/test-helper-chai';
|
|
2
2
|
import sinon from 'sinon';
|
|
3
|
-
import {
|
|
4
|
-
|
|
3
|
+
import {
|
|
4
|
+
LocalCameraStream,
|
|
5
|
+
LocalMicrophoneStream,
|
|
6
|
+
LocalMicrophoneStreamEventNames,
|
|
7
|
+
LocalCameraStreamEventNames,
|
|
8
|
+
LocalDisplayStream,
|
|
9
|
+
LocalSystemAudioStream,
|
|
10
|
+
createCameraStream,
|
|
11
|
+
createMicrophoneStream,
|
|
12
|
+
createDisplayStream,
|
|
13
|
+
createDisplayStreamWithAudio,
|
|
14
|
+
} from '../../../src/webrtc-core';
|
|
15
|
+
import * as wcmeStreams from '@webex/internal-media-core';
|
|
5
16
|
|
|
6
17
|
describe('media-helpers', () => {
|
|
7
18
|
describe('webrtc-core', () => {
|
|
8
|
-
|
|
9
19
|
const classesToTest = [
|
|
10
|
-
{
|
|
11
|
-
|
|
20
|
+
{
|
|
21
|
+
className: LocalCameraStream,
|
|
22
|
+
title: 'LocalCameraStream',
|
|
23
|
+
event: LocalCameraStreamEventNames,
|
|
24
|
+
createFn: createCameraStream,
|
|
25
|
+
spyFn: 'createCameraStream',
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
className: LocalMicrophoneStream,
|
|
29
|
+
title: 'LocalMicrophoneStream',
|
|
30
|
+
event: LocalMicrophoneStreamEventNames,
|
|
31
|
+
createFn: createMicrophoneStream,
|
|
32
|
+
spyFn: 'createMicrophoneStream',
|
|
33
|
+
},
|
|
12
34
|
];
|
|
13
35
|
|
|
14
36
|
classesToTest.forEach(({className, title, event, createFn, spyFn}) =>
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
sinon.restore();
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
it('by default allows unmuting', async () => {
|
|
30
|
-
assert.equal(track.isUnmuteAllowed(), true);
|
|
31
|
-
await track.setMuted(false);
|
|
32
|
-
})
|
|
37
|
+
describe(title, () => {
|
|
38
|
+
const fakeStream = {
|
|
39
|
+
getStreams: sinon.stub().returns([
|
|
40
|
+
{
|
|
41
|
+
label: 'fake Stream',
|
|
42
|
+
id: 'fake Stream id',
|
|
43
|
+
enabled: true,
|
|
44
|
+
},
|
|
45
|
+
]),
|
|
46
|
+
};
|
|
47
|
+
const stream = new className(fakeStream);
|
|
33
48
|
|
|
34
|
-
|
|
35
|
-
|
|
49
|
+
afterEach(() => {
|
|
50
|
+
sinon.restore();
|
|
51
|
+
});
|
|
36
52
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
53
|
+
it('by default allows unmuting', async () => {
|
|
54
|
+
assert.equal(stream.isUnmuteAllowed(), true);
|
|
55
|
+
await stream.setMuted(false);
|
|
56
|
+
});
|
|
41
57
|
|
|
42
|
-
|
|
43
|
-
|
|
58
|
+
it('rejects setMute(false) if unmute is not allowed', async () => {
|
|
59
|
+
stream.setUnmuteAllowed(false);
|
|
44
60
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
61
|
+
assert.equal(stream.isUnmuteAllowed(), false);
|
|
62
|
+
const fn = () => stream.setMuted(false);
|
|
63
|
+
expect(fn).to.throw(/Unmute is not allowed/);
|
|
64
|
+
});
|
|
48
65
|
|
|
49
|
-
|
|
66
|
+
it('resolves setMute(false) if unmute is allowed', async () => {
|
|
67
|
+
stream.setUnmuteAllowed(true);
|
|
50
68
|
|
|
51
|
-
|
|
52
|
-
|
|
69
|
+
assert.equal(stream.isUnmuteAllowed(), true);
|
|
70
|
+
await stream.setMuted(false);
|
|
53
71
|
});
|
|
54
72
|
|
|
55
|
-
|
|
56
|
-
|
|
73
|
+
describe('#setServerMuted', () => {
|
|
74
|
+
afterEach(() => {
|
|
75
|
+
sinon.restore();
|
|
76
|
+
});
|
|
57
77
|
|
|
58
|
-
|
|
78
|
+
const checkSetServerMuted = async (startMute, setMute, expectedCalled) => {
|
|
79
|
+
await stream.setMuted(startMute);
|
|
59
80
|
|
|
60
|
-
|
|
61
|
-
track.on(event.ServerMuted, handler);
|
|
81
|
+
assert.equal(stream.muted, startMute);
|
|
62
82
|
|
|
63
|
-
|
|
83
|
+
const handler = sinon.fake();
|
|
84
|
+
stream.on(event.ServerMuted, handler);
|
|
64
85
|
|
|
65
|
-
|
|
66
|
-
if (expectedCalled) {
|
|
67
|
-
assert.calledOnceWithExactly(handler, {muted: setMute, reason: 'remotelyMuted'});
|
|
68
|
-
} else {
|
|
69
|
-
assert.notCalled(handler);
|
|
70
|
-
}
|
|
71
|
-
};
|
|
86
|
+
await stream.setServerMuted(setMute, 'remotelyMuted');
|
|
72
87
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
88
|
+
assert.equal(stream.muted, setMute);
|
|
89
|
+
if (expectedCalled) {
|
|
90
|
+
assert.calledOnceWithExactly(handler, {muted: setMute, reason: 'remotelyMuted'});
|
|
91
|
+
} else {
|
|
92
|
+
assert.notCalled(handler);
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
it('tests true to false', async () => {
|
|
97
|
+
await checkSetServerMuted(true, false, true);
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
it('tests false to true', async () => {
|
|
101
|
+
await checkSetServerMuted(false, true, true);
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
it('tests true to true', async () => {
|
|
105
|
+
await checkSetServerMuted(true, true, false);
|
|
106
|
+
});
|
|
89
107
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
const spy = sinon.stub(wcmetracks, spyFn).returns('something');
|
|
95
|
-
const result = createFn(constraints);
|
|
96
|
-
|
|
97
|
-
assert.equal(result, 'something');
|
|
98
|
-
assert.calledOnceWithExactly(spy, className, constraints);
|
|
108
|
+
it('tests false to false', async () => {
|
|
109
|
+
await checkSetServerMuted(false, false, false);
|
|
110
|
+
});
|
|
99
111
|
});
|
|
100
|
-
});
|
|
101
112
|
|
|
102
|
-
|
|
103
|
-
|
|
113
|
+
describe('#wcmeCreateMicrophoneStream, #wcmeCreateCameraStream', () => {
|
|
114
|
+
it('checks creating Streams', async () => {
|
|
115
|
+
const constraints = {devideId: 'abc'};
|
|
116
|
+
|
|
117
|
+
const spy = sinon.stub(wcmeStreams, spyFn).returns('something');
|
|
118
|
+
const result = createFn(constraints);
|
|
104
119
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
120
|
+
assert.equal(result, 'something');
|
|
121
|
+
assert.calledOnceWithExactly(spy, className, constraints);
|
|
122
|
+
});
|
|
123
|
+
});
|
|
124
|
+
})
|
|
125
|
+
);
|
|
126
|
+
|
|
127
|
+
describe('createDisplayStream', () => {
|
|
128
|
+
it('checks createDisplayStream', async () => {
|
|
129
|
+
const spy = sinon.stub(wcmeStreams, 'createDisplayStream').returns('something');
|
|
130
|
+
const result = createDisplayStream();
|
|
131
|
+
assert.equal(result, 'something');
|
|
132
|
+
assert.calledOnceWithExactly(spy, LocalDisplayStream);
|
|
133
|
+
});
|
|
111
134
|
});
|
|
112
135
|
|
|
136
|
+
describe('createDisplayStreamWithAudio', () => {
|
|
137
|
+
it('checks createDisplayStreamWithAudio', async () => {
|
|
138
|
+
const spy = sinon.stub(wcmeStreams, 'createDisplayStreamWithAudio').returns('something');
|
|
139
|
+
const result = createDisplayStreamWithAudio();
|
|
140
|
+
assert.equal(result, 'something');
|
|
141
|
+
assert.calledOnceWithExactly(spy, LocalDisplayStream, LocalSystemAudioStream);
|
|
142
|
+
});
|
|
143
|
+
});
|
|
113
144
|
});
|
|
114
|
-
|
|
115
|
-
});
|
|
145
|
+
});
|