fcr-core 3.8.0-alpha → 3.8.1-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-connection/index.js +26 -40
- package/lib/engine/index.js +72 -66
- package/lib/imports.js +0 -1
- package/lib/media-control/desktop.js +13 -18
- package/lib/media-control/mobile.js +13 -18
- package/lib/monitor-control/index.js +5 -10
- package/lib/peer-session/index.js +39 -47
- package/lib/plugins/chatroom.js +213 -229
- package/lib/room-control/ability-control/index.js +9 -14
- package/lib/room-control/group-control/index.js +16 -21
- package/lib/room-control/helpers/validation-helper.js +1 -1
- package/lib/room-control/index.js +36 -53
- package/lib/room-control/interpreter-control/index.js +34 -47
- package/lib/room-control/interpreter-control/room.js +4 -6
- package/lib/room-control/join-before-host-waitingroom-control/index.js +4 -6
- package/lib/room-control/mainroom-control/index.js +27 -35
- package/lib/room-control/privilege-control/helper.js +5 -8
- package/lib/room-control/privilege-control/index.js +19 -26
- package/lib/room-control/room-connector-control/index.js +19 -28
- package/lib/room-control/room-control-factory.js +1 -2
- package/lib/room-control/room-session/index.js +39 -46
- package/lib/room-control/shared-cache.js +29 -36
- package/lib/room-control/sharing-control/index.d.ts +1 -1
- package/lib/room-control/sharing-control/index.js +34 -42
- package/lib/room-control/stream-control/index.js +191 -195
- package/lib/room-control/stream-control/type.d.ts +1 -1
- package/lib/room-control/stt-control/de-compress-gzip.js +0 -10
- package/lib/room-control/stt-control/index.js +95 -98
- package/lib/room-control/stt-control/type.d.ts +1 -1
- package/lib/room-control/user-control/index.js +136 -143
- package/lib/room-control/waitingroom-control/index.js +9 -14
- package/lib/room-control/whiteboard-control/utils.js +2 -4
- package/lib/room-control/whiteboard-control-v1/board-subwindow.js +1 -2
- package/lib/room-control/whiteboard-control-v1/board-window.js +88 -99
- package/lib/room-control/whiteboard-control-v1/factory.js +4 -7
- package/lib/room-control/whiteboard-control-v1/index.js +28 -40
- package/lib/room-control/whiteboard-control-v1/mount-manager.js +2 -4
- package/lib/room-control/whiteboard-control-v1/utils.js +14 -17
- package/lib/room-control/whiteboard-control-v2/annotation-control/control.js +4 -6
- package/lib/room-control/whiteboard-control-v2/annotation-control/factory.js +5 -10
- package/lib/room-control/whiteboard-control-v2/base/index.js +34 -41
- package/lib/room-control/whiteboard-control-v2/base/main-window.js +24 -29
- package/lib/room-control/whiteboard-control-v2/utils.js +6 -7
- package/lib/room-control/whiteboard-control-v2/whiteboard-control/control.d.ts +0 -1
- package/lib/room-control/whiteboard-control-v2/whiteboard-control/control.js +23 -34
- package/lib/room-control/whiteboard-control-v2/whiteboard-control/factory.js +7 -14
- package/lib/room-router/index.js +47 -53
- package/lib/room-router/type.d.ts +2 -2
- package/lib/service/api.js +227 -250
- package/lib/utilities/collection.js +2 -3
- package/lib/utilities/error-helpers.js +27 -34
- package/lib/utilities/error.js +8 -9
- package/lib/utilities/join-helper.js +25 -32
- package/lib/utilities/logger.js +3 -6
- package/lib/utilities/parameters.js +4 -8
- package/lib/utilities/retry-helpers.js +0 -1
- package/lib/utilities/stream.js +11 -16
- package/lib/utilities/user.js +3 -4
- package/lib/utilities/validate-params.js +1 -2
- package/package.json +5 -6
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
require("core-js/modules/es.symbol.description.js");
|
|
4
|
-
require("core-js/modules/es.error.cause.js");
|
|
5
3
|
require("core-js/modules/esnext.function.metadata.js");
|
|
6
|
-
require("core-js/modules/esnext.iterator.for-each.js");
|
|
7
4
|
require("core-js/modules/esnext.symbol.metadata.js");
|
|
8
5
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
9
6
|
Object.defineProperty(exports, "__esModule", {
|
|
@@ -28,8 +25,6 @@ require("core-js/modules/esnext.map.merge.js");
|
|
|
28
25
|
require("core-js/modules/esnext.map.reduce.js");
|
|
29
26
|
require("core-js/modules/esnext.map.some.js");
|
|
30
27
|
require("core-js/modules/esnext.map.update.js");
|
|
31
|
-
require("core-js/modules/web.dom-collections.iterator.js");
|
|
32
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
33
28
|
var _imports = require("../../imports");
|
|
34
29
|
var _logger = require("../../utilities/logger");
|
|
35
30
|
var _schema = require("../../schema");
|
|
@@ -39,10 +34,7 @@ var _type2 = require("../../type");
|
|
|
39
34
|
var _validateParams = _interopRequireDefault(require("../../utilities/validate-params"));
|
|
40
35
|
var _user = require("../../utilities/user");
|
|
41
36
|
var _type3 = require("../type");
|
|
42
|
-
|
|
43
|
-
let _initProto, _startCaptionDecs, _startTranscribingDecs, _updateSourceLanguageDecs, _subscribeTranscribingLanguageDecs, _ref;
|
|
44
|
-
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; }
|
|
45
|
-
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; }
|
|
37
|
+
let _initProto, _startCaptionDecs, _startTranscribingDecs, _updateSourceLanguageDecs, _subscribeTranscribingLanguageDecs;
|
|
46
38
|
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)]; } }; }
|
|
47
39
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
48
40
|
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); }
|
|
@@ -51,84 +43,88 @@ function _checkInRHS(e) { if (Object(e) !== e) throw TypeError("right-hand side
|
|
|
51
43
|
/**
|
|
52
44
|
* @internal
|
|
53
45
|
*/
|
|
54
|
-
_ref = (_startCaptionDecs = [_imports.trace, (0, _validateParams.default)(_schema.fcrLanguageConfigSchema)], _startTranscribingDecs = [_imports.trace, (0, _validateParams.default)(_schema.fcrLanguageConfigSchema)], _updateSourceLanguageDecs = [_imports.trace, (0, _validateParams.default)(_schema.fcrLanguageSchema)], _subscribeTranscribingLanguageDecs = [_imports.trace, (0, _validateParams.default)(_schema.fcrLanguageSchema)], "logger");
|
|
55
46
|
class FcrSttControlImpl {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
47
|
+
static {
|
|
48
|
+
[_initProto] = _applyDecs(this, [[_startCaptionDecs, 2, "startCaption"], [_imports.trace, 2, "stopCaption"], [_startTranscribingDecs, 2, "startTranscribing"], [_imports.trace, 2, "stopTranscribing"], [_updateSourceLanguageDecs, 2, "updateSourceLanguage"], [_subscribeTranscribingLanguageDecs, 2, "subscribeTranscribingLanguage"], [_imports.trace, 2, "unsubscribeTranscribingLanguage"], [_imports.trace, 2, "release"]], []).e;
|
|
49
|
+
}
|
|
50
|
+
//@internal
|
|
51
|
+
[(_startCaptionDecs = [_imports.trace, (0, _validateParams.default)(_schema.fcrLanguageConfigSchema)], _startTranscribingDecs = [_imports.trace, (0, _validateParams.default)(_schema.fcrLanguageConfigSchema)], _updateSourceLanguageDecs = [_imports.trace, (0, _validateParams.default)(_schema.fcrLanguageSchema)], _subscribeTranscribingLanguageDecs = [_imports.trace, (0, _validateParams.default)(_schema.fcrLanguageSchema)], "logger")] = (_initProto(this), (0, _logger.createLogger)({
|
|
52
|
+
prefix: 'FcrUserControlImpl'
|
|
53
|
+
}));
|
|
54
|
+
|
|
55
|
+
//@internal
|
|
56
|
+
_observable = new _imports.AgoraObservable();
|
|
57
|
+
|
|
58
|
+
//@internal
|
|
59
|
+
|
|
60
|
+
_cacheMaxLimit = 10;
|
|
61
|
+
_sttEventWrapperListMap = new Map();
|
|
62
|
+
|
|
63
|
+
//@internal
|
|
64
|
+
_sceneObserver = {
|
|
65
|
+
onStreamMessageReceived: async (sceneId, data) => {
|
|
66
|
+
const sttUids = this._scene.getScenePropertiesByKeyPath('widgets.stt.extra.pubBotUids');
|
|
67
|
+
const isSttBot = sttUids.includes(Number(data.streamId));
|
|
68
|
+
if (!isSttBot) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
const sttStreamMessageData = await (0, _imports.deCompressGzipToJson)(data.payload);
|
|
72
|
+
this._handleSttStreamMessageData(sttStreamMessageData, sceneId);
|
|
73
|
+
},
|
|
74
|
+
onUserPropertiesUpdated: (sceneId, event) => {
|
|
75
|
+
if (event.cause && event.cause.data) {
|
|
76
|
+
const causeData = event.cause.data;
|
|
77
|
+
if (causeData.widgetUuid == _type3.FcrWidgetUuid.STT && causeData.widgetCause && causeData.widgetCause.cmd == 3450) {
|
|
78
|
+
const localUserId = this._scene.localUser.getLocalUserId();
|
|
79
|
+
if (event.operatorUser.userId !== localUserId) {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
const operatorUser = (0, _user.convertRteUserToFcrUser)(event.operatorUser, this._roomCache);
|
|
83
|
+
if (causeData.widgetCause.reason === 0) {
|
|
84
|
+
const isTranscribingStopped = this._getTranscribingState() === _type.FcrTranscribingState.STOPPED;
|
|
85
|
+
if (isTranscribingStopped) {
|
|
86
|
+
this._sttEventWrapperListMap.clear();
|
|
87
|
+
}
|
|
88
|
+
this._observable.notifyObservers('onLocalCaptionStateUpdated', sceneId, _type.FcrCaptionState.STOPPED, operatorUser);
|
|
89
|
+
}
|
|
90
|
+
if (causeData.widgetCause.reason === 1) {
|
|
91
|
+
this._observable.notifyObservers('onLocalCaptionStateUpdated', sceneId, _type.FcrCaptionState.STARTED, operatorUser);
|
|
92
|
+
}
|
|
72
93
|
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
onScenePropertiesUpdated: (sceneId, event) => {
|
|
97
|
+
if (event.cause && event.cause.data) {
|
|
98
|
+
const causeData = event.cause.data;
|
|
99
|
+
if (!causeData.widgetCause) {
|
|
100
|
+
return;
|
|
77
101
|
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
if (event.operatorUser.userId !== localUserId) {
|
|
85
|
-
return;
|
|
86
|
-
}
|
|
87
|
-
const operatorUser = (0, _user.convertRteUserToFcrUser)(event.operatorUser, this._roomCache);
|
|
88
|
-
if (causeData.widgetCause.reason === 0) {
|
|
89
|
-
const isTranscribingStopped = this._getTranscribingState() === _type.FcrTranscribingState.STOPPED;
|
|
90
|
-
if (isTranscribingStopped) {
|
|
91
|
-
this._sttEventWrapperListMap.clear();
|
|
92
|
-
}
|
|
93
|
-
this._observable.notifyObservers('onLocalCaptionStateUpdated', sceneId, _type.FcrCaptionState.STOPPED, operatorUser);
|
|
94
|
-
}
|
|
95
|
-
if (causeData.widgetCause.reason === 1) {
|
|
96
|
-
this._observable.notifyObservers('onLocalCaptionStateUpdated', sceneId, _type.FcrCaptionState.STARTED, operatorUser);
|
|
102
|
+
if (causeData.widgetUuid == _type3.FcrWidgetUuid.TRANSCRIBE && causeData.widgetCause.cmd == _type3.FcrWidgetCauseCmd.TRANSCRIBE) {
|
|
103
|
+
const operatorUser = (0, _user.convertRteUserToFcrUser)(event.operatorUser, this._roomCache);
|
|
104
|
+
if (causeData.widgetCause.reason === 0) {
|
|
105
|
+
const isCaptionStopped = this._getLocalCaptionState() === _type.FcrCaptionState.STOPPED;
|
|
106
|
+
if (isCaptionStopped) {
|
|
107
|
+
this._sttEventWrapperListMap.clear();
|
|
97
108
|
}
|
|
109
|
+
this._observable.notifyObservers('onTranscribingStateUpdated', sceneId, _type.FcrTranscribingState.STOPPED, operatorUser);
|
|
98
110
|
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
onScenePropertiesUpdated: (sceneId, event) => {
|
|
102
|
-
if (event.cause && event.cause.data) {
|
|
103
|
-
const causeData = event.cause.data;
|
|
104
|
-
if (!causeData.widgetCause) {
|
|
105
|
-
return;
|
|
111
|
+
if (causeData.widgetCause.reason === 1) {
|
|
112
|
+
this._observable.notifyObservers('onTranscribingStateUpdated', sceneId, _type.FcrTranscribingState.STARTED, operatorUser);
|
|
106
113
|
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
this._sttEventWrapperListMap.clear();
|
|
113
|
-
}
|
|
114
|
-
this._observable.notifyObservers('onTranscribingStateUpdated', sceneId, _type.FcrTranscribingState.STOPPED, operatorUser);
|
|
115
|
-
}
|
|
116
|
-
if (causeData.widgetCause.reason === 1) {
|
|
117
|
-
this._observable.notifyObservers('onTranscribingStateUpdated', sceneId, _type.FcrTranscribingState.STARTED, operatorUser);
|
|
118
|
-
}
|
|
114
|
+
}
|
|
115
|
+
if (causeData.widgetUuid == _type3.FcrWidgetUuid.STT && causeData.widgetCause.cmd == _type3.FcrWidgetCauseCmd.STT) {
|
|
116
|
+
let operatorUser;
|
|
117
|
+
if (event.operatorUser) {
|
|
118
|
+
operatorUser = (0, _user.convertRteUserToFcrUser)(event.operatorUser, this._roomCache);
|
|
119
119
|
}
|
|
120
|
-
if (causeData.
|
|
121
|
-
|
|
122
|
-
if (event.operatorUser) {
|
|
123
|
-
operatorUser = (0, _user.convertRteUserToFcrUser)(event.operatorUser, this._roomCache);
|
|
124
|
-
}
|
|
125
|
-
if (causeData.widgetCause.reason === 2) {
|
|
126
|
-
this._observable.notifyObservers('onSourceLanguageUpdated', sceneId, operatorUser);
|
|
127
|
-
}
|
|
120
|
+
if (causeData.widgetCause.reason === 2) {
|
|
121
|
+
this._observable.notifyObservers('onSourceLanguageUpdated', sceneId, operatorUser);
|
|
128
122
|
}
|
|
129
123
|
}
|
|
130
124
|
}
|
|
131
|
-
}
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
constructor(_scene, _api, _sharedCache) {
|
|
132
128
|
this._scene = _scene;
|
|
133
129
|
this._api = _api;
|
|
134
130
|
this._sharedCache = _sharedCache;
|
|
@@ -225,8 +221,7 @@ class FcrSttControlImpl {
|
|
|
225
221
|
_getTranscribingState() {
|
|
226
222
|
return this._scene.getScenePropertiesByKeyPath('widgets.transcribe.state');
|
|
227
223
|
}
|
|
228
|
-
|
|
229
|
-
var _this$_scene$getStrea;
|
|
224
|
+
_handleSttStreamMessageData(sttStreamMessageData, sceneId) {
|
|
230
225
|
const codeMap = {
|
|
231
226
|
'zh-CN': _type2.FcrLanguage.ZH,
|
|
232
227
|
'en-US': _type2.FcrLanguage.EN,
|
|
@@ -236,15 +231,15 @@ class FcrSttControlImpl {
|
|
|
236
231
|
'pt-PT': _type2.FcrLanguage.PT,
|
|
237
232
|
'es-ES': _type2.FcrLanguage.ES
|
|
238
233
|
};
|
|
239
|
-
const transcript =
|
|
240
|
-
const translation =
|
|
234
|
+
const transcript = sttStreamMessageData.transcript;
|
|
235
|
+
const translation = sttStreamMessageData.translation;
|
|
241
236
|
const messageItem = transcript || translation;
|
|
242
|
-
const uid = messageItem
|
|
237
|
+
const uid = messageItem?.uid;
|
|
243
238
|
if (!uid) {
|
|
244
239
|
this.logger.error('parseSTT failed, uid is null');
|
|
245
240
|
return null;
|
|
246
241
|
}
|
|
247
|
-
const owner =
|
|
242
|
+
const owner = this._scene.getStreamByStreamId(uid.toString())?.owner;
|
|
248
243
|
if (!owner) {
|
|
249
244
|
this.logger.error('parseSTT failed, owner is null');
|
|
250
245
|
return null;
|
|
@@ -276,6 +271,7 @@ class FcrSttControlImpl {
|
|
|
276
271
|
}
|
|
277
272
|
};
|
|
278
273
|
sttEventWrapperList = [sttEventWrapper];
|
|
274
|
+
this._observable.notifyObservers('onSttEventReceived', sceneId, sttEventWrapper.event);
|
|
279
275
|
} else {
|
|
280
276
|
const lastSttEventWrapper = sttEventWrapperList[sttEventWrapperList.length - 1];
|
|
281
277
|
// add
|
|
@@ -294,42 +290,48 @@ class FcrSttControlImpl {
|
|
|
294
290
|
// remove oldest
|
|
295
291
|
sttEventWrapperList.shift();
|
|
296
292
|
}
|
|
293
|
+
this._observable.notifyObservers('onSttEventReceived', sceneId, sttEventWrapper.event);
|
|
297
294
|
} else {
|
|
298
295
|
if (transcript.textTs >= lastSttEventWrapper.endTs) {
|
|
299
296
|
// update
|
|
300
297
|
sttEventWrapperList[sttEventWrapperList.length - 1] = {
|
|
301
|
-
startTs: lastSttEventWrapper.
|
|
298
|
+
startTs: lastSttEventWrapper.startTs,
|
|
302
299
|
endTs: transcript.textTs,
|
|
303
300
|
event: (0, _imports.merge)(lastSttEventWrapper.event, {
|
|
304
|
-
transcript:
|
|
301
|
+
transcript: {
|
|
302
|
+
...formatTranscript,
|
|
305
303
|
id: lastSttEventWrapper.event.transcript.id
|
|
306
|
-
}
|
|
304
|
+
}
|
|
307
305
|
})
|
|
308
306
|
};
|
|
307
|
+
this._observable.notifyObservers('onSttEventReceived', sceneId, sttEventWrapperList[sttEventWrapperList.length - 1].event);
|
|
309
308
|
}
|
|
310
309
|
}
|
|
311
310
|
}
|
|
312
311
|
}
|
|
313
312
|
if (translation) {
|
|
314
|
-
var _sttEventWrapperList;
|
|
315
313
|
// 获取缓存句子
|
|
316
|
-
sttEventWrapperList =
|
|
314
|
+
sttEventWrapperList = sttEventWrapperList?.map(wrapper => {
|
|
315
|
+
const language = codeMap[translation.results0.language];
|
|
317
316
|
const formatTranslation = {
|
|
318
317
|
id: wrapper.event.transcript.id,
|
|
319
|
-
language
|
|
318
|
+
language,
|
|
320
319
|
text: translation.results0.texts.join(''),
|
|
321
320
|
timestamp: translation.textTs,
|
|
322
321
|
isFinal: translation.isFinal,
|
|
323
322
|
owner: (0, _user.convertRteUserToFcrUser)(owner, this._roomCache)
|
|
324
323
|
};
|
|
325
324
|
if (translation.textTs > wrapper.startTs && translation.textTs <= wrapper.endTs) {
|
|
326
|
-
const transInfo = wrapper.event.translations.get(
|
|
325
|
+
const transInfo = wrapper.event.translations.get(language);
|
|
327
326
|
if (!transInfo) {
|
|
328
327
|
wrapper.event.translations.set(formatTranslation.language, formatTranslation);
|
|
328
|
+
this._observable.notifyObservers('onSttEventReceived', sceneId, wrapper.event);
|
|
329
329
|
} else if (translation.textTs >= transInfo.timestamp) {
|
|
330
|
-
wrapper.event.translations.set(formatTranslation.language,
|
|
330
|
+
wrapper.event.translations.set(formatTranslation.language, {
|
|
331
|
+
...formatTranslation,
|
|
331
332
|
id: wrapper.event.transcript.id
|
|
332
|
-
})
|
|
333
|
+
});
|
|
334
|
+
this._observable.notifyObservers('onSttEventReceived', sceneId, wrapper.event);
|
|
333
335
|
} else if (transInfo.isFinal == true && wrapper.event.transcript.isFinal == true) {
|
|
334
336
|
return null;
|
|
335
337
|
}
|
|
@@ -339,15 +341,10 @@ class FcrSttControlImpl {
|
|
|
339
341
|
}
|
|
340
342
|
if (sttEventWrapperList) {
|
|
341
343
|
this._sttEventWrapperListMap.set(userId, sttEventWrapperList);
|
|
342
|
-
const lastSttEventWrapper = sttEventWrapperList[sttEventWrapperList.length - 1];
|
|
343
|
-
return lastSttEventWrapper.event;
|
|
344
344
|
}
|
|
345
|
-
return null;
|
|
346
345
|
}
|
|
347
346
|
_addLogObserver() {
|
|
348
347
|
this.addObserver((0, _logger.generateLogObserver)(this.logger, ['onSttEventReceived', 'onLocalCaptionStateUpdated', 'onTranscribingStateUpdated', 'onSourceLanguageUpdated']));
|
|
349
348
|
}
|
|
350
349
|
}
|
|
351
|
-
exports.FcrSttControlImpl = FcrSttControlImpl;
|
|
352
|
-
_FcrSttControlImpl = FcrSttControlImpl;
|
|
353
|
-
[_initProto] = _applyDecs(_FcrSttControlImpl, [[_startCaptionDecs, 2, "startCaption"], [_imports.trace, 2, "stopCaption"], [_startTranscribingDecs, 2, "startTranscribing"], [_imports.trace, 2, "stopTranscribing"], [_updateSourceLanguageDecs, 2, "updateSourceLanguage"], [_subscribeTranscribingLanguageDecs, 2, "subscribeTranscribingLanguage"], [_imports.trace, 2, "unsubscribeTranscribingLanguage"], [_imports.trace, 2, "release"]], []).e;
|
|
350
|
+
exports.FcrSttControlImpl = FcrSttControlImpl;
|
|
@@ -136,7 +136,7 @@ export interface FcrSttTranscript extends FcrSttMessageItem {
|
|
|
136
136
|
text: string;
|
|
137
137
|
language: FcrLanguage;
|
|
138
138
|
}
|
|
139
|
-
export interface
|
|
139
|
+
export interface FcrSttStreamMessageData {
|
|
140
140
|
transcript?: FcrSttTranscript;
|
|
141
141
|
translation?: FcrSttTranslation;
|
|
142
142
|
}
|