fcr-core 3.4.0
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/base-session.d.ts +3 -0
- package/lib/base-session.js +8 -0
- package/lib/chat-connection/config.d.ts +51 -0
- package/lib/chat-connection/config.js +105 -0
- package/lib/chat-connection/index.d.ts +25 -0
- package/lib/chat-connection/index.js +118 -0
- package/lib/chat-connection/type.d.ts +17 -0
- package/lib/chat-connection/type.js +12 -0
- package/lib/engine/index.d.ts +86 -0
- package/lib/engine/index.js +317 -0
- package/lib/imports.d.ts +43 -0
- package/lib/imports.js +322 -0
- package/lib/index.d.ts +22 -0
- package/lib/index.js +140 -0
- package/lib/media-control/desktop.d.ts +1 -0
- package/lib/media-control/desktop.js +120 -0
- package/lib/media-control/mobile.d.ts +1 -0
- package/lib/media-control/mobile.js +168 -0
- package/lib/media-control/type.d.ts +640 -0
- package/lib/media-control/type.js +5 -0
- package/lib/monitor-control/index.d.ts +1 -0
- package/lib/monitor-control/index.js +22 -0
- package/lib/monitor-control/type.d.ts +16 -0
- package/lib/monitor-control/type.js +5 -0
- package/lib/peer-session/index.d.ts +1 -0
- package/lib/peer-session/index.js +286 -0
- package/lib/peer-session/type.d.ts +54 -0
- package/lib/peer-session/type.js +5 -0
- package/lib/plugins/chatroom.d.ts +1 -0
- package/lib/plugins/chatroom.js +331 -0
- package/lib/plugins/electron-rtc-plugin.d.ts +1 -0
- package/lib/plugins/electron-rtc-plugin.js +13 -0
- package/lib/plugins/rtm-plugin.d.ts +1 -0
- package/lib/plugins/rtm-plugin.js +13 -0
- package/lib/plugins/web-rtc-plugin.d.ts +1 -0
- package/lib/plugins/web-rtc-plugin.js +13 -0
- package/lib/room-control/chatroom-control/config.d.ts +51 -0
- package/lib/room-control/chatroom-control/config.js +105 -0
- package/lib/room-control/chatroom-control/index.d.ts +1 -0
- package/lib/room-control/chatroom-control/index.js +323 -0
- package/lib/room-control/chatroom-control/type.d.ts +95 -0
- package/lib/room-control/chatroom-control/type.js +18 -0
- package/lib/room-control/group-control/index.d.ts +25 -0
- package/lib/room-control/group-control/index.js +227 -0
- package/lib/room-control/index.d.ts +1 -0
- package/lib/room-control/index.js +459 -0
- package/lib/room-control/interpreter-control/index.d.ts +1 -0
- package/lib/room-control/interpreter-control/index.js +136 -0
- package/lib/room-control/interpreter-control/room.d.ts +1 -0
- package/lib/room-control/interpreter-control/room.js +22 -0
- package/lib/room-control/interpreter-control/types.d.ts +66 -0
- package/lib/room-control/interpreter-control/types.js +32 -0
- package/lib/room-control/mainroom-control/index.d.ts +1 -0
- package/lib/room-control/mainroom-control/index.js +181 -0
- package/lib/room-control/privilege-control/helper.d.ts +9 -0
- package/lib/room-control/privilege-control/helper.js +43 -0
- package/lib/room-control/privilege-control/index.d.ts +1 -0
- package/lib/room-control/privilege-control/index.js +245 -0
- package/lib/room-control/privilege-control/type.d.ts +293 -0
- package/lib/room-control/privilege-control/type.js +141 -0
- package/lib/room-control/room-connector-control/index.d.ts +1 -0
- package/lib/room-control/room-connector-control/index.js +160 -0
- package/lib/room-control/room-connector-control/type.d.ts +102 -0
- package/lib/room-control/room-connector-control/type.js +34 -0
- package/lib/room-control/room-session/index.d.ts +1 -0
- package/lib/room-control/room-session/index.js +286 -0
- package/lib/room-control/room-session/type.d.ts +61 -0
- package/lib/room-control/room-session/type.js +5 -0
- package/lib/room-control/stream-control/index.d.ts +1 -0
- package/lib/room-control/stream-control/index.js +341 -0
- package/lib/room-control/stream-control/type.d.ts +209 -0
- package/lib/room-control/stream-control/type.js +5 -0
- package/lib/room-control/type.d.ts +281 -0
- package/lib/room-control/type.js +23 -0
- package/lib/room-control/user-control/index.d.ts +1 -0
- package/lib/room-control/user-control/index.js +318 -0
- package/lib/room-control/user-control/type.d.ts +177 -0
- package/lib/room-control/user-control/type.js +17 -0
- package/lib/room-control/waitingroom-control/index.d.ts +1 -0
- package/lib/room-control/waitingroom-control/index.js +46 -0
- package/lib/room-control/whiteboard-control/board-window.d.ts +47 -0
- package/lib/room-control/whiteboard-control/board-window.js +396 -0
- package/lib/room-control/whiteboard-control/enums.d.ts +164 -0
- package/lib/room-control/whiteboard-control/enums.js +96 -0
- package/lib/room-control/whiteboard-control/index.d.ts +1 -0
- package/lib/room-control/whiteboard-control/index.js +342 -0
- package/lib/room-control/whiteboard-control/mount-manager.d.ts +4 -0
- package/lib/room-control/whiteboard-control/mount-manager.js +15 -0
- package/lib/room-control/whiteboard-control/types.d.ts +330 -0
- package/lib/room-control/whiteboard-control/types.js +12 -0
- package/lib/room-control/whiteboard-control/utils.d.ts +51 -0
- package/lib/room-control/whiteboard-control/utils.js +273 -0
- package/lib/room-control/whiteboard-control-v2/index.d.ts +35 -0
- package/lib/room-control/whiteboard-control-v2/index.js +242 -0
- package/lib/room-control/whiteboard-control-v2/main-window.d.ts +33 -0
- package/lib/room-control/whiteboard-control-v2/main-window.js +213 -0
- package/lib/room-control/whiteboard-control-v2/utils.d.ts +3 -0
- package/lib/room-control/whiteboard-control-v2/utils.js +39 -0
- package/lib/service/api.d.ts +401 -0
- package/lib/service/api.js +924 -0
- package/lib/service/type.d.ts +7 -0
- package/lib/service/type.js +5 -0
- package/lib/type.d.ts +254 -0
- package/lib/type.js +87 -0
- package/lib/utilities/cmd.d.ts +1 -0
- package/lib/utilities/cmd.js +7 -0
- package/lib/utilities/collection.d.ts +22 -0
- package/lib/utilities/collection.js +74 -0
- package/lib/utilities/error.d.ts +41 -0
- package/lib/utilities/error.js +68 -0
- package/lib/utilities/package-info.d.ts +1 -0
- package/lib/utilities/package-info.js +12 -0
- package/lib/utilities/parameters.d.ts +9 -0
- package/lib/utilities/parameters.js +30 -0
- package/lib/utilities/stream.d.ts +27 -0
- package/lib/utilities/stream.js +34 -0
- package/lib/utilities/user.d.ts +7 -0
- package/lib/utilities/user.js +34 -0
- package/package.json +98 -0
|
@@ -0,0 +1,341 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
require("core-js/modules/es.symbol.description.js");
|
|
4
|
+
require("core-js/modules/es.error.cause.js");
|
|
5
|
+
require("core-js/modules/esnext.async-iterator.filter.js");
|
|
6
|
+
require("core-js/modules/esnext.function.metadata.js");
|
|
7
|
+
require("core-js/modules/esnext.iterator.filter.js");
|
|
8
|
+
require("core-js/modules/esnext.symbol.metadata.js");
|
|
9
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
10
|
+
Object.defineProperty(exports, "__esModule", {
|
|
11
|
+
value: true
|
|
12
|
+
});
|
|
13
|
+
exports.FcrStreamControlImpl = void 0;
|
|
14
|
+
require("core-js/modules/es.array.push.js");
|
|
15
|
+
require("core-js/modules/esnext.async-iterator.for-each.js");
|
|
16
|
+
require("core-js/modules/esnext.async-iterator.map.js");
|
|
17
|
+
require("core-js/modules/esnext.async-iterator.some.js");
|
|
18
|
+
require("core-js/modules/esnext.iterator.constructor.js");
|
|
19
|
+
require("core-js/modules/esnext.iterator.for-each.js");
|
|
20
|
+
require("core-js/modules/esnext.iterator.map.js");
|
|
21
|
+
require("core-js/modules/esnext.iterator.some.js");
|
|
22
|
+
require("core-js/modules/esnext.map.delete-all.js");
|
|
23
|
+
require("core-js/modules/esnext.map.emplace.js");
|
|
24
|
+
require("core-js/modules/esnext.map.every.js");
|
|
25
|
+
require("core-js/modules/esnext.map.filter.js");
|
|
26
|
+
require("core-js/modules/esnext.map.find.js");
|
|
27
|
+
require("core-js/modules/esnext.map.find-key.js");
|
|
28
|
+
require("core-js/modules/esnext.map.includes.js");
|
|
29
|
+
require("core-js/modules/esnext.map.key-of.js");
|
|
30
|
+
require("core-js/modules/esnext.map.map-keys.js");
|
|
31
|
+
require("core-js/modules/esnext.map.map-values.js");
|
|
32
|
+
require("core-js/modules/esnext.map.merge.js");
|
|
33
|
+
require("core-js/modules/esnext.map.reduce.js");
|
|
34
|
+
require("core-js/modules/esnext.map.some.js");
|
|
35
|
+
require("core-js/modules/esnext.map.update.js");
|
|
36
|
+
require("core-js/modules/web.dom-collections.iterator.js");
|
|
37
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
38
|
+
var _imports = require("../../imports");
|
|
39
|
+
var _type = require("../../type");
|
|
40
|
+
var _ = require("../..");
|
|
41
|
+
var _user = require("../../utilities/user");
|
|
42
|
+
var _error = require("../../utilities/error");
|
|
43
|
+
var _FcrStreamControlImpl;
|
|
44
|
+
let _initProto;
|
|
45
|
+
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; }
|
|
46
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
47
|
+
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)]; } }; }
|
|
48
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
49
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
50
|
+
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; }
|
|
51
|
+
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; }
|
|
52
|
+
/**
|
|
53
|
+
* @internal
|
|
54
|
+
*/
|
|
55
|
+
class FcrStreamControlImpl {
|
|
56
|
+
constructor(_engine, _scene, _api) {
|
|
57
|
+
//@internal
|
|
58
|
+
(0, _defineProperty2.default)(this, "logger", (_initProto(this), (0, _imports.getLogger)()));
|
|
59
|
+
//@internal
|
|
60
|
+
(0, _defineProperty2.default)(this, "_observable", new _imports.AgoraObservable());
|
|
61
|
+
//@internal
|
|
62
|
+
(0, _defineProperty2.default)(this, "_streamMapByStreamId", {});
|
|
63
|
+
//@internal
|
|
64
|
+
(0, _defineProperty2.default)(this, "_streamMapByUserId", {});
|
|
65
|
+
//@internal
|
|
66
|
+
(0, _defineProperty2.default)(this, "_streamList", []);
|
|
67
|
+
//@internal
|
|
68
|
+
(0, _defineProperty2.default)(this, "_remoteStreamRenderMap", new Map());
|
|
69
|
+
//@internal
|
|
70
|
+
(0, _defineProperty2.default)(this, "_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: ".concat(stream.streamId));
|
|
78
|
+
} else {
|
|
79
|
+
this._streamList.push(stream);
|
|
80
|
+
this._streamMapByStreamId[stream.streamId] = stream;
|
|
81
|
+
this._putUserStream(stream.owner.userId, stream);
|
|
82
|
+
}
|
|
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: ".concat(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);
|
|
100
|
+
}
|
|
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: ".concat(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);
|
|
118
|
+
}
|
|
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
|
+
(0, _defineProperty2.default)(this, "_addSceneStreamPlayerObserver", {
|
|
140
|
+
onRemoteAudioStreamVolumeUpdated: (streamId, volume) => this._observable.notifyObservers('onStreamVolumeIndicationUpdated', this._scene.sceneId, streamId, volume)
|
|
141
|
+
});
|
|
142
|
+
(0, _defineProperty2.default)(this, "_convertStreamInfo", info => {
|
|
143
|
+
return {
|
|
144
|
+
streamId: info.streamId,
|
|
145
|
+
streamName: info.streamName,
|
|
146
|
+
owner: (0, _user.convertRteUserToFcrUser)(info.owner),
|
|
147
|
+
streamType: info.streamType,
|
|
148
|
+
videoSourceType: info.videoSourceType,
|
|
149
|
+
audioSourceType: info.audioSourceType,
|
|
150
|
+
videoSourceState: info.videoSourceState,
|
|
151
|
+
audioSourceState: info.audioSourceState,
|
|
152
|
+
videoSourceId: info.videoSourceId,
|
|
153
|
+
audioSourceId: info.audioSourceId,
|
|
154
|
+
connectorType: info.connectorType
|
|
155
|
+
};
|
|
156
|
+
});
|
|
157
|
+
(0, _defineProperty2.default)(this, "_convertStreamEvent", event => {
|
|
158
|
+
return {
|
|
159
|
+
modifiedStream: this._convertStreamInfo(event.modifiedStream),
|
|
160
|
+
operatorUser: event.operatorUser ? (0, _user.convertRteUserToFcrUser)(event.operatorUser) : undefined,
|
|
161
|
+
cause: event.cause
|
|
162
|
+
};
|
|
163
|
+
});
|
|
164
|
+
(0, _defineProperty2.default)(this, "_putUserStream", (userId, stream) => {
|
|
165
|
+
if (!this._streamMapByUserId[userId]) {
|
|
166
|
+
this._streamMapByUserId[userId] = [];
|
|
167
|
+
}
|
|
168
|
+
this._streamMapByUserId[userId].push(stream);
|
|
169
|
+
});
|
|
170
|
+
(0, _defineProperty2.default)(this, "_setUserStream", (userId, stream) => {
|
|
171
|
+
const streams = this._streamMapByUserId[userId];
|
|
172
|
+
if (streams) {
|
|
173
|
+
const index = streams.findIndex(s => s.streamId === stream.streamId);
|
|
174
|
+
if (index !== -1) {
|
|
175
|
+
streams.splice(index, 1, stream);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
});
|
|
179
|
+
(0, _defineProperty2.default)(this, "_deleteUserStream", (userId, stream) => {
|
|
180
|
+
const userStreams = this._streamMapByUserId[userId];
|
|
181
|
+
if (userStreams) {
|
|
182
|
+
const index = userStreams.findIndex(s => s.streamId === stream.streamId);
|
|
183
|
+
if (index !== -1) {
|
|
184
|
+
userStreams.splice(index, 1);
|
|
185
|
+
}
|
|
186
|
+
if (userStreams.length === 0) {
|
|
187
|
+
delete this._streamMapByUserId[userId];
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
});
|
|
191
|
+
this._engine = _engine;
|
|
192
|
+
this._scene = _scene;
|
|
193
|
+
this._api = _api;
|
|
194
|
+
this._scene.addObserver(this._sceneObserver);
|
|
195
|
+
this._scene.streamPlayer.addObserver(this._addSceneStreamPlayerObserver);
|
|
196
|
+
const streamList = this._scene.getStreamList();
|
|
197
|
+
streamList.forEach(stream => {
|
|
198
|
+
const user = stream.owner;
|
|
199
|
+
const streamInfo = this._convertStreamInfo(stream);
|
|
200
|
+
this._streamList.push(streamInfo);
|
|
201
|
+
this._streamMapByStreamId[stream.streamId] = streamInfo;
|
|
202
|
+
this._putUserStream(user.userId, streamInfo);
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
getStreams() {
|
|
206
|
+
return this._streamMapByUserId;
|
|
207
|
+
}
|
|
208
|
+
getStreamList() {
|
|
209
|
+
return this._streamList;
|
|
210
|
+
}
|
|
211
|
+
getStreamsByUserId(userId) {
|
|
212
|
+
return this._scene.getStreamsByUserId(userId).map(this._convertStreamInfo);
|
|
213
|
+
}
|
|
214
|
+
getStreamByStreamId(streamId) {
|
|
215
|
+
const streamInfo = this._scene.getStreamByStreamId(streamId);
|
|
216
|
+
if (streamInfo) {
|
|
217
|
+
return this._convertStreamInfo(streamInfo);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
addLocalStreams(streams) {
|
|
221
|
+
return this._scene.localUser.addLocalStreams(streams);
|
|
222
|
+
}
|
|
223
|
+
bindLocalStreams(streams) {
|
|
224
|
+
return this._scene.localUser.bindLocalStreams(streams);
|
|
225
|
+
}
|
|
226
|
+
updatePublishPrivilegeOfStreams() {
|
|
227
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
228
|
+
args[_key] = arguments[_key];
|
|
229
|
+
}
|
|
230
|
+
if (args.length === 1) {
|
|
231
|
+
return this._scene.localUser.updatePublishPrivilegeOfStreams(args[0]);
|
|
232
|
+
} else if (args.length === 2) {
|
|
233
|
+
const [privilege, scope] = args;
|
|
234
|
+
const targetRteRoles = scope.targetRoleType.map(role => _type.FcrUserRoleToStringMap[role]);
|
|
235
|
+
return this._scene.localUser.updatePublishPrivilegeOfStreams(privilege, {
|
|
236
|
+
targetRoleType: targetRteRoles,
|
|
237
|
+
targetRoleTypeIsInclude: scope.targetRoleTypeIsInclude
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
removeStreams(streams) {
|
|
242
|
+
return this._scene.localUser.removeStreams(streams);
|
|
243
|
+
}
|
|
244
|
+
setVideoEncoderConfig(streamId, config, streamType) {
|
|
245
|
+
return this._scene.localUser.setVideoEncoderConfig(config, streamType, streamId);
|
|
246
|
+
}
|
|
247
|
+
startRenderRemoteVideoStream(streamId, type, config, element) {
|
|
248
|
+
this._remoteStreamRenderMap.set(element, streamId);
|
|
249
|
+
this._scene.streamPlayer.subscribeRemoteVideoStream(streamId, type);
|
|
250
|
+
this._scene.streamPlayer.startRenderRemoteVideoStream(streamId, type, config.renderMode, config.isMirror, element);
|
|
251
|
+
}
|
|
252
|
+
stopRenderRemoteVideoStream(streamId, element) {
|
|
253
|
+
this._remoteStreamRenderMap.delete(element);
|
|
254
|
+
this._scene.streamPlayer.stopRenderRemoteVideoStream(streamId, element);
|
|
255
|
+
const hasRender = Array.from(this._remoteStreamRenderMap.values()).some(id => id === streamId);
|
|
256
|
+
if (!hasRender) {
|
|
257
|
+
this._scene.streamPlayer.unsubscribeRemoteVideoStream(streamId);
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
startPlayRemoteAudioStream(streamId) {
|
|
261
|
+
this._scene.streamPlayer.startPlayRemoteAudioStream(streamId);
|
|
262
|
+
}
|
|
263
|
+
stopPlayRemoteAudioStream(streamId) {
|
|
264
|
+
this._scene.streamPlayer.stopPlayRemoteAudioStream(streamId);
|
|
265
|
+
}
|
|
266
|
+
takeSnapshot(streamId, filePath) {
|
|
267
|
+
return this._scene.streamPlayer.takeSnapshot(streamId, filePath);
|
|
268
|
+
}
|
|
269
|
+
async addLocalScreenStream(config) {
|
|
270
|
+
try {
|
|
271
|
+
const res = await this._api.startShareScreen({
|
|
272
|
+
roomId: this._scene.sceneId,
|
|
273
|
+
userId: this._scene.getLocalUser().getLocalUserId(),
|
|
274
|
+
config: _objectSpread({
|
|
275
|
+
videoSourceUuid: 'default',
|
|
276
|
+
videoSourceType: _.FcrVideoSourceType.SCREEN,
|
|
277
|
+
audioSourceType: _.FcrAudioSourceType.LOOPBACK
|
|
278
|
+
}, (0, _imports.convertStreamTypeToPublishState)(config.streamType))
|
|
279
|
+
});
|
|
280
|
+
const {
|
|
281
|
+
data: {
|
|
282
|
+
rtcToken: token,
|
|
283
|
+
streamUuid: streamId
|
|
284
|
+
}
|
|
285
|
+
} = res;
|
|
286
|
+
this._screenStreamId = streamId;
|
|
287
|
+
this._scene.localUser.prepareToPublishScreenStream(streamId, token);
|
|
288
|
+
return streamId;
|
|
289
|
+
} catch (error) {
|
|
290
|
+
if (error instanceof _imports.AgoraRestfulClientError) {
|
|
291
|
+
var _error$serviceCode;
|
|
292
|
+
this.logger.error("[FcrStreamControl] addLocalScreenStream failed, error: ".concat(error.message));
|
|
293
|
+
throw (0, _error.generateFcrCoreServerError)((_error$serviceCode = error.serviceCode) !== null && _error$serviceCode !== void 0 ? _error$serviceCode : -1, error.message, error);
|
|
294
|
+
}
|
|
295
|
+
throw (0, _error.generateFcrCoreClientError)(_error.FcrErrorModuleCode.MEDIA_CONTROL_SCREEN, _error.FcrErrorCode.UNDEFINED_ERROR, 'addLocalScreenStream failed', error);
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
async removeScreenStream() {
|
|
299
|
+
const res = await this._api.stopShareScreen({
|
|
300
|
+
roomId: this._scene.sceneId,
|
|
301
|
+
userId: this._scene.getLocalUser().getLocalUserId()
|
|
302
|
+
});
|
|
303
|
+
if (this._screenStreamId) {
|
|
304
|
+
this._scene.localUser.removePreparePublishScreenStream(this._screenStreamId);
|
|
305
|
+
}
|
|
306
|
+
return res;
|
|
307
|
+
}
|
|
308
|
+
adjustRemoteAudioStreamVolume(streamId, volume) {
|
|
309
|
+
this._scene.streamPlayer.adjustRemoteAudioStreamVolume(streamId, volume);
|
|
310
|
+
}
|
|
311
|
+
mergeAudioStream(targetUserId) {
|
|
312
|
+
return this._api.mergeAudioStream(targetUserId, {
|
|
313
|
+
roomId: this._scene.sceneId
|
|
314
|
+
});
|
|
315
|
+
}
|
|
316
|
+
splitAudioStream(userId) {
|
|
317
|
+
return this._api.splitAudioStream(userId, {
|
|
318
|
+
roomId: this._scene.sceneId
|
|
319
|
+
});
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
// @bound
|
|
323
|
+
// addAudioRawDataObserver(observer: FcrAudioRawDataOutputObserver) {
|
|
324
|
+
// return this._scene.streamPlayer.addAudioRawDataObserver(observer);
|
|
325
|
+
// }
|
|
326
|
+
|
|
327
|
+
// @bound
|
|
328
|
+
// removeAudioRawDataObserver(observer: FcrAudioRawDataOutputObserver) {
|
|
329
|
+
// return this._scene.streamPlayer.removeAudioRawDataObserver(observer);
|
|
330
|
+
// }
|
|
331
|
+
|
|
332
|
+
addObserver(observer) {
|
|
333
|
+
this._observable.addObserver(observer);
|
|
334
|
+
}
|
|
335
|
+
removeObserver(observer) {
|
|
336
|
+
this._observable.removeObserver(observer);
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
exports.FcrStreamControlImpl = FcrStreamControlImpl;
|
|
340
|
+
_FcrStreamControlImpl = FcrStreamControlImpl;
|
|
341
|
+
[_initProto] = _applyDecs(_FcrStreamControlImpl, [[_imports.bound, 2, "getStreams"], [_imports.bound, 2, "getStreamList"], [_imports.bound, 2, "getStreamsByUserId"], [_imports.bound, 2, "getStreamByStreamId"], [_imports.bound, 2, "addLocalStreams"], [_imports.bound, 2, "bindLocalStreams"], [_imports.bound, 2, "updatePublishPrivilegeOfStreams"], [_imports.bound, 2, "removeStreams"], [_imports.bound, 2, "setVideoEncoderConfig"], [_imports.bound, 2, "startRenderRemoteVideoStream"], [_imports.bound, 2, "stopRenderRemoteVideoStream"], [_imports.bound, 2, "startPlayRemoteAudioStream"], [_imports.bound, 2, "stopPlayRemoteAudioStream"], [_imports.bound, 2, "takeSnapshot"], [_imports.bound, 2, "addLocalScreenStream"], [_imports.bound, 2, "removeScreenStream"], [_imports.bound, 2, "adjustRemoteAudioStreamVolume"], [_imports.bound, 2, "mergeAudioStream"], [_imports.bound, 2, "splitAudioStream"], [_imports.bound, 2, "addObserver"], [_imports.bound, 2, "removeObserver"]], []).e;
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
import { FcrOperateCause, FcrRenderView, FcrStreamInfo, FcrUserInfo, FcrUserRole, FcrVideoEncoderConfig, FcrVideoRenderConfig } from '../../type';
|
|
2
|
+
import { FcrVideoStreamType, FcrStreamPrivilegeOperation, FcrStreamPrivilegeVideoSourceType, FcrStreamPrivilegeAudioSourceType } from '../..';
|
|
3
|
+
import { AgoraRteSnapshotInfo, AgoraRteStreamBindConfig, AgoraRtcLocalVideoStats, AgoraRtcLocalAudioStats, AgoraRtcRemoteVideoStats, AgoraRtcRemoteAudioStats, AgoraRtcDimensions, AgoraRteMediaStreamCreateConfig } from '../../imports';
|
|
4
|
+
export interface FcrStreamControl {
|
|
5
|
+
/**
|
|
6
|
+
* Gets the map of list of streams, indexed by user ID.
|
|
7
|
+
*/
|
|
8
|
+
getStreams(): Readonly<Record<string, FcrStreamInfo[]>>;
|
|
9
|
+
/**
|
|
10
|
+
* Gets the list of streams.
|
|
11
|
+
*/
|
|
12
|
+
getStreamList(): Readonly<FcrStreamInfo[]>;
|
|
13
|
+
/**
|
|
14
|
+
* Gets the list of streams by user ID.
|
|
15
|
+
* @param userId
|
|
16
|
+
*/
|
|
17
|
+
getStreamsByUserId(userId: string): Readonly<FcrStreamInfo[]>;
|
|
18
|
+
/**
|
|
19
|
+
* Gets the stream by stream ID.
|
|
20
|
+
* @param streamId
|
|
21
|
+
*/
|
|
22
|
+
getStreamByStreamId(streamId: string): FcrStreamInfo | undefined;
|
|
23
|
+
/**
|
|
24
|
+
* Adds multiple local streams.
|
|
25
|
+
* @param configs
|
|
26
|
+
*/
|
|
27
|
+
addLocalStreams(configs: FcrLocalStreamCreateConfig[]): Promise<void>;
|
|
28
|
+
/**
|
|
29
|
+
* Binds multiple local streams.
|
|
30
|
+
* @param configs
|
|
31
|
+
*/
|
|
32
|
+
bindLocalStreams(configs: FcrStreamBindConfig[]): Promise<void>;
|
|
33
|
+
/**
|
|
34
|
+
* Updates the publish privilege of streams.
|
|
35
|
+
* @param privileges
|
|
36
|
+
*/
|
|
37
|
+
updatePublishPrivilegeOfStreams(privileges: Record<string, FcrUpdateStreamPrivilege>): Promise<void>;
|
|
38
|
+
/**
|
|
39
|
+
* Updates the publish privilege of streams.
|
|
40
|
+
* @param privilege
|
|
41
|
+
* @param scope
|
|
42
|
+
*/
|
|
43
|
+
updatePublishPrivilegeOfStreams(privilege: FcrUpdateStreamPrivilege, scope: FcrUpdateStreamPrivilegeScope): Promise<void>;
|
|
44
|
+
/**
|
|
45
|
+
* Removes multiple streams by stream ID.
|
|
46
|
+
* @param streams
|
|
47
|
+
*/
|
|
48
|
+
removeStreams(streams: string[]): Promise<void>;
|
|
49
|
+
/** Adjust remote audio stream volume
|
|
50
|
+
* @param streamId
|
|
51
|
+
* @param volume
|
|
52
|
+
*/
|
|
53
|
+
adjustRemoteAudioStreamVolume(streamId: string, volume: number): void;
|
|
54
|
+
/**
|
|
55
|
+
* Sets the video encoder configuration for local a stream.
|
|
56
|
+
* @param streamId
|
|
57
|
+
* @param config
|
|
58
|
+
* @param streamType
|
|
59
|
+
*/
|
|
60
|
+
setVideoEncoderConfig(streamId: string, config: FcrVideoEncoderConfig, streamType: FcrVideoStreamType): void;
|
|
61
|
+
/**
|
|
62
|
+
* Starts rendering the remote video stream.
|
|
63
|
+
* @param streamId
|
|
64
|
+
* @param type
|
|
65
|
+
* @param config
|
|
66
|
+
* @param element
|
|
67
|
+
*/
|
|
68
|
+
startRenderRemoteVideoStream(streamId: string, type: FcrVideoStreamType, config: FcrVideoRenderConfig, element: FcrRenderView): void;
|
|
69
|
+
/**
|
|
70
|
+
* Stops rendering the remote video stream.
|
|
71
|
+
* @param streamId
|
|
72
|
+
* @param element
|
|
73
|
+
*/
|
|
74
|
+
stopRenderRemoteVideoStream(streamId: string, element: FcrRenderView): void;
|
|
75
|
+
/**
|
|
76
|
+
* Starts playing the remote audio stream.
|
|
77
|
+
* @param streamId
|
|
78
|
+
*/
|
|
79
|
+
startPlayRemoteAudioStream(streamId: string): void;
|
|
80
|
+
/**
|
|
81
|
+
* Stops playing the remote audio stream.
|
|
82
|
+
* @param streamId
|
|
83
|
+
*/
|
|
84
|
+
stopPlayRemoteAudioStream(streamId: string): void;
|
|
85
|
+
/**
|
|
86
|
+
* Takes a snapshot of the remote video stream.
|
|
87
|
+
* @param streamId
|
|
88
|
+
* @param filePath
|
|
89
|
+
*/
|
|
90
|
+
takeSnapshot(streamId: string, filePath: string): Promise<FcrSnapshotInfo>;
|
|
91
|
+
/**
|
|
92
|
+
* Merges the specified audio stream into the local audio stream.
|
|
93
|
+
* @param targetUserId
|
|
94
|
+
*/
|
|
95
|
+
mergeAudioStream(targetUserId: string): Promise<void>;
|
|
96
|
+
/**
|
|
97
|
+
* Splits the specified audio stream from the local audio stream.
|
|
98
|
+
* @param userId
|
|
99
|
+
*/
|
|
100
|
+
splitAudioStream(userId: string): Promise<void>;
|
|
101
|
+
/**
|
|
102
|
+
* Adds a local screen stream.
|
|
103
|
+
* @param config
|
|
104
|
+
*/
|
|
105
|
+
addLocalScreenStream(config: FcrScreenStreamCreateConfig): Promise<string>;
|
|
106
|
+
/**
|
|
107
|
+
* Removes the local screen stream.
|
|
108
|
+
*/
|
|
109
|
+
removeScreenStream(): Promise<void>;
|
|
110
|
+
/**
|
|
111
|
+
* Adds an observer.
|
|
112
|
+
* @param observer
|
|
113
|
+
*/
|
|
114
|
+
addObserver(observer: FcrStreamObserver): void;
|
|
115
|
+
/**
|
|
116
|
+
* Removes an observer.
|
|
117
|
+
* @param observer
|
|
118
|
+
*/
|
|
119
|
+
removeObserver(observer: FcrStreamObserver): void;
|
|
120
|
+
}
|
|
121
|
+
export type FcrLocalStreamCreateConfig = AgoraRteMediaStreamCreateConfig;
|
|
122
|
+
export type FcrStreamBindConfig = AgoraRteStreamBindConfig;
|
|
123
|
+
export type FcrScreenStreamCreateConfig = Pick<FcrStreamCreateConfig, 'streamType'> & {
|
|
124
|
+
audioDeviceName?: string;
|
|
125
|
+
};
|
|
126
|
+
export type FcrUpdateStreamPrivilege = {
|
|
127
|
+
videoPrivilege: FcrStreamPrivilegeOperation;
|
|
128
|
+
audioPrivilege: FcrStreamPrivilegeOperation;
|
|
129
|
+
};
|
|
130
|
+
export type FcrUpdateStreamPrivilegeScope = {
|
|
131
|
+
videoSourceType?: FcrStreamPrivilegeVideoSourceType;
|
|
132
|
+
audioSourceType?: FcrStreamPrivilegeAudioSourceType;
|
|
133
|
+
targetRoleType: FcrUserRole[];
|
|
134
|
+
targetRoleTypeIsInclude: boolean;
|
|
135
|
+
};
|
|
136
|
+
export type FcrStreamEvent = {
|
|
137
|
+
readonly modifiedStream: FcrStreamInfo;
|
|
138
|
+
readonly operatorUser?: FcrUserInfo;
|
|
139
|
+
readonly cause?: FcrOperateCause;
|
|
140
|
+
};
|
|
141
|
+
export type FcrLocalVideoStats = AgoraRtcLocalVideoStats;
|
|
142
|
+
export type FcrLocalAudioStats = AgoraRtcLocalAudioStats;
|
|
143
|
+
export type FcrRemoteVideoStats = AgoraRtcRemoteVideoStats;
|
|
144
|
+
export type FcrRemoteAudioStats = AgoraRtcRemoteAudioStats;
|
|
145
|
+
export type FcrDimensions = AgoraRtcDimensions;
|
|
146
|
+
export type FcrStreamObserver = {
|
|
147
|
+
/**
|
|
148
|
+
* Callback to receive the stream added events.
|
|
149
|
+
* @param roomId
|
|
150
|
+
* @param events
|
|
151
|
+
*/
|
|
152
|
+
onStreamsAdded?(roomId: string, events: FcrStreamEvent[]): void;
|
|
153
|
+
/**
|
|
154
|
+
* Callback to receive the stream removed events.
|
|
155
|
+
* @param roomId
|
|
156
|
+
* @param events
|
|
157
|
+
*/
|
|
158
|
+
onStreamsRemoved?(roomId: string, events: FcrStreamEvent[]): void;
|
|
159
|
+
/**
|
|
160
|
+
* Callback to receive the stream updated events.
|
|
161
|
+
* @param roomId
|
|
162
|
+
* @param events
|
|
163
|
+
*/
|
|
164
|
+
onStreamsUpdated?(roomId: string, events: FcrStreamEvent[]): void;
|
|
165
|
+
/**
|
|
166
|
+
* Callback to receive the volume indication change of a remote stream.
|
|
167
|
+
* @param roomId
|
|
168
|
+
* @param streamId
|
|
169
|
+
* @param volume
|
|
170
|
+
*/
|
|
171
|
+
onStreamVolumeIndicationUpdated?(roomId: string, streamId: string, volume: number): void;
|
|
172
|
+
/**
|
|
173
|
+
* Callback to receive the local video stats updated events.
|
|
174
|
+
* @param roomId
|
|
175
|
+
* @param streamId
|
|
176
|
+
* @param stats
|
|
177
|
+
*/
|
|
178
|
+
onLocalVideoStatsUpdated?(roomId: string, streamId: string, stats: FcrLocalVideoStats): void;
|
|
179
|
+
/**
|
|
180
|
+
* Callback to receive the local audio stats updated events.
|
|
181
|
+
* @param roomId
|
|
182
|
+
* @param streamId
|
|
183
|
+
* @param stats
|
|
184
|
+
*/
|
|
185
|
+
onLocalAudioStatsUpdated?(roomId: string, streamId: string, stats: FcrLocalAudioStats): void;
|
|
186
|
+
/**
|
|
187
|
+
* Callback to receive the remote video stats updated events.
|
|
188
|
+
* @param roomId
|
|
189
|
+
* @param streamId
|
|
190
|
+
* @param stats
|
|
191
|
+
*/
|
|
192
|
+
onRemoteVideoStatsUpdated?(roomId: string, streamId: string, stats: FcrRemoteVideoStats): void;
|
|
193
|
+
/**
|
|
194
|
+
* Callback to receive the remote audio stats updated events.
|
|
195
|
+
* @param roomId
|
|
196
|
+
* @param streamId
|
|
197
|
+
* @param stats
|
|
198
|
+
*/
|
|
199
|
+
onRemoteAudioStatsUpdated?(roomId: string, streamId: string, stats: FcrRemoteAudioStats): void;
|
|
200
|
+
/**
|
|
201
|
+
* Callback to receive the first remote video frame rendered events.
|
|
202
|
+
* @param roomId
|
|
203
|
+
* @param streamId
|
|
204
|
+
* @param dimensions
|
|
205
|
+
*/
|
|
206
|
+
onFirstRemoteVideoFrameRendered?(roomId: string, streamId: string): void;
|
|
207
|
+
};
|
|
208
|
+
export type FcrSnapshotInfo = AgoraRteSnapshotInfo;
|
|
209
|
+
export type FcrStreamCreateConfig = AgoraRteMediaStreamCreateConfig;
|