fcr-core 3.7.8 → 3.7.9-alpha
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/lib/chat-connection/index.js +26 -41
- package/lib/engine/index.js +74 -67
- package/lib/imports.js +0 -1
- package/lib/media-control/desktop.js +13 -18
- package/lib/media-control/mobile.js +13 -18
- package/lib/monitor-control/index.js +5 -10
- package/lib/peer-session/index.js +39 -48
- package/lib/plugins/chatroom.js +202 -218
- package/lib/room-control/ability-control/index.js +9 -14
- package/lib/room-control/group-control/index.js +16 -21
- package/lib/room-control/helpers/validation-helper.js +1 -1
- package/lib/room-control/index.js +36 -53
- package/lib/room-control/interpreter-control/index.js +34 -47
- package/lib/room-control/interpreter-control/room.js +4 -6
- package/lib/room-control/join-before-host-waitingroom-control/index.js +4 -6
- package/lib/room-control/mainroom-control/index.js +17 -25
- package/lib/room-control/privilege-control/helper.js +5 -8
- package/lib/room-control/privilege-control/index.js +19 -26
- package/lib/room-control/room-connector-control/index.js +19 -28
- package/lib/room-control/room-control-factory.js +1 -2
- package/lib/room-control/room-session/index.js +39 -48
- package/lib/room-control/shared-cache.js +29 -36
- package/lib/room-control/sharing-control/index.js +32 -40
- package/lib/room-control/stream-control/index.js +173 -181
- package/lib/room-control/user-control/index.js +136 -143
- package/lib/room-control/waitingroom-control/index.js +9 -14
- package/lib/room-control/whiteboard-control-v2/annotation-control/control.js +24 -32
- package/lib/room-control/whiteboard-control-v2/annotation-control/index.js +16 -27
- package/lib/room-control/whiteboard-control-v2/annotation-control/privilege-control.js +53 -63
- package/lib/room-control/whiteboard-control-v2/index.js +28 -40
- package/lib/room-control/whiteboard-control-v2/main-window.js +23 -28
- package/lib/room-control/whiteboard-control-v2/utils.js +6 -7
- package/lib/room-control/whiteboard-control-v2/whiteboard-control/control.js +27 -38
- package/lib/room-control/whiteboard-control-v2/whiteboard-control/index.js +3 -5
- package/lib/room-control/whiteboard-control-v2/whiteboard-control/privilege-control.js +42 -54
- package/lib/room-router/index.js +42 -52
- package/lib/service/api.js +207 -231
- package/lib/utilities/collection.js +2 -3
- package/lib/utilities/error-helpers.js +27 -34
- package/lib/utilities/error.js +8 -9
- package/lib/utilities/join-helper.js +25 -32
- package/lib/utilities/logger.js +3 -6
- package/lib/utilities/parameters.js +4 -8
- package/lib/utilities/retry-helpers.js +0 -1
- package/lib/utilities/shared-storage.js +0 -1
- package/lib/utilities/storage.js +0 -1
- package/lib/utilities/stream.js +11 -16
- package/lib/utilities/user.js +3 -4
- package/lib/utilities/validate-params.js +1 -2
- package/package.json +4 -4
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
require("core-js/modules/es.symbol.description.js");
|
|
4
|
-
require("core-js/modules/es.error.cause.js");
|
|
5
3
|
require("core-js/modules/esnext.function.metadata.js");
|
|
6
4
|
require("core-js/modules/esnext.symbol.metadata.js");
|
|
7
5
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
@@ -29,8 +27,6 @@ require("core-js/modules/esnext.map.merge.js");
|
|
|
29
27
|
require("core-js/modules/esnext.map.reduce.js");
|
|
30
28
|
require("core-js/modules/esnext.map.some.js");
|
|
31
29
|
require("core-js/modules/esnext.map.update.js");
|
|
32
|
-
require("core-js/modules/web.dom-collections.iterator.js");
|
|
33
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
34
30
|
var _imports = require("../../imports");
|
|
35
31
|
var _type = require("../../type");
|
|
36
32
|
var _user = require("../../utilities/user");
|
|
@@ -38,10 +34,7 @@ var _error = require("../../utilities/error");
|
|
|
38
34
|
var _logger = require("../../utilities/logger");
|
|
39
35
|
var _validateParams = _interopRequireDefault(require("../../utilities/validate-params"));
|
|
40
36
|
var _schema = require("../../schema");
|
|
41
|
-
|
|
42
|
-
let _initProto, _addLocalStreamsDecs, _bindLocalStreamsDecs, _updatePublishPrivilegeOfStreamsDecs, _removeStreamsDecs, _setVideoEncoderConfigDecs, _setScreenScenarioDecs, _startRenderRemoteVideoStreamDecs, _stopRenderRemoteVideoStreamDecs, _startPlayRemoteAudioStreamDecs, _stopPlayRemoteAudioStreamDecs, _takeSnapshotDecs, _addLocalScreenStreamDecs, _adjustRemoteAudioStreamVolumeDecs, _mergeAudioStreamDecs, _splitAudioStreamDecs, _ref;
|
|
43
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
44
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
37
|
+
let _initProto, _addLocalStreamsDecs, _bindLocalStreamsDecs, _updatePublishPrivilegeOfStreamsDecs, _removeStreamsDecs, _setVideoEncoderConfigDecs, _setScreenScenarioDecs, _startRenderRemoteVideoStreamDecs, _stopRenderRemoteVideoStreamDecs, _startPlayRemoteAudioStreamDecs, _stopPlayRemoteAudioStreamDecs, _takeSnapshotDecs, _addLocalScreenStreamDecs, _adjustRemoteAudioStreamVolumeDecs, _mergeAudioStreamDecs, _splitAudioStreamDecs;
|
|
45
38
|
function _applyDecs(e, t, r, n, o, a) { function i(e, t, r) { return function (n, o) { return r && r(n), e[t].call(n, o); }; } function c(e, t) { for (var r = 0; r < e.length; r++) e[r].call(t); return t; } function s(e, t, r, n) { if ("function" != typeof e && (n || void 0 !== e)) throw new TypeError(t + " must " + (r || "be") + " a function" + (n ? "" : " or undefined")); return e; } function applyDec(e, t, r, n, o, a, c, u, l, f, p, d, h) { function m(e) { if (!h(e)) throw new TypeError("Attempted to access private element on non-instance"); } var y, v = t[0], g = t[3], b = !u; if (!b) { r || Array.isArray(v) || (v = [v]); var w = {}, S = [], A = 3 === o ? "get" : 4 === o || d ? "set" : "value"; f ? (p || d ? w = { get: _setFunctionName(function () { return g(this); }, n, "get"), set: function (e) { t[4](this, e); } } : w[A] = g, p || _setFunctionName(w[A], n, 2 === o ? "" : A)) : p || (w = Object.getOwnPropertyDescriptor(e, n)); } for (var P = e, j = v.length - 1; j >= 0; j -= r ? 2 : 1) { var D = v[j], E = r ? v[j - 1] : void 0, I = {}, O = { kind: ["field", "accessor", "method", "getter", "setter", "class"][o], name: n, metadata: a, addInitializer: function (e, t) { if (e.v) throw Error("attempted to call addInitializer after decoration was finished"); s(t, "An initializer", "be", !0), c.push(t); }.bind(null, I) }; try { if (b) (y = s(D.call(E, P, O), "class decorators", "return")) && (P = y);else { var k, F; O.static = l, O.private = f, f ? 2 === o ? k = function (e) { return m(e), w.value; } : (o < 4 && (k = i(w, "get", m)), 3 !== o && (F = i(w, "set", m))) : (k = function (e) { return e[n]; }, (o < 2 || 4 === o) && (F = function (e, t) { e[n] = t; })); var N = O.access = { has: f ? h.bind() : function (e) { return n in e; } }; if (k && (N.get = k), F && (N.set = F), P = D.call(E, d ? { get: w.get, set: w.set } : w[A], O), d) { if ("object" == typeof P && P) (y = s(P.get, "accessor.get")) && (w.get = y), (y = s(P.set, "accessor.set")) && (w.set = y), (y = s(P.init, "accessor.init")) && S.push(y);else if (void 0 !== P) throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0"); } else s(P, (p ? "field" : "method") + " decorators", "return") && (p ? S.push(P) : w[A] = P); } } finally { I.v = !0; } } return (p || d) && u.push(function (e, t) { for (var r = S.length - 1; r >= 0; r--) t = S[r].call(e, t); return t; }), p || b || (f ? d ? u.push(i(w, "get"), i(w, "set")) : u.push(2 === o ? w[A] : i.call.bind(w[A])) : Object.defineProperty(e, n, w)), P; } function u(e, t) { return Object.defineProperty(e, Symbol.metadata || Symbol.for("Symbol.metadata"), { configurable: !0, enumerable: !0, value: t }); } if (arguments.length >= 6) var l = a[Symbol.metadata || Symbol.for("Symbol.metadata")]; var f = Object.create(null == l ? null : l), p = function (e, t, r, n) { var o, a, i = [], s = function (t) { return _checkInRHS(t) === e; }, u = new Map(); function l(e) { e && i.push(c.bind(null, e)); } for (var f = 0; f < t.length; f++) { var p = t[f]; if (Array.isArray(p)) { var d = p[1], h = p[2], m = p.length > 3, y = 16 & d, v = !!(8 & d), g = 0 == (d &= 7), b = h + "/" + v; if (!g && !m) { var w = u.get(b); if (!0 === w || 3 === w && 4 !== d || 4 === w && 3 !== d) throw Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: " + h); u.set(b, !(d > 2) || d); } applyDec(v ? e : e.prototype, p, y, m ? "#" + h : _toPropertyKey(h), d, n, v ? a = a || [] : o = o || [], i, v, m, g, 1 === d, v && m ? s : r); } } return l(o), l(a), i; }(e, t, o, f); return r.length || u(e, f), { e: p, get c() { var t = []; return r.length && [u(applyDec(e, [r], n, e.name, 5, f, t), f), c.bind(null, t, e)]; } }; }
|
|
46
39
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
47
40
|
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
@@ -50,148 +43,104 @@ function _checkInRHS(e) { if (Object(e) !== e) throw TypeError("right-hand side
|
|
|
50
43
|
/**
|
|
51
44
|
* @internal
|
|
52
45
|
*/
|
|
53
|
-
_ref = (_addLocalStreamsDecs = [_imports.bound, _imports.trace, (0, _validateParams.default)(_schema.fcrLocalStreamCreateArrayConfigSchema)], _bindLocalStreamsDecs = [_imports.bound, _imports.trace, (0, _validateParams.default)(_schema.fcrStreamBindConfigArrySchema)], _updatePublishPrivilegeOfStreamsDecs = [_imports.bound, _imports.trace, (0, _validateParams.default)(_schema.fcrUpdateStreamCustomSchema, _schema.fcrUpdateStreamPrivilegeScopeSchema.optional())], _removeStreamsDecs = [_imports.bound, _imports.trace, (0, _validateParams.default)(_schema.stringArraySchema)], _setVideoEncoderConfigDecs = [_imports.bound, _imports.trace, (0, _validateParams.default)(_schema.stringSchema, _schema.agoraRtcVideoEncoderConfigurationSchema, _schema.fcrVideoStreamTypeSchema)], _setScreenScenarioDecs = [_imports.bound, _imports.trace, (0, _validateParams.default)(_schema.fcrScreenScenarioTypeSchema)], _startRenderRemoteVideoStreamDecs = [_imports.bound, _imports.trace, (0, _validateParams.default)(_schema.stringSchema, _schema.fcrVideoStreamTypeSchema, _schema.fcrRenderConfigSchema, (0, _schema.createUnionSchema)([_schema.fcrRenderViewSchema, _imports.objectSchema]))], _stopRenderRemoteVideoStreamDecs = [_imports.bound, _imports.trace, (0, _validateParams.default)(_schema.stringSchema, _schema.fcrRenderViewSchema)], _startPlayRemoteAudioStreamDecs = [_imports.bound, _imports.trace, (0, _validateParams.default)(_schema.stringSchema)], _stopPlayRemoteAudioStreamDecs = [_imports.bound, _imports.trace, (0, _validateParams.default)(_schema.stringSchema)], _takeSnapshotDecs = [_imports.bound, _imports.trace, (0, _validateParams.default)(_schema.stringSchema, _schema.stringSchema)], _addLocalScreenStreamDecs = [_imports.bound, _imports.trace, (0, _validateParams.default)(_schema.fcrScreenStreamCreateConfigSchema, _schema.fcrSizeSchema)], _adjustRemoteAudioStreamVolumeDecs = [_imports.bound, _imports.trace, (0, _validateParams.default)(_schema.stringSchema, _schema.numberSchema)], _mergeAudioStreamDecs = [_imports.bound, _imports.trace, (0, _validateParams.default)(_schema.stringSchema)], _splitAudioStreamDecs = [_imports.bound, _imports.trace, (0, _validateParams.default)(_schema.stringSchema)], "logger");
|
|
54
46
|
class FcrStreamControlImpl {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
const exists = stream.streamId in this._streamMapByStreamId;
|
|
92
|
-
if (!exists) {
|
|
93
|
-
this.logger.warn("[FcrStreamControl] stream removed when the stream does not exist, streamId: ".concat(stream.streamId));
|
|
94
|
-
} else {
|
|
95
|
-
const index = this._streamList.findIndex(s => stream.streamId === s.streamId);
|
|
96
|
-
if (index !== -1) {
|
|
97
|
-
this._streamList.splice(index, 1);
|
|
98
|
-
}
|
|
99
|
-
delete this._streamMapByStreamId[stream.streamId];
|
|
100
|
-
this._deleteUserStream(stream.owner.userId, stream);
|
|
101
|
-
}
|
|
102
|
-
});
|
|
103
|
-
this._observable.notifyObservers('onStreamsRemoved', sceneId, fcrStreamEvents);
|
|
104
|
-
},
|
|
105
|
-
onStreamsUpdated: (sceneId, events) => {
|
|
106
|
-
const fcrStreamEvents = events.map(this._convertStreamEvent);
|
|
107
|
-
fcrStreamEvents.forEach(event => {
|
|
108
|
-
const stream = event.modifiedStream;
|
|
109
|
-
const exists = stream.streamId in this._streamMapByStreamId;
|
|
110
|
-
if (!exists) {
|
|
111
|
-
this.logger.warn("[FcrStreamControl] stream updated when the stream does not exist, streamId: ".concat(stream.streamId));
|
|
112
|
-
} else {
|
|
113
|
-
const index = this._streamList.findIndex(s => stream.streamId === s.streamId);
|
|
114
|
-
if (index !== -1) {
|
|
115
|
-
this._streamList.splice(index, 1, stream);
|
|
116
|
-
}
|
|
117
|
-
this._streamMapByStreamId[stream.streamId] = stream;
|
|
118
|
-
this._setUserStream(stream.owner.userId, stream);
|
|
119
|
-
}
|
|
120
|
-
});
|
|
121
|
-
this._observable.notifyObservers('onStreamsUpdated', sceneId, fcrStreamEvents);
|
|
122
|
-
},
|
|
123
|
-
onLocalVideoStatsUpdated: (sceneId, streamId, stats) => {
|
|
124
|
-
this._observable.notifyObservers('onLocalVideoStatsUpdated', sceneId, streamId, stats);
|
|
125
|
-
},
|
|
126
|
-
onLocalAudioStatsUpdated: (sceneId, streamId, stats) => {
|
|
127
|
-
this._observable.notifyObservers('onLocalAudioStatsUpdated', sceneId, streamId, stats);
|
|
128
|
-
},
|
|
129
|
-
onRemoteVideoStatsUpdated: (sceneId, streamId, stats) => {
|
|
130
|
-
this._observable.notifyObservers('onRemoteVideoStatsUpdated', sceneId, streamId, stats);
|
|
131
|
-
},
|
|
132
|
-
onRemoteAudioStatsUpdated: (sceneId, streamId, stats) => {
|
|
133
|
-
this._observable.notifyObservers('onRemoteAudioStatsUpdated', sceneId, streamId, stats);
|
|
134
|
-
},
|
|
135
|
-
onFirstRemoteVideoFrameRendered: (sceneId, streamId) => {
|
|
136
|
-
this._observable.notifyObservers('onFirstRemoteVideoFrameRendered', sceneId, streamId);
|
|
137
|
-
}
|
|
138
|
-
});
|
|
139
|
-
//@internal
|
|
140
|
-
(0, _defineProperty2.default)(this, "_addSceneStreamPlayerObserver", {
|
|
141
|
-
onRemoteAudioStreamVolumeUpdated: (streamId, volume) => this._observable.notifyObservers('onStreamVolumeIndicationUpdated', this._scene.sceneId, streamId, volume)
|
|
142
|
-
});
|
|
143
|
-
(0, _defineProperty2.default)(this, "_convertStreamInfo", info => {
|
|
144
|
-
return {
|
|
145
|
-
streamId: info.streamId,
|
|
146
|
-
streamName: info.streamName,
|
|
147
|
-
owner: (0, _user.convertRteUserToFcrUser)(info.owner, this._roomCache),
|
|
148
|
-
streamType: info.streamType,
|
|
149
|
-
videoSourceType: info.videoSourceType,
|
|
150
|
-
audioSourceType: info.audioSourceType,
|
|
151
|
-
videoSourceState: info.videoSourceState,
|
|
152
|
-
audioSourceState: info.audioSourceState,
|
|
153
|
-
videoSourceId: info.videoSourceId,
|
|
154
|
-
audioSourceId: info.audioSourceId,
|
|
155
|
-
connectorType: info.connectorType
|
|
156
|
-
};
|
|
157
|
-
});
|
|
158
|
-
(0, _defineProperty2.default)(this, "_getPublishStateByPrivilege", privilege => {
|
|
159
|
-
return privilege === _imports.AgoraRteStreamPrivilegeOperation.HAS_PRIVILEGE ? 1 : privilege === _imports.AgoraRteStreamPrivilegeOperation.NOPRIVILEGE ? 0 : undefined;
|
|
160
|
-
});
|
|
161
|
-
(0, _defineProperty2.default)(this, "_convertStreamEvent", event => {
|
|
162
|
-
return {
|
|
163
|
-
modifiedStream: this._convertStreamInfo(event.modifiedStream),
|
|
164
|
-
operatorUser: event.operatorUser ? (0, _user.convertRteUserToFcrUser)(event.operatorUser, this._roomCache) : undefined,
|
|
165
|
-
cause: event.cause
|
|
166
|
-
};
|
|
167
|
-
});
|
|
168
|
-
(0, _defineProperty2.default)(this, "_putUserStream", (userId, stream) => {
|
|
169
|
-
if (!this._streamMapByUserId[userId]) {
|
|
170
|
-
this._streamMapByUserId[userId] = [];
|
|
171
|
-
}
|
|
172
|
-
this._streamMapByUserId[userId].push(stream);
|
|
173
|
-
});
|
|
174
|
-
(0, _defineProperty2.default)(this, "_setUserStream", (userId, stream) => {
|
|
175
|
-
const streams = this._streamMapByUserId[userId];
|
|
176
|
-
if (streams) {
|
|
177
|
-
const index = streams.findIndex(s => s.streamId === stream.streamId);
|
|
178
|
-
if (index !== -1) {
|
|
179
|
-
streams.splice(index, 1, stream);
|
|
47
|
+
static {
|
|
48
|
+
[_initProto] = _applyDecs(this, [[_imports.bound, 2, "getStreams"], [_imports.bound, 2, "getStreamList"], [_imports.bound, 2, "getStreamsByUserId"], [_imports.bound, 2, "getStreamByStreamId"], [_addLocalStreamsDecs, 2, "addLocalStreams"], [_bindLocalStreamsDecs, 2, "bindLocalStreams"], [_updatePublishPrivilegeOfStreamsDecs, 2, "updatePublishPrivilegeOfStreams"], [_removeStreamsDecs, 2, "removeStreams"], [_setVideoEncoderConfigDecs, 2, "setVideoEncoderConfig"], [_setScreenScenarioDecs, 2, "setScreenScenario"], [_startRenderRemoteVideoStreamDecs, 2, "startRenderRemoteVideoStream"], [_stopRenderRemoteVideoStreamDecs, 2, "stopRenderRemoteVideoStream"], [_startPlayRemoteAudioStreamDecs, 2, "startPlayRemoteAudioStream"], [_stopPlayRemoteAudioStreamDecs, 2, "stopPlayRemoteAudioStream"], [_takeSnapshotDecs, 2, "takeSnapshot"], [_addLocalScreenStreamDecs, 2, "addLocalScreenStream"], [[_imports.bound, _imports.trace], 2, "removeScreenStream"], [_adjustRemoteAudioStreamVolumeDecs, 2, "adjustRemoteAudioStreamVolume"], [_mergeAudioStreamDecs, 2, "mergeAudioStream"], [_splitAudioStreamDecs, 2, "splitAudioStream"]], []).e;
|
|
49
|
+
}
|
|
50
|
+
//@internal
|
|
51
|
+
[(_addLocalStreamsDecs = [_imports.bound, _imports.trace, (0, _validateParams.default)(_schema.fcrLocalStreamCreateArrayConfigSchema)], _bindLocalStreamsDecs = [_imports.bound, _imports.trace, (0, _validateParams.default)(_schema.fcrStreamBindConfigArrySchema)], _updatePublishPrivilegeOfStreamsDecs = [_imports.bound, _imports.trace, (0, _validateParams.default)(_schema.fcrUpdateStreamCustomSchema, _schema.fcrUpdateStreamPrivilegeScopeSchema.optional())], _removeStreamsDecs = [_imports.bound, _imports.trace, (0, _validateParams.default)(_schema.stringArraySchema)], _setVideoEncoderConfigDecs = [_imports.bound, _imports.trace, (0, _validateParams.default)(_schema.stringSchema, _schema.agoraRtcVideoEncoderConfigurationSchema, _schema.fcrVideoStreamTypeSchema)], _setScreenScenarioDecs = [_imports.bound, _imports.trace, (0, _validateParams.default)(_schema.fcrScreenScenarioTypeSchema)], _startRenderRemoteVideoStreamDecs = [_imports.bound, _imports.trace, (0, _validateParams.default)(_schema.stringSchema, _schema.fcrVideoStreamTypeSchema, _schema.fcrRenderConfigSchema, (0, _schema.createUnionSchema)([_schema.fcrRenderViewSchema, _imports.objectSchema]))], _stopRenderRemoteVideoStreamDecs = [_imports.bound, _imports.trace, (0, _validateParams.default)(_schema.stringSchema, _schema.fcrRenderViewSchema)], _startPlayRemoteAudioStreamDecs = [_imports.bound, _imports.trace, (0, _validateParams.default)(_schema.stringSchema)], _stopPlayRemoteAudioStreamDecs = [_imports.bound, _imports.trace, (0, _validateParams.default)(_schema.stringSchema)], _takeSnapshotDecs = [_imports.bound, _imports.trace, (0, _validateParams.default)(_schema.stringSchema, _schema.stringSchema)], _addLocalScreenStreamDecs = [_imports.bound, _imports.trace, (0, _validateParams.default)(_schema.fcrScreenStreamCreateConfigSchema, _schema.fcrSizeSchema)], _adjustRemoteAudioStreamVolumeDecs = [_imports.bound, _imports.trace, (0, _validateParams.default)(_schema.stringSchema, _schema.numberSchema)], _mergeAudioStreamDecs = [_imports.bound, _imports.trace, (0, _validateParams.default)(_schema.stringSchema)], _splitAudioStreamDecs = [_imports.bound, _imports.trace, (0, _validateParams.default)(_schema.stringSchema)], "logger")] = (_initProto(this), (0, _logger.createLogger)({
|
|
52
|
+
prefix: 'FcrStreamControlImpl'
|
|
53
|
+
}));
|
|
54
|
+
//@internal
|
|
55
|
+
_observable = new _imports.AgoraObservable();
|
|
56
|
+
//@internal
|
|
57
|
+
_streamMapByStreamId = {};
|
|
58
|
+
//@internal
|
|
59
|
+
_streamMapByUserId = {};
|
|
60
|
+
//@internal
|
|
61
|
+
_streamList = [];
|
|
62
|
+
//@internal
|
|
63
|
+
|
|
64
|
+
//@internal
|
|
65
|
+
_remoteSubscribedStreamRenderMap = new Map();
|
|
66
|
+
//@internal
|
|
67
|
+
|
|
68
|
+
//@internal
|
|
69
|
+
|
|
70
|
+
//@internal
|
|
71
|
+
_sceneObserver = {
|
|
72
|
+
onStreamsAdded: (sceneId, events) => {
|
|
73
|
+
const fcrStreamEvents = events.map(this._convertStreamEvent);
|
|
74
|
+
fcrStreamEvents.forEach(event => {
|
|
75
|
+
const stream = event.modifiedStream;
|
|
76
|
+
const exists = stream.streamId in this._streamMapByStreamId;
|
|
77
|
+
if (exists) {
|
|
78
|
+
this.logger.warn(`[FcrStreamControl] stream added when the stream already exists, streamId: ${stream.streamId}`);
|
|
79
|
+
} else {
|
|
80
|
+
this._streamList.push(stream);
|
|
81
|
+
this._streamMapByStreamId[stream.streamId] = stream;
|
|
82
|
+
this._putUserStream(stream.owner.userId, stream);
|
|
180
83
|
}
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
84
|
+
});
|
|
85
|
+
this._observable.notifyObservers('onStreamsAdded', sceneId, fcrStreamEvents);
|
|
86
|
+
},
|
|
87
|
+
onStreamsRemoved: (sceneId, events) => {
|
|
88
|
+
const fcrStreamEvents = events.map(this._convertStreamEvent);
|
|
89
|
+
fcrStreamEvents.forEach(event => {
|
|
90
|
+
const stream = event.modifiedStream;
|
|
91
|
+
const exists = stream.streamId in this._streamMapByStreamId;
|
|
92
|
+
if (!exists) {
|
|
93
|
+
this.logger.warn(`[FcrStreamControl] stream removed when the stream does not exist, streamId: ${stream.streamId}`);
|
|
94
|
+
} else {
|
|
95
|
+
const index = this._streamList.findIndex(s => stream.streamId === s.streamId);
|
|
96
|
+
if (index !== -1) {
|
|
97
|
+
this._streamList.splice(index, 1);
|
|
98
|
+
}
|
|
99
|
+
delete this._streamMapByStreamId[stream.streamId];
|
|
100
|
+
this._deleteUserStream(stream.owner.userId, stream);
|
|
189
101
|
}
|
|
190
|
-
|
|
191
|
-
|
|
102
|
+
});
|
|
103
|
+
this._observable.notifyObservers('onStreamsRemoved', sceneId, fcrStreamEvents);
|
|
104
|
+
},
|
|
105
|
+
onStreamsUpdated: (sceneId, events) => {
|
|
106
|
+
const fcrStreamEvents = events.map(this._convertStreamEvent);
|
|
107
|
+
fcrStreamEvents.forEach(event => {
|
|
108
|
+
const stream = event.modifiedStream;
|
|
109
|
+
const exists = stream.streamId in this._streamMapByStreamId;
|
|
110
|
+
if (!exists) {
|
|
111
|
+
this.logger.warn(`[FcrStreamControl] stream updated when the stream does not exist, streamId: ${stream.streamId}`);
|
|
112
|
+
} else {
|
|
113
|
+
const index = this._streamList.findIndex(s => stream.streamId === s.streamId);
|
|
114
|
+
if (index !== -1) {
|
|
115
|
+
this._streamList.splice(index, 1, stream);
|
|
116
|
+
}
|
|
117
|
+
this._streamMapByStreamId[stream.streamId] = stream;
|
|
118
|
+
this._setUserStream(stream.owner.userId, stream);
|
|
192
119
|
}
|
|
193
|
-
}
|
|
194
|
-
|
|
120
|
+
});
|
|
121
|
+
this._observable.notifyObservers('onStreamsUpdated', sceneId, fcrStreamEvents);
|
|
122
|
+
},
|
|
123
|
+
onLocalVideoStatsUpdated: (sceneId, streamId, stats) => {
|
|
124
|
+
this._observable.notifyObservers('onLocalVideoStatsUpdated', sceneId, streamId, stats);
|
|
125
|
+
},
|
|
126
|
+
onLocalAudioStatsUpdated: (sceneId, streamId, stats) => {
|
|
127
|
+
this._observable.notifyObservers('onLocalAudioStatsUpdated', sceneId, streamId, stats);
|
|
128
|
+
},
|
|
129
|
+
onRemoteVideoStatsUpdated: (sceneId, streamId, stats) => {
|
|
130
|
+
this._observable.notifyObservers('onRemoteVideoStatsUpdated', sceneId, streamId, stats);
|
|
131
|
+
},
|
|
132
|
+
onRemoteAudioStatsUpdated: (sceneId, streamId, stats) => {
|
|
133
|
+
this._observable.notifyObservers('onRemoteAudioStatsUpdated', sceneId, streamId, stats);
|
|
134
|
+
},
|
|
135
|
+
onFirstRemoteVideoFrameRendered: (sceneId, streamId) => {
|
|
136
|
+
this._observable.notifyObservers('onFirstRemoteVideoFrameRendered', sceneId, streamId);
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
//@internal
|
|
140
|
+
_addSceneStreamPlayerObserver = {
|
|
141
|
+
onRemoteAudioStreamVolumeUpdated: (streamId, volume) => this._observable.notifyObservers('onStreamVolumeIndicationUpdated', this._scene.sceneId, streamId, volume)
|
|
142
|
+
};
|
|
143
|
+
constructor(_engine, _scene, _api, _sharedCache) {
|
|
195
144
|
this._engine = _engine;
|
|
196
145
|
this._scene = _scene;
|
|
197
146
|
this._api = _api;
|
|
@@ -230,28 +179,23 @@ class FcrStreamControlImpl {
|
|
|
230
179
|
}
|
|
231
180
|
}
|
|
232
181
|
addLocalStreams(streams) {
|
|
233
|
-
return (0, _error.handleRequestError)(() => this._api.createStreamBatch(this._scene.sceneId, streams.map(config => {
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
}, (0, _imports.convertStreamTypeToPublishState)(config.streamType));
|
|
246
|
-
})), _error.FcrErrorModuleCode.ROOM_STREAM, 'add local streams failed');
|
|
182
|
+
return (0, _error.handleRequestError)(() => this._api.createStreamBatch(this._scene.sceneId, streams.map(config => ({
|
|
183
|
+
streamName: config.streamName,
|
|
184
|
+
streamUuid: '0',
|
|
185
|
+
// means that this stream needs to be created
|
|
186
|
+
generateToken: config.generateToken ?? config.videoSourceType === _imports.AgoraRteVideoSourceType.SCREEN,
|
|
187
|
+
userUuid: config.ownerId,
|
|
188
|
+
videoSourceType: config.videoSourceType,
|
|
189
|
+
audioSourceType: config.audioSourceType,
|
|
190
|
+
videoSourceUuid: config.videoSourceId,
|
|
191
|
+
audioSourceUuid: config.audioSourceId,
|
|
192
|
+
...(0, _imports.convertStreamTypeToPublishState)(config.streamType)
|
|
193
|
+
}))), _error.FcrErrorModuleCode.ROOM_STREAM, 'add local streams failed');
|
|
247
194
|
}
|
|
248
195
|
bindLocalStreams(streams) {
|
|
249
196
|
return this._scene.localUser.bindLocalStreams(streams);
|
|
250
197
|
}
|
|
251
|
-
updatePublishPrivilegeOfStreams() {
|
|
252
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
253
|
-
args[_key] = arguments[_key];
|
|
254
|
-
}
|
|
198
|
+
updatePublishPrivilegeOfStreams(...args) {
|
|
255
199
|
if (args.length === 1) {
|
|
256
200
|
const privileges = args[0];
|
|
257
201
|
return (0, _error.handleRequestError)(() => this._api.updateStreamBatch(this._scene.sceneId, Object.keys(privileges).map(streamId => ({
|
|
@@ -304,11 +248,10 @@ class FcrStreamControlImpl {
|
|
|
304
248
|
|
|
305
249
|
const elements = this._remoteSubscribedStreamRenderMap.get(streamId) || [];
|
|
306
250
|
const renderCount = elements.length;
|
|
307
|
-
const isDifferentCanvas = !
|
|
251
|
+
const isDifferentCanvas = !elements?.includes(element);
|
|
308
252
|
if (renderCount === 0 || isDifferentCanvas) {
|
|
309
|
-
var _this$_remoteSubscrib;
|
|
310
253
|
this._remoteSubscribedStreamRenderMap.set(streamId, [...elements, element]);
|
|
311
|
-
this.logger.info(
|
|
254
|
+
this.logger.info(`[FcrStreamControl][subscribe-remote-video-stream] start subscribe streamId: ${streamId}, before subscribe renderCount: ${renderCount}, after subscribe renderCount: ${this._remoteSubscribedStreamRenderMap.get(streamId)?.length}`);
|
|
312
255
|
}
|
|
313
256
|
this._scene.streamPlayer.subscribeRemoteVideoStream(streamId, type);
|
|
314
257
|
this._scene.streamPlayer.startRenderRemoteVideoStream(streamId, type, config.renderMode, config.isMirror, element);
|
|
@@ -317,15 +260,15 @@ class FcrStreamControlImpl {
|
|
|
317
260
|
// 当 stopRender 相同的 streamId 与 canvasId 时,计数减一
|
|
318
261
|
// 引用计数减为 0 时,调用 unsubscribeRemoteVideoStream
|
|
319
262
|
const elements = this._remoteSubscribedStreamRenderMap.get(streamId) || [];
|
|
320
|
-
const isSameCanvas = elements
|
|
263
|
+
const isSameCanvas = elements?.includes(element);
|
|
321
264
|
if (isSameCanvas) {
|
|
322
|
-
const rest = elements
|
|
265
|
+
const rest = elements?.filter(e => e !== element);
|
|
323
266
|
this._remoteSubscribedStreamRenderMap.set(streamId, rest);
|
|
324
|
-
this.logger.info(
|
|
267
|
+
this.logger.info(`[FcrStreamControl][unsubscribe-remote-video-stream] has same canvas, streamId: ${streamId}, subtract renderCount, do not unsubscribe remote video stream, rest renderCount: ${rest.length}`);
|
|
325
268
|
}
|
|
326
269
|
if (elements.length === 0) {
|
|
327
270
|
this._scene.streamPlayer.unsubscribeRemoteVideoStream(streamId);
|
|
328
|
-
this.logger.info(
|
|
271
|
+
this.logger.info(`[FcrStreamControl][unsubscribe-remote-video-stream] renderCount ${elements.length} is 0, unsubscribeRemoteVideoStream streamId: ${streamId}`);
|
|
329
272
|
}
|
|
330
273
|
this._scene.streamPlayer.stopRenderRemoteVideoStream(streamId, element);
|
|
331
274
|
}
|
|
@@ -342,14 +285,14 @@ class FcrStreamControlImpl {
|
|
|
342
285
|
const res = await (0, _error.handleRequestError)(() => this._api.startShareScreen({
|
|
343
286
|
roomId: this._scene.sceneId,
|
|
344
287
|
userId: this._scene.getLocalUser().getLocalUserId(),
|
|
345
|
-
config:
|
|
288
|
+
config: {
|
|
346
289
|
videoSourceType: _type.FcrVideoSourceType.SCREEN,
|
|
347
290
|
audioSourceType: _type.FcrAudioSourceType.LOOPBACK,
|
|
348
291
|
videoSourceState: _type.FcrMediaSourceState.CLOSE,
|
|
349
292
|
audioSourceState: _type.FcrMediaSourceState.CLOSE,
|
|
350
293
|
videoSourceUuid: config.videoSourceId,
|
|
351
|
-
audioSourceUuid: config.audioSourceId
|
|
352
|
-
|
|
294
|
+
audioSourceUuid: config.audioSourceId,
|
|
295
|
+
...(0, _imports.convertStreamTypeToPublishState)(config.streamType),
|
|
353
296
|
annotation: size ? {
|
|
354
297
|
size: {
|
|
355
298
|
width: size.width,
|
|
@@ -361,7 +304,7 @@ class FcrStreamControlImpl {
|
|
|
361
304
|
height: 0
|
|
362
305
|
}
|
|
363
306
|
}
|
|
364
|
-
}
|
|
307
|
+
}
|
|
365
308
|
}), _error.FcrErrorModuleCode.ROOM_STREAM, 'add local screen stream failed');
|
|
366
309
|
const {
|
|
367
310
|
data: {
|
|
@@ -416,14 +359,65 @@ class FcrStreamControlImpl {
|
|
|
416
359
|
this._observable.removeObserver(observer);
|
|
417
360
|
}
|
|
418
361
|
async findSelectionByParamId(paramSourceId) {
|
|
419
|
-
|
|
420
|
-
const
|
|
421
|
-
const displays = (await ((_this$_mediaControl2 = this._mediaControl) === null || _this$_mediaControl2 === void 0 ? void 0 : _this$_mediaControl2.getDisplayList())) || [];
|
|
362
|
+
const wins = (await this._mediaControl?.getWindowList()) || [];
|
|
363
|
+
const displays = (await this._mediaControl?.getDisplayList()) || [];
|
|
422
364
|
const findInList = list => list.find(item => item.id === paramSourceId);
|
|
423
365
|
const winMatch = findInList(wins);
|
|
424
366
|
const displayMatch = findInList(displays);
|
|
425
367
|
return winMatch || displayMatch || null;
|
|
426
368
|
}
|
|
369
|
+
_convertStreamInfo = info => {
|
|
370
|
+
return {
|
|
371
|
+
streamId: info.streamId,
|
|
372
|
+
streamName: info.streamName,
|
|
373
|
+
owner: (0, _user.convertRteUserToFcrUser)(info.owner, this._roomCache),
|
|
374
|
+
streamType: info.streamType,
|
|
375
|
+
videoSourceType: info.videoSourceType,
|
|
376
|
+
audioSourceType: info.audioSourceType,
|
|
377
|
+
videoSourceState: info.videoSourceState,
|
|
378
|
+
audioSourceState: info.audioSourceState,
|
|
379
|
+
videoSourceId: info.videoSourceId,
|
|
380
|
+
audioSourceId: info.audioSourceId,
|
|
381
|
+
connectorType: info.connectorType
|
|
382
|
+
};
|
|
383
|
+
};
|
|
384
|
+
_getPublishStateByPrivilege = privilege => {
|
|
385
|
+
return privilege === _imports.AgoraRteStreamPrivilegeOperation.HAS_PRIVILEGE ? 1 : privilege === _imports.AgoraRteStreamPrivilegeOperation.NOPRIVILEGE ? 0 : undefined;
|
|
386
|
+
};
|
|
387
|
+
_convertStreamEvent = event => {
|
|
388
|
+
return {
|
|
389
|
+
modifiedStream: this._convertStreamInfo(event.modifiedStream),
|
|
390
|
+
operatorUser: event.operatorUser ? (0, _user.convertRteUserToFcrUser)(event.operatorUser, this._roomCache) : undefined,
|
|
391
|
+
cause: event.cause
|
|
392
|
+
};
|
|
393
|
+
};
|
|
394
|
+
_putUserStream = (userId, stream) => {
|
|
395
|
+
if (!this._streamMapByUserId[userId]) {
|
|
396
|
+
this._streamMapByUserId[userId] = [];
|
|
397
|
+
}
|
|
398
|
+
this._streamMapByUserId[userId].push(stream);
|
|
399
|
+
};
|
|
400
|
+
_setUserStream = (userId, stream) => {
|
|
401
|
+
const streams = this._streamMapByUserId[userId];
|
|
402
|
+
if (streams) {
|
|
403
|
+
const index = streams.findIndex(s => s.streamId === stream.streamId);
|
|
404
|
+
if (index !== -1) {
|
|
405
|
+
streams.splice(index, 1, stream);
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
};
|
|
409
|
+
_deleteUserStream = (userId, stream) => {
|
|
410
|
+
const userStreams = this._streamMapByUserId[userId];
|
|
411
|
+
if (userStreams) {
|
|
412
|
+
const index = userStreams.findIndex(s => s.streamId === stream.streamId);
|
|
413
|
+
if (index !== -1) {
|
|
414
|
+
userStreams.splice(index, 1);
|
|
415
|
+
}
|
|
416
|
+
if (userStreams.length === 0) {
|
|
417
|
+
delete this._streamMapByUserId[userId];
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
};
|
|
427
421
|
_addLogObserver() {
|
|
428
422
|
this.addObserver((0, _logger.generateLogObserver)(this.logger, [
|
|
429
423
|
// 'onLocalVideoStatsUpdated',
|
|
@@ -435,6 +429,4 @@ class FcrStreamControlImpl {
|
|
|
435
429
|
'onStreamsAdded', 'onStreamsRemoved', 'onStreamsUpdated']));
|
|
436
430
|
}
|
|
437
431
|
}
|
|
438
|
-
exports.FcrStreamControlImpl = FcrStreamControlImpl;
|
|
439
|
-
_FcrStreamControlImpl = FcrStreamControlImpl;
|
|
440
|
-
[_initProto] = _applyDecs(_FcrStreamControlImpl, [[_imports.bound, 2, "getStreams"], [_imports.bound, 2, "getStreamList"], [_imports.bound, 2, "getStreamsByUserId"], [_imports.bound, 2, "getStreamByStreamId"], [_addLocalStreamsDecs, 2, "addLocalStreams"], [_bindLocalStreamsDecs, 2, "bindLocalStreams"], [_updatePublishPrivilegeOfStreamsDecs, 2, "updatePublishPrivilegeOfStreams"], [_removeStreamsDecs, 2, "removeStreams"], [_setVideoEncoderConfigDecs, 2, "setVideoEncoderConfig"], [_setScreenScenarioDecs, 2, "setScreenScenario"], [_startRenderRemoteVideoStreamDecs, 2, "startRenderRemoteVideoStream"], [_stopRenderRemoteVideoStreamDecs, 2, "stopRenderRemoteVideoStream"], [_startPlayRemoteAudioStreamDecs, 2, "startPlayRemoteAudioStream"], [_stopPlayRemoteAudioStreamDecs, 2, "stopPlayRemoteAudioStream"], [_takeSnapshotDecs, 2, "takeSnapshot"], [_addLocalScreenStreamDecs, 2, "addLocalScreenStream"], [[_imports.bound, _imports.trace], 2, "removeScreenStream"], [_adjustRemoteAudioStreamVolumeDecs, 2, "adjustRemoteAudioStreamVolume"], [_mergeAudioStreamDecs, 2, "mergeAudioStream"], [_splitAudioStreamDecs, 2, "splitAudioStream"]], []).e;
|
|
432
|
+
exports.FcrStreamControlImpl = FcrStreamControlImpl;
|