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,307 @@
|
|
|
1
|
+
import "core-js/modules/es.array.push.js";
|
|
2
|
+
import "core-js/modules/esnext.function.metadata.js";
|
|
3
|
+
import "core-js/modules/esnext.map.delete-all.js";
|
|
4
|
+
import "core-js/modules/esnext.map.emplace.js";
|
|
5
|
+
import "core-js/modules/esnext.map.every.js";
|
|
6
|
+
import "core-js/modules/esnext.map.filter.js";
|
|
7
|
+
import "core-js/modules/esnext.map.find.js";
|
|
8
|
+
import "core-js/modules/esnext.map.find-key.js";
|
|
9
|
+
import "core-js/modules/esnext.map.includes.js";
|
|
10
|
+
import "core-js/modules/esnext.map.key-of.js";
|
|
11
|
+
import "core-js/modules/esnext.map.map-keys.js";
|
|
12
|
+
import "core-js/modules/esnext.map.map-values.js";
|
|
13
|
+
import "core-js/modules/esnext.map.merge.js";
|
|
14
|
+
import "core-js/modules/esnext.map.reduce.js";
|
|
15
|
+
import "core-js/modules/esnext.map.some.js";
|
|
16
|
+
import "core-js/modules/esnext.map.update.js";
|
|
17
|
+
import "core-js/modules/esnext.symbol.metadata.js";
|
|
18
|
+
let _initProto, _startScreenSharingDecs, _updateScreenSharingDecs;
|
|
19
|
+
import "core-js/modules/esnext.iterator.constructor.js";
|
|
20
|
+
import "core-js/modules/esnext.iterator.for-each.js";
|
|
21
|
+
import "core-js/modules/esnext.iterator.some.js";
|
|
22
|
+
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)]; } }; }
|
|
23
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
24
|
+
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); }
|
|
25
|
+
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; }
|
|
26
|
+
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; }
|
|
27
|
+
import { FcrScreenSharingState, FcrWhiteboardState } from './type';
|
|
28
|
+
import { AgoraObservable, AgoraRteMediaStreamType, trace } from '../../imports';
|
|
29
|
+
import { FcrVideoSourceType } from '../..';
|
|
30
|
+
import { FcrSharePermissionState } from './type';
|
|
31
|
+
import { createLogger, generateLogObserver } from '../../utilities/logger';
|
|
32
|
+
import { FcrWhiteboardControlFactoryImpl } from '../whiteboard-control-v2/whiteboard-control/factory';
|
|
33
|
+
import { FcrAnnotationControlFactoryImpl } from '../whiteboard-control-v2/annotation-control/factory';
|
|
34
|
+
import { hasAnnotationWritePermission, hasBoardWritePermission } from '../whiteboard-control/utils';
|
|
35
|
+
import { FcrWidgetCauseCmd, FcrWidgetUuid } from '../type';
|
|
36
|
+
import { FcrBoardPropertiesState } from '../whiteboard-control/type';
|
|
37
|
+
export class FcrSharingControlImpl {
|
|
38
|
+
static {
|
|
39
|
+
[_initProto] = _applyDecs(this, [[_startScreenSharingDecs, 2, "startScreenSharing"], [trace, 2, "startWhiteboard"], [_updateScreenSharingDecs, 2, "updateScreenSharing"], [trace, 2, "stop"], [trace, 2, "getScreenSharingState"]], []).e;
|
|
40
|
+
}
|
|
41
|
+
[(_startScreenSharingDecs = trace(['config', 'size', 'labels']), _updateScreenSharingDecs = trace(['enableAnnotation']), "logger")] = (_initProto(this), createLogger({
|
|
42
|
+
prefix: 'FcrSharingControlImpl'
|
|
43
|
+
}));
|
|
44
|
+
_observable = new AgoraObservable();
|
|
45
|
+
_isActive = false;
|
|
46
|
+
_shareOwnerId = '';
|
|
47
|
+
_shareOwnerStream = null;
|
|
48
|
+
_streamObserver = {
|
|
49
|
+
onStreamsAdded: this._handleOnStreamsAdded.bind(this),
|
|
50
|
+
onStreamsRemoved: this._handleOnStreamsRemoved.bind(this)
|
|
51
|
+
};
|
|
52
|
+
_sceneObserver = {
|
|
53
|
+
onScenePropertiesUpdated: this._handleOnScenePropertiesUpdated.bind(this)
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
// TODO: 这里不应该再维护一套白板的状态和事件了, ui-scene 应该直接用 board control 的
|
|
57
|
+
_whiteboardObserver = {
|
|
58
|
+
onActive: this._handleOnWhiteboardActive.bind(this),
|
|
59
|
+
onInactive: this._handleOnWhiteboardInActive.bind(this)
|
|
60
|
+
};
|
|
61
|
+
get ownerId() {
|
|
62
|
+
return this._shareOwnerId;
|
|
63
|
+
}
|
|
64
|
+
get ownerStream() {
|
|
65
|
+
return this._shareOwnerStream;
|
|
66
|
+
}
|
|
67
|
+
constructor(_scene, _api, _engine, _privilegeControl, _streamControl, _sharedCache, _userControl) {
|
|
68
|
+
this._scene = _scene;
|
|
69
|
+
this._api = _api;
|
|
70
|
+
this._engine = _engine;
|
|
71
|
+
this._privilegeControl = _privilegeControl;
|
|
72
|
+
this._streamControl = _streamControl;
|
|
73
|
+
this._sharedCache = _sharedCache;
|
|
74
|
+
this._userControl = _userControl;
|
|
75
|
+
this._addLogObserver();
|
|
76
|
+
this._whiteboardControl = this.getBoardControl();
|
|
77
|
+
this._annotationControl = this.getAnnotationControl();
|
|
78
|
+
this._isActive = this._whiteboardControl.getActivity();
|
|
79
|
+
this._streamControl.addObserver(this._streamObserver);
|
|
80
|
+
this._whiteboardControl.addObserver(this._whiteboardObserver);
|
|
81
|
+
this._scene.addObserver(this._sceneObserver);
|
|
82
|
+
this.logger.info(`initialized, room id: ${this._scene.sceneId}`);
|
|
83
|
+
}
|
|
84
|
+
async startScreenSharing(config, size, labels) {
|
|
85
|
+
try {
|
|
86
|
+
const streamId = await this._streamControl.addLocalScreenStream(config, size, labels);
|
|
87
|
+
return streamId;
|
|
88
|
+
} catch (error) {
|
|
89
|
+
throw error;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
startWhiteboard() {
|
|
93
|
+
return this._whiteboardControl.active();
|
|
94
|
+
}
|
|
95
|
+
updateScreenSharing(enableAnnotation) {
|
|
96
|
+
const currentShareState = this.getScreenSharingState();
|
|
97
|
+
if (currentShareState === FcrScreenSharingState.START_ONLY_SCREEN) {
|
|
98
|
+
if (enableAnnotation) {
|
|
99
|
+
return this._api.toggleAnnotationActivityState(this._scene.sceneId, FcrSharePermissionState.ON);
|
|
100
|
+
} else {
|
|
101
|
+
return this._api.toggleAnnotationActivityState(this._scene.sceneId, FcrSharePermissionState.OFF);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return Promise.resolve();
|
|
105
|
+
}
|
|
106
|
+
stop() {
|
|
107
|
+
const currentScreenSharingState = this.getScreenSharingState();
|
|
108
|
+
if (currentScreenSharingState !== FcrScreenSharingState.END) {
|
|
109
|
+
return this._streamControl.removeScreenStream();
|
|
110
|
+
}
|
|
111
|
+
const currentWhiteboardState = this.getWhiteboardState();
|
|
112
|
+
if (currentWhiteboardState === FcrWhiteboardState.START) {
|
|
113
|
+
return this._whiteboardControl.inactive();
|
|
114
|
+
}
|
|
115
|
+
return Promise.resolve();
|
|
116
|
+
}
|
|
117
|
+
getScreenSharingState() {
|
|
118
|
+
const streams = this._streamControl.getStreamList();
|
|
119
|
+
const hasScreenSharing = streams.some(streamInfo => this._isStreamToHandleScreenSharing(streamInfo));
|
|
120
|
+
if (!hasScreenSharing) {
|
|
121
|
+
return FcrScreenSharingState.END;
|
|
122
|
+
} else {
|
|
123
|
+
const annotationState = this._getPureSceneAnnotationState();
|
|
124
|
+
return annotationState === 0 ? FcrScreenSharingState.START_ONLY_SCREEN : FcrScreenSharingState.START_WHIT_ANNOTATION;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
getWhiteboardState() {
|
|
128
|
+
const isActive = this._whiteboardControl.getActivity();
|
|
129
|
+
return isActive ? FcrWhiteboardState.START : FcrWhiteboardState.END;
|
|
130
|
+
}
|
|
131
|
+
getAnnotationControl() {
|
|
132
|
+
if (!this._annotationControl) {
|
|
133
|
+
const {
|
|
134
|
+
userId,
|
|
135
|
+
userName
|
|
136
|
+
} = this._userControl.getLocalUser();
|
|
137
|
+
const annotationConfig = {
|
|
138
|
+
userId,
|
|
139
|
+
userName,
|
|
140
|
+
roomId: this._scene.sceneId,
|
|
141
|
+
boardRatio: 1,
|
|
142
|
+
size: {
|
|
143
|
+
width: 1280,
|
|
144
|
+
height: 720
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
const permissions = this._privilegeControl.getAllLocalUserPermissionInfo();
|
|
148
|
+
const hasOperationPrivilege = hasAnnotationWritePermission(permissions);
|
|
149
|
+
this._annotationControl = new FcrAnnotationControlFactoryImpl().createForMainProcess(
|
|
150
|
+
// @ts-ignore
|
|
151
|
+
this._engine._rtmClient._client, hasOperationPrivilege, annotationConfig, {
|
|
152
|
+
sceneId: this._scene.sceneId,
|
|
153
|
+
getAnnotationState: () => {
|
|
154
|
+
return this._scene.getScenePropertiesByKeyPath('widgets.annotation.state') ?? FcrBoardPropertiesState.INACTIVE;
|
|
155
|
+
}
|
|
156
|
+
}, this._api);
|
|
157
|
+
}
|
|
158
|
+
return this._annotationControl;
|
|
159
|
+
}
|
|
160
|
+
getSharingWindowSize() {
|
|
161
|
+
const width = this._scene.getScenePropertiesByKeyPath('widgets.annotation.size.width');
|
|
162
|
+
const height = this._scene.getScenePropertiesByKeyPath('widgets.annotation.size.height');
|
|
163
|
+
if (typeof width === 'number' && typeof height === 'number') {
|
|
164
|
+
return {
|
|
165
|
+
width,
|
|
166
|
+
height
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
return undefined;
|
|
170
|
+
}
|
|
171
|
+
getBoardControl() {
|
|
172
|
+
if (!this._whiteboardControl) {
|
|
173
|
+
const factory = new FcrWhiteboardControlFactoryImpl();
|
|
174
|
+
const permissions = this._privilegeControl.getAllLocalUserPermissionInfo();
|
|
175
|
+
const hasOperationPrivilege = hasBoardWritePermission(permissions);
|
|
176
|
+
const {
|
|
177
|
+
userId,
|
|
178
|
+
userName
|
|
179
|
+
} = this._userControl.getLocalUser();
|
|
180
|
+
const boardConfig = {
|
|
181
|
+
userId,
|
|
182
|
+
userName,
|
|
183
|
+
roomId: this._scene.sceneId,
|
|
184
|
+
boardRatio: 0
|
|
185
|
+
};
|
|
186
|
+
this._whiteboardControl = factory.createForMainProcess(
|
|
187
|
+
// @ts-ignore
|
|
188
|
+
this._engine._rtmClient._client, hasOperationPrivilege, boardConfig, this._scene, this._api, this._sharedCache);
|
|
189
|
+
}
|
|
190
|
+
return this._whiteboardControl;
|
|
191
|
+
}
|
|
192
|
+
addObserver(observer) {
|
|
193
|
+
this._observable.addObserver(observer);
|
|
194
|
+
}
|
|
195
|
+
removeObserver(observer) {
|
|
196
|
+
this._observable.removeObserver(observer);
|
|
197
|
+
}
|
|
198
|
+
release() {
|
|
199
|
+
this._scene.removeObserver(this._sceneObserver);
|
|
200
|
+
this._streamControl.removeObserver(this._streamObserver);
|
|
201
|
+
this._whiteboardControl.removeObserver(this._whiteboardObserver);
|
|
202
|
+
}
|
|
203
|
+
_getPureSceneAnnotationState() {
|
|
204
|
+
return this._scene.getScenePropertiesByKeyPath('widgets.annotation.state');
|
|
205
|
+
}
|
|
206
|
+
_isStreamToHandleScreenSharing(stream) {
|
|
207
|
+
return stream.videoSourceType === FcrVideoSourceType.SCREEN && (stream.streamType === AgoraRteMediaStreamType.BOTH || stream.streamType === AgoraRteMediaStreamType.VIDEO);
|
|
208
|
+
}
|
|
209
|
+
_handleOnStreamsAdded(roomId, events) {
|
|
210
|
+
events.forEach(event => {
|
|
211
|
+
const {
|
|
212
|
+
modifiedStream
|
|
213
|
+
} = event;
|
|
214
|
+
if (this._isStreamToHandleScreenSharing(modifiedStream)) {
|
|
215
|
+
this._shareOwnerId = modifiedStream.owner.userId;
|
|
216
|
+
this._shareOwnerStream = modifiedStream;
|
|
217
|
+
this._observable.notifyObservers('onScreenSharingUpdated', modifiedStream, FcrScreenSharingState.START_ONLY_SCREEN);
|
|
218
|
+
}
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
_handleOnStreamsRemoved(roomId, events) {
|
|
222
|
+
events.forEach(event => {
|
|
223
|
+
const {
|
|
224
|
+
modifiedStream
|
|
225
|
+
} = event;
|
|
226
|
+
const ownerId = modifiedStream.owner.userId;
|
|
227
|
+
if (this._isStreamToHandleScreenSharing(modifiedStream)) {
|
|
228
|
+
this._observable.notifyObservers('onScreenSharingUpdated', modifiedStream, FcrScreenSharingState.END);
|
|
229
|
+
if (this.getScreenSharingState() === FcrScreenSharingState.END) {
|
|
230
|
+
const isMeSharing = ownerId === this._userControl.getLocalUser().userId;
|
|
231
|
+
if (isMeSharing) {
|
|
232
|
+
this.logger.info('on stream removed, clean before terminal Annotation app');
|
|
233
|
+
this._annotationControl.getMainWindow()?.clean();
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
_handleOnScenePropertiesUpdated(sceneId, event) {
|
|
240
|
+
const {
|
|
241
|
+
cause
|
|
242
|
+
} = event;
|
|
243
|
+
const causeData = cause?.data;
|
|
244
|
+
const currentScreenSharingState = this.getScreenSharingState();
|
|
245
|
+
const causeCmd = cause?.cmd;
|
|
246
|
+
if (currentScreenSharingState === FcrScreenSharingState.END) {
|
|
247
|
+
if (causeData && causeCmd === 10 && causeData.widgetUuid === FcrWidgetUuid.ANNOTATION) {
|
|
248
|
+
if (causeData.widgetCause?.cmd === FcrWidgetCauseCmd.ANNOTATION) {
|
|
249
|
+
this._observable.notifyObservers('onScreenSharingUpdated', this.ownerStream, FcrScreenSharingState.END);
|
|
250
|
+
const isMeSharing = this.ownerId === this._userControl.getLocalUser().userId;
|
|
251
|
+
if (isMeSharing) {
|
|
252
|
+
this.logger.info('clean annotation board');
|
|
253
|
+
this._annotationControl.getMainWindow()?.clean();
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
} else {
|
|
258
|
+
// 当屏幕共享开启时
|
|
259
|
+
if (causeData && causeCmd === 10 && causeData.widgetUuid === FcrWidgetUuid.ANNOTATION) {
|
|
260
|
+
if (causeData.widgetCause?.cmd === FcrWidgetCauseCmd.ANNOTATION) {
|
|
261
|
+
const screenStream = this._getScreenShareStreamByUuid();
|
|
262
|
+
this._observable.notifyObservers('onScreenSharingUpdated', screenStream ?? this.ownerStream, FcrScreenSharingState.START_WHIT_ANNOTATION);
|
|
263
|
+
// const owner = this._userControl.getUser(this.ownerId);
|
|
264
|
+
// const isElectron =
|
|
265
|
+
// owner &&
|
|
266
|
+
// [FcrPlatform.WEB_DESKTOP, FcrPlatform.MACOS, FcrPlatform.WINDOWS].includes(
|
|
267
|
+
// owner.platform,
|
|
268
|
+
// );
|
|
269
|
+
// const mainWindow = this._annotationControl?.getMainWindow();
|
|
270
|
+
// const isAndroid = owner && owner.platform === FcrPlatform.ANDROID;
|
|
271
|
+
// if (isElectron && mainWindow) {
|
|
272
|
+
// mainWindow.setAutoCancelDraw(false);
|
|
273
|
+
// }
|
|
274
|
+
// if (isAndroid && mainWindow) {
|
|
275
|
+
// const isNotMeSharing = this.ownerId !== this._userControl.getLocalUser().userId;
|
|
276
|
+
// mainWindow.setAutoCancelDraw(isNotMeSharing);
|
|
277
|
+
// }
|
|
278
|
+
} else {
|
|
279
|
+
if (causeData.reason === 1) {
|
|
280
|
+
this._observable.notifyObservers('onScreenSharingUpdated', this.ownerStream, FcrScreenSharingState.END);
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
_handleOnWhiteboardActive(ownerId, operatorUser) {
|
|
287
|
+
if (!this._isActive) {
|
|
288
|
+
this._observable.notifyObservers('onWhiteboardStarted', ownerId, operatorUser);
|
|
289
|
+
this._isActive = true;
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
_handleOnWhiteboardInActive(reason, operatorUser) {
|
|
293
|
+
if (this._isActive) {
|
|
294
|
+
this._observable.notifyObservers('onWhiteboardEnded', reason, operatorUser);
|
|
295
|
+
this._isActive = false;
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
_getScreenShareStreamByUuid() {
|
|
299
|
+
const screenStreamUuid = this._scene.getScenePropertiesByKeyPath('widgets.annotation.extra.screenStreamUuid');
|
|
300
|
+
this.logger.info('scene properties screenStreamUuid: ', screenStreamUuid);
|
|
301
|
+
const stream = this._streamControl.getStreamByStreamId(screenStreamUuid);
|
|
302
|
+
return typeof stream === 'undefined' ? null : stream;
|
|
303
|
+
}
|
|
304
|
+
_addLogObserver() {
|
|
305
|
+
this.addObserver(generateLogObserver(this.logger, [['onScreenSharingUpdated', ['streamInfo', 'state']], ['onWhiteboardStarted', ['ownerId', 'operatorUser']], ['onWhiteboardEnded', ['reason', 'operatorUser']]]));
|
|
306
|
+
}
|
|
307
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export let FcrScreenSharingState = /*#__PURE__*/function (FcrScreenSharingState) {
|
|
2
|
+
FcrScreenSharingState[FcrScreenSharingState["END"] = 0] = "END";
|
|
3
|
+
FcrScreenSharingState[FcrScreenSharingState["START_ONLY_SCREEN"] = 1] = "START_ONLY_SCREEN";
|
|
4
|
+
FcrScreenSharingState[FcrScreenSharingState["START_WHIT_ANNOTATION"] = 2] = "START_WHIT_ANNOTATION";
|
|
5
|
+
return FcrScreenSharingState;
|
|
6
|
+
}({});
|
|
7
|
+
export let FcrWhiteboardState = /*#__PURE__*/function (FcrWhiteboardState) {
|
|
8
|
+
FcrWhiteboardState[FcrWhiteboardState["END"] = 0] = "END";
|
|
9
|
+
FcrWhiteboardState[FcrWhiteboardState["START"] = 1] = "START";
|
|
10
|
+
return FcrWhiteboardState;
|
|
11
|
+
}({});
|
|
12
|
+
export let FcrSharePermissionState = /*#__PURE__*/function (FcrSharePermissionState) {
|
|
13
|
+
FcrSharePermissionState[FcrSharePermissionState["ON"] = 1] = "ON";
|
|
14
|
+
FcrSharePermissionState[FcrSharePermissionState["OFF"] = 0] = "OFF";
|
|
15
|
+
return FcrSharePermissionState;
|
|
16
|
+
}({});
|