fcr-core 3.8.1 → 3.9.0-alpha
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/chat-connector/type.d.ts +40 -0
- package/lib/{chat-connection → chat-connector}/type.js +1 -1
- package/lib/engine/index.d.ts +10 -11
- package/lib/engine/index.js +63 -72
- package/lib/engine/type.d.ts +96 -0
- package/lib/engine/type.js +5 -0
- package/lib/imports.d.ts +7 -4
- package/lib/imports.js +30 -4
- package/lib/index.d.ts +3 -2
- package/lib/index.js +21 -2
- package/lib/media-control/desktop.js +12 -12
- package/lib/media-control/mobile.js +4 -0
- package/lib/media-control/type.d.ts +32 -33
- package/lib/monitor-control/index.js +3 -3
- package/lib/peer-session/index.js +14 -14
- package/lib/peer-session/type.d.ts +1 -1
- package/lib/plugins/chat/chatroom.js +417 -0
- package/lib/{chat-connection → plugins/chat}/config.d.ts +1 -0
- package/lib/{room-control/chatroom-control → plugins/chat}/config.js +2 -1
- package/lib/plugins/chat/connector.d.ts +38 -0
- package/lib/{chat-connection/index.js → plugins/chat/connector.js} +181 -61
- package/lib/room-control/ability-control/index.js +5 -4
- package/lib/room-control/ability-control/type.d.ts +5 -1
- package/lib/room-control/ability-control/type.js +4 -0
- package/lib/room-control/chatroom-control/type.d.ts +44 -35
- package/lib/room-control/group-control/index.js +9 -9
- package/lib/room-control/index.js +37 -22
- package/lib/room-control/interpreter-control/index.js +7 -4
- package/lib/room-control/interpreter-control/room.js +3 -3
- package/lib/room-control/interpreter-control/types.d.ts +2 -2
- package/lib/room-control/join-before-host-waitingroom-control/index.js +3 -3
- package/lib/room-control/mainroom-control/index.js +15 -13
- package/lib/room-control/privilege-control/index.js +39 -24
- package/lib/room-control/privilege-control/type.d.ts +15 -15
- package/lib/room-control/room-connector-control/index.js +7 -5
- package/lib/room-control/room-connector-control/type.d.ts +1 -1
- package/lib/room-control/room-control-factory.d.ts +3 -3
- package/lib/room-control/room-control-factory.js +7 -7
- package/lib/room-control/room-session/index.js +17 -15
- package/lib/room-control/room-session/type.d.ts +3 -3
- package/lib/room-control/sharing-control/index.js +13 -7
- package/lib/room-control/stream-control/index.js +18 -16
- package/lib/room-control/stream-control/type.d.ts +5 -5
- package/lib/room-control/stt-control/index.js +38 -31
- package/lib/room-control/type.d.ts +19 -19
- package/lib/room-control/user-control/index.js +20 -22
- package/lib/room-control/user-control/type.d.ts +1 -1
- package/lib/room-control/waitingroom-control/index.js +11 -11
- package/lib/room-control/whiteboard-control-v1/board-window.d.ts +21 -20
- package/lib/room-control/whiteboard-control-v1/board-window.js +27 -8
- package/lib/room-control/whiteboard-control-v1/factory.js +1 -1
- package/lib/room-control/whiteboard-control-v1/index.js +26 -18
- package/lib/room-control/whiteboard-control-v1/type.d.ts +26 -25
- package/lib/room-control/whiteboard-control-v1/type.js +1 -0
- package/lib/room-control/whiteboard-control-v2/annotation-control/control.d.ts +15 -6
- package/lib/room-control/whiteboard-control-v2/annotation-control/control.js +39 -5
- package/lib/room-control/whiteboard-control-v2/annotation-control/factory.d.ts +4 -5
- package/lib/room-control/whiteboard-control-v2/annotation-control/factory.js +6 -5
- package/lib/room-control/whiteboard-control-v2/annotation-control/type.d.ts +7 -1
- package/lib/room-control/whiteboard-control-v2/base/index.d.ts +9 -8
- package/lib/room-control/whiteboard-control-v2/base/index.js +84 -42
- package/lib/room-control/whiteboard-control-v2/base/main-window.d.ts +16 -15
- package/lib/room-control/whiteboard-control-v2/base/main-window.js +23 -4
- package/lib/room-control/whiteboard-control-v2/type.d.ts +17 -17
- package/lib/room-control/whiteboard-control-v2/whiteboard-control/control.d.ts +12 -6
- package/lib/room-control/whiteboard-control-v2/whiteboard-control/control.js +64 -18
- package/lib/room-control/whiteboard-control-v2/whiteboard-control/factory.d.ts +2 -2
- package/lib/room-control/whiteboard-control-v2/whiteboard-control/factory.js +10 -10
- package/lib/room-control/whiteboard-control-v2/whiteboard-control/type.d.ts +1 -1
- package/lib/room-router/index.js +10 -7
- package/lib/room-router/type.d.ts +1 -1
- package/lib/schema.d.ts +24 -46
- package/lib/schema.js +1 -2
- package/lib/service/api.d.ts +5 -3
- package/lib/service/api.js +17 -12
- package/lib/type.d.ts +64 -45
- package/lib/type.js +76 -11
- package/lib/utilities/abortable-retry.d.ts +38 -0
- package/lib/utilities/abortable-retry.js +61 -0
- package/lib/utilities/dual-video-stream-config.d.ts +6 -0
- package/lib/utilities/dual-video-stream-config.js +25 -0
- package/lib/utilities/error-helpers.d.ts +10 -9
- package/lib/utilities/error-helpers.js +12 -11
- package/lib/utilities/error.d.ts +4 -40
- package/lib/utilities/error.js +20 -77
- package/lib/utilities/join-helper.js +2 -2
- package/lib/utilities/logger.d.ts +2 -2
- package/lib/utilities/logger.js +6 -25
- package/lib/utilities/package-info.d.ts +1 -2
- package/lib/utilities/package-info.js +4 -8
- package/lib/utilities/parameters.js +88 -15
- package/lib/utilities/validate-params.js +1 -1
- package/lib/utilities/video-encoder-config.d.ts +9 -0
- package/lib/utilities/video-encoder-config.js +109 -0
- package/lib-es/base-session.js +1 -0
- package/lib-es/chat-connector/type.js +6 -0
- package/lib-es/engine/index.js +412 -0
- package/lib-es/engine/type.js +1 -0
- package/lib-es/imports.js +59 -0
- package/lib-es/index.js +8 -0
- package/lib-es/media-control/desktop.js +172 -0
- package/lib-es/media-control/mobile.js +198 -0
- package/lib-es/media-control/type.js +6 -0
- package/lib-es/monitor-control/index.js +46 -0
- package/lib-es/monitor-control/type.js +1 -0
- package/lib-es/peer-session/index.js +279 -0
- package/lib-es/peer-session/type.js +1 -0
- package/lib-es/plugins/chat/chatroom.js +409 -0
- package/{lib/chat-connection → lib-es/plugins/chat}/config.js +5 -9
- package/lib-es/plugins/chat/connector.js +269 -0
- package/lib-es/plugins/electron-rtc-plugin.js +1 -0
- package/lib-es/plugins/rtm-plugin.js +1 -0
- package/lib-es/plugins/web-rtc-plugin.js +1 -0
- package/lib-es/room-control/ability-control/index.js +58 -0
- package/lib-es/room-control/ability-control/type.js +15 -0
- package/lib-es/room-control/chatroom-control/type.js +12 -0
- package/lib-es/room-control/group-control/index.js +256 -0
- package/lib-es/room-control/helpers/constants.js +92 -0
- package/lib-es/room-control/helpers/index.js +20 -0
- package/lib-es/room-control/helpers/validation-helper.js +46 -0
- package/lib-es/room-control/index.js +623 -0
- package/lib-es/room-control/interpreter-control/index.js +172 -0
- package/lib-es/room-control/interpreter-control/room.js +28 -0
- package/lib-es/room-control/interpreter-control/types.js +26 -0
- package/lib-es/room-control/join-before-host-waitingroom-control/index.js +29 -0
- package/lib-es/room-control/mainroom-control/index.js +248 -0
- package/lib-es/room-control/privilege-control/helper.js +97 -0
- package/lib-es/room-control/privilege-control/index.js +339 -0
- package/lib-es/room-control/privilege-control/type.js +159 -0
- package/lib-es/room-control/room-connector-control/index.js +182 -0
- package/lib-es/room-control/room-connector-control/type.js +28 -0
- package/lib-es/room-control/room-control-factory.js +77 -0
- package/lib-es/room-control/room-session/index.js +292 -0
- package/lib-es/room-control/room-session/type.js +1 -0
- package/lib-es/room-control/shared-cache.js +47 -0
- package/lib-es/room-control/sharing-control/index.js +307 -0
- package/lib-es/room-control/sharing-control/type.js +16 -0
- package/lib-es/room-control/stream-control/index.js +536 -0
- package/lib-es/room-control/stream-control/type.js +1 -0
- package/lib-es/room-control/stt-control/de-compress-gzip.js +33 -0
- package/lib-es/room-control/stt-control/index.js +350 -0
- package/lib-es/room-control/stt-control/type.js +10 -0
- package/lib-es/room-control/type.js +30 -0
- package/lib-es/room-control/user-control/index.js +344 -0
- package/lib-es/room-control/user-control/type.js +21 -0
- package/lib-es/room-control/waitingroom-control/index.js +68 -0
- package/lib-es/room-control/whiteboard-control/enum.js +18 -0
- package/lib-es/room-control/whiteboard-control/type.js +10 -0
- package/lib-es/room-control/whiteboard-control/utils.js +13 -0
- package/lib-es/room-control/whiteboard-control-v1/board-subwindow.js +18 -0
- package/lib-es/room-control/whiteboard-control-v1/board-window.js +573 -0
- package/lib-es/room-control/whiteboard-control-v1/enum.js +157 -0
- package/lib-es/room-control/whiteboard-control-v1/factory.js +12 -0
- package/lib-es/room-control/whiteboard-control-v1/index.js +427 -0
- package/lib-es/room-control/whiteboard-control-v1/mount-manager.js +6 -0
- package/lib-es/room-control/whiteboard-control-v1/type.js +8 -0
- package/lib-es/room-control/whiteboard-control-v1/utils.js +273 -0
- package/lib-es/room-control/whiteboard-control-v2/annotation-control/control.js +76 -0
- package/lib-es/room-control/whiteboard-control-v2/annotation-control/factory.js +37 -0
- package/lib-es/room-control/whiteboard-control-v2/annotation-control/type.js +1 -0
- package/lib-es/room-control/whiteboard-control-v2/base/index.js +347 -0
- package/lib-es/room-control/whiteboard-control-v2/base/main-window.js +269 -0
- package/lib-es/room-control/whiteboard-control-v2/constant.js +9 -0
- package/lib-es/room-control/whiteboard-control-v2/enum.js +28 -0
- package/lib-es/room-control/whiteboard-control-v2/type.js +1 -0
- package/lib-es/room-control/whiteboard-control-v2/utils.js +92 -0
- package/lib-es/room-control/whiteboard-control-v2/whiteboard-control/control.js +204 -0
- package/lib-es/room-control/whiteboard-control-v2/whiteboard-control/factory.js +61 -0
- package/lib-es/room-control/whiteboard-control-v2/whiteboard-control/type.js +1 -0
- package/lib-es/room-router/index.js +263 -0
- package/lib-es/room-router/type.js +5 -0
- package/lib-es/schema.js +231 -0
- package/lib-es/service/api.js +1211 -0
- package/lib-es/service/type.js +1 -0
- package/lib-es/type.js +222 -0
- package/lib-es/utilities/abortable-retry.js +54 -0
- package/lib-es/utilities/cmd.js +1 -0
- package/lib-es/utilities/collection.js +64 -0
- package/lib-es/utilities/dual-video-stream-config.js +19 -0
- package/lib-es/utilities/error-helpers.js +224 -0
- package/lib-es/utilities/error.js +43 -0
- package/lib-es/utilities/join-helper.js +219 -0
- package/lib-es/utilities/logger.js +7 -0
- package/lib-es/utilities/package-info.js +5 -0
- package/lib-es/utilities/parameters.js +106 -0
- package/lib-es/utilities/retry-helpers.js +66 -0
- package/lib-es/utilities/shared-storage.js +31 -0
- package/lib-es/utilities/stream.js +18 -0
- package/lib-es/utilities/user.js +30 -0
- package/lib-es/utilities/validate-params.js +8 -0
- package/lib-es/utilities/video-encoder-config.js +103 -0
- package/package.json +11 -10
- package/lib/chat-connection/index.d.ts +0 -24
- package/lib/chat-connection/type.d.ts +0 -17
- package/lib/plugins/chatroom.js +0 -454
- package/lib/room-control/chatroom-control/config.d.ts +0 -51
- package/lib/utilities/storage.d.ts +0 -8
- package/lib/utilities/storage.js +0 -33
- /package/lib/plugins/{chatroom.d.ts → chat/chatroom.d.ts} +0 -0
|
@@ -0,0 +1,536 @@
|
|
|
1
|
+
import "core-js/modules/esnext.function.metadata.js";
|
|
2
|
+
import "core-js/modules/esnext.symbol.metadata.js";
|
|
3
|
+
let _initProto, _addLocalStreamsDecs, _bindLocalStreamsDecs, _updatePublishPrivilegeOfStreamsDecs, _removeStreamsDecs, _setVideoEncoderConfigDecs, _setDualStreamModeDecs, _setScreenScenarioDecs, _startRenderRemoteVideoStreamDecs, _stopRenderRemoteVideoStreamDecs, _startPlayRemoteAudioStreamDecs, _stopPlayRemoteAudioStreamDecs, _takeSnapshotDecs, _addLocalScreenStreamDecs, _adjustRemoteAudioStreamVolumeDecs, _mergeAudioStreamDecs, _splitAudioStreamDecs;
|
|
4
|
+
import "core-js/modules/es.array.push.js";
|
|
5
|
+
import "core-js/modules/es.json.stringify.js";
|
|
6
|
+
import "core-js/modules/esnext.iterator.constructor.js";
|
|
7
|
+
import "core-js/modules/esnext.iterator.filter.js";
|
|
8
|
+
import "core-js/modules/esnext.iterator.find.js";
|
|
9
|
+
import "core-js/modules/esnext.iterator.for-each.js";
|
|
10
|
+
import "core-js/modules/esnext.iterator.map.js";
|
|
11
|
+
import "core-js/modules/esnext.map.delete-all.js";
|
|
12
|
+
import "core-js/modules/esnext.map.emplace.js";
|
|
13
|
+
import "core-js/modules/esnext.map.every.js";
|
|
14
|
+
import "core-js/modules/esnext.map.filter.js";
|
|
15
|
+
import "core-js/modules/esnext.map.find.js";
|
|
16
|
+
import "core-js/modules/esnext.map.find-key.js";
|
|
17
|
+
import "core-js/modules/esnext.map.includes.js";
|
|
18
|
+
import "core-js/modules/esnext.map.key-of.js";
|
|
19
|
+
import "core-js/modules/esnext.map.map-keys.js";
|
|
20
|
+
import "core-js/modules/esnext.map.map-values.js";
|
|
21
|
+
import "core-js/modules/esnext.map.merge.js";
|
|
22
|
+
import "core-js/modules/esnext.map.reduce.js";
|
|
23
|
+
import "core-js/modules/esnext.map.some.js";
|
|
24
|
+
import "core-js/modules/esnext.map.update.js";
|
|
25
|
+
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)]; } }; }
|
|
26
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
27
|
+
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); }
|
|
28
|
+
function _setFunctionName(e, t, n) { "symbol" == typeof t && (t = (t = t.description) ? "[" + t + "]" : ""); try { Object.defineProperty(e, "name", { configurable: !0, value: n ? n + " " + t : t }); } catch (e) {} return e; }
|
|
29
|
+
function _checkInRHS(e) { if (Object(e) !== e) throw TypeError("right-hand side of 'in' should be an object, got " + (null !== e ? typeof e : "null")); return e; }
|
|
30
|
+
import { AgoraObservable, bound, convertStreamTypeToPublishState, objectSchema, trace, AgoraRteVideoSourceType, v4 } from '../../imports';
|
|
31
|
+
import { FcrReturnCode, FcrUserRoleToStringMap } from '../../type';
|
|
32
|
+
import { FcrVideoSourceType, FcrAudioSourceType, FcrMediaSourceState } from '../../type';
|
|
33
|
+
import { convertRteUserToFcrUser } from '../../utilities/user';
|
|
34
|
+
import { handleRequestError } from '../../utilities/error';
|
|
35
|
+
import { createLogger, generateLogObserver } from '../../utilities/logger';
|
|
36
|
+
import validateParams from '../../utilities/validate-params';
|
|
37
|
+
import { stringArraySchema, stringSchema, numberSchema, fcrStreamBindConfigArrySchema, agoraRtcVideoEncoderConfigurationSchema, fcrVideoStreamTypeSchema, fcrRenderConfigSchema, fcrRenderViewSchema, fcrScreenStreamCreateConfigSchema, fcrLocalStreamCreateArrayConfigSchema, fcrUpdateStreamPrivilegeScopeSchema, fcrUpdateStreamCustomSchema, createUnionSchema, fcrSizeSchema, fcrScreenScenarioTypeSchema } from '../../schema';
|
|
38
|
+
import { AgoraRteStreamPrivilegeOperation } from '../../imports';
|
|
39
|
+
import { ErrorModuleCode } from '../../imports';
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* @internal
|
|
43
|
+
*/
|
|
44
|
+
export class FcrStreamControlImpl {
|
|
45
|
+
static {
|
|
46
|
+
[_initProto] = _applyDecs(this, [[bound, 2, "getStreams"], [bound, 2, "getStreamList"], [bound, 2, "getStreamsByUserId"], [bound, 2, "getStreamByStreamId"], [_addLocalStreamsDecs, 2, "addLocalStreams"], [_bindLocalStreamsDecs, 2, "bindLocalStreams"], [_updatePublishPrivilegeOfStreamsDecs, 2, "updatePublishPrivilegeOfStreams"], [_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"]], []).e;
|
|
47
|
+
}
|
|
48
|
+
//@internal
|
|
49
|
+
[(_addLocalStreamsDecs = [bound, trace(['streams']), validateParams(fcrLocalStreamCreateArrayConfigSchema)], _bindLocalStreamsDecs = [bound, trace(['streams']), validateParams(fcrStreamBindConfigArrySchema)], _updatePublishPrivilegeOfStreamsDecs = [bound, trace, validateParams(fcrUpdateStreamCustomSchema, fcrUpdateStreamPrivilegeScopeSchema.optional())], _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({
|
|
50
|
+
prefix: 'FcrStreamControlImpl'
|
|
51
|
+
}));
|
|
52
|
+
//@internal
|
|
53
|
+
_observable = new AgoraObservable();
|
|
54
|
+
//@internal
|
|
55
|
+
_streamMapByStreamId = {};
|
|
56
|
+
//@internal
|
|
57
|
+
_streamMapByUserId = {};
|
|
58
|
+
//@internal
|
|
59
|
+
_streamList = [];
|
|
60
|
+
//@internal
|
|
61
|
+
|
|
62
|
+
//@internal
|
|
63
|
+
_subscribedStreamsControl = new FcrSubscribedStreamsControl();
|
|
64
|
+
//@internal
|
|
65
|
+
|
|
66
|
+
//@internal
|
|
67
|
+
|
|
68
|
+
//@internal
|
|
69
|
+
_sceneObserver = {
|
|
70
|
+
onStreamsAdded: (sceneId, events) => {
|
|
71
|
+
const fcrStreamEvents = events.map(this._convertStreamEvent);
|
|
72
|
+
fcrStreamEvents.forEach(event => {
|
|
73
|
+
const stream = event.modifiedStream;
|
|
74
|
+
const exists = stream.streamId in this._streamMapByStreamId;
|
|
75
|
+
if (exists) {
|
|
76
|
+
this.logger.warn(`[FcrStreamControl] stream added when the stream already exists, streamId: ${stream.streamId}`);
|
|
77
|
+
} else {
|
|
78
|
+
this._streamList.push(stream);
|
|
79
|
+
this._streamMapByStreamId[stream.streamId] = stream;
|
|
80
|
+
this._putUserStream(stream.owner.userId, stream);
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
this._observable.notifyObservers('onStreamsAdded', sceneId, fcrStreamEvents);
|
|
84
|
+
},
|
|
85
|
+
onStreamsRemoved: (sceneId, events) => {
|
|
86
|
+
const fcrStreamEvents = events.map(this._convertStreamEvent);
|
|
87
|
+
fcrStreamEvents.forEach(event => {
|
|
88
|
+
const stream = event.modifiedStream;
|
|
89
|
+
const exists = stream.streamId in this._streamMapByStreamId;
|
|
90
|
+
if (!exists) {
|
|
91
|
+
this.logger.warn(`[FcrStreamControl] stream removed when the stream does not exist, streamId: ${stream.streamId}`);
|
|
92
|
+
} else {
|
|
93
|
+
const index = this._streamList.findIndex(s => stream.streamId === s.streamId);
|
|
94
|
+
if (index !== -1) {
|
|
95
|
+
this._streamList.splice(index, 1);
|
|
96
|
+
}
|
|
97
|
+
delete this._streamMapByStreamId[stream.streamId];
|
|
98
|
+
this._deleteUserStream(stream.owner.userId, stream);
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
this._observable.notifyObservers('onStreamsRemoved', sceneId, fcrStreamEvents);
|
|
102
|
+
},
|
|
103
|
+
onStreamsUpdated: (sceneId, events) => {
|
|
104
|
+
const fcrStreamEvents = events.map(this._convertStreamEvent);
|
|
105
|
+
fcrStreamEvents.forEach(event => {
|
|
106
|
+
const stream = event.modifiedStream;
|
|
107
|
+
const exists = stream.streamId in this._streamMapByStreamId;
|
|
108
|
+
if (!exists) {
|
|
109
|
+
this.logger.warn(`[FcrStreamControl] stream updated when the stream does not exist, streamId: ${stream.streamId}`);
|
|
110
|
+
} else {
|
|
111
|
+
const index = this._streamList.findIndex(s => stream.streamId === s.streamId);
|
|
112
|
+
if (index !== -1) {
|
|
113
|
+
this._streamList.splice(index, 1, stream);
|
|
114
|
+
}
|
|
115
|
+
this._streamMapByStreamId[stream.streamId] = stream;
|
|
116
|
+
this._setUserStream(stream.owner.userId, stream);
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
this._observable.notifyObservers('onStreamsUpdated', sceneId, fcrStreamEvents);
|
|
120
|
+
},
|
|
121
|
+
onLocalVideoStatsUpdated: (sceneId, streamId, stats) => {
|
|
122
|
+
this._observable.notifyObservers('onLocalVideoStatsUpdated', sceneId, streamId, stats);
|
|
123
|
+
},
|
|
124
|
+
onLocalAudioStatsUpdated: (sceneId, streamId, stats) => {
|
|
125
|
+
this._observable.notifyObservers('onLocalAudioStatsUpdated', sceneId, streamId, stats);
|
|
126
|
+
},
|
|
127
|
+
onRemoteVideoStatsUpdated: (sceneId, streamId, stats) => {
|
|
128
|
+
this._observable.notifyObservers('onRemoteVideoStatsUpdated', sceneId, streamId, stats);
|
|
129
|
+
},
|
|
130
|
+
onRemoteAudioStatsUpdated: (sceneId, streamId, stats) => {
|
|
131
|
+
this._observable.notifyObservers('onRemoteAudioStatsUpdated', sceneId, streamId, stats);
|
|
132
|
+
},
|
|
133
|
+
onFirstRemoteVideoFrameRendered: (sceneId, streamId) => {
|
|
134
|
+
this._observable.notifyObservers('onFirstRemoteVideoFrameRendered', sceneId, streamId);
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
//@internal
|
|
138
|
+
_addSceneStreamPlayerObserver = {
|
|
139
|
+
onRemoteAudioStreamVolumeUpdated: (streamId, volume) => this._observable.notifyObservers('onStreamVolumeIndicationUpdated', this._scene.sceneId, streamId, volume)
|
|
140
|
+
};
|
|
141
|
+
constructor(_engine, _scene, _api, _sharedCache) {
|
|
142
|
+
this._engine = _engine;
|
|
143
|
+
this._scene = _scene;
|
|
144
|
+
this._api = _api;
|
|
145
|
+
this._sharedCache = _sharedCache;
|
|
146
|
+
this._roomCache = _sharedCache.getRoomCache(this._scene.sceneId);
|
|
147
|
+
const streamList = this._scene.getStreamList();
|
|
148
|
+
this._mediaControl = this._engine.getMediaControl();
|
|
149
|
+
streamList.forEach(stream => {
|
|
150
|
+
const user = convertRteUserToFcrUser(stream.owner, this._roomCache);
|
|
151
|
+
const streamInfo = this._convertStreamInfo(stream);
|
|
152
|
+
this._streamList.push(streamInfo);
|
|
153
|
+
this._streamMapByStreamId[stream.streamId] = streamInfo;
|
|
154
|
+
this._putUserStream(user.userId, streamInfo);
|
|
155
|
+
});
|
|
156
|
+
this._addLogObserver();
|
|
157
|
+
this._scene.addObserver(this._sceneObserver);
|
|
158
|
+
this._scene.streamPlayer.addObserver(this._addSceneStreamPlayerObserver);
|
|
159
|
+
}
|
|
160
|
+
// @trace
|
|
161
|
+
getStreams() {
|
|
162
|
+
return this._streamMapByUserId;
|
|
163
|
+
}
|
|
164
|
+
// @trace
|
|
165
|
+
getStreamList() {
|
|
166
|
+
return this._streamList;
|
|
167
|
+
}
|
|
168
|
+
// @trace
|
|
169
|
+
getStreamsByUserId(userId) {
|
|
170
|
+
return this._scene.getStreamsByUserId(userId).map(this._convertStreamInfo);
|
|
171
|
+
}
|
|
172
|
+
// @trace
|
|
173
|
+
getStreamByStreamId(streamId) {
|
|
174
|
+
const streamInfo = this._scene.getStreamByStreamId(streamId);
|
|
175
|
+
if (streamInfo) {
|
|
176
|
+
return this._convertStreamInfo(streamInfo);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
async addLocalStreams(streams) {
|
|
180
|
+
const streamCreateResult = await handleRequestError(() => this._api.createStreamBatch(this._scene.sceneId, streams.map(config => ({
|
|
181
|
+
streamName: config.streamName,
|
|
182
|
+
streamUuid: '0',
|
|
183
|
+
// means that this stream needs to be created
|
|
184
|
+
generateToken: config.generateToken ?? config.videoSourceType === AgoraRteVideoSourceType.SCREEN,
|
|
185
|
+
userUuid: config.ownerId,
|
|
186
|
+
videoSourceType: config.videoSourceType,
|
|
187
|
+
audioSourceType: config.audioSourceType,
|
|
188
|
+
videoSourceUuid: config.videoSourceId,
|
|
189
|
+
audioSourceUuid: config.audioSourceId,
|
|
190
|
+
...convertStreamTypeToPublishState(config.streamType)
|
|
191
|
+
}))), ErrorModuleCode.FCR_ROOM_STREAM, 'add local streams failed');
|
|
192
|
+
|
|
193
|
+
// 处理需要 token 的流
|
|
194
|
+
this._handleStreamTokensPreparation(streams, streamCreateResult.data);
|
|
195
|
+
return streamCreateResult;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* 处理流的 token 准备工作
|
|
200
|
+
* @param streams 流配置列表
|
|
201
|
+
*/
|
|
202
|
+
_handleStreamTokensPreparation(streams, streamCreateResultData) {
|
|
203
|
+
// 提前过滤出需要 token
|
|
204
|
+
const streamConfigMap = new Map();
|
|
205
|
+
streams.forEach(config => {
|
|
206
|
+
const needsToken = config.generateToken || config.videoSourceType === AgoraRteVideoSourceType.SCREEN;
|
|
207
|
+
if (needsToken) {
|
|
208
|
+
streamConfigMap.set(config.ownerId, config);
|
|
209
|
+
}
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
// 如果没有需要 token 的流,直接返回
|
|
213
|
+
if (streamConfigMap.size === 0) {
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
// 遍历返回的流数据,准备发布流
|
|
218
|
+
streamCreateResultData.forEach(stream => {
|
|
219
|
+
if (stream.rtcToken && streamConfigMap.has(stream.userUuid)) {
|
|
220
|
+
this._scene.localUser.prepareToPublishStream(stream.streamUuid, stream.rtcToken);
|
|
221
|
+
}
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
bindLocalStreams(streams) {
|
|
225
|
+
return this._scene.localUser.bindLocalStreams(streams);
|
|
226
|
+
}
|
|
227
|
+
updatePublishPrivilegeOfStreams(...args) {
|
|
228
|
+
if (args.length === 1) {
|
|
229
|
+
const privileges = args[0];
|
|
230
|
+
return handleRequestError(() => this._api.updateStreamBatch(this._scene.sceneId, Object.keys(privileges).map(streamId => ({
|
|
231
|
+
streamUuid: streamId,
|
|
232
|
+
audioState: this._getPublishStateByPrivilege(privileges[streamId].audioPrivilege),
|
|
233
|
+
videoState: this._getPublishStateByPrivilege(privileges[streamId].videoPrivilege)
|
|
234
|
+
}))), ErrorModuleCode.FCR_ROOM_STREAM, 'update publish privilege of streams failed');
|
|
235
|
+
} else if (args.length === 2) {
|
|
236
|
+
const [privilege, scope] = args;
|
|
237
|
+
const targetRteRoles = scope.targetRoleType.map(role => FcrUserRoleToStringMap[role]);
|
|
238
|
+
const includeRoles = [];
|
|
239
|
+
const excludeRoles = [];
|
|
240
|
+
const condition = {
|
|
241
|
+
videoSourceType: scope.videoSourceType,
|
|
242
|
+
audioSourceType: scope.audioSourceType
|
|
243
|
+
};
|
|
244
|
+
if (scope.targetRoleTypeIsInclude) {
|
|
245
|
+
includeRoles.push(...targetRteRoles);
|
|
246
|
+
} else {
|
|
247
|
+
excludeRoles.push(...targetRteRoles);
|
|
248
|
+
}
|
|
249
|
+
const audioState = this._getPublishStateByPrivilege(privilege.audioPrivilege);
|
|
250
|
+
const videoState = this._getPublishStateByPrivilege(privilege.videoPrivilege);
|
|
251
|
+
return handleRequestError(() => this._api.updateStreamBatchByCondition({
|
|
252
|
+
roomUuid: this._scene.sceneId,
|
|
253
|
+
includeRoles,
|
|
254
|
+
excludeRoles,
|
|
255
|
+
videoState,
|
|
256
|
+
audioState,
|
|
257
|
+
condition
|
|
258
|
+
}), ErrorModuleCode.FCR_ROOM_STREAM, 'update publish privilege of streams failed');
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
async removeStreams(streams) {
|
|
262
|
+
const res = await handleRequestError(() => this._api.deleteStreamBatch(this._scene.sceneId, streams.map(streamUuid => ({
|
|
263
|
+
streamUuid
|
|
264
|
+
}))), ErrorModuleCode.FCR_ROOM_STREAM, 'remove streams failed');
|
|
265
|
+
streams.forEach(streamUuid => {
|
|
266
|
+
this._scene.localUser.removePreparePublishStream(streamUuid);
|
|
267
|
+
});
|
|
268
|
+
return res;
|
|
269
|
+
}
|
|
270
|
+
setVideoEncoderConfig(streamId, config, streamType) {
|
|
271
|
+
return this._scene.localUser.setVideoEncoderConfig(config, streamType, streamId);
|
|
272
|
+
}
|
|
273
|
+
setDualStreamMode(streamId, enable) {
|
|
274
|
+
return this._scene.localUser.setDualStreamMode(streamId, enable);
|
|
275
|
+
}
|
|
276
|
+
setScreenScenario(type) {
|
|
277
|
+
return this._scene.localUser.setScreenScenario(type);
|
|
278
|
+
}
|
|
279
|
+
startRenderRemoteVideoStream(streamId, type, config, element) {
|
|
280
|
+
const startTime = Date.now();
|
|
281
|
+
const parameters = `streamId: ${streamId}, config: ${JSON.stringify(config)}, type: ${type}, element: ${element}`;
|
|
282
|
+
this._scene.streamPlayer.subscribeRemoteVideoStream(streamId, type);
|
|
283
|
+
try {
|
|
284
|
+
this._scene.streamPlayer.startRenderRemoteVideoStream(streamId, config.renderMode, config.isMirror, element);
|
|
285
|
+
const viewId = this._subscribedStreamsControl.getViewId(element);
|
|
286
|
+
this._subscribedStreamsControl.bind(viewId, streamId);
|
|
287
|
+
return FcrReturnCode.SUCCESS;
|
|
288
|
+
} catch (error) {
|
|
289
|
+
this.logger.error(`[FcrStreamControl][start-render-remote-video-stream] render failed, streamId: ${streamId}, error: ${error}, parameters: ${parameters}, duration: ${Date.now() - startTime}ms`);
|
|
290
|
+
throw error;
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
stopRenderRemoteVideoStream(streamId, element) {
|
|
294
|
+
const startTime = Date.now();
|
|
295
|
+
const parameters = `streamId: ${streamId}, element: ${element}`;
|
|
296
|
+
try {
|
|
297
|
+
this._scene.streamPlayer.stopRenderRemoteVideoStream(streamId, element);
|
|
298
|
+
const viewId = this._subscribedStreamsControl.getViewId(element);
|
|
299
|
+
this._subscribedStreamsControl.unbind(viewId, streamId);
|
|
300
|
+
const shouldUnsubscribe = this._subscribedStreamsControl.isEmpty(streamId);
|
|
301
|
+
if (shouldUnsubscribe) {
|
|
302
|
+
this._scene.streamPlayer.unsubscribeRemoteVideoStream(streamId);
|
|
303
|
+
} else {
|
|
304
|
+
this.logger.info(`[FcrStreamControl][unsubscribe-remote-video-stream] still has other views, do not unsubscribe, streamId: ${streamId}, parameters: ${parameters}, duration: ${Date.now() - startTime}ms`);
|
|
305
|
+
}
|
|
306
|
+
return FcrReturnCode.SUCCESS;
|
|
307
|
+
} catch (error) {
|
|
308
|
+
this.logger.error(`[FcrStreamControl][stop-render-remote-video-stream] stop render failed, streamId: ${streamId}, error: ${error}, parameters: ${parameters}, duration: ${Date.now() - startTime}ms`);
|
|
309
|
+
throw error;
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
startPlayRemoteAudioStream(streamId) {
|
|
313
|
+
return this._scene.streamPlayer.startPlayRemoteAudioStream(streamId);
|
|
314
|
+
}
|
|
315
|
+
stopPlayRemoteAudioStream(streamId) {
|
|
316
|
+
return this._scene.streamPlayer.stopPlayRemoteAudioStream(streamId);
|
|
317
|
+
}
|
|
318
|
+
takeSnapshot(streamId, filePath) {
|
|
319
|
+
return this._scene.streamPlayer.takeSnapshot(streamId, filePath);
|
|
320
|
+
}
|
|
321
|
+
async addLocalScreenStream(config, size, labels) {
|
|
322
|
+
const res = await handleRequestError(() => this._api.startShareScreen({
|
|
323
|
+
roomId: this._scene.sceneId,
|
|
324
|
+
userId: this._scene.getLocalUser().getLocalUserId(),
|
|
325
|
+
config: {
|
|
326
|
+
videoSourceType: FcrVideoSourceType.SCREEN,
|
|
327
|
+
audioSourceType: FcrAudioSourceType.LOOPBACK,
|
|
328
|
+
videoSourceState: FcrMediaSourceState.CLOSE,
|
|
329
|
+
audioSourceState: FcrMediaSourceState.CLOSE,
|
|
330
|
+
videoSourceUuid: config.videoSourceId,
|
|
331
|
+
audioSourceUuid: config.audioSourceId,
|
|
332
|
+
...convertStreamTypeToPublishState(config.streamType),
|
|
333
|
+
annotation: size ? {
|
|
334
|
+
size: {
|
|
335
|
+
width: size.width,
|
|
336
|
+
height: size.height
|
|
337
|
+
}
|
|
338
|
+
} : {
|
|
339
|
+
size: {
|
|
340
|
+
width: 0,
|
|
341
|
+
height: 0
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
}), ErrorModuleCode.FCR_ROOM_STREAM, 'add local screen stream failed');
|
|
346
|
+
const {
|
|
347
|
+
data: {
|
|
348
|
+
rtcToken: token,
|
|
349
|
+
streamUuid: streamId
|
|
350
|
+
}
|
|
351
|
+
} = res;
|
|
352
|
+
this._screenStreamId = streamId;
|
|
353
|
+
this._scene.localUser.prepareToPublishStream(streamId, token);
|
|
354
|
+
if (labels) {
|
|
355
|
+
// add label to scene
|
|
356
|
+
this._scene.addLocalStreamLabels(streamId, labels);
|
|
357
|
+
}
|
|
358
|
+
return streamId;
|
|
359
|
+
}
|
|
360
|
+
async removeScreenStream() {
|
|
361
|
+
const res = await handleRequestError(async () => {
|
|
362
|
+
await this._api.stopShareScreen({
|
|
363
|
+
roomId: this._scene.sceneId,
|
|
364
|
+
userId: this._scene.localUser.getLocalUserId()
|
|
365
|
+
});
|
|
366
|
+
}, ErrorModuleCode.FCR_ROOM_STREAM, 'remove screen stream failed');
|
|
367
|
+
if (this._screenStreamId) {
|
|
368
|
+
this._scene.removeLocalStreamLabel(this._screenStreamId);
|
|
369
|
+
this._scene.localUser.removePreparePublishStream(this._screenStreamId);
|
|
370
|
+
}
|
|
371
|
+
return res;
|
|
372
|
+
}
|
|
373
|
+
adjustRemoteAudioStreamVolume(streamId, volume) {
|
|
374
|
+
return this._scene.streamPlayer.adjustRemoteAudioStreamVolume(streamId, volume);
|
|
375
|
+
}
|
|
376
|
+
mergeAudioStream(targetUserId) {
|
|
377
|
+
return handleRequestError(() => this._api.mergeAudioStream(targetUserId, {
|
|
378
|
+
roomId: this._scene.sceneId
|
|
379
|
+
}), ErrorModuleCode.FCR_ROOM_STREAM, 'merge audio stream failed');
|
|
380
|
+
}
|
|
381
|
+
splitAudioStream(userId) {
|
|
382
|
+
return handleRequestError(() => this._api.splitAudioStream(userId, {
|
|
383
|
+
roomId: this._scene.sceneId
|
|
384
|
+
}), ErrorModuleCode.FCR_ROOM_STREAM, 'split audio stream failed');
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
// @bound
|
|
388
|
+
// addAudioRawDataObserver(observer: FcrAudioRawDataOutputObserver) {
|
|
389
|
+
// return this._scene.streamPlayer.addAudioRawDataObserver(observer);
|
|
390
|
+
// }
|
|
391
|
+
|
|
392
|
+
// @bound
|
|
393
|
+
// removeAudioRawDataObserver(observer: FcrAudioRawDataOutputObserver) {
|
|
394
|
+
// return this._scene.streamPlayer.removeAudioRawDataObserver(observer);
|
|
395
|
+
// }
|
|
396
|
+
|
|
397
|
+
addObserver(observer) {
|
|
398
|
+
this._observable.addObserver(observer);
|
|
399
|
+
}
|
|
400
|
+
removeObserver(observer) {
|
|
401
|
+
this._observable.removeObserver(observer);
|
|
402
|
+
}
|
|
403
|
+
async findSelectionByParamId(paramSourceId) {
|
|
404
|
+
const wins = (await this._mediaControl?.getWindowList()) || [];
|
|
405
|
+
const displays = (await this._mediaControl?.getDisplayList()) || [];
|
|
406
|
+
const findInList = list => list.find(item => item.id === paramSourceId);
|
|
407
|
+
const winMatch = findInList(wins);
|
|
408
|
+
const displayMatch = findInList(displays);
|
|
409
|
+
return winMatch || displayMatch || null;
|
|
410
|
+
}
|
|
411
|
+
_convertStreamInfo = info => {
|
|
412
|
+
return {
|
|
413
|
+
streamId: info.streamId,
|
|
414
|
+
streamName: info.streamName,
|
|
415
|
+
owner: convertRteUserToFcrUser(info.owner, this._roomCache),
|
|
416
|
+
streamType: info.streamType,
|
|
417
|
+
videoSourceType: info.videoSourceType,
|
|
418
|
+
audioSourceType: info.audioSourceType,
|
|
419
|
+
videoSourceState: info.videoSourceState,
|
|
420
|
+
audioSourceState: info.audioSourceState,
|
|
421
|
+
videoSourceId: info.videoSourceId,
|
|
422
|
+
audioSourceId: info.audioSourceId,
|
|
423
|
+
connectorType: info.connectorType
|
|
424
|
+
};
|
|
425
|
+
};
|
|
426
|
+
_getPublishStateByPrivilege = privilege => {
|
|
427
|
+
return privilege === AgoraRteStreamPrivilegeOperation.HAS_PRIVILEGE ? 1 : privilege === AgoraRteStreamPrivilegeOperation.NOPRIVILEGE ? 0 : undefined;
|
|
428
|
+
};
|
|
429
|
+
_convertStreamEvent = event => {
|
|
430
|
+
return {
|
|
431
|
+
modifiedStream: this._convertStreamInfo(event.modifiedStream),
|
|
432
|
+
operatorUser: event.operatorUser ? convertRteUserToFcrUser(event.operatorUser, this._roomCache) : undefined,
|
|
433
|
+
cause: event.cause
|
|
434
|
+
};
|
|
435
|
+
};
|
|
436
|
+
_putUserStream = (userId, stream) => {
|
|
437
|
+
if (!this._streamMapByUserId[userId]) {
|
|
438
|
+
this._streamMapByUserId[userId] = [];
|
|
439
|
+
}
|
|
440
|
+
this._streamMapByUserId[userId].push(stream);
|
|
441
|
+
};
|
|
442
|
+
_setUserStream = (userId, stream) => {
|
|
443
|
+
const streams = this._streamMapByUserId[userId];
|
|
444
|
+
if (streams) {
|
|
445
|
+
const index = streams.findIndex(s => s.streamId === stream.streamId);
|
|
446
|
+
if (index !== -1) {
|
|
447
|
+
streams.splice(index, 1, stream);
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
};
|
|
451
|
+
_deleteUserStream = (userId, stream) => {
|
|
452
|
+
const userStreams = this._streamMapByUserId[userId];
|
|
453
|
+
if (userStreams) {
|
|
454
|
+
const index = userStreams.findIndex(s => s.streamId === stream.streamId);
|
|
455
|
+
if (index !== -1) {
|
|
456
|
+
userStreams.splice(index, 1);
|
|
457
|
+
}
|
|
458
|
+
if (userStreams.length === 0) {
|
|
459
|
+
delete this._streamMapByUserId[userId];
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
};
|
|
463
|
+
_addLogObserver() {
|
|
464
|
+
this.addObserver(generateLogObserver(this.logger, [
|
|
465
|
+
// 'onLocalVideoStatsUpdated',
|
|
466
|
+
// 'onLocalAudioStatsUpdated',
|
|
467
|
+
// 'onRemoteVideoStatsUpdated',
|
|
468
|
+
// 'onRemoteAudioStatsUpdated',
|
|
469
|
+
['onFirstRemoteVideoFrameRendered', ['roomId', 'streamId']],
|
|
470
|
+
// 'onStreamVolumeIndicationUpdated',
|
|
471
|
+
['onStreamsAdded', ['roomId', 'events']], ['onStreamsRemoved', ['roomId', 'events']], ['onStreamsUpdated', ['roomId', 'events']]]));
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
export class FcrSubscribedStreamsControl {
|
|
475
|
+
logger = createLogger({
|
|
476
|
+
prefix: 'StreamSubscriptionManager'
|
|
477
|
+
});
|
|
478
|
+
//@internal
|
|
479
|
+
/**
|
|
480
|
+
* Map of remote subscribed streams to their bound view IDs
|
|
481
|
+
* key: streamId - The ID of the remote video stream
|
|
482
|
+
* value: string[] - Array of viewIds bound to this stream
|
|
483
|
+
*/
|
|
484
|
+
_remoteSubscribedStreamRenderMap = new Map();
|
|
485
|
+
getViewId(element) {
|
|
486
|
+
// Adapt for harmony: AgoraRteRenderView is string in harmony, HTMLElement in web
|
|
487
|
+
if (typeof element === 'string') {
|
|
488
|
+
return element;
|
|
489
|
+
} else {
|
|
490
|
+
// @ts-ignore
|
|
491
|
+
const viewId = element.getAttribute('data-render-id');
|
|
492
|
+
if (!viewId) {
|
|
493
|
+
const uniqueId = v4();
|
|
494
|
+
// @ts-ignore
|
|
495
|
+
element.setAttribute('data-render-id', uniqueId);
|
|
496
|
+
return uniqueId;
|
|
497
|
+
}
|
|
498
|
+
return viewId;
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
isEmpty(streamId) {
|
|
502
|
+
const viewIds = this._remoteSubscribedStreamRenderMap.get(streamId);
|
|
503
|
+
return !viewIds || viewIds.length === 0;
|
|
504
|
+
}
|
|
505
|
+
bind(viewId, streamId) {
|
|
506
|
+
if (!streamId || !viewId) {
|
|
507
|
+
this.logger.warn(`[FcrStreamControl][bind-view-to-stream] invalid parameters, streamId: ${streamId}, viewId: ${viewId}`);
|
|
508
|
+
return;
|
|
509
|
+
}
|
|
510
|
+
const viewIds = this._remoteSubscribedStreamRenderMap.get(streamId) || [];
|
|
511
|
+
const isAlreadyBound = viewIds.includes(viewId);
|
|
512
|
+
if (!isAlreadyBound) {
|
|
513
|
+
viewIds.push(viewId);
|
|
514
|
+
this._remoteSubscribedStreamRenderMap.set(streamId, viewIds);
|
|
515
|
+
} else {
|
|
516
|
+
this.logger.warn(`[FcrStreamControl][bind-view-to-stream] viewId already bound, streamId: ${streamId}, viewId: ${viewId}`);
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
unbind(viewId, streamId) {
|
|
520
|
+
if (!streamId || !viewId) {
|
|
521
|
+
this.logger.warn(`[FcrStreamControl][unbind-view-from-stream] invalid parameters, streamId: ${streamId}, viewId: ${viewId}`);
|
|
522
|
+
return;
|
|
523
|
+
}
|
|
524
|
+
const viewIds = this._remoteSubscribedStreamRenderMap.get(streamId);
|
|
525
|
+
if (!viewIds || !viewIds.includes(viewId)) {
|
|
526
|
+
this.logger.warn(`[FcrStreamControl][unbind-view-from-stream] viewId not found, streamId: ${streamId}, viewId: ${viewId}`);
|
|
527
|
+
return;
|
|
528
|
+
}
|
|
529
|
+
const rest = viewIds.filter(id => id !== viewId);
|
|
530
|
+
if (rest.length === 0) {
|
|
531
|
+
this._remoteSubscribedStreamRenderMap.delete(streamId);
|
|
532
|
+
} else {
|
|
533
|
+
this._remoteSubscribedStreamRenderMap.set(streamId, rest);
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import "core-js/modules/es.typed-array.to-reversed.js";
|
|
2
|
+
import "core-js/modules/es.typed-array.to-sorted.js";
|
|
3
|
+
import "core-js/modules/es.typed-array.with.js";
|
|
4
|
+
import "core-js/modules/esnext.array-buffer.detached.js";
|
|
5
|
+
import "core-js/modules/esnext.array-buffer.transfer.js";
|
|
6
|
+
import "core-js/modules/esnext.array-buffer.transfer-to-fixed-length.js";
|
|
7
|
+
import "core-js/modules/esnext.json.parse.js";
|
|
8
|
+
import "core-js/modules/esnext.typed-array.filter-reject.js";
|
|
9
|
+
import "core-js/modules/esnext.typed-array.group-by.js";
|
|
10
|
+
import "core-js/modules/esnext.typed-array.to-spliced.js";
|
|
11
|
+
import "core-js/modules/esnext.typed-array.unique-by.js";
|
|
12
|
+
export async function deCompressGzipToJson(compressedData) {
|
|
13
|
+
try {
|
|
14
|
+
// 检查浏览器是否支持 Compression Streams API
|
|
15
|
+
if (typeof DecompressionStream === 'undefined') {
|
|
16
|
+
throw new Error('DecompressionStream is not supported in this browser');
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// 创建解压缩流
|
|
20
|
+
const decompressionStream = new DecompressionStream('gzip');
|
|
21
|
+
const decompressedStream = new Blob([new Uint8Array(compressedData)]).stream().pipeThrough(decompressionStream);
|
|
22
|
+
|
|
23
|
+
// 获取解压缩后的文本
|
|
24
|
+
const response = new Response(decompressedStream);
|
|
25
|
+
const text = await response.text();
|
|
26
|
+
|
|
27
|
+
// 解析为 JSON 对象
|
|
28
|
+
return JSON.parse(text);
|
|
29
|
+
} catch (error) {
|
|
30
|
+
console.error('Gzip decompression to JSON failed:', error);
|
|
31
|
+
throw error;
|
|
32
|
+
}
|
|
33
|
+
}
|