fcr-core 3.7.9-alpha → 3.8.0-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.d.ts +1 -1
- package/lib/chat-connection/index.js +41 -26
- package/lib/engine/index.js +72 -78
- package/lib/imports.d.ts +7 -2
- package/lib/imports.js +26 -4
- package/lib/index.d.ts +2 -2
- package/lib/index.js +12 -0
- package/lib/media-control/desktop.js +22 -17
- package/lib/media-control/mobile.js +38 -33
- package/lib/media-control/type.d.ts +8 -0
- package/lib/monitor-control/index.js +10 -5
- package/lib/peer-session/index.js +48 -39
- package/lib/plugins/chatroom.js +237 -205
- package/lib/room-control/ability-control/index.js +14 -9
- package/lib/room-control/ability-control/type.d.ts +4 -1
- package/lib/room-control/ability-control/type.js +3 -0
- package/lib/room-control/group-control/index.js +21 -16
- package/lib/room-control/helpers/constants.d.ts +4 -0
- package/lib/room-control/helpers/constants.js +5 -1
- package/lib/room-control/helpers/validation-helper.js +1 -1
- package/lib/room-control/index.js +66 -38
- package/lib/room-control/interpreter-control/index.js +49 -38
- package/lib/room-control/interpreter-control/room.js +6 -4
- package/lib/room-control/join-before-host-waitingroom-control/index.js +6 -4
- package/lib/room-control/mainroom-control/index.js +90 -17
- package/lib/room-control/privilege-control/helper.js +8 -5
- package/lib/room-control/privilege-control/index.js +66 -19
- package/lib/room-control/privilege-control/type.d.ts +57 -10
- package/lib/room-control/privilege-control/type.js +17 -0
- package/lib/room-control/room-connector-control/index.js +28 -19
- package/lib/room-control/room-control-factory.js +3 -2
- package/lib/room-control/room-session/index.js +68 -49
- package/lib/room-control/room-session/type.d.ts +2 -2
- package/lib/room-control/shared-cache.js +36 -29
- package/lib/room-control/sharing-control/index.d.ts +5 -5
- package/lib/room-control/sharing-control/index.js +81 -43
- package/lib/room-control/sharing-control/type.d.ts +9 -5
- package/lib/room-control/sharing-control/type.js +6 -1
- package/lib/room-control/stream-control/index.d.ts +8 -1
- package/lib/room-control/stream-control/index.js +310 -199
- package/lib/room-control/stream-control/type.d.ts +6 -0
- package/lib/room-control/stt-control/de-compress-gzip.d.ts +1 -0
- package/lib/room-control/stt-control/de-compress-gzip.js +49 -0
- package/lib/room-control/stt-control/index.d.ts +1 -0
- package/lib/room-control/stt-control/index.js +353 -0
- package/lib/room-control/stt-control/type.d.ts +142 -0
- package/lib/room-control/stt-control/type.js +16 -0
- package/lib/room-control/type.d.ts +15 -0
- package/lib/room-control/type.js +13 -1
- package/lib/room-control/user-control/index.js +143 -136
- package/lib/room-control/waitingroom-control/index.js +14 -9
- package/lib/room-control/whiteboard-control/enum.d.ts +15 -0
- package/lib/room-control/whiteboard-control/{types.js → enum.js} +12 -1
- package/lib/room-control/whiteboard-control/type.d.ts +38 -0
- package/lib/room-control/whiteboard-control/type.js +15 -0
- package/lib/room-control/whiteboard-control/utils.d.ts +3 -0
- package/lib/room-control/whiteboard-control/utils.js +23 -0
- package/lib/room-control/whiteboard-control-v1/board-subwindow.d.ts +6 -0
- package/lib/room-control/whiteboard-control-v1/board-subwindow.js +26 -0
- package/lib/room-control/whiteboard-control-v1/board-window.d.ts +58 -0
- package/lib/room-control/whiteboard-control-v1/board-window.js +571 -0
- package/lib/room-control/{whiteboard-control/enums.d.ts → whiteboard-control-v1/enum.d.ts} +3 -17
- package/lib/room-control/{whiteboard-control/enums.js → whiteboard-control-v1/enum.js} +3 -20
- package/lib/room-control/whiteboard-control-v1/factory.d.ts +9 -0
- package/lib/room-control/whiteboard-control-v1/factory.js +22 -0
- package/lib/room-control/whiteboard-control-v1/index.d.ts +1 -0
- package/lib/room-control/whiteboard-control-v1/index.js +440 -0
- package/lib/room-control/whiteboard-control-v1/mount-manager.d.ts +4 -0
- package/lib/room-control/whiteboard-control-v1/mount-manager.js +15 -0
- package/lib/room-control/whiteboard-control-v1/type.d.ts +300 -0
- package/lib/room-control/whiteboard-control-v1/type.js +13 -0
- package/lib/room-control/whiteboard-control-v1/utils.d.ts +53 -0
- package/lib/room-control/whiteboard-control-v1/utils.js +290 -0
- package/lib/room-control/whiteboard-control-v2/annotation-control/control.d.ts +17 -31
- package/lib/room-control/whiteboard-control-v2/annotation-control/control.js +42 -228
- package/lib/room-control/whiteboard-control-v2/annotation-control/factory.d.ts +10 -0
- package/lib/room-control/whiteboard-control-v2/annotation-control/factory.js +48 -0
- package/lib/room-control/whiteboard-control-v2/annotation-control/type.d.ts +11 -19
- package/lib/room-control/whiteboard-control-v2/annotation-control/type.js +1 -3
- package/lib/room-control/whiteboard-control-v2/base/index.d.ts +42 -0
- package/lib/room-control/whiteboard-control-v2/base/index.js +317 -0
- package/lib/room-control/whiteboard-control-v2/{main-window.d.ts → base/main-window.d.ts} +6 -4
- package/lib/room-control/whiteboard-control-v2/{main-window.js → base/main-window.js} +54 -36
- package/lib/room-control/whiteboard-control-v2/constant.d.ts +6 -0
- package/lib/room-control/whiteboard-control-v2/constant.js +15 -0
- package/lib/room-control/whiteboard-control-v2/enum.d.ts +26 -0
- package/lib/room-control/whiteboard-control-v2/enum.js +34 -0
- package/lib/room-control/{whiteboard-control/types.d.ts → whiteboard-control-v2/type.d.ts} +51 -165
- package/lib/room-control/whiteboard-control-v2/type.js +5 -0
- package/lib/room-control/whiteboard-control-v2/utils.d.ts +5 -4
- package/lib/room-control/whiteboard-control-v2/utils.js +29 -27
- package/lib/room-control/whiteboard-control-v2/whiteboard-control/control.d.ts +34 -33
- package/lib/room-control/whiteboard-control-v2/whiteboard-control/control.js +131 -187
- package/lib/room-control/whiteboard-control-v2/whiteboard-control/factory.d.ts +11 -0
- package/lib/room-control/whiteboard-control-v2/{annotation-control/index.js → whiteboard-control/factory.js} +40 -38
- package/lib/room-control/whiteboard-control-v2/whiteboard-control/type.d.ts +18 -30
- package/lib/room-control/whiteboard-control-v2/whiteboard-control/type.js +1 -9
- package/lib/room-router/index.js +56 -42
- package/lib/schema.d.ts +23 -9
- package/lib/schema.js +10 -4
- package/lib/service/api.d.ts +75 -19
- package/lib/service/api.js +401 -208
- package/lib/type.d.ts +15 -2
- package/lib/type.js +13 -0
- package/lib/utilities/collection.js +3 -2
- package/lib/utilities/error-helpers.d.ts +2 -1
- package/lib/utilities/error-helpers.js +35 -27
- package/lib/utilities/error.d.ts +1 -0
- package/lib/utilities/error.js +10 -8
- package/lib/utilities/join-helper.js +32 -25
- package/lib/utilities/logger.d.ts +2 -2
- package/lib/utilities/logger.js +6 -3
- package/lib/utilities/parameters.js +8 -4
- package/lib/utilities/retry-helpers.js +1 -0
- package/lib/utilities/shared-storage.d.ts +3 -1
- package/lib/utilities/shared-storage.js +10 -1
- package/lib/utilities/storage.js +1 -0
- package/lib/utilities/stream.js +16 -11
- package/lib/utilities/user.js +4 -3
- package/lib/utilities/validate-params.js +2 -1
- package/package.json +11 -5
- package/lib/room-control/whiteboard-control-v2/annotation-control/index.d.ts +0 -19
- package/lib/room-control/whiteboard-control-v2/annotation-control/privilege-control.d.ts +0 -36
- package/lib/room-control/whiteboard-control-v2/annotation-control/privilege-control.js +0 -252
- package/lib/room-control/whiteboard-control-v2/index.d.ts +0 -38
- package/lib/room-control/whiteboard-control-v2/index.js +0 -274
- package/lib/room-control/whiteboard-control-v2/whiteboard-control/index.d.ts +0 -17
- package/lib/room-control/whiteboard-control-v2/whiteboard-control/index.js +0 -30
- package/lib/room-control/whiteboard-control-v2/whiteboard-control/privilege-control.d.ts +0 -36
- package/lib/room-control/whiteboard-control-v2/whiteboard-control/privilege-control.js +0 -240
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
require("core-js/modules/es.symbol.description.js");
|
|
4
|
+
require("core-js/modules/es.error.cause.js");
|
|
3
5
|
require("core-js/modules/esnext.function.metadata.js");
|
|
4
6
|
require("core-js/modules/esnext.symbol.metadata.js");
|
|
5
7
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
6
8
|
Object.defineProperty(exports, "__esModule", {
|
|
7
9
|
value: true
|
|
8
10
|
});
|
|
9
|
-
exports.FcrStreamControlImpl = void 0;
|
|
11
|
+
exports.FcrSubscribedStreamsControl = exports.FcrStreamControlImpl = void 0;
|
|
10
12
|
require("core-js/modules/es.array.push.js");
|
|
13
|
+
require("core-js/modules/es.json.stringify.js");
|
|
11
14
|
require("core-js/modules/esnext.iterator.constructor.js");
|
|
12
15
|
require("core-js/modules/esnext.iterator.filter.js");
|
|
13
16
|
require("core-js/modules/esnext.iterator.find.js");
|
|
@@ -27,6 +30,8 @@ require("core-js/modules/esnext.map.merge.js");
|
|
|
27
30
|
require("core-js/modules/esnext.map.reduce.js");
|
|
28
31
|
require("core-js/modules/esnext.map.some.js");
|
|
29
32
|
require("core-js/modules/esnext.map.update.js");
|
|
33
|
+
require("core-js/modules/web.dom-collections.iterator.js");
|
|
34
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
30
35
|
var _imports = require("../../imports");
|
|
31
36
|
var _type = require("../../type");
|
|
32
37
|
var _user = require("../../utilities/user");
|
|
@@ -34,7 +39,10 @@ var _error = require("../../utilities/error");
|
|
|
34
39
|
var _logger = require("../../utilities/logger");
|
|
35
40
|
var _validateParams = _interopRequireDefault(require("../../utilities/validate-params"));
|
|
36
41
|
var _schema = require("../../schema");
|
|
37
|
-
|
|
42
|
+
var _FcrStreamControlImpl;
|
|
43
|
+
let _initProto, _addLocalStreamsDecs, _bindLocalStreamsDecs, _updatePublishPrivilegeOfStreamsDecs, _removeStreamsDecs, _setVideoEncoderConfigDecs, _setScreenScenarioDecs, _startRenderRemoteVideoStreamDecs, _stopRenderRemoteVideoStreamDecs, _startPlayRemoteAudioStreamDecs, _stopPlayRemoteAudioStreamDecs, _takeSnapshotDecs, _addLocalScreenStreamDecs, _adjustRemoteAudioStreamVolumeDecs, _mergeAudioStreamDecs, _splitAudioStreamDecs, _ref;
|
|
44
|
+
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; }
|
|
45
|
+
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; }
|
|
38
46
|
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)]; } }; }
|
|
39
47
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
40
48
|
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); }
|
|
@@ -43,104 +51,148 @@ function _checkInRHS(e) { if (Object(e) !== e) throw TypeError("right-hand side
|
|
|
43
51
|
/**
|
|
44
52
|
* @internal
|
|
45
53
|
*/
|
|
54
|
+
_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");
|
|
46
55
|
class FcrStreamControlImpl {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
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);
|
|
83
|
-
}
|
|
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);
|
|
56
|
+
constructor(_engine, _scene, _api, _sharedCache) {
|
|
57
|
+
//@internal
|
|
58
|
+
(0, _defineProperty2.default)(this, _ref, (_initProto(this), (0, _logger.createLogger)({
|
|
59
|
+
prefix: 'FcrStreamControlImpl'
|
|
60
|
+
})));
|
|
61
|
+
//@internal
|
|
62
|
+
(0, _defineProperty2.default)(this, "_observable", new _imports.AgoraObservable());
|
|
63
|
+
//@internal
|
|
64
|
+
(0, _defineProperty2.default)(this, "_streamMapByStreamId", {});
|
|
65
|
+
//@internal
|
|
66
|
+
(0, _defineProperty2.default)(this, "_streamMapByUserId", {});
|
|
67
|
+
//@internal
|
|
68
|
+
(0, _defineProperty2.default)(this, "_streamList", []);
|
|
69
|
+
//@internal
|
|
70
|
+
(0, _defineProperty2.default)(this, "_subscribedStreamsControl", new FcrSubscribedStreamsControl());
|
|
71
|
+
//@internal
|
|
72
|
+
(0, _defineProperty2.default)(this, "_sceneObserver", {
|
|
73
|
+
onStreamsAdded: (sceneId, events) => {
|
|
74
|
+
const fcrStreamEvents = events.map(this._convertStreamEvent);
|
|
75
|
+
fcrStreamEvents.forEach(event => {
|
|
76
|
+
const stream = event.modifiedStream;
|
|
77
|
+
const exists = stream.streamId in this._streamMapByStreamId;
|
|
78
|
+
if (exists) {
|
|
79
|
+
this.logger.warn("[FcrStreamControl] stream added when the stream already exists, streamId: ".concat(stream.streamId));
|
|
80
|
+
} else {
|
|
81
|
+
this._streamList.push(stream);
|
|
82
|
+
this._streamMapByStreamId[stream.streamId] = stream;
|
|
83
|
+
this._putUserStream(stream.owner.userId, stream);
|
|
98
84
|
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
this.
|
|
85
|
+
});
|
|
86
|
+
this._observable.notifyObservers('onStreamsAdded', sceneId, fcrStreamEvents);
|
|
87
|
+
},
|
|
88
|
+
onStreamsRemoved: (sceneId, events) => {
|
|
89
|
+
const fcrStreamEvents = events.map(this._convertStreamEvent);
|
|
90
|
+
fcrStreamEvents.forEach(event => {
|
|
91
|
+
const stream = event.modifiedStream;
|
|
92
|
+
const exists = stream.streamId in this._streamMapByStreamId;
|
|
93
|
+
if (!exists) {
|
|
94
|
+
this.logger.warn("[FcrStreamControl] stream removed when the stream does not exist, streamId: ".concat(stream.streamId));
|
|
95
|
+
} else {
|
|
96
|
+
const index = this._streamList.findIndex(s => stream.streamId === s.streamId);
|
|
97
|
+
if (index !== -1) {
|
|
98
|
+
this._streamList.splice(index, 1);
|
|
99
|
+
}
|
|
100
|
+
delete this._streamMapByStreamId[stream.streamId];
|
|
101
|
+
this._deleteUserStream(stream.owner.userId, stream);
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
this._observable.notifyObservers('onStreamsRemoved', sceneId, fcrStreamEvents);
|
|
105
|
+
},
|
|
106
|
+
onStreamsUpdated: (sceneId, events) => {
|
|
107
|
+
const fcrStreamEvents = events.map(this._convertStreamEvent);
|
|
108
|
+
fcrStreamEvents.forEach(event => {
|
|
109
|
+
const stream = event.modifiedStream;
|
|
110
|
+
const exists = stream.streamId in this._streamMapByStreamId;
|
|
111
|
+
if (!exists) {
|
|
112
|
+
this.logger.warn("[FcrStreamControl] stream updated when the stream does not exist, streamId: ".concat(stream.streamId));
|
|
113
|
+
} else {
|
|
114
|
+
const index = this._streamList.findIndex(s => stream.streamId === s.streamId);
|
|
115
|
+
if (index !== -1) {
|
|
116
|
+
this._streamList.splice(index, 1, stream);
|
|
117
|
+
}
|
|
118
|
+
this._streamMapByStreamId[stream.streamId] = stream;
|
|
119
|
+
this._setUserStream(stream.owner.userId, stream);
|
|
116
120
|
}
|
|
117
|
-
|
|
118
|
-
|
|
121
|
+
});
|
|
122
|
+
this._observable.notifyObservers('onStreamsUpdated', sceneId, fcrStreamEvents);
|
|
123
|
+
},
|
|
124
|
+
onLocalVideoStatsUpdated: (sceneId, streamId, stats) => {
|
|
125
|
+
this._observable.notifyObservers('onLocalVideoStatsUpdated', sceneId, streamId, stats);
|
|
126
|
+
},
|
|
127
|
+
onLocalAudioStatsUpdated: (sceneId, streamId, stats) => {
|
|
128
|
+
this._observable.notifyObservers('onLocalAudioStatsUpdated', sceneId, streamId, stats);
|
|
129
|
+
},
|
|
130
|
+
onRemoteVideoStatsUpdated: (sceneId, streamId, stats) => {
|
|
131
|
+
this._observable.notifyObservers('onRemoteVideoStatsUpdated', sceneId, streamId, stats);
|
|
132
|
+
},
|
|
133
|
+
onRemoteAudioStatsUpdated: (sceneId, streamId, stats) => {
|
|
134
|
+
this._observable.notifyObservers('onRemoteAudioStatsUpdated', sceneId, streamId, stats);
|
|
135
|
+
},
|
|
136
|
+
onFirstRemoteVideoFrameRendered: (sceneId, streamId) => {
|
|
137
|
+
this._observable.notifyObservers('onFirstRemoteVideoFrameRendered', sceneId, streamId);
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
//@internal
|
|
141
|
+
(0, _defineProperty2.default)(this, "_addSceneStreamPlayerObserver", {
|
|
142
|
+
onRemoteAudioStreamVolumeUpdated: (streamId, volume) => this._observable.notifyObservers('onStreamVolumeIndicationUpdated', this._scene.sceneId, streamId, volume)
|
|
143
|
+
});
|
|
144
|
+
(0, _defineProperty2.default)(this, "_convertStreamInfo", info => {
|
|
145
|
+
return {
|
|
146
|
+
streamId: info.streamId,
|
|
147
|
+
streamName: info.streamName,
|
|
148
|
+
owner: (0, _user.convertRteUserToFcrUser)(info.owner, this._roomCache),
|
|
149
|
+
streamType: info.streamType,
|
|
150
|
+
videoSourceType: info.videoSourceType,
|
|
151
|
+
audioSourceType: info.audioSourceType,
|
|
152
|
+
videoSourceState: info.videoSourceState,
|
|
153
|
+
audioSourceState: info.audioSourceState,
|
|
154
|
+
videoSourceId: info.videoSourceId,
|
|
155
|
+
audioSourceId: info.audioSourceId,
|
|
156
|
+
connectorType: info.connectorType
|
|
157
|
+
};
|
|
158
|
+
});
|
|
159
|
+
(0, _defineProperty2.default)(this, "_getPublishStateByPrivilege", privilege => {
|
|
160
|
+
return privilege === _imports.AgoraRteStreamPrivilegeOperation.HAS_PRIVILEGE ? 1 : privilege === _imports.AgoraRteStreamPrivilegeOperation.NOPRIVILEGE ? 0 : undefined;
|
|
161
|
+
});
|
|
162
|
+
(0, _defineProperty2.default)(this, "_convertStreamEvent", event => {
|
|
163
|
+
return {
|
|
164
|
+
modifiedStream: this._convertStreamInfo(event.modifiedStream),
|
|
165
|
+
operatorUser: event.operatorUser ? (0, _user.convertRteUserToFcrUser)(event.operatorUser, this._roomCache) : undefined,
|
|
166
|
+
cause: event.cause
|
|
167
|
+
};
|
|
168
|
+
});
|
|
169
|
+
(0, _defineProperty2.default)(this, "_putUserStream", (userId, stream) => {
|
|
170
|
+
if (!this._streamMapByUserId[userId]) {
|
|
171
|
+
this._streamMapByUserId[userId] = [];
|
|
172
|
+
}
|
|
173
|
+
this._streamMapByUserId[userId].push(stream);
|
|
174
|
+
});
|
|
175
|
+
(0, _defineProperty2.default)(this, "_setUserStream", (userId, stream) => {
|
|
176
|
+
const streams = this._streamMapByUserId[userId];
|
|
177
|
+
if (streams) {
|
|
178
|
+
const index = streams.findIndex(s => s.streamId === stream.streamId);
|
|
179
|
+
if (index !== -1) {
|
|
180
|
+
streams.splice(index, 1, stream);
|
|
119
181
|
}
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
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) {
|
|
182
|
+
}
|
|
183
|
+
});
|
|
184
|
+
(0, _defineProperty2.default)(this, "_deleteUserStream", (userId, stream) => {
|
|
185
|
+
const userStreams = this._streamMapByUserId[userId];
|
|
186
|
+
if (userStreams) {
|
|
187
|
+
const index = userStreams.findIndex(s => s.streamId === stream.streamId);
|
|
188
|
+
if (index !== -1) {
|
|
189
|
+
userStreams.splice(index, 1);
|
|
190
|
+
}
|
|
191
|
+
if (userStreams.length === 0) {
|
|
192
|
+
delete this._streamMapByUserId[userId];
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
});
|
|
144
196
|
this._engine = _engine;
|
|
145
197
|
this._scene = _scene;
|
|
146
198
|
this._api = _api;
|
|
@@ -178,24 +230,60 @@ class FcrStreamControlImpl {
|
|
|
178
230
|
return this._convertStreamInfo(streamInfo);
|
|
179
231
|
}
|
|
180
232
|
}
|
|
181
|
-
addLocalStreams(streams) {
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
233
|
+
async addLocalStreams(streams) {
|
|
234
|
+
const streamCreateResult = await (0, _error.handleRequestError)(() => this._api.createStreamBatch(this._scene.sceneId, streams.map(config => {
|
|
235
|
+
var _config$generateToken;
|
|
236
|
+
return _objectSpread({
|
|
237
|
+
streamName: config.streamName,
|
|
238
|
+
streamUuid: '0',
|
|
239
|
+
// means that this stream needs to be created
|
|
240
|
+
generateToken: (_config$generateToken = config.generateToken) !== null && _config$generateToken !== void 0 ? _config$generateToken : config.videoSourceType === _imports.AgoraRteVideoSourceType.SCREEN,
|
|
241
|
+
userUuid: config.ownerId,
|
|
242
|
+
videoSourceType: config.videoSourceType,
|
|
243
|
+
audioSourceType: config.audioSourceType,
|
|
244
|
+
videoSourceUuid: config.videoSourceId,
|
|
245
|
+
audioSourceUuid: config.audioSourceId
|
|
246
|
+
}, (0, _imports.convertStreamTypeToPublishState)(config.streamType));
|
|
247
|
+
})), _error.FcrErrorModuleCode.ROOM_STREAM, 'add local streams failed');
|
|
248
|
+
|
|
249
|
+
// 处理需要 token 的流
|
|
250
|
+
this._handleStreamTokensPreparation(streams, streamCreateResult.data);
|
|
251
|
+
return streamCreateResult;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* 处理流的 token 准备工作
|
|
256
|
+
* @param streams 流配置列表
|
|
257
|
+
*/
|
|
258
|
+
_handleStreamTokensPreparation(streams, streamCreateResultData) {
|
|
259
|
+
// 提前过滤出需要 token
|
|
260
|
+
const streamConfigMap = new Map();
|
|
261
|
+
streams.forEach(config => {
|
|
262
|
+
const needsToken = config.generateToken || config.videoSourceType === _imports.AgoraRteVideoSourceType.SCREEN;
|
|
263
|
+
if (needsToken) {
|
|
264
|
+
streamConfigMap.set(config.ownerId, config);
|
|
265
|
+
}
|
|
266
|
+
});
|
|
267
|
+
|
|
268
|
+
// 如果没有需要 token 的流,直接返回
|
|
269
|
+
if (streamConfigMap.size === 0) {
|
|
270
|
+
return;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
// 遍历返回的流数据,准备发布流
|
|
274
|
+
streamCreateResultData.forEach(stream => {
|
|
275
|
+
if (stream.rtcToken && streamConfigMap.has(stream.userUuid)) {
|
|
276
|
+
this._scene.localUser.prepareToPublishStream(stream.streamUuid, stream.rtcToken);
|
|
277
|
+
}
|
|
278
|
+
});
|
|
194
279
|
}
|
|
195
280
|
bindLocalStreams(streams) {
|
|
196
281
|
return this._scene.localUser.bindLocalStreams(streams);
|
|
197
282
|
}
|
|
198
|
-
updatePublishPrivilegeOfStreams(
|
|
283
|
+
updatePublishPrivilegeOfStreams() {
|
|
284
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
285
|
+
args[_key] = arguments[_key];
|
|
286
|
+
}
|
|
199
287
|
if (args.length === 1) {
|
|
200
288
|
const privileges = args[0];
|
|
201
289
|
return (0, _error.handleRequestError)(() => this._api.updateStreamBatch(this._scene.sceneId, Object.keys(privileges).map(streamId => ({
|
|
@@ -229,48 +317,54 @@ class FcrStreamControlImpl {
|
|
|
229
317
|
}), _error.FcrErrorModuleCode.ROOM_STREAM, 'update publish privilege of streams failed');
|
|
230
318
|
}
|
|
231
319
|
}
|
|
232
|
-
removeStreams(streams) {
|
|
233
|
-
|
|
320
|
+
async removeStreams(streams) {
|
|
321
|
+
const res = await (0, _error.handleRequestError)(() => this._api.deleteStreamBatch(this._scene.sceneId, streams.map(streamUuid => ({
|
|
234
322
|
streamUuid
|
|
235
323
|
}))), _error.FcrErrorModuleCode.ROOM_STREAM, 'remove streams failed');
|
|
324
|
+
streams.forEach(streamUuid => {
|
|
325
|
+
this._scene.localUser.removePreparePublishStream(streamUuid);
|
|
326
|
+
});
|
|
327
|
+
return res;
|
|
236
328
|
}
|
|
237
329
|
setVideoEncoderConfig(streamId, config, streamType) {
|
|
238
330
|
return this._scene.localUser.setVideoEncoderConfig(config, streamType, streamId);
|
|
239
331
|
}
|
|
332
|
+
setDualStreamMode(streamId, enable) {
|
|
333
|
+
return this._scene.localUser.setDualStreamMode(streamId, enable);
|
|
334
|
+
}
|
|
240
335
|
setScreenScenario(type) {
|
|
241
336
|
return this._scene.localUser.setScreenScenario(type);
|
|
242
337
|
}
|
|
243
338
|
startRenderRemoteVideoStream(streamId, type, config, element) {
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
// 当 startRender 相同的 streamId 时且 canvasId 不同时,计数加一
|
|
247
|
-
// 引用计数大于0时,不再调用 subscribeRemoteVideoStream;
|
|
248
|
-
|
|
249
|
-
const elements = this._remoteSubscribedStreamRenderMap.get(streamId) || [];
|
|
250
|
-
const renderCount = elements.length;
|
|
251
|
-
const isDifferentCanvas = !elements?.includes(element);
|
|
252
|
-
if (renderCount === 0 || isDifferentCanvas) {
|
|
253
|
-
this._remoteSubscribedStreamRenderMap.set(streamId, [...elements, element]);
|
|
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}`);
|
|
255
|
-
}
|
|
339
|
+
const startTime = Date.now();
|
|
340
|
+
const parameters = "streamId: ".concat(streamId, ", config: ").concat(JSON.stringify(config), ", type: ").concat(type, ", element: ").concat(element);
|
|
256
341
|
this._scene.streamPlayer.subscribeRemoteVideoStream(streamId, type);
|
|
257
|
-
|
|
342
|
+
try {
|
|
343
|
+
this._scene.streamPlayer.startRenderRemoteVideoStream(streamId, config.renderMode, config.isMirror, element);
|
|
344
|
+
const viewId = this._subscribedStreamsControl.getViewId(element);
|
|
345
|
+
this._subscribedStreamsControl.bind(viewId, streamId);
|
|
346
|
+
} catch (error) {
|
|
347
|
+
this.logger.error("[FcrStreamControl][start-render-remote-video-stream] render failed, streamId: ".concat(streamId, ", error: ").concat(error, ", parameters: ").concat(parameters, ", duration: ").concat(Date.now() - startTime, "ms"));
|
|
348
|
+
throw error;
|
|
349
|
+
}
|
|
258
350
|
}
|
|
259
351
|
stopRenderRemoteVideoStream(streamId, element) {
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
this.
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
352
|
+
const startTime = Date.now();
|
|
353
|
+
const parameters = "streamId: ".concat(streamId, ", element: ").concat(element);
|
|
354
|
+
try {
|
|
355
|
+
this._scene.streamPlayer.stopRenderRemoteVideoStream(streamId, element);
|
|
356
|
+
const viewId = this._subscribedStreamsControl.getViewId(element);
|
|
357
|
+
this._subscribedStreamsControl.unbind(viewId, streamId);
|
|
358
|
+
const shouldUnsubscribe = this._subscribedStreamsControl.isEmpty(streamId);
|
|
359
|
+
if (shouldUnsubscribe) {
|
|
360
|
+
this._scene.streamPlayer.unsubscribeRemoteVideoStream(streamId);
|
|
361
|
+
} else {
|
|
362
|
+
this.logger.info("[FcrStreamControl][unsubscribe-remote-video-stream] still has other views, do not unsubscribe, streamId: ".concat(streamId, ", parameters: ").concat(parameters, ", duration: ").concat(Date.now() - startTime, "ms"));
|
|
363
|
+
}
|
|
364
|
+
} catch (error) {
|
|
365
|
+
this.logger.error("[FcrStreamControl][stop-render-remote-video-stream] stop render failed, streamId: ".concat(streamId, ", error: ").concat(error, ", parameters: ").concat(parameters, ", duration: ").concat(Date.now() - startTime, "ms"));
|
|
366
|
+
throw error;
|
|
272
367
|
}
|
|
273
|
-
this._scene.streamPlayer.stopRenderRemoteVideoStream(streamId, element);
|
|
274
368
|
}
|
|
275
369
|
startPlayRemoteAudioStream(streamId) {
|
|
276
370
|
this._scene.streamPlayer.startPlayRemoteAudioStream(streamId);
|
|
@@ -285,14 +379,14 @@ class FcrStreamControlImpl {
|
|
|
285
379
|
const res = await (0, _error.handleRequestError)(() => this._api.startShareScreen({
|
|
286
380
|
roomId: this._scene.sceneId,
|
|
287
381
|
userId: this._scene.getLocalUser().getLocalUserId(),
|
|
288
|
-
config: {
|
|
382
|
+
config: _objectSpread(_objectSpread({
|
|
289
383
|
videoSourceType: _type.FcrVideoSourceType.SCREEN,
|
|
290
384
|
audioSourceType: _type.FcrAudioSourceType.LOOPBACK,
|
|
291
385
|
videoSourceState: _type.FcrMediaSourceState.CLOSE,
|
|
292
386
|
audioSourceState: _type.FcrMediaSourceState.CLOSE,
|
|
293
387
|
videoSourceUuid: config.videoSourceId,
|
|
294
|
-
audioSourceUuid: config.audioSourceId
|
|
295
|
-
|
|
388
|
+
audioSourceUuid: config.audioSourceId
|
|
389
|
+
}, (0, _imports.convertStreamTypeToPublishState)(config.streamType)), {}, {
|
|
296
390
|
annotation: size ? {
|
|
297
391
|
size: {
|
|
298
392
|
width: size.width,
|
|
@@ -304,7 +398,7 @@ class FcrStreamControlImpl {
|
|
|
304
398
|
height: 0
|
|
305
399
|
}
|
|
306
400
|
}
|
|
307
|
-
}
|
|
401
|
+
})
|
|
308
402
|
}), _error.FcrErrorModuleCode.ROOM_STREAM, 'add local screen stream failed');
|
|
309
403
|
const {
|
|
310
404
|
data: {
|
|
@@ -313,7 +407,7 @@ class FcrStreamControlImpl {
|
|
|
313
407
|
}
|
|
314
408
|
} = res;
|
|
315
409
|
this._screenStreamId = streamId;
|
|
316
|
-
this._scene.localUser.
|
|
410
|
+
this._scene.localUser.prepareToPublishStream(streamId, token);
|
|
317
411
|
return streamId;
|
|
318
412
|
}
|
|
319
413
|
async removeScreenStream() {
|
|
@@ -324,7 +418,7 @@ class FcrStreamControlImpl {
|
|
|
324
418
|
});
|
|
325
419
|
}, _error.FcrErrorModuleCode.ROOM_STREAM, 'remove screen stream failed');
|
|
326
420
|
if (this._screenStreamId) {
|
|
327
|
-
this._scene.localUser.
|
|
421
|
+
this._scene.localUser.removePreparePublishStream(this._screenStreamId);
|
|
328
422
|
}
|
|
329
423
|
return res;
|
|
330
424
|
}
|
|
@@ -359,65 +453,14 @@ class FcrStreamControlImpl {
|
|
|
359
453
|
this._observable.removeObserver(observer);
|
|
360
454
|
}
|
|
361
455
|
async findSelectionByParamId(paramSourceId) {
|
|
362
|
-
|
|
363
|
-
const
|
|
456
|
+
var _this$_mediaControl, _this$_mediaControl2;
|
|
457
|
+
const wins = (await ((_this$_mediaControl = this._mediaControl) === null || _this$_mediaControl === void 0 ? void 0 : _this$_mediaControl.getWindowList())) || [];
|
|
458
|
+
const displays = (await ((_this$_mediaControl2 = this._mediaControl) === null || _this$_mediaControl2 === void 0 ? void 0 : _this$_mediaControl2.getDisplayList())) || [];
|
|
364
459
|
const findInList = list => list.find(item => item.id === paramSourceId);
|
|
365
460
|
const winMatch = findInList(wins);
|
|
366
461
|
const displayMatch = findInList(displays);
|
|
367
462
|
return winMatch || displayMatch || null;
|
|
368
463
|
}
|
|
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
|
-
};
|
|
421
464
|
_addLogObserver() {
|
|
422
465
|
this.addObserver((0, _logger.generateLogObserver)(this.logger, [
|
|
423
466
|
// 'onLocalVideoStatsUpdated',
|
|
@@ -429,4 +472,72 @@ class FcrStreamControlImpl {
|
|
|
429
472
|
'onStreamsAdded', 'onStreamsRemoved', 'onStreamsUpdated']));
|
|
430
473
|
}
|
|
431
474
|
}
|
|
432
|
-
exports.FcrStreamControlImpl = FcrStreamControlImpl;
|
|
475
|
+
exports.FcrStreamControlImpl = FcrStreamControlImpl;
|
|
476
|
+
_FcrStreamControlImpl = FcrStreamControlImpl;
|
|
477
|
+
[_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"], [[_imports.bound, _imports.trace], 2, "setDualStreamMode"], [_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;
|
|
478
|
+
class FcrSubscribedStreamsControl {
|
|
479
|
+
constructor() {
|
|
480
|
+
(0, _defineProperty2.default)(this, "logger", (0, _logger.createLogger)({
|
|
481
|
+
prefix: 'StreamSubscriptionManager'
|
|
482
|
+
}));
|
|
483
|
+
//@internal
|
|
484
|
+
/**
|
|
485
|
+
* Map of remote subscribed streams to their bound view IDs
|
|
486
|
+
* key: streamId - The ID of the remote video stream
|
|
487
|
+
* value: string[] - Array of viewIds bound to this stream
|
|
488
|
+
*/
|
|
489
|
+
(0, _defineProperty2.default)(this, "_remoteSubscribedStreamRenderMap", new Map());
|
|
490
|
+
}
|
|
491
|
+
getViewId(element) {
|
|
492
|
+
// Adapt for harmony: AgoraRteRenderView is string in harmony, HTMLElement in web
|
|
493
|
+
if (typeof element === 'string') {
|
|
494
|
+
return element;
|
|
495
|
+
} else {
|
|
496
|
+
// @ts-ignore
|
|
497
|
+
const viewId = element.getAttribute('data-render-id');
|
|
498
|
+
if (!viewId) {
|
|
499
|
+
const uniqueId = (0, _imports.v4)();
|
|
500
|
+
// @ts-ignore
|
|
501
|
+
element.setAttribute('data-render-id', uniqueId);
|
|
502
|
+
return uniqueId;
|
|
503
|
+
}
|
|
504
|
+
return viewId;
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
isEmpty(streamId) {
|
|
508
|
+
const viewIds = this._remoteSubscribedStreamRenderMap.get(streamId);
|
|
509
|
+
return !viewIds || viewIds.length === 0;
|
|
510
|
+
}
|
|
511
|
+
bind(viewId, streamId) {
|
|
512
|
+
if (!streamId || !viewId) {
|
|
513
|
+
this.logger.warn("[FcrStreamControl][bind-view-to-stream] invalid parameters, streamId: ".concat(streamId, ", viewId: ").concat(viewId));
|
|
514
|
+
return;
|
|
515
|
+
}
|
|
516
|
+
const viewIds = this._remoteSubscribedStreamRenderMap.get(streamId) || [];
|
|
517
|
+
const isAlreadyBound = viewIds.includes(viewId);
|
|
518
|
+
if (!isAlreadyBound) {
|
|
519
|
+
viewIds.push(viewId);
|
|
520
|
+
this._remoteSubscribedStreamRenderMap.set(streamId, viewIds);
|
|
521
|
+
} else {
|
|
522
|
+
this.logger.warn("[FcrStreamControl][bind-view-to-stream] viewId already bound, streamId: ".concat(streamId, ", viewId: ").concat(viewId));
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
unbind(viewId, streamId) {
|
|
526
|
+
if (!streamId || !viewId) {
|
|
527
|
+
this.logger.warn("[FcrStreamControl][unbind-view-from-stream] invalid parameters, streamId: ".concat(streamId, ", viewId: ").concat(viewId));
|
|
528
|
+
return;
|
|
529
|
+
}
|
|
530
|
+
const viewIds = this._remoteSubscribedStreamRenderMap.get(streamId);
|
|
531
|
+
if (!viewIds || !viewIds.includes(viewId)) {
|
|
532
|
+
this.logger.warn("[FcrStreamControl][unbind-view-from-stream] viewId not found, streamId: ".concat(streamId, ", viewId: ").concat(viewId));
|
|
533
|
+
return;
|
|
534
|
+
}
|
|
535
|
+
const rest = viewIds.filter(id => id !== viewId);
|
|
536
|
+
if (rest.length === 0) {
|
|
537
|
+
this._remoteSubscribedStreamRenderMap.delete(streamId);
|
|
538
|
+
} else {
|
|
539
|
+
this._remoteSubscribedStreamRenderMap.set(streamId, rest);
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
exports.FcrSubscribedStreamsControl = FcrSubscribedStreamsControl;
|