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