fcr-core 3.7.5 → 3.7.7-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/chat-connection/index.js +34 -20
- package/lib/engine/index.js +62 -69
- package/lib/imports.js +1 -0
- package/lib/media-control/desktop.js +13 -8
- package/lib/media-control/mobile.js +17 -12
- package/lib/monitor-control/index.js +9 -4
- package/lib/peer-session/index.js +47 -38
- package/lib/plugins/chatroom.js +217 -202
- package/lib/room-control/ability-control/index.js +13 -8
- package/lib/room-control/group-control/index.js +20 -15
- package/lib/room-control/helpers/validation-helper.js +1 -1
- package/lib/room-control/index.js +53 -36
- package/lib/room-control/interpreter-control/index.js +23 -17
- package/lib/room-control/interpreter-control/room.js +6 -4
- package/lib/room-control/join-before-host-waitingroom-control/index.js +6 -4
- package/lib/room-control/mainroom-control/index.js +24 -16
- package/lib/room-control/privilege-control/helper.js +8 -5
- package/lib/room-control/privilege-control/index.js +25 -18
- package/lib/room-control/room-connector-control/index.js +22 -15
- package/lib/room-control/room-control-factory.js +2 -1
- package/lib/room-control/room-session/index.js +47 -38
- package/lib/room-control/shared-cache.js +36 -29
- package/lib/room-control/sharing-control/index.js +40 -29
- package/lib/room-control/stream-control/index.js +177 -172
- package/lib/room-control/user-control/index.js +142 -135
- package/lib/room-control/waitingroom-control/index.js +13 -8
- package/lib/room-control/whiteboard-control-v2/annotation-control/control.js +25 -18
- package/lib/room-control/whiteboard-control-v2/annotation-control/index.js +26 -15
- package/lib/room-control/whiteboard-control-v2/annotation-control/privilege-control.js +62 -52
- package/lib/room-control/whiteboard-control-v2/index.js +35 -24
- package/lib/room-control/whiteboard-control-v2/main-window.js +27 -22
- package/lib/room-control/whiteboard-control-v2/utils.js +5 -5
- package/lib/room-control/whiteboard-control-v2/whiteboard-control/control.js +32 -23
- package/lib/room-control/whiteboard-control-v2/whiteboard-control/index.js +5 -3
- package/lib/room-control/whiteboard-control-v2/whiteboard-control/privilege-control.js +53 -41
- package/lib/room-router/index.js +67 -34
- package/lib/room-router/type.d.ts +4 -0
- package/lib/service/api.d.ts +12 -1
- package/lib/service/api.js +98 -88
- package/lib/utilities/collection.js +3 -2
- package/lib/utilities/error-helpers.js +32 -26
- package/lib/utilities/error.js +9 -8
- package/lib/utilities/join-helper.js +22 -18
- package/lib/utilities/logger.js +2 -2
- package/lib/utilities/parameters.js +8 -4
- package/lib/utilities/retry-helpers.js +1 -0
- package/lib/utilities/shared-storage.js +1 -0
- package/lib/utilities/storage.js +1 -0
- package/lib/utilities/stream.js +16 -11
- package/lib/utilities/user.js +4 -3
- package/lib/utilities/validate-params.js +2 -1
- package/package.json +4 -4
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
require("core-js/modules/es.symbol.description.js");
|
|
4
|
+
require("core-js/modules/es.error.cause.js");
|
|
3
5
|
require("core-js/modules/esnext.function.metadata.js");
|
|
4
6
|
require("core-js/modules/esnext.symbol.metadata.js");
|
|
5
7
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
@@ -27,6 +29,8 @@ require("core-js/modules/esnext.map.merge.js");
|
|
|
27
29
|
require("core-js/modules/esnext.map.reduce.js");
|
|
28
30
|
require("core-js/modules/esnext.map.some.js");
|
|
29
31
|
require("core-js/modules/esnext.map.update.js");
|
|
32
|
+
require("core-js/modules/web.dom-collections.iterator.js");
|
|
33
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
30
34
|
var _imports = require("../../imports");
|
|
31
35
|
var _type = require("../../type");
|
|
32
36
|
var _user = require("../../utilities/user");
|
|
@@ -34,8 +38,10 @@ var _error = require("../../utilities/error");
|
|
|
34
38
|
var _logger = require("../../utilities/logger");
|
|
35
39
|
var _validateParams = _interopRequireDefault(require("../../utilities/validate-params"));
|
|
36
40
|
var _schema = require("../../schema");
|
|
37
|
-
var
|
|
38
|
-
let _initProto, _addLocalStreamsDecs, _bindLocalStreamsDecs, _updatePublishPrivilegeOfStreamsDecs, _removeStreamsDecs, _setVideoEncoderConfigDecs, _setScreenScenarioDecs, _startRenderRemoteVideoStreamDecs, _stopRenderRemoteVideoStreamDecs, _startPlayRemoteAudioStreamDecs, _stopPlayRemoteAudioStreamDecs, _takeSnapshotDecs, _addLocalScreenStreamDecs, _adjustRemoteAudioStreamVolumeDecs, _mergeAudioStreamDecs, _splitAudioStreamDecs;
|
|
41
|
+
var _FcrStreamControlImpl;
|
|
42
|
+
let _initProto, _addLocalStreamsDecs, _bindLocalStreamsDecs, _updatePublishPrivilegeOfStreamsDecs, _removeStreamsDecs, _setVideoEncoderConfigDecs, _setScreenScenarioDecs, _startRenderRemoteVideoStreamDecs, _stopRenderRemoteVideoStreamDecs, _startPlayRemoteAudioStreamDecs, _stopPlayRemoteAudioStreamDecs, _takeSnapshotDecs, _addLocalScreenStreamDecs, _adjustRemoteAudioStreamVolumeDecs, _mergeAudioStreamDecs, _splitAudioStreamDecs, _ref;
|
|
43
|
+
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; }
|
|
44
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
39
45
|
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)]; } }; }
|
|
40
46
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
41
47
|
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); }
|
|
@@ -44,101 +50,148 @@ function _checkInRHS(e) { if (Object(e) !== e) throw TypeError("right-hand side
|
|
|
44
50
|
/**
|
|
45
51
|
* @internal
|
|
46
52
|
*/
|
|
53
|
+
_ref = (_addLocalStreamsDecs = [_imports.bound, _imports.trace, (0, _validateParams.default)(_schema.fcrLocalStreamCreateArrayConfigSchema)], _bindLocalStreamsDecs = [_imports.bound, _imports.trace, (0, _validateParams.default)(_schema.fcrStreamBindConfigArrySchema)], _updatePublishPrivilegeOfStreamsDecs = [_imports.bound, _imports.trace, (0, _validateParams.default)(_schema.fcrUpdateStreamCustomSchema, _schema.fcrUpdateStreamPrivilegeScopeSchema.optional())], _removeStreamsDecs = [_imports.bound, _imports.trace, (0, _validateParams.default)(_schema.stringArraySchema)], _setVideoEncoderConfigDecs = [_imports.bound, _imports.trace, (0, _validateParams.default)(_schema.stringSchema, _schema.agoraRtcVideoEncoderConfigurationSchema, _schema.fcrVideoStreamTypeSchema)], _setScreenScenarioDecs = [_imports.bound, _imports.trace, (0, _validateParams.default)(_schema.fcrScreenScenarioTypeSchema)], _startRenderRemoteVideoStreamDecs = [_imports.bound, _imports.trace, (0, _validateParams.default)(_schema.stringSchema, _schema.fcrVideoStreamTypeSchema, _schema.fcrRenderConfigSchema, (0, _schema.createUnionSchema)([_schema.fcrRenderViewSchema, _imports.objectSchema]))], _stopRenderRemoteVideoStreamDecs = [_imports.bound, _imports.trace, (0, _validateParams.default)(_schema.stringSchema, _schema.fcrRenderViewSchema)], _startPlayRemoteAudioStreamDecs = [_imports.bound, _imports.trace, (0, _validateParams.default)(_schema.stringSchema)], _stopPlayRemoteAudioStreamDecs = [_imports.bound, _imports.trace, (0, _validateParams.default)(_schema.stringSchema)], _takeSnapshotDecs = [_imports.bound, _imports.trace, (0, _validateParams.default)(_schema.stringSchema, _schema.stringSchema)], _addLocalScreenStreamDecs = [_imports.bound, _imports.trace, (0, _validateParams.default)(_schema.fcrScreenStreamCreateConfigSchema, _schema.fcrSizeSchema)], _adjustRemoteAudioStreamVolumeDecs = [_imports.bound, _imports.trace, (0, _validateParams.default)(_schema.stringSchema, _schema.numberSchema)], _mergeAudioStreamDecs = [_imports.bound, _imports.trace, (0, _validateParams.default)(_schema.stringSchema)], _splitAudioStreamDecs = [_imports.bound, _imports.trace, (0, _validateParams.default)(_schema.stringSchema)], "logger");
|
|
47
54
|
class FcrStreamControlImpl {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
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);
|
|
55
|
+
constructor(_engine, _scene, _api, _sharedCache) {
|
|
56
|
+
//@internal
|
|
57
|
+
(0, _defineProperty2.default)(this, _ref, (_initProto(this), (0, _logger.createLogger)({
|
|
58
|
+
prefix: 'FcrStreamControlImpl'
|
|
59
|
+
})));
|
|
60
|
+
//@internal
|
|
61
|
+
(0, _defineProperty2.default)(this, "_observable", new _imports.AgoraObservable());
|
|
62
|
+
//@internal
|
|
63
|
+
(0, _defineProperty2.default)(this, "_streamMapByStreamId", {});
|
|
64
|
+
//@internal
|
|
65
|
+
(0, _defineProperty2.default)(this, "_streamMapByUserId", {});
|
|
66
|
+
//@internal
|
|
67
|
+
(0, _defineProperty2.default)(this, "_streamList", []);
|
|
68
|
+
//@internal
|
|
69
|
+
(0, _defineProperty2.default)(this, "_remoteSubscribedStreamRenderMap", new Map());
|
|
70
|
+
//@internal
|
|
71
|
+
(0, _defineProperty2.default)(this, "_sceneObserver", {
|
|
72
|
+
onStreamsAdded: (sceneId, events) => {
|
|
73
|
+
const fcrStreamEvents = events.map(this._convertStreamEvent);
|
|
74
|
+
fcrStreamEvents.forEach(event => {
|
|
75
|
+
const stream = event.modifiedStream;
|
|
76
|
+
const exists = stream.streamId in this._streamMapByStreamId;
|
|
77
|
+
if (exists) {
|
|
78
|
+
this.logger.warn("[FcrStreamControl] stream added when the stream already exists, streamId: ".concat(stream.streamId));
|
|
79
|
+
} else {
|
|
80
|
+
this._streamList.push(stream);
|
|
81
|
+
this._streamMapByStreamId[stream.streamId] = stream;
|
|
82
|
+
this._putUserStream(stream.owner.userId, stream);
|
|
96
83
|
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
this.
|
|
84
|
+
});
|
|
85
|
+
this._observable.notifyObservers('onStreamsAdded', sceneId, fcrStreamEvents);
|
|
86
|
+
},
|
|
87
|
+
onStreamsRemoved: (sceneId, events) => {
|
|
88
|
+
const fcrStreamEvents = events.map(this._convertStreamEvent);
|
|
89
|
+
fcrStreamEvents.forEach(event => {
|
|
90
|
+
const stream = event.modifiedStream;
|
|
91
|
+
const exists = stream.streamId in this._streamMapByStreamId;
|
|
92
|
+
if (!exists) {
|
|
93
|
+
this.logger.warn("[FcrStreamControl] stream removed when the stream does not exist, streamId: ".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);
|
|
114
119
|
}
|
|
115
|
-
|
|
116
|
-
|
|
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
|
+
(0, _defineProperty2.default)(this, "_addSceneStreamPlayerObserver", {
|
|
141
|
+
onRemoteAudioStreamVolumeUpdated: (streamId, volume) => this._observable.notifyObservers('onStreamVolumeIndicationUpdated', this._scene.sceneId, streamId, volume)
|
|
142
|
+
});
|
|
143
|
+
(0, _defineProperty2.default)(this, "_convertStreamInfo", info => {
|
|
144
|
+
return {
|
|
145
|
+
streamId: info.streamId,
|
|
146
|
+
streamName: info.streamName,
|
|
147
|
+
owner: (0, _user.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
|
+
(0, _defineProperty2.default)(this, "_getPublishStateByPrivilege", privilege => {
|
|
159
|
+
return privilege === _imports.AgoraRteStreamPrivilegeOperation.HAS_PRIVILEGE ? 1 : privilege === _imports.AgoraRteStreamPrivilegeOperation.NOPRIVILEGE ? 0 : undefined;
|
|
160
|
+
});
|
|
161
|
+
(0, _defineProperty2.default)(this, "_convertStreamEvent", event => {
|
|
162
|
+
return {
|
|
163
|
+
modifiedStream: this._convertStreamInfo(event.modifiedStream),
|
|
164
|
+
operatorUser: event.operatorUser ? (0, _user.convertRteUserToFcrUser)(event.operatorUser, this._roomCache) : undefined,
|
|
165
|
+
cause: event.cause
|
|
166
|
+
};
|
|
167
|
+
});
|
|
168
|
+
(0, _defineProperty2.default)(this, "_putUserStream", (userId, stream) => {
|
|
169
|
+
if (!this._streamMapByUserId[userId]) {
|
|
170
|
+
this._streamMapByUserId[userId] = [];
|
|
171
|
+
}
|
|
172
|
+
this._streamMapByUserId[userId].push(stream);
|
|
173
|
+
});
|
|
174
|
+
(0, _defineProperty2.default)(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);
|
|
117
180
|
}
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
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) {
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
(0, _defineProperty2.default)(this, "_deleteUserStream", (userId, stream) => {
|
|
184
|
+
const userStreams = this._streamMapByUserId[userId];
|
|
185
|
+
if (userStreams) {
|
|
186
|
+
const index = userStreams.findIndex(s => s.streamId === stream.streamId);
|
|
187
|
+
if (index !== -1) {
|
|
188
|
+
userStreams.splice(index, 1);
|
|
189
|
+
}
|
|
190
|
+
if (userStreams.length === 0) {
|
|
191
|
+
delete this._streamMapByUserId[userId];
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
});
|
|
142
195
|
this._engine = _engine;
|
|
143
196
|
this._scene = _scene;
|
|
144
197
|
this._api = _api;
|
|
@@ -177,18 +230,20 @@ class FcrStreamControlImpl {
|
|
|
177
230
|
}
|
|
178
231
|
}
|
|
179
232
|
addLocalStreams(streams) {
|
|
180
|
-
return (0, _error.handleRequestError)(() => this._api.
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
233
|
+
return (0, _error.handleRequestError)(() => this._api.createStreamBatch(this._scene.sceneId, streams.map(config => {
|
|
234
|
+
var _config$generateToken;
|
|
235
|
+
return _objectSpread({
|
|
236
|
+
streamName: config.streamName,
|
|
237
|
+
streamUuid: '0',
|
|
238
|
+
// means that this stream needs to be created
|
|
239
|
+
generateToken: (_config$generateToken = config.generateToken) !== null && _config$generateToken !== void 0 ? _config$generateToken : config.videoSourceType === _imports.AgoraRteVideoSourceType.SCREEN,
|
|
240
|
+
userUuid: config.ownerId,
|
|
241
|
+
videoSourceType: config.videoSourceType,
|
|
242
|
+
audioSourceType: config.audioSourceType,
|
|
243
|
+
videoSourceUuid: config.videoSourceId,
|
|
244
|
+
audioSourceUuid: config.audioSourceId
|
|
245
|
+
}, (0, _imports.convertStreamTypeToPublishState)(config.streamType));
|
|
246
|
+
})), _error.FcrErrorModuleCode.ROOM_STREAM, 'add local streams failed');
|
|
192
247
|
}
|
|
193
248
|
bindLocalStreams(streams) {
|
|
194
249
|
return this._scene.localUser.bindLocalStreams(streams);
|
|
@@ -199,7 +254,7 @@ class FcrStreamControlImpl {
|
|
|
199
254
|
}
|
|
200
255
|
if (args.length === 1) {
|
|
201
256
|
const privileges = args[0];
|
|
202
|
-
return (0, _error.handleRequestError)(() => this._api.
|
|
257
|
+
return (0, _error.handleRequestError)(() => this._api.updateStreamBatch(this._scene.sceneId, Object.keys(privileges).map(streamId => ({
|
|
203
258
|
streamUuid: streamId,
|
|
204
259
|
audioState: this._getPublishStateByPrivilege(privileges[streamId].audioPrivilege),
|
|
205
260
|
videoState: this._getPublishStateByPrivilege(privileges[streamId].videoPrivilege)
|
|
@@ -249,10 +304,11 @@ class FcrStreamControlImpl {
|
|
|
249
304
|
|
|
250
305
|
const elements = this._remoteSubscribedStreamRenderMap.get(streamId) || [];
|
|
251
306
|
const renderCount = elements.length;
|
|
252
|
-
const isDifferentCanvas = !elements
|
|
307
|
+
const isDifferentCanvas = !(elements !== null && elements !== void 0 && elements.includes(element));
|
|
253
308
|
if (renderCount === 0 || isDifferentCanvas) {
|
|
309
|
+
var _this$_remoteSubscrib;
|
|
254
310
|
this._remoteSubscribedStreamRenderMap.set(streamId, [...elements, element]);
|
|
255
|
-
this.logger.info(
|
|
311
|
+
this.logger.info("[FcrStreamControl][subscribe-remote-video-stream] start subscribe streamId: ".concat(streamId, ", before subscribe renderCount: ").concat(renderCount, ", after subscribe renderCount: ").concat((_this$_remoteSubscrib = this._remoteSubscribedStreamRenderMap.get(streamId)) === null || _this$_remoteSubscrib === void 0 ? void 0 : _this$_remoteSubscrib.length));
|
|
256
312
|
}
|
|
257
313
|
this._scene.streamPlayer.subscribeRemoteVideoStream(streamId, type);
|
|
258
314
|
this._scene.streamPlayer.startRenderRemoteVideoStream(streamId, type, config.renderMode, config.isMirror, element);
|
|
@@ -261,15 +317,15 @@ class FcrStreamControlImpl {
|
|
|
261
317
|
// 当 stopRender 相同的 streamId 与 canvasId 时,计数减一
|
|
262
318
|
// 引用计数减为 0 时,调用 unsubscribeRemoteVideoStream
|
|
263
319
|
const elements = this._remoteSubscribedStreamRenderMap.get(streamId) || [];
|
|
264
|
-
const isSameCanvas = elements
|
|
320
|
+
const isSameCanvas = elements === null || elements === void 0 ? void 0 : elements.includes(element);
|
|
265
321
|
if (isSameCanvas) {
|
|
266
|
-
const rest = elements
|
|
322
|
+
const rest = elements === null || elements === void 0 ? void 0 : elements.filter(e => e !== element);
|
|
267
323
|
this._remoteSubscribedStreamRenderMap.set(streamId, rest);
|
|
268
|
-
this.logger.info(
|
|
324
|
+
this.logger.info("[FcrStreamControl][unsubscribe-remote-video-stream] has same canvas, streamId: ".concat(streamId, ", subtract renderCount, do not unsubscribe remote video stream, rest renderCount: ").concat(rest.length));
|
|
269
325
|
}
|
|
270
326
|
if (elements.length === 0) {
|
|
271
327
|
this._scene.streamPlayer.unsubscribeRemoteVideoStream(streamId);
|
|
272
|
-
this.logger.info(
|
|
328
|
+
this.logger.info("[FcrStreamControl][unsubscribe-remote-video-stream] renderCount ".concat(elements.length, " is 0, unsubscribeRemoteVideoStream streamId: ").concat(streamId));
|
|
273
329
|
}
|
|
274
330
|
this._scene.streamPlayer.stopRenderRemoteVideoStream(streamId, element);
|
|
275
331
|
}
|
|
@@ -286,14 +342,14 @@ class FcrStreamControlImpl {
|
|
|
286
342
|
const res = await (0, _error.handleRequestError)(() => this._api.startShareScreen({
|
|
287
343
|
roomId: this._scene.sceneId,
|
|
288
344
|
userId: this._scene.getLocalUser().getLocalUserId(),
|
|
289
|
-
config: {
|
|
345
|
+
config: _objectSpread(_objectSpread({
|
|
290
346
|
videoSourceType: _type.FcrVideoSourceType.SCREEN,
|
|
291
347
|
audioSourceType: _type.FcrAudioSourceType.LOOPBACK,
|
|
292
348
|
videoSourceState: _type.FcrMediaSourceState.CLOSE,
|
|
293
349
|
audioSourceState: _type.FcrMediaSourceState.CLOSE,
|
|
294
350
|
videoSourceUuid: config.videoSourceId,
|
|
295
|
-
audioSourceUuid: config.audioSourceId
|
|
296
|
-
|
|
351
|
+
audioSourceUuid: config.audioSourceId
|
|
352
|
+
}, (0, _imports.convertStreamTypeToPublishState)(config.streamType)), {}, {
|
|
297
353
|
annotation: size ? {
|
|
298
354
|
size: {
|
|
299
355
|
width: size.width,
|
|
@@ -305,7 +361,7 @@ class FcrStreamControlImpl {
|
|
|
305
361
|
height: 0
|
|
306
362
|
}
|
|
307
363
|
}
|
|
308
|
-
}
|
|
364
|
+
})
|
|
309
365
|
}), _error.FcrErrorModuleCode.ROOM_STREAM, 'add local screen stream failed');
|
|
310
366
|
const {
|
|
311
367
|
data: {
|
|
@@ -364,65 +420,14 @@ class FcrStreamControlImpl {
|
|
|
364
420
|
this._observable.removeObserver(observer);
|
|
365
421
|
}
|
|
366
422
|
async findSelectionByParamId(paramSourceId) {
|
|
367
|
-
|
|
368
|
-
const
|
|
423
|
+
var _this$_mediaControl, _this$_mediaControl2;
|
|
424
|
+
const wins = (await ((_this$_mediaControl = this._mediaControl) === null || _this$_mediaControl === void 0 ? void 0 : _this$_mediaControl.getWindowList())) || [];
|
|
425
|
+
const displays = (await ((_this$_mediaControl2 = this._mediaControl) === null || _this$_mediaControl2 === void 0 ? void 0 : _this$_mediaControl2.getDisplayList())) || [];
|
|
369
426
|
const findInList = list => list.find(item => item.id === paramSourceId);
|
|
370
427
|
const winMatch = findInList(wins);
|
|
371
428
|
const displayMatch = findInList(displays);
|
|
372
429
|
return winMatch || displayMatch || null;
|
|
373
430
|
}
|
|
374
|
-
_convertStreamInfo = info => {
|
|
375
|
-
return {
|
|
376
|
-
streamId: info.streamId,
|
|
377
|
-
streamName: info.streamName,
|
|
378
|
-
owner: (0, _user.convertRteUserToFcrUser)(info.owner, this._roomCache),
|
|
379
|
-
streamType: info.streamType,
|
|
380
|
-
videoSourceType: info.videoSourceType,
|
|
381
|
-
audioSourceType: info.audioSourceType,
|
|
382
|
-
videoSourceState: info.videoSourceState,
|
|
383
|
-
audioSourceState: info.audioSourceState,
|
|
384
|
-
videoSourceId: info.videoSourceId,
|
|
385
|
-
audioSourceId: info.audioSourceId,
|
|
386
|
-
connectorType: info.connectorType
|
|
387
|
-
};
|
|
388
|
-
};
|
|
389
|
-
_getPublishStateByPrivilege = privilege => {
|
|
390
|
-
return privilege === _imports.AgoraRteStreamPrivilegeOperation.HAS_PRIVILEGE ? 1 : privilege === _imports.AgoraRteStreamPrivilegeOperation.NOPRIVILEGE ? 0 : undefined;
|
|
391
|
-
};
|
|
392
|
-
_convertStreamEvent = event => {
|
|
393
|
-
return {
|
|
394
|
-
modifiedStream: this._convertStreamInfo(event.modifiedStream),
|
|
395
|
-
operatorUser: event.operatorUser ? (0, _user.convertRteUserToFcrUser)(event.operatorUser, this._roomCache) : undefined,
|
|
396
|
-
cause: event.cause
|
|
397
|
-
};
|
|
398
|
-
};
|
|
399
|
-
_putUserStream = (userId, stream) => {
|
|
400
|
-
if (!this._streamMapByUserId[userId]) {
|
|
401
|
-
this._streamMapByUserId[userId] = [];
|
|
402
|
-
}
|
|
403
|
-
this._streamMapByUserId[userId].push(stream);
|
|
404
|
-
};
|
|
405
|
-
_setUserStream = (userId, stream) => {
|
|
406
|
-
const streams = this._streamMapByUserId[userId];
|
|
407
|
-
if (streams) {
|
|
408
|
-
const index = streams.findIndex(s => s.streamId === stream.streamId);
|
|
409
|
-
if (index !== -1) {
|
|
410
|
-
streams.splice(index, 1, stream);
|
|
411
|
-
}
|
|
412
|
-
}
|
|
413
|
-
};
|
|
414
|
-
_deleteUserStream = (userId, stream) => {
|
|
415
|
-
const userStreams = this._streamMapByUserId[userId];
|
|
416
|
-
if (userStreams) {
|
|
417
|
-
const index = userStreams.findIndex(s => s.streamId === stream.streamId);
|
|
418
|
-
if (index !== -1) {
|
|
419
|
-
userStreams.splice(index, 1);
|
|
420
|
-
}
|
|
421
|
-
if (userStreams.length === 0) {
|
|
422
|
-
delete this._streamMapByUserId[userId];
|
|
423
|
-
}
|
|
424
|
-
}
|
|
425
|
-
};
|
|
426
431
|
_addLogObserver() {
|
|
427
432
|
this.addObserver((0, _logger.generateLogObserver)(this.logger, [
|
|
428
433
|
// 'onLocalVideoStatsUpdated',
|
|
@@ -433,7 +438,7 @@ class FcrStreamControlImpl {
|
|
|
433
438
|
// 'onStreamVolumeIndicationUpdated',
|
|
434
439
|
'onStreamsAdded', 'onStreamsRemoved', 'onStreamsUpdated']));
|
|
435
440
|
}
|
|
436
|
-
static #_ = (() => _staticBlock = () => [_initProto] = _applyDecs(this, [[_imports.bound, 2, "getStreams"], [_imports.bound, 2, "getStreamList"], [_imports.bound, 2, "getStreamsByUserId"], [_imports.bound, 2, "getStreamByStreamId"], [_addLocalStreamsDecs, 2, "addLocalStreams"], [_bindLocalStreamsDecs, 2, "bindLocalStreams"], [_updatePublishPrivilegeOfStreamsDecs, 2, "updatePublishPrivilegeOfStreams"], [_removeStreamsDecs, 2, "removeStreams"], [_setVideoEncoderConfigDecs, 2, "setVideoEncoderConfig"], [_setScreenScenarioDecs, 2, "setScreenScenario"], [_startRenderRemoteVideoStreamDecs, 2, "startRenderRemoteVideoStream"], [_stopRenderRemoteVideoStreamDecs, 2, "stopRenderRemoteVideoStream"], [_startPlayRemoteAudioStreamDecs, 2, "startPlayRemoteAudioStream"], [_stopPlayRemoteAudioStreamDecs, 2, "stopPlayRemoteAudioStream"], [_takeSnapshotDecs, 2, "takeSnapshot"], [_addLocalScreenStreamDecs, 2, "addLocalScreenStream"], [[_imports.bound, _imports.trace], 2, "removeScreenStream"], [_adjustRemoteAudioStreamVolumeDecs, 2, "adjustRemoteAudioStreamVolume"], [_mergeAudioStreamDecs, 2, "mergeAudioStream"], [_splitAudioStreamDecs, 2, "splitAudioStream"]], []).e)();
|
|
437
441
|
}
|
|
438
442
|
exports.FcrStreamControlImpl = FcrStreamControlImpl;
|
|
439
|
-
|
|
443
|
+
_FcrStreamControlImpl = FcrStreamControlImpl;
|
|
444
|
+
[_initProto] = _applyDecs(_FcrStreamControlImpl, [[_imports.bound, 2, "getStreams"], [_imports.bound, 2, "getStreamList"], [_imports.bound, 2, "getStreamsByUserId"], [_imports.bound, 2, "getStreamByStreamId"], [_addLocalStreamsDecs, 2, "addLocalStreams"], [_bindLocalStreamsDecs, 2, "bindLocalStreams"], [_updatePublishPrivilegeOfStreamsDecs, 2, "updatePublishPrivilegeOfStreams"], [_removeStreamsDecs, 2, "removeStreams"], [_setVideoEncoderConfigDecs, 2, "setVideoEncoderConfig"], [_setScreenScenarioDecs, 2, "setScreenScenario"], [_startRenderRemoteVideoStreamDecs, 2, "startRenderRemoteVideoStream"], [_stopRenderRemoteVideoStreamDecs, 2, "stopRenderRemoteVideoStream"], [_startPlayRemoteAudioStreamDecs, 2, "startPlayRemoteAudioStream"], [_stopPlayRemoteAudioStreamDecs, 2, "stopPlayRemoteAudioStream"], [_takeSnapshotDecs, 2, "takeSnapshot"], [_addLocalScreenStreamDecs, 2, "addLocalScreenStream"], [[_imports.bound, _imports.trace], 2, "removeScreenStream"], [_adjustRemoteAudioStreamVolumeDecs, 2, "adjustRemoteAudioStreamVolume"], [_mergeAudioStreamDecs, 2, "mergeAudioStream"], [_splitAudioStreamDecs, 2, "splitAudioStream"]], []).e;
|