@webex/plugin-meetings 3.0.0-beta.1 → 3.0.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/common/errors/webex-errors.js +5 -29
- package/dist/common/errors/webex-errors.js.map +1 -1
- package/dist/constants.js +15 -74
- package/dist/constants.js.map +1 -1
- package/dist/media/index.js +68 -213
- package/dist/media/index.js.map +1 -1
- package/dist/media/internal-media-core-wrapper.js +22 -0
- package/dist/media/internal-media-core-wrapper.js.map +1 -0
- package/dist/media/properties.js +20 -25
- package/dist/media/properties.js.map +1 -1
- package/dist/media/util.js +0 -27
- package/dist/media/util.js.map +1 -1
- package/dist/meeting/index.js +694 -432
- package/dist/meeting/index.js.map +1 -1
- package/dist/meeting/request.js +1 -0
- package/dist/meeting/request.js.map +1 -1
- package/dist/meeting/util.js +3 -44
- package/dist/meeting/util.js.map +1 -1
- package/dist/meetings/index.js +64 -5
- package/dist/meetings/index.js.map +1 -1
- package/dist/meetings/util.js +24 -1
- package/dist/meetings/util.js.map +1 -1
- package/dist/members/index.js +68 -0
- package/dist/members/index.js.map +1 -1
- package/dist/multistream/mediaRequestManager.js +132 -0
- package/dist/multistream/mediaRequestManager.js.map +1 -0
- package/dist/multistream/multistreamMedia.js +116 -0
- package/dist/multistream/multistreamMedia.js.map +1 -0
- package/dist/multistream/receiveSlot.js +209 -0
- package/dist/multistream/receiveSlot.js.map +1 -0
- package/dist/multistream/receiveSlotManager.js +195 -0
- package/dist/multistream/receiveSlotManager.js.map +1 -0
- package/dist/multistream/remoteMedia.js +284 -0
- package/dist/multistream/remoteMedia.js.map +1 -0
- package/dist/multistream/remoteMediaGroup.js +243 -0
- package/dist/multistream/remoteMediaGroup.js.map +1 -0
- package/dist/multistream/remoteMediaManager.js +1113 -0
- package/dist/multistream/remoteMediaManager.js.map +1 -0
- package/dist/reconnection-manager/index.js +109 -130
- package/dist/reconnection-manager/index.js.map +1 -1
- package/dist/roap/index.js +57 -240
- package/dist/roap/index.js.map +1 -1
- package/dist/roap/request.js +2 -114
- package/dist/roap/request.js.map +1 -1
- package/dist/roap/turnDiscovery.js +11 -5
- package/dist/roap/turnDiscovery.js.map +1 -1
- package/dist/statsAnalyzer/global.js +2 -0
- package/dist/statsAnalyzer/global.js.map +1 -1
- package/dist/statsAnalyzer/index.js +39 -36
- package/dist/statsAnalyzer/index.js.map +1 -1
- package/package.json +20 -19
- package/src/common/errors/webex-errors.js +0 -18
- package/src/constants.ts +139 -180
- package/src/media/index.js +60 -194
- package/src/media/internal-media-core-wrapper.ts +9 -0
- package/src/media/properties.js +19 -25
- package/src/media/util.js +0 -22
- package/src/meeting/index.js +565 -320
- package/src/meeting/request.js +1 -0
- package/src/meeting/util.js +3 -46
- package/src/meetings/index.js +30 -1
- package/src/meetings/util.js +23 -2
- package/src/members/index.js +48 -0
- package/src/multistream/mediaRequestManager.ts +164 -0
- package/src/multistream/multistreamMedia.ts +92 -0
- package/src/multistream/receiveSlot.ts +141 -0
- package/src/multistream/receiveSlotManager.ts +142 -0
- package/src/multistream/remoteMedia.ts +219 -0
- package/src/multistream/remoteMediaGroup.ts +224 -0
- package/src/multistream/remoteMediaManager.ts +911 -0
- package/src/reconnection-manager/index.js +40 -53
- package/src/roap/index.js +47 -207
- package/src/roap/request.js +1 -72
- package/src/roap/turnDiscovery.ts +12 -6
- package/src/statsAnalyzer/global.js +2 -0
- package/src/statsAnalyzer/index.js +32 -46
- package/test/integration/spec/journey.js +1 -1
- package/test/unit/spec/media/index.ts +223 -0
- package/test/unit/spec/media/properties.ts +73 -82
- package/test/unit/spec/meeting/effectsState.js +1 -3
- package/test/unit/spec/meeting/index.js +420 -228
- package/test/unit/spec/meeting/muteState.js +7 -0
- package/test/unit/spec/meeting/utils.js +61 -2
- package/test/unit/spec/meetings/index.js +0 -4
- package/test/unit/spec/members/index.js +164 -2
- package/test/unit/spec/multistream/mediaRequestManager.ts +511 -0
- package/test/unit/spec/multistream/receiveSlot.ts +104 -0
- package/test/unit/spec/multistream/receiveSlotManager.ts +173 -0
- package/test/unit/spec/multistream/remoteMedia.ts +217 -0
- package/test/unit/spec/multistream/remoteMediaGroup.ts +396 -0
- package/test/unit/spec/multistream/remoteMediaManager.ts +1251 -0
- package/test/unit/spec/roap/index.ts +63 -35
- package/test/unit/spec/stats-analyzer/index.js +19 -22
- package/dist/peer-connection-manager/index.js +0 -794
- package/dist/peer-connection-manager/index.js.map +0 -1
- package/dist/roap/collection.js +0 -73
- package/dist/roap/collection.js.map +0 -1
- package/dist/roap/handler.js +0 -337
- package/dist/roap/handler.js.map +0 -1
- package/dist/roap/state.js +0 -164
- package/dist/roap/state.js.map +0 -1
- package/dist/roap/util.js +0 -102
- package/dist/roap/util.js.map +0 -1
- package/src/peer-connection-manager/index.js +0 -723
- package/src/roap/collection.js +0 -63
- package/src/roap/handler.js +0 -252
- package/src/roap/state.js +0 -149
- package/src/roap/util.js +0 -93
- package/test/unit/spec/peerconnection-manager/index.js +0 -188
- package/test/unit/spec/peerconnection-manager/utils.js +0 -48
- package/test/unit/spec/roap/util.js +0 -30
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _Reflect$construct = require("@babel/runtime-corejs2/core-js/reflect/construct");
|
|
4
|
+
|
|
5
|
+
var _Object$defineProperty = require("@babel/runtime-corejs2/core-js/object/define-property");
|
|
6
|
+
|
|
7
|
+
var _interopRequireDefault = require("@babel/runtime-corejs2/helpers/interopRequireDefault");
|
|
8
|
+
|
|
9
|
+
_Object$defineProperty(exports, "__esModule", {
|
|
10
|
+
value: true
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
exports.RemoteMediaEvents = exports.RemoteMedia = void 0;
|
|
14
|
+
exports.getMaxFs = getMaxFs;
|
|
15
|
+
|
|
16
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/classCallCheck"));
|
|
17
|
+
|
|
18
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/createClass"));
|
|
19
|
+
|
|
20
|
+
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/assertThisInitialized"));
|
|
21
|
+
|
|
22
|
+
var _inherits2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/inherits"));
|
|
23
|
+
|
|
24
|
+
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/possibleConstructorReturn"));
|
|
25
|
+
|
|
26
|
+
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/getPrototypeOf"));
|
|
27
|
+
|
|
28
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/defineProperty"));
|
|
29
|
+
|
|
30
|
+
var _loggerProxy = _interopRequireDefault(require("../common/logs/logger-proxy"));
|
|
31
|
+
|
|
32
|
+
var _eventsScope = _interopRequireDefault(require("../common/events/events-scope"));
|
|
33
|
+
|
|
34
|
+
var _receiveSlot = require("./receiveSlot");
|
|
35
|
+
|
|
36
|
+
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); }; }
|
|
37
|
+
|
|
38
|
+
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; } }
|
|
39
|
+
|
|
40
|
+
var RemoteMediaEvents = {
|
|
41
|
+
SourceUpdate: _receiveSlot.ReceiveSlotEvents.SourceUpdate
|
|
42
|
+
};
|
|
43
|
+
exports.RemoteMediaEvents = RemoteMediaEvents;
|
|
44
|
+
|
|
45
|
+
// highest possible resolution
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Converts pane size into h264 maxFs
|
|
49
|
+
* @param {PaneSize} paneSize
|
|
50
|
+
* @returns {number}
|
|
51
|
+
*/
|
|
52
|
+
function getMaxFs(paneSize) {
|
|
53
|
+
var maxFs;
|
|
54
|
+
|
|
55
|
+
switch (paneSize) {
|
|
56
|
+
case 'thumbnail':
|
|
57
|
+
maxFs = 60;
|
|
58
|
+
break;
|
|
59
|
+
|
|
60
|
+
case 'very small':
|
|
61
|
+
maxFs = 240;
|
|
62
|
+
break;
|
|
63
|
+
|
|
64
|
+
case 'small':
|
|
65
|
+
maxFs = 920;
|
|
66
|
+
break;
|
|
67
|
+
|
|
68
|
+
case 'medium':
|
|
69
|
+
maxFs = 3600;
|
|
70
|
+
break;
|
|
71
|
+
|
|
72
|
+
case 'large':
|
|
73
|
+
maxFs = 8192;
|
|
74
|
+
break;
|
|
75
|
+
|
|
76
|
+
case 'best':
|
|
77
|
+
maxFs = 8192; // for now 'best' is 1080p, so same as 'large'
|
|
78
|
+
|
|
79
|
+
break;
|
|
80
|
+
|
|
81
|
+
default:
|
|
82
|
+
_loggerProxy.default.logger.warn("RemoteMedia#getMaxFs --> unsupported paneSize: ".concat(paneSize, ", using \"medium\" instead"));
|
|
83
|
+
|
|
84
|
+
maxFs = 3600;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
return maxFs;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
var remoteMediaCounter = 0;
|
|
91
|
+
/**
|
|
92
|
+
* Class representing a remote audio/video stream.
|
|
93
|
+
*
|
|
94
|
+
* Internally it is associated with a specific receive slot
|
|
95
|
+
* and a media request for it.
|
|
96
|
+
*/
|
|
97
|
+
|
|
98
|
+
var RemoteMedia = /*#__PURE__*/function (_EventsScope) {
|
|
99
|
+
(0, _inherits2.default)(RemoteMedia, _EventsScope);
|
|
100
|
+
|
|
101
|
+
var _super = _createSuper(RemoteMedia);
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Constructs RemoteMedia instance
|
|
105
|
+
*
|
|
106
|
+
* @param receiveSlot
|
|
107
|
+
* @param mediaRequestManager
|
|
108
|
+
* @param options
|
|
109
|
+
*/
|
|
110
|
+
function RemoteMedia(receiveSlot, mediaRequestManager, options) {
|
|
111
|
+
var _this;
|
|
112
|
+
|
|
113
|
+
(0, _classCallCheck2.default)(this, RemoteMedia);
|
|
114
|
+
_this = _super.call(this);
|
|
115
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "receiveSlot", void 0);
|
|
116
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "mediaRequestManager", void 0);
|
|
117
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "options", void 0);
|
|
118
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "mediaRequestId", void 0);
|
|
119
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "id", void 0);
|
|
120
|
+
remoteMediaCounter += 1;
|
|
121
|
+
_this.receiveSlot = receiveSlot;
|
|
122
|
+
_this.mediaRequestManager = mediaRequestManager;
|
|
123
|
+
_this.options = options || {};
|
|
124
|
+
|
|
125
|
+
_this.setupEventListeners();
|
|
126
|
+
|
|
127
|
+
_this.id = "RM".concat(remoteMediaCounter, "-").concat(_this.receiveSlot.id);
|
|
128
|
+
return _this;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Invalidates the remote media by clearing the reference to a receive slot and
|
|
132
|
+
* cancelling the media request.
|
|
133
|
+
* After this call the remote media is unusable.
|
|
134
|
+
*
|
|
135
|
+
* @param {boolean} commit - whether to commit the cancellation of the media request
|
|
136
|
+
* @internal
|
|
137
|
+
*/
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
(0, _createClass2.default)(RemoteMedia, [{
|
|
141
|
+
key: "stop",
|
|
142
|
+
value: function stop() {
|
|
143
|
+
var _this$receiveSlot;
|
|
144
|
+
|
|
145
|
+
var commit = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
146
|
+
this.cancelMediaRequest(commit);
|
|
147
|
+
(_this$receiveSlot = this.receiveSlot) === null || _this$receiveSlot === void 0 ? void 0 : _this$receiveSlot.removeAllListeners();
|
|
148
|
+
this.receiveSlot = undefined;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Sends a new media request. This method can only be used for receiver-selected policy,
|
|
152
|
+
* because only in that policy we have a 1-1 relationship between RemoteMedia and MediaRequest
|
|
153
|
+
* and the request id is then stored in this RemoteMedia instance.
|
|
154
|
+
* For active-speaker policy, the same request is shared among many RemoteMedia instances,
|
|
155
|
+
* so it's managed through RemoteMediaGroup
|
|
156
|
+
*
|
|
157
|
+
* @internal
|
|
158
|
+
*/
|
|
159
|
+
|
|
160
|
+
}, {
|
|
161
|
+
key: "sendMediaRequest",
|
|
162
|
+
value: function sendMediaRequest(csi, commit) {
|
|
163
|
+
if (this.mediaRequestId) {
|
|
164
|
+
this.cancelMediaRequest(false);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
if (!this.receiveSlot) {
|
|
168
|
+
throw new Error('sendMediaRequest() called on an invalidated RemoteMedia instance');
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
this.mediaRequestId = this.mediaRequestManager.addRequest({
|
|
172
|
+
policyInfo: {
|
|
173
|
+
policy: 'receiver-selected',
|
|
174
|
+
csi: csi
|
|
175
|
+
},
|
|
176
|
+
receiveSlots: [this.receiveSlot],
|
|
177
|
+
codecInfo: this.options.resolution && {
|
|
178
|
+
codec: 'h264',
|
|
179
|
+
maxFs: getMaxFs(this.options.resolution)
|
|
180
|
+
}
|
|
181
|
+
}, commit);
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* @internal
|
|
185
|
+
*/
|
|
186
|
+
|
|
187
|
+
}, {
|
|
188
|
+
key: "cancelMediaRequest",
|
|
189
|
+
value: function cancelMediaRequest(commit) {
|
|
190
|
+
if (this.mediaRequestId) {
|
|
191
|
+
this.mediaRequestManager.cancelRequest(this.mediaRequestId, commit);
|
|
192
|
+
this.mediaRequestId = undefined;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* registers event listeners on the receive slot and forwards all the events
|
|
197
|
+
*/
|
|
198
|
+
|
|
199
|
+
}, {
|
|
200
|
+
key: "setupEventListeners",
|
|
201
|
+
value: function setupEventListeners() {
|
|
202
|
+
var _this2 = this;
|
|
203
|
+
|
|
204
|
+
if (this.receiveSlot) {
|
|
205
|
+
var scope = {
|
|
206
|
+
file: 'meeting/remoteMedia',
|
|
207
|
+
function: 'setupEventListeners'
|
|
208
|
+
};
|
|
209
|
+
this.receiveSlot.on(_receiveSlot.ReceiveSlotEvents.SourceUpdate, function (data) {
|
|
210
|
+
_this2.emit(scope, RemoteMediaEvents.SourceUpdate, data);
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Getter for mediaType
|
|
216
|
+
*/
|
|
217
|
+
|
|
218
|
+
}, {
|
|
219
|
+
key: "mediaType",
|
|
220
|
+
get: function get() {
|
|
221
|
+
var _this$receiveSlot2;
|
|
222
|
+
|
|
223
|
+
return (_this$receiveSlot2 = this.receiveSlot) === null || _this$receiveSlot2 === void 0 ? void 0 : _this$receiveSlot2.mediaType;
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Getter for memberId
|
|
227
|
+
*/
|
|
228
|
+
|
|
229
|
+
}, {
|
|
230
|
+
key: "memberId",
|
|
231
|
+
get: function get() {
|
|
232
|
+
var _this$receiveSlot3;
|
|
233
|
+
|
|
234
|
+
return (_this$receiveSlot3 = this.receiveSlot) === null || _this$receiveSlot3 === void 0 ? void 0 : _this$receiveSlot3.memberId;
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* Getter for csi
|
|
238
|
+
*/
|
|
239
|
+
|
|
240
|
+
}, {
|
|
241
|
+
key: "csi",
|
|
242
|
+
get: function get() {
|
|
243
|
+
var _this$receiveSlot4;
|
|
244
|
+
|
|
245
|
+
return (_this$receiveSlot4 = this.receiveSlot) === null || _this$receiveSlot4 === void 0 ? void 0 : _this$receiveSlot4.csi;
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* Getter for source state
|
|
249
|
+
*/
|
|
250
|
+
|
|
251
|
+
}, {
|
|
252
|
+
key: "sourceState",
|
|
253
|
+
get: function get() {
|
|
254
|
+
var _this$receiveSlot5;
|
|
255
|
+
|
|
256
|
+
return (_this$receiveSlot5 = this.receiveSlot) === null || _this$receiveSlot5 === void 0 ? void 0 : _this$receiveSlot5.sourceState;
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* Getter for remote media stream
|
|
260
|
+
*/
|
|
261
|
+
|
|
262
|
+
}, {
|
|
263
|
+
key: "stream",
|
|
264
|
+
get: function get() {
|
|
265
|
+
var _this$receiveSlot6;
|
|
266
|
+
|
|
267
|
+
return (_this$receiveSlot6 = this.receiveSlot) === null || _this$receiveSlot6 === void 0 ? void 0 : _this$receiveSlot6.stream;
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* @internal
|
|
271
|
+
* @returns {ReceiveSlot}
|
|
272
|
+
*/
|
|
273
|
+
|
|
274
|
+
}, {
|
|
275
|
+
key: "getUnderlyingReceiveSlot",
|
|
276
|
+
value: function getUnderlyingReceiveSlot() {
|
|
277
|
+
return this.receiveSlot;
|
|
278
|
+
}
|
|
279
|
+
}]);
|
|
280
|
+
return RemoteMedia;
|
|
281
|
+
}(_eventsScope.default);
|
|
282
|
+
|
|
283
|
+
exports.RemoteMedia = RemoteMedia;
|
|
284
|
+
//# sourceMappingURL=remoteMedia.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["RemoteMediaEvents","SourceUpdate","ReceiveSlotEvents","getMaxFs","paneSize","maxFs","LoggerProxy","logger","warn","remoteMediaCounter","RemoteMedia","receiveSlot","mediaRequestManager","options","setupEventListeners","id","commit","cancelMediaRequest","removeAllListeners","undefined","csi","mediaRequestId","Error","addRequest","policyInfo","policy","receiveSlots","codecInfo","resolution","codec","cancelRequest","scope","file","function","on","data","emit","mediaType","memberId","sourceState","stream","EventsScope"],"sources":["remoteMedia.ts"],"sourcesContent":["/* eslint-disable valid-jsdoc */\nimport LoggerProxy from '../common/logs/logger-proxy';\nimport EventsScope from '../common/events/events-scope';\n\nimport {MediaRequestId, MediaRequestManager} from './mediaRequestManager';\nimport {CSI, ReceiveSlot, ReceiveSlotEvents} from './receiveSlot';\n\nexport const RemoteMediaEvents = {\n SourceUpdate: ReceiveSlotEvents.SourceUpdate,\n};\n\nexport type RemoteVideoResolution =\n | 'thumbnail' // the smallest possible resolution, 90p or less\n | 'very small' // 180p or less\n | 'small' // 360p or less\n | 'medium' // 720p or less\n | 'large' // 1080p or less\n | 'best'; // highest possible resolution\n\n/**\n * Converts pane size into h264 maxFs\n * @param {PaneSize} paneSize\n * @returns {number}\n */\nexport function getMaxFs(paneSize: RemoteVideoResolution): number {\n let maxFs;\n\n switch (paneSize) {\n case 'thumbnail':\n maxFs = 60;\n break;\n case 'very small':\n maxFs = 240;\n break;\n case 'small':\n maxFs = 920;\n break;\n case 'medium':\n maxFs = 3600;\n break;\n case 'large':\n maxFs = 8192;\n break;\n case 'best':\n maxFs = 8192; // for now 'best' is 1080p, so same as 'large'\n break;\n default:\n LoggerProxy.logger.warn(\n `RemoteMedia#getMaxFs --> unsupported paneSize: ${paneSize}, using \"medium\" instead`\n );\n maxFs = 3600;\n }\n\n return maxFs;\n}\n\ntype Options = {\n resolution?: RemoteVideoResolution; // applies only to groups of type MC.MediaType.VideoMain and MC.MediaType.VideoSlides\n};\n\nexport type RemoteMediaId = string;\n\nlet remoteMediaCounter = 0;\n\n/**\n * Class representing a remote audio/video stream.\n *\n * Internally it is associated with a specific receive slot\n * and a media request for it.\n */\nexport class RemoteMedia extends EventsScope {\n private receiveSlot?: ReceiveSlot;\n\n private readonly mediaRequestManager: MediaRequestManager;\n\n private readonly options: Options;\n\n private mediaRequestId?: MediaRequestId;\n\n public readonly id: RemoteMediaId;\n\n /**\n * Constructs RemoteMedia instance\n *\n * @param receiveSlot\n * @param mediaRequestManager\n * @param options\n */\n constructor(\n receiveSlot: ReceiveSlot,\n mediaRequestManager: MediaRequestManager,\n options?: Options\n ) {\n super();\n remoteMediaCounter += 1;\n this.receiveSlot = receiveSlot;\n this.mediaRequestManager = mediaRequestManager;\n this.options = options || {};\n this.setupEventListeners();\n this.id = `RM${remoteMediaCounter}-${this.receiveSlot.id}`;\n }\n\n /**\n * Invalidates the remote media by clearing the reference to a receive slot and\n * cancelling the media request.\n * After this call the remote media is unusable.\n *\n * @param {boolean} commit - whether to commit the cancellation of the media request\n * @internal\n */\n public stop(commit: boolean = true) {\n this.cancelMediaRequest(commit);\n this.receiveSlot?.removeAllListeners();\n this.receiveSlot = undefined;\n }\n\n /**\n * Sends a new media request. This method can only be used for receiver-selected policy,\n * because only in that policy we have a 1-1 relationship between RemoteMedia and MediaRequest\n * and the request id is then stored in this RemoteMedia instance.\n * For active-speaker policy, the same request is shared among many RemoteMedia instances,\n * so it's managed through RemoteMediaGroup\n *\n * @internal\n */\n public sendMediaRequest(csi: CSI, commit: boolean) {\n if (this.mediaRequestId) {\n this.cancelMediaRequest(false);\n }\n\n if (!this.receiveSlot) {\n throw new Error('sendMediaRequest() called on an invalidated RemoteMedia instance');\n }\n\n this.mediaRequestId = this.mediaRequestManager.addRequest(\n {\n policyInfo: {\n policy: 'receiver-selected',\n csi,\n },\n receiveSlots: [this.receiveSlot],\n codecInfo: this.options.resolution && {\n codec: 'h264',\n maxFs: getMaxFs(this.options.resolution),\n },\n },\n commit\n );\n }\n\n /**\n * @internal\n */\n public cancelMediaRequest(commit: boolean) {\n if (this.mediaRequestId) {\n this.mediaRequestManager.cancelRequest(this.mediaRequestId, commit);\n this.mediaRequestId = undefined;\n }\n }\n\n /**\n * registers event listeners on the receive slot and forwards all the events\n */\n private setupEventListeners() {\n if (this.receiveSlot) {\n const scope = {\n file: 'meeting/remoteMedia',\n function: 'setupEventListeners',\n };\n\n this.receiveSlot.on(ReceiveSlotEvents.SourceUpdate, (data) => {\n this.emit(scope, RemoteMediaEvents.SourceUpdate, data);\n });\n }\n }\n\n /**\n * Getter for mediaType\n */\n public get mediaType() {\n return this.receiveSlot?.mediaType;\n }\n\n /**\n * Getter for memberId\n */\n public get memberId() {\n return this.receiveSlot?.memberId;\n }\n\n /**\n * Getter for csi\n */\n public get csi() {\n return this.receiveSlot?.csi;\n }\n\n /**\n * Getter for source state\n */\n public get sourceState() {\n return this.receiveSlot?.sourceState;\n }\n\n /**\n * Getter for remote media stream\n */\n public get stream() {\n return this.receiveSlot?.stream;\n }\n\n /**\n * @internal\n * @returns {ReceiveSlot}\n */\n public getUnderlyingReceiveSlot() {\n return this.receiveSlot;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA;;AACA;;AAGA;;;;;;AAEO,IAAMA,iBAAiB,GAAG;EAC/BC,YAAY,EAAEC,8BAAA,CAAkBD;AADD,CAA1B;;;AAUK;;AAEZ;AACA;AACA;AACA;AACA;AACO,SAASE,QAAT,CAAkBC,QAAlB,EAA2D;EAChE,IAAIC,KAAJ;;EAEA,QAAQD,QAAR;IACE,KAAK,WAAL;MACEC,KAAK,GAAG,EAAR;MACA;;IACF,KAAK,YAAL;MACEA,KAAK,GAAG,GAAR;MACA;;IACF,KAAK,OAAL;MACEA,KAAK,GAAG,GAAR;MACA;;IACF,KAAK,QAAL;MACEA,KAAK,GAAG,IAAR;MACA;;IACF,KAAK,OAAL;MACEA,KAAK,GAAG,IAAR;MACA;;IACF,KAAK,MAAL;MACEA,KAAK,GAAG,IAAR,CADF,CACgB;;MACd;;IACF;MACEC,oBAAA,CAAYC,MAAZ,CAAmBC,IAAnB,0DACoDJ,QADpD;;MAGAC,KAAK,GA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|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _Object$defineProperty = require("@babel/runtime-corejs2/core-js/object/define-property");
|
|
4
|
+
|
|
5
|
+
var _interopRequireDefault = require("@babel/runtime-corejs2/helpers/interopRequireDefault");
|
|
6
|
+
|
|
7
|
+
_Object$defineProperty(exports, "__esModule", {
|
|
8
|
+
value: true
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
exports.RemoteMediaGroup = void 0;
|
|
12
|
+
|
|
13
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/toConsumableArray"));
|
|
14
|
+
|
|
15
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/classCallCheck"));
|
|
16
|
+
|
|
17
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/createClass"));
|
|
18
|
+
|
|
19
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/defineProperty"));
|
|
20
|
+
|
|
21
|
+
var _loggerProxy = _interopRequireDefault(require("../common/logs/logger-proxy"));
|
|
22
|
+
|
|
23
|
+
var _remoteMedia = require("./remoteMedia");
|
|
24
|
+
|
|
25
|
+
/* eslint-disable valid-jsdoc */
|
|
26
|
+
|
|
27
|
+
/* eslint-disable require-jsdoc */
|
|
28
|
+
|
|
29
|
+
/* eslint-disable import/prefer-default-export */
|
|
30
|
+
var RemoteMediaGroup = /*#__PURE__*/function () {
|
|
31
|
+
// id of the "active-speaker" media request id
|
|
32
|
+
function RemoteMediaGroup(mediaRequestManager, receiveSlots, priority, commitMediaRequest) {
|
|
33
|
+
var _this = this;
|
|
34
|
+
|
|
35
|
+
var options = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
|
|
36
|
+
(0, _classCallCheck2.default)(this, RemoteMediaGroup);
|
|
37
|
+
(0, _defineProperty2.default)(this, "mediaRequestManager", void 0);
|
|
38
|
+
(0, _defineProperty2.default)(this, "priority", void 0);
|
|
39
|
+
(0, _defineProperty2.default)(this, "options", void 0);
|
|
40
|
+
(0, _defineProperty2.default)(this, "unpinnedRemoteMedia", void 0);
|
|
41
|
+
(0, _defineProperty2.default)(this, "mediaRequestId", void 0);
|
|
42
|
+
(0, _defineProperty2.default)(this, "pinnedRemoteMedia", void 0);
|
|
43
|
+
this.mediaRequestManager = mediaRequestManager;
|
|
44
|
+
this.priority = priority;
|
|
45
|
+
this.options = options;
|
|
46
|
+
this.unpinnedRemoteMedia = receiveSlots.map(function (slot) {
|
|
47
|
+
return new _remoteMedia.RemoteMedia(slot, _this.mediaRequestManager, {
|
|
48
|
+
resolution: _this.options.resolution
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
this.pinnedRemoteMedia = [];
|
|
52
|
+
this.sendActiveSpeakerMediaRequest(commitMediaRequest);
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Gets the array of remote media elements from the group
|
|
56
|
+
*
|
|
57
|
+
* @param {string} filter - 'all' (default) returns both pinned and unpinned
|
|
58
|
+
* @returns {Array<RemoteMedia>}
|
|
59
|
+
*/
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
(0, _createClass2.default)(RemoteMediaGroup, [{
|
|
63
|
+
key: "getRemoteMedia",
|
|
64
|
+
value: function getRemoteMedia() {
|
|
65
|
+
var filter = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'all';
|
|
66
|
+
|
|
67
|
+
if (filter === 'unpinned') {
|
|
68
|
+
// return a shallow copy so that the client cannot modify this.unpinnedRemoteMedia array
|
|
69
|
+
return (0, _toConsumableArray2.default)(this.unpinnedRemoteMedia);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if (filter === 'pinned') {
|
|
73
|
+
// return a shallow copy so that the client cannot modify this.pinnedRemoteMedia array
|
|
74
|
+
return (0, _toConsumableArray2.default)(this.pinnedRemoteMedia);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return [].concat((0, _toConsumableArray2.default)(this.unpinnedRemoteMedia), (0, _toConsumableArray2.default)(this.pinnedRemoteMedia));
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Pins a specific remote media instance to a specfic CSI, so the media will
|
|
81
|
+
* no longer come from active speaker, but from that CSI.
|
|
82
|
+
* If no CSI is given, the current CSI value is used.
|
|
83
|
+
*
|
|
84
|
+
*/
|
|
85
|
+
|
|
86
|
+
}, {
|
|
87
|
+
key: "pin",
|
|
88
|
+
value: function pin(remoteMedia, csi) {
|
|
89
|
+
// if csi is not specified, use the current one
|
|
90
|
+
var targetCsi = csi || remoteMedia.csi;
|
|
91
|
+
|
|
92
|
+
if (!targetCsi) {
|
|
93
|
+
throw new Error("failed to pin a remote media object ".concat(remoteMedia.id, ", because it has no CSI set and no CSI value was given"));
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
if (this.pinnedRemoteMedia.indexOf(remoteMedia) >= 0) {
|
|
97
|
+
if (targetCsi === remoteMedia.csi) {
|
|
98
|
+
// remote media already pinned to target CSI, nothing to do
|
|
99
|
+
_loggerProxy.default.logger.log("RemoteMediaGroup#pin --> remote media ".concat(remoteMedia.id, " already pinned"));
|
|
100
|
+
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
} else {
|
|
104
|
+
var idx = this.unpinnedRemoteMedia.indexOf(remoteMedia);
|
|
105
|
+
|
|
106
|
+
if (idx < 0) {
|
|
107
|
+
throw new Error("failed to pin a remote media object ".concat(remoteMedia.id, ", because it is not found in this remote media group"));
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
this.unpinnedRemoteMedia.splice(idx, 1);
|
|
111
|
+
this.pinnedRemoteMedia.push(remoteMedia);
|
|
112
|
+
this.cancelActiveSpeakerMediaRequest(false);
|
|
113
|
+
this.sendActiveSpeakerMediaRequest(false);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
remoteMedia.sendMediaRequest(targetCsi, false);
|
|
117
|
+
this.mediaRequestManager.commit();
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Unpins a remote media instance, so that it will again provide media from active speakers
|
|
121
|
+
*
|
|
122
|
+
*/
|
|
123
|
+
|
|
124
|
+
}, {
|
|
125
|
+
key: "unpin",
|
|
126
|
+
value: function unpin(remoteMedia) {
|
|
127
|
+
if (this.unpinnedRemoteMedia.indexOf(remoteMedia) >= 0) {
|
|
128
|
+
_loggerProxy.default.logger.log("RemoteMediaGroup#pin --> remote media ".concat(remoteMedia.id, " already unpinned"));
|
|
129
|
+
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
var idx = this.pinnedRemoteMedia.indexOf(remoteMedia);
|
|
134
|
+
|
|
135
|
+
if (idx < 0) {
|
|
136
|
+
throw new Error("failed to unpin a remote media object ".concat(remoteMedia.id, ", because it is not found in this remote media group"));
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
this.pinnedRemoteMedia.splice(idx, 1);
|
|
140
|
+
this.unpinnedRemoteMedia.push(remoteMedia);
|
|
141
|
+
remoteMedia.cancelMediaRequest(false);
|
|
142
|
+
this.cancelActiveSpeakerMediaRequest(false);
|
|
143
|
+
this.sendActiveSpeakerMediaRequest(false);
|
|
144
|
+
this.mediaRequestManager.commit();
|
|
145
|
+
}
|
|
146
|
+
}, {
|
|
147
|
+
key: "isPinned",
|
|
148
|
+
value: function isPinned(remoteMedia) {
|
|
149
|
+
if (this.unpinnedRemoteMedia.indexOf(remoteMedia) >= 0) {
|
|
150
|
+
return false;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
if (this.pinnedRemoteMedia.indexOf(remoteMedia) >= 0) {
|
|
154
|
+
return true;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
throw new Error("remote media object ".concat(remoteMedia.id, " not found in the group"));
|
|
158
|
+
}
|
|
159
|
+
}, {
|
|
160
|
+
key: "sendActiveSpeakerMediaRequest",
|
|
161
|
+
value: function sendActiveSpeakerMediaRequest(commit) {
|
|
162
|
+
var _this$options;
|
|
163
|
+
|
|
164
|
+
this.cancelActiveSpeakerMediaRequest(false);
|
|
165
|
+
this.mediaRequestId = this.mediaRequestManager.addRequest({
|
|
166
|
+
policyInfo: {
|
|
167
|
+
policy: 'active-speaker',
|
|
168
|
+
priority: this.priority,
|
|
169
|
+
crossPriorityDuplication: false,
|
|
170
|
+
crossPolicyDuplication: false,
|
|
171
|
+
preferLiveVideo: !!((_this$options = this.options) !== null && _this$options !== void 0 && _this$options.preferLiveVideo)
|
|
172
|
+
},
|
|
173
|
+
receiveSlots: this.unpinnedRemoteMedia.map(function (remoteMedia) {
|
|
174
|
+
return remoteMedia.getUnderlyingReceiveSlot();
|
|
175
|
+
}),
|
|
176
|
+
codecInfo: this.options.resolution && {
|
|
177
|
+
codec: 'h264',
|
|
178
|
+
maxFs: (0, _remoteMedia.getMaxFs)(this.options.resolution)
|
|
179
|
+
}
|
|
180
|
+
}, commit);
|
|
181
|
+
}
|
|
182
|
+
}, {
|
|
183
|
+
key: "cancelActiveSpeakerMediaRequest",
|
|
184
|
+
value: function cancelActiveSpeakerMediaRequest(commit) {
|
|
185
|
+
if (this.mediaRequestId) {
|
|
186
|
+
this.mediaRequestManager.cancelRequest(this.mediaRequestId, commit);
|
|
187
|
+
this.mediaRequestId = undefined;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Invalidates the remote media group by clearing the references to the receive slots
|
|
192
|
+
* used by all remote media from that group and cancelling all media requests.
|
|
193
|
+
* After this call the remote media group is unusable.
|
|
194
|
+
*
|
|
195
|
+
* @param{boolean} commit whether to commit the cancellation of media requests
|
|
196
|
+
* @internal
|
|
197
|
+
*/
|
|
198
|
+
|
|
199
|
+
}, {
|
|
200
|
+
key: "stop",
|
|
201
|
+
value: function stop() {
|
|
202
|
+
var commit = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
203
|
+
this.unpinnedRemoteMedia.forEach(function (remoteMedia) {
|
|
204
|
+
return remoteMedia.stop(false);
|
|
205
|
+
});
|
|
206
|
+
this.pinnedRemoteMedia.forEach(function (remoteMedia) {
|
|
207
|
+
return remoteMedia.stop(false);
|
|
208
|
+
});
|
|
209
|
+
this.cancelActiveSpeakerMediaRequest(false);
|
|
210
|
+
|
|
211
|
+
if (commit) {
|
|
212
|
+
this.mediaRequestManager.commit();
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Checks if a given RemoteMedia instance belongs to this group.
|
|
217
|
+
*
|
|
218
|
+
* @param remoteMedia RemoteMedia instance to check
|
|
219
|
+
* @param filter controls which remote media from the group to check
|
|
220
|
+
* @returns true if remote media is found
|
|
221
|
+
*/
|
|
222
|
+
|
|
223
|
+
}, {
|
|
224
|
+
key: "includes",
|
|
225
|
+
value: function includes(remoteMedia) {
|
|
226
|
+
var filter = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'all';
|
|
227
|
+
|
|
228
|
+
if (filter === 'pinned') {
|
|
229
|
+
return this.pinnedRemoteMedia.includes(remoteMedia);
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
if (filter === 'unpinned') {
|
|
233
|
+
return this.unpinnedRemoteMedia.includes(remoteMedia);
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
return this.unpinnedRemoteMedia.includes(remoteMedia) || this.pinnedRemoteMedia.includes(remoteMedia);
|
|
237
|
+
}
|
|
238
|
+
}]);
|
|
239
|
+
return RemoteMediaGroup;
|
|
240
|
+
}();
|
|
241
|
+
|
|
242
|
+
exports.RemoteMediaGroup = RemoteMediaGroup;
|
|
243
|
+
//# sourceMappingURL=remoteMediaGroup.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["RemoteMediaGroup","mediaRequestManager","receiveSlots","priority","commitMediaRequest","options","unpinnedRemoteMedia","map","slot","RemoteMedia","resolution","pinnedRemoteMedia","sendActiveSpeakerMediaRequest","filter","remoteMedia","csi","targetCsi","Error","id","indexOf","LoggerProxy","logger","log","idx","splice","push","cancelActiveSpeakerMediaRequest","sendMediaRequest","commit","cancelMediaRequest","mediaRequestId","addRequest","policyInfo","policy","crossPriorityDuplication","crossPolicyDuplication","preferLiveVideo","getUnderlyingReceiveSlot","codecInfo","codec","maxFs","getMaxFs","cancelRequest","undefined","forEach","stop","includes"],"sources":["remoteMediaGroup.ts"],"sourcesContent":["/* eslint-disable valid-jsdoc */\n/* eslint-disable require-jsdoc */\n/* eslint-disable import/prefer-default-export */\nimport LoggerProxy from '../common/logs/logger-proxy';\n\nimport {getMaxFs, RemoteMedia, RemoteVideoResolution} from './remoteMedia';\nimport {MediaRequestId, MediaRequestManager} from './mediaRequestManager';\nimport {CSI, ReceiveSlot} from './receiveSlot';\n\ntype Options = {\n resolution?: RemoteVideoResolution; // applies only to groups of type MC.MediaType.VideoMain and MC.MediaType.VideoSlides\n preferLiveVideo?: boolean; // applies only to groups of type MC.MediaType.VideoMain and MC.MediaType.VideoSlides\n};\n\nexport class RemoteMediaGroup {\n private mediaRequestManager: MediaRequestManager;\n\n private priority: number;\n\n private options: Options;\n\n private unpinnedRemoteMedia: RemoteMedia[];\n\n private mediaRequestId?: MediaRequestId; // id of the \"active-speaker\" media request id\n\n private pinnedRemoteMedia: RemoteMedia[];\n\n constructor(\n mediaRequestManager: MediaRequestManager,\n receiveSlots: ReceiveSlot[],\n priority: number,\n commitMediaRequest: boolean,\n options: Options = {}\n ) {\n this.mediaRequestManager = mediaRequestManager;\n this.priority = priority;\n this.options = options;\n\n this.unpinnedRemoteMedia = receiveSlots.map(\n (slot) =>\n new RemoteMedia(slot, this.mediaRequestManager, {\n resolution: this.options.resolution,\n })\n );\n this.pinnedRemoteMedia = [];\n\n this.sendActiveSpeakerMediaRequest(commitMediaRequest);\n }\n\n /**\n * Gets the array of remote media elements from the group\n *\n * @param {string} filter - 'all' (default) returns both pinned and unpinned\n * @returns {Array<RemoteMedia>}\n */\n public getRemoteMedia(filter: 'all' | 'pinned' | 'unpinned' = 'all') {\n if (filter === 'unpinned') {\n // return a shallow copy so that the client cannot modify this.unpinnedRemoteMedia array\n return [...this.unpinnedRemoteMedia];\n }\n if (filter === 'pinned') {\n // return a shallow copy so that the client cannot modify this.pinnedRemoteMedia array\n return [...this.pinnedRemoteMedia];\n }\n return [...this.unpinnedRemoteMedia, ...this.pinnedRemoteMedia];\n }\n\n /**\n * Pins a specific remote media instance to a specfic CSI, so the media will\n * no longer come from active speaker, but from that CSI.\n * If no CSI is given, the current CSI value is used.\n *\n */\n public pin(remoteMedia: RemoteMedia, csi?: CSI): void {\n // if csi is not specified, use the current one\n const targetCsi = csi || remoteMedia.csi;\n\n if (!targetCsi) {\n throw new Error(\n `failed to pin a remote media object ${remoteMedia.id}, because it has no CSI set and no CSI value was given`\n );\n }\n\n if (this.pinnedRemoteMedia.indexOf(remoteMedia) >= 0) {\n if (targetCsi === remoteMedia.csi) {\n // remote media already pinned to target CSI, nothing to do\n LoggerProxy.logger.log(\n `RemoteMediaGroup#pin --> remote media ${remoteMedia.id} already pinned`\n );\n\n return;\n }\n } else {\n const idx = this.unpinnedRemoteMedia.indexOf(remoteMedia);\n\n if (idx < 0) {\n throw new Error(\n `failed to pin a remote media object ${remoteMedia.id}, because it is not found in this remote media group`\n );\n }\n\n this.unpinnedRemoteMedia.splice(idx, 1);\n this.pinnedRemoteMedia.push(remoteMedia);\n\n this.cancelActiveSpeakerMediaRequest(false);\n this.sendActiveSpeakerMediaRequest(false);\n }\n\n remoteMedia.sendMediaRequest(targetCsi, false);\n this.mediaRequestManager.commit();\n }\n\n /**\n * Unpins a remote media instance, so that it will again provide media from active speakers\n *\n */\n public unpin(remoteMedia: RemoteMedia) {\n if (this.unpinnedRemoteMedia.indexOf(remoteMedia) >= 0) {\n LoggerProxy.logger.log(\n `RemoteMediaGroup#pin --> remote media ${remoteMedia.id} already unpinned`\n );\n\n return;\n }\n const idx = this.pinnedRemoteMedia.indexOf(remoteMedia);\n\n if (idx < 0) {\n throw new Error(\n `failed to unpin a remote media object ${remoteMedia.id}, because it is not found in this remote media group`\n );\n }\n\n this.pinnedRemoteMedia.splice(idx, 1);\n this.unpinnedRemoteMedia.push(remoteMedia);\n\n remoteMedia.cancelMediaRequest(false);\n this.cancelActiveSpeakerMediaRequest(false);\n this.sendActiveSpeakerMediaRequest(false);\n this.mediaRequestManager.commit();\n }\n\n public isPinned(remoteMedia: RemoteMedia) {\n if (this.unpinnedRemoteMedia.indexOf(remoteMedia) >= 0) {\n return false;\n }\n if (this.pinnedRemoteMedia.indexOf(remoteMedia) >= 0) {\n return true;\n }\n\n throw new Error(`remote media object ${remoteMedia.id} not found in the group`);\n }\n\n private sendActiveSpeakerMediaRequest(commit: boolean) {\n this.cancelActiveSpeakerMediaRequest(false);\n\n this.mediaRequestId = this.mediaRequestManager.addRequest(\n {\n policyInfo: {\n policy: 'active-speaker',\n priority: this.priority,\n crossPriorityDuplication: false,\n crossPolicyDuplication: false,\n preferLiveVideo: !!this.options?.preferLiveVideo,\n },\n receiveSlots: this.unpinnedRemoteMedia.map((remoteMedia) =>\n remoteMedia.getUnderlyingReceiveSlot()\n ) as ReceiveSlot[],\n codecInfo: this.options.resolution && {\n codec: 'h264',\n maxFs: getMaxFs(this.options.resolution),\n },\n },\n commit\n );\n }\n\n private cancelActiveSpeakerMediaRequest(commit: boolean) {\n if (this.mediaRequestId) {\n this.mediaRequestManager.cancelRequest(this.mediaRequestId, commit);\n this.mediaRequestId = undefined;\n }\n }\n\n /**\n * Invalidates the remote media group by clearing the references to the receive slots\n * used by all remote media from that group and cancelling all media requests.\n * After this call the remote media group is unusable.\n *\n * @param{boolean} commit whether to commit the cancellation of media requests\n * @internal\n */\n public stop(commit: boolean = true) {\n this.unpinnedRemoteMedia.forEach((remoteMedia) => remoteMedia.stop(false));\n this.pinnedRemoteMedia.forEach((remoteMedia) => remoteMedia.stop(false));\n this.cancelActiveSpeakerMediaRequest(false);\n\n if (commit) {\n this.mediaRequestManager.commit();\n }\n }\n\n /**\n * Checks if a given RemoteMedia instance belongs to this group.\n *\n * @param remoteMedia RemoteMedia instance to check\n * @param filter controls which remote media from the group to check\n * @returns true if remote media is found\n */\n public includes(\n remoteMedia: RemoteMedia,\n filter: 'all' | 'pinned' | 'unpinned' = 'all'\n ): boolean {\n if (filter === 'pinned') {\n return this.pinnedRemoteMedia.includes(remoteMedia);\n }\n if (filter === 'unpinned') {\n return this.unpinnedRemoteMedia.includes(remoteMedia);\n }\n\n return (\n this.unpinnedRemoteMedia.includes(remoteMedia) || this.pinnedRemoteMedia.includes(remoteMedia)\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAGA;;AAEA;;AALA;;AACA;;AACA;IAYaA,gB;EAS8B;EAIzC,0BACEC,mBADF,EAEEC,YAFF,EAGEC,QAHF,EAIEC,kBAJF,EAME;IAAA;;IAAA,IADAC,OACA,uEADmB,EACnB;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IACA,KAAKJ,mBAAL,GAA2BA,mBAA3B;IACA,KAAKE,QAAL,GAAgBA,QAAhB;IACA,KAAKE,OAAL,GAAeA,OAAf;IAEA,KAAKC,mBAAL,GAA2BJ,YAAY,CAACK,GAAb,CACzB,UAACC,IAAD;MAAA,OACE,IAAIC,wBAAJ,CAAgBD,IAAhB,EAAsB,KAAI,CAACP,mBAA3B,EAAgD;QAC9CS,UAAU,EAAE,KAAI,CAACL,OAAL,CAAaK;MADqB,CAAhD,CADF;IAAA,CADyB,CAA3B;IAMA,KAAKC,iBAAL,GAAyB,EAAzB;IAEA,KAAKC,6BAAL,CAAmCR,kBAAnC;EACD;EAED;AACF;AACA;AACA;AACA;AACA;;;;;WACE,0BAAqE;MAAA,IAA/CS,MAA+C,uEAAP,KAAO;;MACnE,IAAIA,MAAM,KAAK,UAAf,EAA2B;QACzB;QACA,wCAAW,KAAKP,mBAAhB;MACD;;MACD,IAAIO,MAAM,KAAK,QAAf,EAAyB;QACvB;QACA,wCAAW,KAAKF,iBAAhB;MAC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