fcr-core 3.10.5 → 3.10.6
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/engine/index.js +108 -102
- package/lib/imports.js +0 -1
- package/lib/index.d.ts +1 -1
- package/lib/media-control/desktop.js +13 -22
- package/lib/media-control/mobile.js +13 -22
- package/lib/monitor-control/index.js +7 -17
- package/lib/peer-session/index.js +121 -120
- package/lib/plugins/chat/chatroom.js +96 -119
- package/lib/plugins/chat/connector.js +48 -69
- package/lib/remote-control/index.js +216 -194
- package/lib/room-control/ability-control/index.js +10 -20
- package/lib/room-control/application-control/index.js +75 -82
- package/lib/room-control/group-control/index.js +30 -31
- package/lib/room-control/helpers/board-init-info-helper.js +10 -16
- package/lib/room-control/helpers/validation-helper.js +1 -1
- package/lib/room-control/index.js +51 -70
- package/lib/room-control/infinity-room-control/index.js +19 -27
- package/lib/room-control/interpreter-control/index.js +65 -77
- 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 +25 -37
- package/lib/room-control/privilege-control/helper.js +13 -28
- package/lib/room-control/privilege-control/index.js +28 -36
- package/lib/room-control/room-connector-control/index.js +47 -52
- package/lib/room-control/room-control-factory.js +12 -10
- package/lib/room-control/room-session/index.js +74 -77
- package/lib/room-control/shared-cache.js +56 -63
- package/lib/room-control/sharing-control/index.js +57 -65
- package/lib/room-control/stream-control/index.js +238 -203
- package/lib/room-control/stream-control/type.d.ts +11 -1
- package/lib/room-control/stt-control/de-compress-gzip.js +0 -10
- package/lib/room-control/stt-control/index.js +86 -93
- package/lib/room-control/user-control/index.js +155 -162
- package/lib/room-control/waitingroom-control/index.js +9 -18
- package/lib/room-control/whiteboard-control/utils.js +2 -4
- package/lib/room-control/whiteboard-control-v1/board-subwindow.js +1 -2
- package/lib/room-control/whiteboard-control-v1/board-window.js +103 -120
- package/lib/room-control/whiteboard-control-v1/factory.js +4 -7
- package/lib/room-control/whiteboard-control-v1/index.js +67 -80
- package/lib/room-control/whiteboard-control-v1/mount-manager.js +2 -4
- package/lib/room-control/whiteboard-control-v1/utils.js +14 -17
- package/lib/room-control/whiteboard-control-v2/annotation-control/control.js +10 -14
- package/lib/room-control/whiteboard-control-v2/annotation-control/factory.js +8 -17
- package/lib/room-control/whiteboard-control-v2/base/index.js +53 -61
- package/lib/room-control/whiteboard-control-v2/base/main-window.js +30 -39
- package/lib/room-control/whiteboard-control-v2/utils.js +10 -10
- package/lib/room-control/whiteboard-control-v2/whiteboard-control/control.js +33 -45
- package/lib/room-control/whiteboard-control-v2/whiteboard-control/factory.js +11 -27
- package/lib/room-control/widget-control/index.js +33 -43
- package/lib/room-router/index.js +58 -66
- package/lib/service/api.js +548 -446
- package/lib/struct.js +2 -5
- package/lib/type.d.ts +1 -1
- package/lib/utilities/abortable-retry.js +0 -3
- package/lib/utilities/collection.js +11 -15
- package/lib/utilities/error-helpers.js +27 -34
- package/lib/utilities/error.js +3 -4
- package/lib/utilities/join-helper.js +31 -37
- package/lib/utilities/logger.js +5 -8
- package/lib/utilities/parameters.js +10 -21
- package/lib/utilities/retry-helpers.js +0 -1
- package/lib/utilities/stream.js +11 -16
- package/lib/utilities/user.js +3 -4
- package/lib/utilities/validate-params.js +1 -1
- package/lib/utilities/video-encoder-config.js +5 -10
- package/lib-es/engine/index.js +108 -102
- package/lib-es/media-control/desktop.js +13 -22
- package/lib-es/media-control/mobile.js +13 -22
- package/lib-es/monitor-control/index.js +7 -16
- package/lib-es/peer-session/index.js +121 -120
- package/lib-es/plugins/chat/chatroom.js +95 -118
- package/lib-es/plugins/chat/connector.js +47 -67
- package/lib-es/remote-control/index.js +216 -194
- package/lib-es/room-control/ability-control/index.js +10 -19
- package/lib-es/room-control/application-control/index.js +75 -81
- package/lib-es/room-control/group-control/index.js +30 -31
- package/lib-es/room-control/helpers/board-init-info-helper.js +10 -15
- package/lib-es/room-control/helpers/validation-helper.js +1 -1
- package/lib-es/room-control/index.js +51 -69
- package/lib-es/room-control/infinity-room-control/index.js +19 -26
- package/lib-es/room-control/interpreter-control/index.js +65 -77
- package/lib-es/room-control/interpreter-control/room.js +4 -5
- package/lib-es/room-control/join-before-host-waitingroom-control/index.js +4 -5
- package/lib-es/room-control/mainroom-control/index.js +25 -37
- package/lib-es/room-control/privilege-control/helper.js +13 -27
- package/lib-es/room-control/privilege-control/index.js +28 -36
- package/lib-es/room-control/room-connector-control/index.js +47 -52
- package/lib-es/room-control/room-control-factory.js +12 -10
- package/lib-es/room-control/room-session/index.js +74 -77
- package/lib-es/room-control/shared-cache.js +56 -62
- package/lib-es/room-control/sharing-control/index.js +57 -64
- package/lib-es/room-control/stream-control/index.js +240 -205
- package/lib-es/room-control/stt-control/de-compress-gzip.js +0 -10
- package/lib-es/room-control/stt-control/index.js +86 -93
- package/lib-es/room-control/user-control/index.js +155 -162
- package/lib-es/room-control/waitingroom-control/index.js +9 -18
- package/lib-es/room-control/whiteboard-control/utils.js +2 -4
- package/lib-es/room-control/whiteboard-control-v1/board-subwindow.js +1 -2
- package/lib-es/room-control/whiteboard-control-v1/board-window.js +103 -120
- package/lib-es/room-control/whiteboard-control-v1/factory.js +4 -6
- package/lib-es/room-control/whiteboard-control-v1/index.js +67 -80
- package/lib-es/room-control/whiteboard-control-v1/mount-manager.js +2 -3
- package/lib-es/room-control/whiteboard-control-v1/utils.js +14 -17
- package/lib-es/room-control/whiteboard-control-v2/annotation-control/control.js +10 -13
- package/lib-es/room-control/whiteboard-control-v2/annotation-control/factory.js +8 -16
- package/lib-es/room-control/whiteboard-control-v2/base/index.js +53 -60
- package/lib-es/room-control/whiteboard-control-v2/base/main-window.js +30 -39
- package/lib-es/room-control/whiteboard-control-v2/utils.js +10 -10
- package/lib-es/room-control/whiteboard-control-v2/whiteboard-control/control.js +33 -45
- package/lib-es/room-control/whiteboard-control-v2/whiteboard-control/factory.js +11 -26
- package/lib-es/room-control/widget-control/index.js +33 -42
- package/lib-es/room-router/index.js +58 -66
- package/lib-es/service/api.js +548 -445
- package/lib-es/struct.js +2 -4
- package/lib-es/utilities/abortable-retry.js +0 -3
- package/lib-es/utilities/collection.js +11 -14
- package/lib-es/utilities/error-helpers.js +26 -33
- package/lib-es/utilities/error.js +3 -4
- package/lib-es/utilities/join-helper.js +29 -36
- package/lib-es/utilities/logger.js +5 -7
- package/lib-es/utilities/parameters.js +10 -21
- package/lib-es/utilities/retry-helpers.js +0 -1
- package/lib-es/utilities/stream.js +11 -15
- package/lib-es/utilities/user.js +3 -4
- package/lib-es/utilities/validate-params.js +1 -1
- package/lib-es/utilities/video-encoder-config.js +5 -10
- 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");
|
|
@@ -31,9 +29,6 @@ require("core-js/modules/esnext.map.merge.js");
|
|
|
31
29
|
require("core-js/modules/esnext.map.reduce.js");
|
|
32
30
|
require("core-js/modules/esnext.map.some.js");
|
|
33
31
|
require("core-js/modules/esnext.map.update.js");
|
|
34
|
-
require("core-js/modules/web.dom-collections.iterator.js");
|
|
35
|
-
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
36
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
37
32
|
var _imports = require("../../imports");
|
|
38
33
|
var _type = require("../../type");
|
|
39
34
|
var _user = require("../../utilities/user");
|
|
@@ -41,10 +36,7 @@ var _error = require("../../utilities/error");
|
|
|
41
36
|
var _logger = require("../../utilities/logger");
|
|
42
37
|
var _validateParams = _interopRequireDefault(require("../../utilities/validate-params"));
|
|
43
38
|
var _schema = require("../../schema");
|
|
44
|
-
|
|
45
|
-
let _initProto, _addLocalStreamsDecs, _bindLocalStreamsDecs, _updatePublishPrivilegeOfStreamsDecs, _updatePublishPrivilegeOfStreamsByScopeDecs, _removeStreamsDecs, _setVideoEncoderConfigDecs, _setDualStreamModeDecs, _setScreenScenarioDecs, _startRenderRemoteVideoStreamDecs, _stopRenderRemoteVideoStreamDecs, _startPlayRemoteAudioStreamDecs, _stopPlayRemoteAudioStreamDecs, _takeSnapshotDecs, _addLocalScreenStreamDecs, _adjustRemoteAudioStreamVolumeDecs, _mergeAudioStreamDecs, _splitAudioStreamDecs, _ref;
|
|
46
|
-
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; }
|
|
47
|
-
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; }
|
|
39
|
+
let _initProto, _addLocalStreamsDecs, _bindLocalStreamsDecs, _updatePublishPrivilegeOfStreamsDecs, _updatePublishPrivilegeOfStreamsByScopeDecs, _removeStreamsDecs, _setVideoEncoderConfigDecs, _setDualStreamModeDecs, _setScreenScenarioDecs, _startRenderRemoteVideoStreamDecs, _stopRenderRemoteVideoStreamDecs, _startPlayRemoteAudioStreamDecs, _stopPlayRemoteAudioStreamDecs, _takeSnapshotDecs, _addLocalScreenStreamDecs, _adjustRemoteAudioStreamVolumeDecs, _mergeAudioStreamDecs, _splitAudioStreamDecs;
|
|
48
40
|
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)]; } }; }
|
|
49
41
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
50
42
|
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); }
|
|
@@ -53,148 +45,104 @@ function _checkInRHS(e) { if (Object(e) !== e) throw TypeError("right-hand side
|
|
|
53
45
|
/**
|
|
54
46
|
* @internal
|
|
55
47
|
*/
|
|
56
|
-
_ref = (_addLocalStreamsDecs = [_imports.bound, (0, _imports.trace)(['streams']), (0, _validateParams.default)(_schema.fcrLocalStreamCreateArrayConfigSchema)], _bindLocalStreamsDecs = [_imports.bound, (0, _imports.trace)(['streams']), (0, _validateParams.default)(_schema.fcrStreamBindConfigArrySchema)], _updatePublishPrivilegeOfStreamsDecs = [_imports.bound, _imports.trace, (0, _validateParams.default)(_schema.fcrUpdateStreamPrivilegesRecordSchema)], _updatePublishPrivilegeOfStreamsByScopeDecs = [_imports.bound, _imports.trace, (0, _validateParams.default)(_schema.fcrUpdateStreamPrivilegeSchema, _schema.fcrUpdateStreamPrivilegeScopeSchema)], _removeStreamsDecs = [_imports.bound, (0, _imports.trace)(['streams']), (0, _validateParams.default)(_schema.stringArraySchema)], _setVideoEncoderConfigDecs = [_imports.bound, (0, _imports.trace)(['streamId', 'config', 'streamType']), (0, _validateParams.default)(_schema.stringSchema, _schema.agoraRtcVideoEncoderConfigurationSchema, _schema.fcrVideoStreamTypeSchema)], _setDualStreamModeDecs = [_imports.bound, (0, _imports.trace)(['streamId', 'enable'])], _setScreenScenarioDecs = [_imports.bound, (0, _imports.trace)(['type']), (0, _validateParams.default)(_schema.fcrScreenScenarioTypeSchema)], _startRenderRemoteVideoStreamDecs = [_imports.bound, (0, _imports.trace)(['streamId', 'type', 'config', 'element']), (0, _validateParams.default)(_schema.stringSchema, _schema.fcrVideoStreamTypeSchema, _schema.fcrRenderConfigSchema, (0, _schema.createUnionSchema)([_schema.fcrRenderViewSchema, _imports.objectSchema]))], _stopRenderRemoteVideoStreamDecs = [_imports.bound, (0, _imports.trace)(['streamId', 'element']), (0, _validateParams.default)(_schema.stringSchema, _schema.fcrRenderViewSchema)], _startPlayRemoteAudioStreamDecs = [_imports.bound, (0, _imports.trace)(['streamId']), (0, _validateParams.default)(_schema.stringSchema)], _stopPlayRemoteAudioStreamDecs = [_imports.bound, (0, _imports.trace)(['streamId']), (0, _validateParams.default)(_schema.stringSchema)], _takeSnapshotDecs = [_imports.bound, (0, _imports.trace)(['streamId', 'filePath']), (0, _validateParams.default)(_schema.stringSchema, _schema.stringSchema)], _addLocalScreenStreamDecs = [_imports.bound, (0, _imports.trace)(['config', 'size']), (0, _validateParams.default)(_schema.fcrScreenStreamCreateConfigSchema, _schema.fcrSizeSchema)], _adjustRemoteAudioStreamVolumeDecs = [_imports.bound, (0, _imports.trace)(['streamId', 'volume']), (0, _validateParams.default)(_schema.stringSchema, _schema.numberSchema)], _mergeAudioStreamDecs = [_imports.bound, (0, _imports.trace)(['targetUserId']), (0, _validateParams.default)(_schema.stringSchema)], _splitAudioStreamDecs = [_imports.bound, (0, _imports.trace)(['userId']), (0, _validateParams.default)(_schema.stringSchema)], "logger");
|
|
57
48
|
class FcrStreamControlImpl {
|
|
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
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
const exists = stream.streamId in this._streamMapByStreamId;
|
|
95
|
-
if (!exists) {
|
|
96
|
-
this.logger.warn("[FcrStreamControl] stream removed when the stream does not exist, streamId: ".concat(stream.streamId));
|
|
97
|
-
} else {
|
|
98
|
-
const index = this._streamList.findIndex(s => stream.streamId === s.streamId);
|
|
99
|
-
if (index !== -1) {
|
|
100
|
-
this._streamList.splice(index, 1);
|
|
101
|
-
}
|
|
102
|
-
delete this._streamMapByStreamId[stream.streamId];
|
|
103
|
-
this._deleteUserStream(stream.owner.userId, stream);
|
|
104
|
-
}
|
|
105
|
-
});
|
|
106
|
-
this._observable.notifyObservers('onStreamsRemoved', sceneId, fcrStreamEvents);
|
|
107
|
-
},
|
|
108
|
-
onStreamsUpdated: (sceneId, events) => {
|
|
109
|
-
const fcrStreamEvents = events.map(this._convertStreamEvent);
|
|
110
|
-
fcrStreamEvents.forEach(event => {
|
|
111
|
-
const stream = event.modifiedStream;
|
|
112
|
-
const exists = stream.streamId in this._streamMapByStreamId;
|
|
113
|
-
if (!exists) {
|
|
114
|
-
this.logger.warn("[FcrStreamControl] stream updated when the stream does not exist, streamId: ".concat(stream.streamId));
|
|
115
|
-
} else {
|
|
116
|
-
const index = this._streamList.findIndex(s => stream.streamId === s.streamId);
|
|
117
|
-
if (index !== -1) {
|
|
118
|
-
this._streamList.splice(index, 1, stream);
|
|
119
|
-
}
|
|
120
|
-
this._streamMapByStreamId[stream.streamId] = stream;
|
|
121
|
-
this._setUserStream(stream.owner.userId, stream);
|
|
122
|
-
}
|
|
123
|
-
});
|
|
124
|
-
this._observable.notifyObservers('onStreamsUpdated', sceneId, fcrStreamEvents);
|
|
125
|
-
},
|
|
126
|
-
onLocalVideoStatsUpdated: (sceneId, streamId, stats) => {
|
|
127
|
-
this._observable.notifyObservers('onLocalVideoStatsUpdated', sceneId, streamId, stats);
|
|
128
|
-
},
|
|
129
|
-
onLocalAudioStatsUpdated: (sceneId, streamId, stats) => {
|
|
130
|
-
this._observable.notifyObservers('onLocalAudioStatsUpdated', sceneId, streamId, stats);
|
|
131
|
-
},
|
|
132
|
-
onRemoteVideoStatsUpdated: (sceneId, streamId, stats) => {
|
|
133
|
-
this._observable.notifyObservers('onRemoteVideoStatsUpdated', sceneId, streamId, stats);
|
|
134
|
-
},
|
|
135
|
-
onRemoteAudioStatsUpdated: (sceneId, streamId, stats) => {
|
|
136
|
-
this._observable.notifyObservers('onRemoteAudioStatsUpdated', sceneId, streamId, stats);
|
|
137
|
-
},
|
|
138
|
-
onFirstRemoteVideoFrameRendered: (sceneId, streamId) => {
|
|
139
|
-
this._observable.notifyObservers('onFirstRemoteVideoFrameRendered', sceneId, streamId);
|
|
140
|
-
}
|
|
141
|
-
});
|
|
142
|
-
//@internal
|
|
143
|
-
(0, _defineProperty2.default)(this, "_addSceneStreamPlayerObserver", {
|
|
144
|
-
onRemoteAudioStreamVolumeUpdated: (streamId, volume) => this._observable.notifyObservers('onStreamVolumeIndicationUpdated', this._scene.sceneId, streamId, volume)
|
|
145
|
-
});
|
|
146
|
-
(0, _defineProperty2.default)(this, "_convertStreamInfo", info => {
|
|
147
|
-
return {
|
|
148
|
-
streamId: info.streamId,
|
|
149
|
-
streamName: info.streamName,
|
|
150
|
-
owner: (0, _user.convertRteUserToFcrUser)(info.owner, this._roomCache),
|
|
151
|
-
streamType: info.streamType,
|
|
152
|
-
videoSourceType: info.videoSourceType,
|
|
153
|
-
audioSourceType: info.audioSourceType,
|
|
154
|
-
videoSourceState: info.videoSourceState,
|
|
155
|
-
audioSourceState: info.audioSourceState,
|
|
156
|
-
videoSourceId: info.videoSourceId,
|
|
157
|
-
audioSourceId: info.audioSourceId,
|
|
158
|
-
connectorType: info.connectorType
|
|
159
|
-
};
|
|
160
|
-
});
|
|
161
|
-
(0, _defineProperty2.default)(this, "_getPublishStateByPrivilege", privilege => {
|
|
162
|
-
return privilege === _imports.AgoraRteStreamPrivilegeOperation.HAS_PRIVILEGE ? 1 : privilege === _imports.AgoraRteStreamPrivilegeOperation.NOPRIVILEGE ? 0 : undefined;
|
|
163
|
-
});
|
|
164
|
-
(0, _defineProperty2.default)(this, "_convertStreamEvent", event => {
|
|
165
|
-
return {
|
|
166
|
-
modifiedStream: this._convertStreamInfo(event.modifiedStream),
|
|
167
|
-
operatorUser: event.operatorUser ? (0, _user.convertRteUserToFcrUser)(event.operatorUser, this._roomCache) : undefined,
|
|
168
|
-
cause: event.cause
|
|
169
|
-
};
|
|
170
|
-
});
|
|
171
|
-
(0, _defineProperty2.default)(this, "_putUserStream", (userId, stream) => {
|
|
172
|
-
if (!this._streamMapByUserId[userId]) {
|
|
173
|
-
this._streamMapByUserId[userId] = [];
|
|
174
|
-
}
|
|
175
|
-
this._streamMapByUserId[userId].push(stream);
|
|
176
|
-
});
|
|
177
|
-
(0, _defineProperty2.default)(this, "_setUserStream", (userId, stream) => {
|
|
178
|
-
const streams = this._streamMapByUserId[userId];
|
|
179
|
-
if (streams) {
|
|
180
|
-
const index = streams.findIndex(s => s.streamId === stream.streamId);
|
|
181
|
-
if (index !== -1) {
|
|
182
|
-
streams.splice(index, 1, stream);
|
|
49
|
+
static {
|
|
50
|
+
[_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"], [_updatePublishPrivilegeOfStreamsByScopeDecs, 2, "updatePublishPrivilegeOfStreamsByScope"], [_removeStreamsDecs, 2, "removeStreams"], [_setVideoEncoderConfigDecs, 2, "setVideoEncoderConfig"], [_setDualStreamModeDecs, 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"], [_imports.trace, 2, "release"]], []).e;
|
|
51
|
+
}
|
|
52
|
+
//@internal
|
|
53
|
+
[(_addLocalStreamsDecs = [_imports.bound, (0, _imports.trace)(['streams']), (0, _validateParams.default)(_schema.fcrLocalStreamCreateArrayConfigSchema)], _bindLocalStreamsDecs = [_imports.bound, (0, _imports.trace)(['streams']), (0, _validateParams.default)(_schema.fcrStreamBindConfigArrySchema)], _updatePublishPrivilegeOfStreamsDecs = [_imports.bound, _imports.trace, (0, _validateParams.default)(_schema.fcrUpdateStreamPrivilegesRecordSchema)], _updatePublishPrivilegeOfStreamsByScopeDecs = [_imports.bound, _imports.trace, (0, _validateParams.default)(_schema.fcrUpdateStreamPrivilegeSchema, _schema.fcrUpdateStreamPrivilegeScopeSchema)], _removeStreamsDecs = [_imports.bound, (0, _imports.trace)(['streams']), (0, _validateParams.default)(_schema.stringArraySchema)], _setVideoEncoderConfigDecs = [_imports.bound, (0, _imports.trace)(['streamId', 'config', 'streamType']), (0, _validateParams.default)(_schema.stringSchema, _schema.agoraRtcVideoEncoderConfigurationSchema, _schema.fcrVideoStreamTypeSchema)], _setDualStreamModeDecs = [_imports.bound, (0, _imports.trace)(['streamId', 'enable'])], _setScreenScenarioDecs = [_imports.bound, (0, _imports.trace)(['type']), (0, _validateParams.default)(_schema.fcrScreenScenarioTypeSchema)], _startRenderRemoteVideoStreamDecs = [_imports.bound, (0, _imports.trace)(['streamId', 'type', 'config', 'element']), (0, _validateParams.default)(_schema.stringSchema, _schema.fcrVideoStreamTypeSchema, _schema.fcrRenderConfigSchema, (0, _schema.createUnionSchema)([_schema.fcrRenderViewSchema, _imports.objectSchema]))], _stopRenderRemoteVideoStreamDecs = [_imports.bound, (0, _imports.trace)(['streamId', 'element']), (0, _validateParams.default)(_schema.stringSchema, _schema.fcrRenderViewSchema)], _startPlayRemoteAudioStreamDecs = [_imports.bound, (0, _imports.trace)(['streamId']), (0, _validateParams.default)(_schema.stringSchema)], _stopPlayRemoteAudioStreamDecs = [_imports.bound, (0, _imports.trace)(['streamId']), (0, _validateParams.default)(_schema.stringSchema)], _takeSnapshotDecs = [_imports.bound, (0, _imports.trace)(['streamId', 'filePath']), (0, _validateParams.default)(_schema.stringSchema, _schema.stringSchema)], _addLocalScreenStreamDecs = [_imports.bound, (0, _imports.trace)(['config', 'size']), (0, _validateParams.default)(_schema.fcrScreenStreamCreateConfigSchema, _schema.fcrSizeSchema)], _adjustRemoteAudioStreamVolumeDecs = [_imports.bound, (0, _imports.trace)(['streamId', 'volume']), (0, _validateParams.default)(_schema.stringSchema, _schema.numberSchema)], _mergeAudioStreamDecs = [_imports.bound, (0, _imports.trace)(['targetUserId']), (0, _validateParams.default)(_schema.stringSchema)], _splitAudioStreamDecs = [_imports.bound, (0, _imports.trace)(['userId']), (0, _validateParams.default)(_schema.stringSchema)], "logger")] = (_initProto(this), (0, _logger.createLogger)({
|
|
54
|
+
prefix: 'FcrStreamControlImpl'
|
|
55
|
+
}));
|
|
56
|
+
//@internal
|
|
57
|
+
_observable = new _imports.AgoraObservable();
|
|
58
|
+
//@internal
|
|
59
|
+
_streamMapByStreamId = {};
|
|
60
|
+
//@internal
|
|
61
|
+
_streamMapByUserId = {};
|
|
62
|
+
//@internal
|
|
63
|
+
_streamList = [];
|
|
64
|
+
//@internal
|
|
65
|
+
|
|
66
|
+
//@internal
|
|
67
|
+
_subscribedStreamsControl = new FcrSubscribedStreamsControl();
|
|
68
|
+
//@internal
|
|
69
|
+
|
|
70
|
+
//@internal
|
|
71
|
+
|
|
72
|
+
//@internal
|
|
73
|
+
_sceneObserver = {
|
|
74
|
+
onStreamsAdded: (sceneId, events) => {
|
|
75
|
+
const fcrStreamEvents = events.map(this._convertStreamEvent);
|
|
76
|
+
fcrStreamEvents.forEach(event => {
|
|
77
|
+
const stream = event.modifiedStream;
|
|
78
|
+
const exists = stream.streamId in this._streamMapByStreamId;
|
|
79
|
+
if (exists) {
|
|
80
|
+
this.logger.warn(`[FcrStreamControl] stream added when the stream already exists, streamId: ${stream.streamId}`);
|
|
81
|
+
} else {
|
|
82
|
+
this._streamList.push(stream);
|
|
83
|
+
this._streamMapByStreamId[stream.streamId] = stream;
|
|
84
|
+
this._putUserStream(stream.owner.userId, stream);
|
|
183
85
|
}
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
86
|
+
});
|
|
87
|
+
this._observable.notifyObservers('onStreamsAdded', sceneId, fcrStreamEvents);
|
|
88
|
+
},
|
|
89
|
+
onStreamsRemoved: (sceneId, events) => {
|
|
90
|
+
const fcrStreamEvents = events.map(this._convertStreamEvent);
|
|
91
|
+
fcrStreamEvents.forEach(event => {
|
|
92
|
+
const stream = event.modifiedStream;
|
|
93
|
+
const exists = stream.streamId in this._streamMapByStreamId;
|
|
94
|
+
if (!exists) {
|
|
95
|
+
this.logger.warn(`[FcrStreamControl] stream removed when the stream does not exist, streamId: ${stream.streamId}`);
|
|
96
|
+
} else {
|
|
97
|
+
const index = this._streamList.findIndex(s => stream.streamId === s.streamId);
|
|
98
|
+
if (index !== -1) {
|
|
99
|
+
this._streamList.splice(index, 1);
|
|
100
|
+
}
|
|
101
|
+
delete this._streamMapByStreamId[stream.streamId];
|
|
102
|
+
this._deleteUserStream(stream.owner.userId, stream);
|
|
192
103
|
}
|
|
193
|
-
|
|
194
|
-
|
|
104
|
+
});
|
|
105
|
+
this._observable.notifyObservers('onStreamsRemoved', sceneId, fcrStreamEvents);
|
|
106
|
+
},
|
|
107
|
+
onStreamsUpdated: (sceneId, events) => {
|
|
108
|
+
const fcrStreamEvents = events.map(this._convertStreamEvent);
|
|
109
|
+
fcrStreamEvents.forEach(event => {
|
|
110
|
+
const stream = event.modifiedStream;
|
|
111
|
+
const exists = stream.streamId in this._streamMapByStreamId;
|
|
112
|
+
if (!exists) {
|
|
113
|
+
this.logger.warn(`[FcrStreamControl] stream updated when the stream does not exist, streamId: ${stream.streamId}`);
|
|
114
|
+
} else {
|
|
115
|
+
const index = this._streamList.findIndex(s => stream.streamId === s.streamId);
|
|
116
|
+
if (index !== -1) {
|
|
117
|
+
this._streamList.splice(index, 1, stream);
|
|
118
|
+
}
|
|
119
|
+
this._streamMapByStreamId[stream.streamId] = stream;
|
|
120
|
+
this._setUserStream(stream.owner.userId, stream);
|
|
195
121
|
}
|
|
196
|
-
}
|
|
197
|
-
|
|
122
|
+
});
|
|
123
|
+
this._observable.notifyObservers('onStreamsUpdated', sceneId, fcrStreamEvents);
|
|
124
|
+
},
|
|
125
|
+
onLocalVideoStatsUpdated: (sceneId, streamId, stats) => {
|
|
126
|
+
this._observable.notifyObservers('onLocalVideoStatsUpdated', sceneId, streamId, stats);
|
|
127
|
+
},
|
|
128
|
+
onLocalAudioStatsUpdated: (sceneId, streamId, stats) => {
|
|
129
|
+
this._observable.notifyObservers('onLocalAudioStatsUpdated', sceneId, streamId, stats);
|
|
130
|
+
},
|
|
131
|
+
onRemoteVideoStatsUpdated: (sceneId, streamId, stats) => {
|
|
132
|
+
this._observable.notifyObservers('onRemoteVideoStatsUpdated', sceneId, streamId, stats);
|
|
133
|
+
},
|
|
134
|
+
onRemoteAudioStatsUpdated: (sceneId, streamId, stats) => {
|
|
135
|
+
this._observable.notifyObservers('onRemoteAudioStatsUpdated', sceneId, streamId, stats);
|
|
136
|
+
},
|
|
137
|
+
onFirstRemoteVideoFrameRendered: (sceneId, streamId) => {
|
|
138
|
+
this._observable.notifyObservers('onFirstRemoteVideoFrameRendered', sceneId, streamId);
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
//@internal
|
|
142
|
+
_addSceneStreamPlayerObserver = {
|
|
143
|
+
onRemoteAudioStreamVolumeUpdated: (streamId, volume) => this._observable.notifyObservers('onStreamVolumeIndicationUpdated', this._scene.sceneId, streamId, volume)
|
|
144
|
+
};
|
|
145
|
+
constructor(_engine, _scene, _api, _sharedCache) {
|
|
198
146
|
this._engine = _engine;
|
|
199
147
|
this._scene = _scene;
|
|
200
148
|
this._api = _api;
|
|
@@ -233,20 +181,19 @@ class FcrStreamControlImpl {
|
|
|
233
181
|
}
|
|
234
182
|
}
|
|
235
183
|
async addLocalStreams(streams) {
|
|
236
|
-
const streamCreateResult = await (0, _error.handleRequestError)(() => this._api.createStreamBatch(this._scene.sceneId, streams.map(config => {
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
})), _imports.ErrorModuleCode.FCR_ROOM_STREAM, 'add local streams failed');
|
|
184
|
+
const streamCreateResult = await (0, _error.handleRequestError)(() => this._api.createStreamBatch(this._scene.sceneId, streams.map(config => ({
|
|
185
|
+
streamName: config.streamName,
|
|
186
|
+
streamUuid: '0',
|
|
187
|
+
// means that this stream needs to be created
|
|
188
|
+
generateToken: config.generateToken ?? config.videoSourceType === _imports.AgoraRteVideoSourceType.SCREEN,
|
|
189
|
+
userUuid: config.ownerId,
|
|
190
|
+
videoSourceType: config.videoSourceType,
|
|
191
|
+
audioSourceType: config.audioSourceType,
|
|
192
|
+
videoSourceUuid: config.videoSourceId,
|
|
193
|
+
audioSourceUuid: config.audioSourceId,
|
|
194
|
+
strict: true,
|
|
195
|
+
...(0, _imports.convertStreamTypeToPublishState)(config.streamType)
|
|
196
|
+
}))), _imports.ErrorModuleCode.FCR_ROOM_STREAM, 'add local streams failed');
|
|
250
197
|
|
|
251
198
|
// 处理需要 token 的流
|
|
252
199
|
this._handleStreamTokensPreparation(streams, streamCreateResult.data);
|
|
@@ -282,12 +229,50 @@ class FcrStreamControlImpl {
|
|
|
282
229
|
bindLocalStreams(streams) {
|
|
283
230
|
return this._scene.localUser.bindLocalStreams(streams);
|
|
284
231
|
}
|
|
285
|
-
updatePublishPrivilegeOfStreams(privileges) {
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
232
|
+
async updatePublishPrivilegeOfStreams(privileges) {
|
|
233
|
+
let response;
|
|
234
|
+
try {
|
|
235
|
+
response = await this._api.updateStreamBatch(this._scene.sceneId, Object.keys(privileges).map(streamId => ({
|
|
236
|
+
streamUuid: streamId,
|
|
237
|
+
audioState: this._getPublishStateByPrivilege(privileges[streamId].audioPrivilege),
|
|
238
|
+
videoState: this._getPublishStateByPrivilege(privileges[streamId].videoPrivilege),
|
|
239
|
+
strict: true
|
|
240
|
+
})));
|
|
241
|
+
} catch (error) {
|
|
242
|
+
const restfulError = error;
|
|
243
|
+
if (restfulError instanceof _imports.AgoraRestfulClientError && restfulError.serviceCode === 30418001) {
|
|
244
|
+
response = {
|
|
245
|
+
code: restfulError.serviceCode,
|
|
246
|
+
message: restfulError.message,
|
|
247
|
+
data: Array.isArray(restfulError.data) ? restfulError.data : []
|
|
248
|
+
};
|
|
249
|
+
} else {
|
|
250
|
+
return (0, _error.handleRequestError)(() => Promise.reject(error), _imports.ErrorModuleCode.FCR_ROOM_STREAM, 'update publish privilege of streams failed');
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
const code = response.code ?? -1;
|
|
254
|
+
const message = response.message ?? response.msg;
|
|
255
|
+
if (code !== 0 && code !== 30418001) {
|
|
256
|
+
throw (0, _error.generateFcrCoreServerError)(code, message ?? 'update publish privilege of streams failed');
|
|
257
|
+
}
|
|
258
|
+
const result = {
|
|
259
|
+
code,
|
|
260
|
+
list: (response.data ?? []).map(item => {
|
|
261
|
+
const detail = {
|
|
262
|
+
streamId: item.streamId ?? item.streamUuid ?? '',
|
|
263
|
+
code: item.code ?? 0
|
|
264
|
+
};
|
|
265
|
+
const itemMessage = item.message ?? item.msg;
|
|
266
|
+
if (itemMessage !== undefined) {
|
|
267
|
+
detail.message = itemMessage;
|
|
268
|
+
}
|
|
269
|
+
return detail;
|
|
270
|
+
})
|
|
271
|
+
};
|
|
272
|
+
if (message !== undefined) {
|
|
273
|
+
result.message = message;
|
|
274
|
+
}
|
|
275
|
+
return result;
|
|
291
276
|
}
|
|
292
277
|
updatePublishPrivilegeOfStreamsByScope(privilege, scope) {
|
|
293
278
|
const targetRteRoles = scope.targetRoleType.map(role => _type.FcrUserRoleToStringMap[role]);
|
|
@@ -334,7 +319,7 @@ class FcrStreamControlImpl {
|
|
|
334
319
|
}
|
|
335
320
|
startRenderRemoteVideoStream(streamId, type, config, element) {
|
|
336
321
|
const startTime = Date.now();
|
|
337
|
-
const parameters =
|
|
322
|
+
const parameters = `streamId: ${streamId}, config: ${JSON.stringify(config)}, type: ${type}, element: ${element}`;
|
|
338
323
|
|
|
339
324
|
// 将 FcrVideoStreamType 转换为 AgoraRteStreamLayer
|
|
340
325
|
const streamLayer = this._convertToStreamLayer(type);
|
|
@@ -345,13 +330,13 @@ class FcrStreamControlImpl {
|
|
|
345
330
|
this._subscribedStreamsControl.bind(viewId, streamId);
|
|
346
331
|
return _type.FcrReturnCode.SUCCESS;
|
|
347
332
|
} catch (error) {
|
|
348
|
-
this.logger.error(
|
|
333
|
+
this.logger.error(`[FcrStreamControl][start-render-remote-video-stream] render failed, streamId: ${streamId}, error: ${error}, parameters: ${parameters}, duration: ${Date.now() - startTime}ms`);
|
|
349
334
|
throw error;
|
|
350
335
|
}
|
|
351
336
|
}
|
|
352
337
|
stopRenderRemoteVideoStream(streamId, element) {
|
|
353
338
|
const startTime = Date.now();
|
|
354
|
-
const parameters =
|
|
339
|
+
const parameters = `streamId: ${streamId}, element: ${element}`;
|
|
355
340
|
try {
|
|
356
341
|
this._scene.streamPlayer.stopRenderRemoteVideoStream(streamId, element);
|
|
357
342
|
const viewId = this._subscribedStreamsControl.getViewId(element);
|
|
@@ -360,11 +345,11 @@ class FcrStreamControlImpl {
|
|
|
360
345
|
if (shouldUnsubscribe) {
|
|
361
346
|
this._scene.streamPlayer.unsubscribeRemoteVideoStream(streamId);
|
|
362
347
|
} else {
|
|
363
|
-
this.logger.info(
|
|
348
|
+
this.logger.info(`[FcrStreamControl][unsubscribe-remote-video-stream] still has other views, do not unsubscribe, streamId: ${streamId}, parameters: ${parameters}, duration: ${Date.now() - startTime}ms`);
|
|
364
349
|
}
|
|
365
350
|
return _type.FcrReturnCode.SUCCESS;
|
|
366
351
|
} catch (error) {
|
|
367
|
-
this.logger.error(
|
|
352
|
+
this.logger.error(`[FcrStreamControl][stop-render-remote-video-stream] stop render failed, streamId: ${streamId}, error: ${error}, parameters: ${parameters}, duration: ${Date.now() - startTime}ms`);
|
|
368
353
|
throw error;
|
|
369
354
|
}
|
|
370
355
|
}
|
|
@@ -381,14 +366,14 @@ class FcrStreamControlImpl {
|
|
|
381
366
|
const res = await (0, _error.handleRequestError)(() => this._api.startShareScreen({
|
|
382
367
|
roomId: this._scene.sceneId,
|
|
383
368
|
userId: this._scene.getLocalUser().getLocalUserId(),
|
|
384
|
-
config:
|
|
369
|
+
config: {
|
|
385
370
|
videoSourceType: _type.FcrVideoSourceType.SCREEN,
|
|
386
371
|
audioSourceType: _type.FcrAudioSourceType.LOOPBACK,
|
|
387
372
|
videoSourceState: _type.FcrMediaSourceState.CLOSE,
|
|
388
373
|
audioSourceState: _type.FcrMediaSourceState.CLOSE,
|
|
389
374
|
videoSourceUuid: config.videoSourceId,
|
|
390
|
-
audioSourceUuid: config.audioSourceId
|
|
391
|
-
|
|
375
|
+
audioSourceUuid: config.audioSourceId,
|
|
376
|
+
...(0, _imports.convertStreamTypeToPublishState)(config.streamType),
|
|
392
377
|
annotation: size ? {
|
|
393
378
|
size: {
|
|
394
379
|
width: size.width,
|
|
@@ -400,11 +385,14 @@ class FcrStreamControlImpl {
|
|
|
400
385
|
height: 0
|
|
401
386
|
}
|
|
402
387
|
}
|
|
403
|
-
}
|
|
388
|
+
}
|
|
404
389
|
}), _imports.ErrorModuleCode.FCR_ROOM_STREAM, 'add local screen stream failed');
|
|
405
|
-
const
|
|
406
|
-
|
|
407
|
-
|
|
390
|
+
const {
|
|
391
|
+
data: {
|
|
392
|
+
rtcToken: token,
|
|
393
|
+
streamUuid: streamId
|
|
394
|
+
}
|
|
395
|
+
} = res;
|
|
408
396
|
this._screenStreamId = streamId;
|
|
409
397
|
this._scene.localUser.prepareToPublishStream(streamId, token);
|
|
410
398
|
if (labels) {
|
|
@@ -418,7 +406,7 @@ class FcrStreamControlImpl {
|
|
|
418
406
|
let localUserId;
|
|
419
407
|
try {
|
|
420
408
|
localUserId = this._scene.localUser.getLocalUserId();
|
|
421
|
-
} catch
|
|
409
|
+
} catch {
|
|
422
410
|
// localUser 已被清除(房间已结束),无需调用 API
|
|
423
411
|
this.logger.warn('removeScreenStream: localUser not exist, skip API call');
|
|
424
412
|
if (this._screenStreamId) {
|
|
@@ -437,7 +425,7 @@ class FcrStreamControlImpl {
|
|
|
437
425
|
try {
|
|
438
426
|
this._scene.localUser.removePreparePublishStream(this._screenStreamId);
|
|
439
427
|
} catch (e) {
|
|
440
|
-
this.logger.warn(
|
|
428
|
+
this.logger.warn(`removeScreenStream: localUser not exist ${JSON.stringify(e)} `);
|
|
441
429
|
}
|
|
442
430
|
}
|
|
443
431
|
return res;
|
|
@@ -478,14 +466,39 @@ class FcrStreamControlImpl {
|
|
|
478
466
|
this._observable.removeAllObservers();
|
|
479
467
|
}
|
|
480
468
|
async findSelectionByParamId(paramSourceId) {
|
|
481
|
-
|
|
482
|
-
const
|
|
483
|
-
const displays = (await ((_this$_mediaControl2 = this._mediaControl) === null || _this$_mediaControl2 === void 0 ? void 0 : _this$_mediaControl2.getDisplayList())) || [];
|
|
469
|
+
const wins = (await this._mediaControl?.getWindowList()) || [];
|
|
470
|
+
const displays = (await this._mediaControl?.getDisplayList()) || [];
|
|
484
471
|
const findInList = list => list.find(item => item.id === paramSourceId);
|
|
485
472
|
const winMatch = findInList(wins);
|
|
486
473
|
const displayMatch = findInList(displays);
|
|
487
474
|
return winMatch || displayMatch || null;
|
|
488
475
|
}
|
|
476
|
+
_convertStreamInfo = info => {
|
|
477
|
+
return {
|
|
478
|
+
streamId: info.streamId,
|
|
479
|
+
streamName: info.streamName,
|
|
480
|
+
owner: (0, _user.convertRteUserToFcrUser)(info.owner, this._roomCache),
|
|
481
|
+
streamType: info.streamType,
|
|
482
|
+
videoSourceType: info.videoSourceType,
|
|
483
|
+
audioSourceType: info.audioSourceType,
|
|
484
|
+
videoSourceState: info.videoSourceState,
|
|
485
|
+
audioSourceState: info.audioSourceState,
|
|
486
|
+
videoSourceId: info.videoSourceId,
|
|
487
|
+
audioSourceId: info.audioSourceId,
|
|
488
|
+
connectorType: info.connectorType
|
|
489
|
+
};
|
|
490
|
+
};
|
|
491
|
+
_getPublishStateByPrivilege = privilege => {
|
|
492
|
+
return privilege === _imports.AgoraRteStreamPrivilegeOperation.HAS_PRIVILEGE ? 1 : privilege === _imports.AgoraRteStreamPrivilegeOperation.NOPRIVILEGE ? 0 : undefined;
|
|
493
|
+
};
|
|
494
|
+
_convertStreamEvent = event => {
|
|
495
|
+
return {
|
|
496
|
+
modifiedStream: this._convertStreamInfo(event.modifiedStream),
|
|
497
|
+
operatorUser: event.operatorUser ? (0, _user.convertRteUserToFcrUser)(event.operatorUser, this._roomCache) : undefined,
|
|
498
|
+
cause: event.cause
|
|
499
|
+
};
|
|
500
|
+
};
|
|
501
|
+
|
|
489
502
|
/**
|
|
490
503
|
* 将 FcrVideoStreamType 转换为 AgoraRteStreamLayer
|
|
491
504
|
* @param streamType - FcrVideoStreamType (HIGH_STREAM=0, LOW_STREAM=1)
|
|
@@ -495,6 +508,33 @@ class FcrStreamControlImpl {
|
|
|
495
508
|
_convertToStreamLayer(streamType) {
|
|
496
509
|
return streamType === _type.FcrVideoStreamType.HIGH_STREAM ? _imports.AgoraRteStreamLayer.HIGH : _imports.AgoraRteStreamLayer.LOW;
|
|
497
510
|
}
|
|
511
|
+
_putUserStream = (userId, stream) => {
|
|
512
|
+
if (!this._streamMapByUserId[userId]) {
|
|
513
|
+
this._streamMapByUserId[userId] = [];
|
|
514
|
+
}
|
|
515
|
+
this._streamMapByUserId[userId].push(stream);
|
|
516
|
+
};
|
|
517
|
+
_setUserStream = (userId, stream) => {
|
|
518
|
+
const streams = this._streamMapByUserId[userId];
|
|
519
|
+
if (streams) {
|
|
520
|
+
const index = streams.findIndex(s => s.streamId === stream.streamId);
|
|
521
|
+
if (index !== -1) {
|
|
522
|
+
streams.splice(index, 1, stream);
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
};
|
|
526
|
+
_deleteUserStream = (userId, stream) => {
|
|
527
|
+
const userStreams = this._streamMapByUserId[userId];
|
|
528
|
+
if (userStreams) {
|
|
529
|
+
const index = userStreams.findIndex(s => s.streamId === stream.streamId);
|
|
530
|
+
if (index !== -1) {
|
|
531
|
+
userStreams.splice(index, 1);
|
|
532
|
+
}
|
|
533
|
+
if (userStreams.length === 0) {
|
|
534
|
+
delete this._streamMapByUserId[userId];
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
};
|
|
498
538
|
_addLogObserver() {
|
|
499
539
|
this.addObserver((0, _logger.generateLogObserver)(this.logger, [
|
|
500
540
|
// 'onLocalVideoStatsUpdated',
|
|
@@ -507,22 +547,17 @@ class FcrStreamControlImpl {
|
|
|
507
547
|
}
|
|
508
548
|
}
|
|
509
549
|
exports.FcrStreamControlImpl = FcrStreamControlImpl;
|
|
510
|
-
_FcrStreamControlImpl = FcrStreamControlImpl;
|
|
511
|
-
var _applyDecs$e = (0, _slicedToArray2.default)(_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"], [_updatePublishPrivilegeOfStreamsByScopeDecs, 2, "updatePublishPrivilegeOfStreamsByScope"], [_removeStreamsDecs, 2, "removeStreams"], [_setVideoEncoderConfigDecs, 2, "setVideoEncoderConfig"], [_setDualStreamModeDecs, 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"], [_imports.trace, 2, "release"]], []).e, 1);
|
|
512
|
-
_initProto = _applyDecs$e[0];
|
|
513
550
|
class FcrSubscribedStreamsControl {
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
(0, _defineProperty2.default)(this, "_remoteSubscribedStreamRenderMap", new Map());
|
|
525
|
-
}
|
|
551
|
+
logger = (0, _logger.createLogger)({
|
|
552
|
+
prefix: 'StreamSubscriptionManager'
|
|
553
|
+
});
|
|
554
|
+
//@internal
|
|
555
|
+
/**
|
|
556
|
+
* Map of remote subscribed streams to their bound view IDs
|
|
557
|
+
* key: streamId - The ID of the remote video stream
|
|
558
|
+
* value: string[] - Array of viewIds bound to this stream
|
|
559
|
+
*/
|
|
560
|
+
_remoteSubscribedStreamRenderMap = new Map();
|
|
526
561
|
getViewId(element) {
|
|
527
562
|
// Adapt for harmony: AgoraRteRenderView is string in harmony, HTMLElement in web
|
|
528
563
|
if (typeof element === 'string') {
|
|
@@ -545,7 +580,7 @@ class FcrSubscribedStreamsControl {
|
|
|
545
580
|
}
|
|
546
581
|
bind(viewId, streamId) {
|
|
547
582
|
if (!streamId || !viewId) {
|
|
548
|
-
this.logger.warn(
|
|
583
|
+
this.logger.warn(`[FcrStreamControl][bind-view-to-stream] invalid parameters, streamId: ${streamId}, viewId: ${viewId}`);
|
|
549
584
|
return;
|
|
550
585
|
}
|
|
551
586
|
const viewIds = this._remoteSubscribedStreamRenderMap.get(streamId) || [];
|
|
@@ -554,17 +589,17 @@ class FcrSubscribedStreamsControl {
|
|
|
554
589
|
viewIds.push(viewId);
|
|
555
590
|
this._remoteSubscribedStreamRenderMap.set(streamId, viewIds);
|
|
556
591
|
} else {
|
|
557
|
-
this.logger.warn(
|
|
592
|
+
this.logger.warn(`[FcrStreamControl][bind-view-to-stream] viewId already bound, streamId: ${streamId}, viewId: ${viewId}`);
|
|
558
593
|
}
|
|
559
594
|
}
|
|
560
595
|
unbind(viewId, streamId) {
|
|
561
596
|
if (!streamId || !viewId) {
|
|
562
|
-
this.logger.warn(
|
|
597
|
+
this.logger.warn(`[FcrStreamControl][unbind-view-from-stream] invalid parameters, streamId: ${streamId}, viewId: ${viewId}`);
|
|
563
598
|
return;
|
|
564
599
|
}
|
|
565
600
|
const viewIds = this._remoteSubscribedStreamRenderMap.get(streamId);
|
|
566
601
|
if (!viewIds || !viewIds.includes(viewId)) {
|
|
567
|
-
this.logger.warn(
|
|
602
|
+
this.logger.warn(`[FcrStreamControl][unbind-view-from-stream] viewId not found, streamId: ${streamId}, viewId: ${viewId}`);
|
|
568
603
|
return;
|
|
569
604
|
}
|
|
570
605
|
const rest = viewIds.filter(id => id !== viewId);
|
|
@@ -35,7 +35,7 @@ export interface FcrStreamControl {
|
|
|
35
35
|
* Updates the publish privilege of streams.
|
|
36
36
|
* @param privileges
|
|
37
37
|
*/
|
|
38
|
-
updatePublishPrivilegeOfStreams(privileges: Record<string, FcrUpdateStreamPrivilege>): Promise<
|
|
38
|
+
updatePublishPrivilegeOfStreams(privileges: Record<string, FcrUpdateStreamPrivilege>): Promise<FcrBatchResult<FcrStreamUpdateResultDetail>>;
|
|
39
39
|
/**
|
|
40
40
|
* Updates the publish privilege of streams.
|
|
41
41
|
* @param privilege
|
|
@@ -142,6 +142,16 @@ export type FcrUpdateStreamPrivilege = {
|
|
|
142
142
|
videoPrivilege: FcrStreamPrivilegeOperation;
|
|
143
143
|
audioPrivilege: FcrStreamPrivilegeOperation;
|
|
144
144
|
};
|
|
145
|
+
export type FcrBatchResult<T> = {
|
|
146
|
+
code: number;
|
|
147
|
+
message?: string;
|
|
148
|
+
list: T[];
|
|
149
|
+
};
|
|
150
|
+
export type FcrStreamUpdateResultDetail = {
|
|
151
|
+
streamId: string;
|
|
152
|
+
code: number;
|
|
153
|
+
message?: string;
|
|
154
|
+
};
|
|
145
155
|
export type FcrUpdateStreamPrivilegeScope = {
|
|
146
156
|
videoSourceType?: FcrStreamPrivilegeVideoSourceType;
|
|
147
157
|
audioSourceType?: FcrStreamPrivilegeAudioSourceType;
|