@rongcloud/plugin-rtc 5.5.4-alpha.3 → 5.5.5-beem-alpha.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/dist/index.d.ts +155 -17
- package/dist/index.esm.js +858 -504
- package/dist/index.js +857 -503
- package/dist/index.umd.js +857 -503
- package/package.json +2 -2
package/dist/index.umd.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* RCRTC - v5.5.
|
|
3
|
-
* CommitId -
|
|
4
|
-
*
|
|
2
|
+
* RCRTC - v5.5.5-beem-alpha.1
|
|
3
|
+
* CommitId - 4807d9272db7b224e762a75df11762453a730f9e
|
|
4
|
+
* Thu Oct 13 2022 21:01:14 GMT+0800 (China Standard Time)
|
|
5
5
|
* ©2020 RongCloud, Inc. All rights reserved.
|
|
6
6
|
*/
|
|
7
7
|
(function (global, factory) {
|
|
@@ -837,6 +837,22 @@
|
|
|
837
837
|
* 连通率相关日志-对端接收首次发布资源
|
|
838
838
|
*/
|
|
839
839
|
RCLoggerTag["L_QS_RECV_PUB_MSG_S"] = "RTC-recvPubMsg-S";
|
|
840
|
+
/**
|
|
841
|
+
* 下消息通知拉取房间状态
|
|
842
|
+
*/
|
|
843
|
+
RCLoggerTag["L_RTCNTF_PULL_ROOM_STATUS_O"] = "L-rtcntf_pull_room_status-O";
|
|
844
|
+
/**
|
|
845
|
+
* rtcping 返回的 version 比内存中的大,拉取房间状态
|
|
846
|
+
*/
|
|
847
|
+
RCLoggerTag["L_RTCPING_PULL_ROOM_STATUS_O"] = "L-rtcping_pull_room_status-O";
|
|
848
|
+
/**
|
|
849
|
+
* 房间状态通知拉取行为
|
|
850
|
+
*/
|
|
851
|
+
RCLoggerTag["L_PULL_ROOM_STATUS_T"] = "L-pull_room_status-T";
|
|
852
|
+
/**
|
|
853
|
+
* 房间状态通知拉取结果
|
|
854
|
+
*/
|
|
855
|
+
RCLoggerTag["L_PULL_ROOM_STATUS_R"] = "L-pull_room_status-R";
|
|
840
856
|
/**
|
|
841
857
|
* 旧版日志
|
|
842
858
|
*/
|
|
@@ -6983,11 +6999,11 @@
|
|
|
6983
6999
|
setTimeout(() => {
|
|
6984
7000
|
const originTrack = audioStream === null || audioStream === void 0 ? void 0 : audioStream.getAudioTracks()[0];
|
|
6985
7001
|
originTrack === null || originTrack === void 0 ? void 0 : originTrack.stop();
|
|
6986
|
-
audioCxt.suspend();
|
|
6987
|
-
audioCxt.close();
|
|
6988
|
-
destination.disconnect();
|
|
6989
|
-
AAAnoiseWorklet.disconnect();
|
|
6990
|
-
renoise.disconnect();
|
|
7002
|
+
audioCxt === null || audioCxt === void 0 ? void 0 : audioCxt.suspend();
|
|
7003
|
+
audioCxt === null || audioCxt === void 0 ? void 0 : audioCxt.close();
|
|
7004
|
+
destination === null || destination === void 0 ? void 0 : destination.disconnect();
|
|
7005
|
+
AAAnoiseWorklet === null || AAAnoiseWorklet === void 0 ? void 0 : AAAnoiseWorklet.disconnect();
|
|
7006
|
+
renoise === null || renoise === void 0 ? void 0 : renoise.disconnect();
|
|
6991
7007
|
audioCxt = null;
|
|
6992
7008
|
AAAnoiseWorklet = null;
|
|
6993
7009
|
destination = null;
|
|
@@ -7874,9 +7890,8 @@
|
|
|
7874
7890
|
* RTCPing 类,在下发的 ping 超时时间 _offlineKickTime 内,未能 Ping 成功则认为 ping 失败
|
|
7875
7891
|
*/
|
|
7876
7892
|
class Pinger {
|
|
7877
|
-
constructor(
|
|
7878
|
-
this.
|
|
7879
|
-
this._roomMode = _roomMode;
|
|
7893
|
+
constructor(_store, _context, _gap = PING_GAP, _offlineKickTime = 60 * 1000) {
|
|
7894
|
+
this._store = _store;
|
|
7880
7895
|
this._context = _context;
|
|
7881
7896
|
this._gap = _gap;
|
|
7882
7897
|
this._offlineKickTime = _offlineKickTime;
|
|
@@ -7886,12 +7901,17 @@
|
|
|
7886
7901
|
this._latestTimestamp = Date.now();
|
|
7887
7902
|
this._started = false;
|
|
7888
7903
|
this._timer = null;
|
|
7904
|
+
this._pullRTCRoomStatus = (roomId, tracId) => { };
|
|
7905
|
+
const { roomId, roomMode } = this._store;
|
|
7906
|
+
this._roomId = roomId;
|
|
7907
|
+
this._roomMode = roomMode;
|
|
7889
7908
|
}
|
|
7890
7909
|
/**
|
|
7891
7910
|
* 启动 Ping
|
|
7892
7911
|
*/
|
|
7893
|
-
start() {
|
|
7912
|
+
start(pullRoomStatusFN) {
|
|
7894
7913
|
var _a, _b, _c, _d;
|
|
7914
|
+
this._pullRTCRoomStatus = pullRoomStatusFN;
|
|
7895
7915
|
if (this._started) {
|
|
7896
7916
|
return;
|
|
7897
7917
|
}
|
|
@@ -7910,11 +7930,25 @@
|
|
|
7910
7930
|
.catch((error) => {
|
|
7911
7931
|
var _a, _b;
|
|
7912
7932
|
(_b = (_a = this._context) === null || _a === void 0 ? void 0 : _a.logger) === null || _b === void 0 ? void 0 : _b.error(RCLoggerTag.L_OLD_DAILY_RECORD_O, `rtcping receive unknown error -> ${error}`);
|
|
7913
|
-
resolve(engine.ErrorCode.UNKNOWN);
|
|
7933
|
+
resolve({ code: engine.ErrorCode.UNKNOWN });
|
|
7914
7934
|
});
|
|
7915
7935
|
setTimeout(resolve, PING_TIMEOUT, engine.ErrorCode.TIMEOUT);
|
|
7916
7936
|
});
|
|
7917
7937
|
}
|
|
7938
|
+
/**
|
|
7939
|
+
* 本地 version 小于 rtcping 返回的 version,需拉取房间最新数据
|
|
7940
|
+
*/
|
|
7941
|
+
_diffPullRTCRoomStatus(pingerVersion) {
|
|
7942
|
+
var _a, _b, _c, _d;
|
|
7943
|
+
const oldVersion = this._store.getRoomStatusVersion();
|
|
7944
|
+
if (pingerVersion > oldVersion) {
|
|
7945
|
+
const traceId = (_b = (_a = this._context) === null || _a === void 0 ? void 0 : _a.logger) === null || _b === void 0 ? void 0 : _b.createTraceId();
|
|
7946
|
+
(_d = (_c = this._context) === null || _c === void 0 ? void 0 : _c.logger) === null || _d === void 0 ? void 0 : _d.info(RCLoggerTag.L_RTCPING_PULL_ROOM_STATUS_O, JSON.stringify({
|
|
7947
|
+
pingerVersion,
|
|
7948
|
+
}), traceId);
|
|
7949
|
+
this._pullRTCRoomStatus(this._roomId, traceId);
|
|
7950
|
+
}
|
|
7951
|
+
}
|
|
7918
7952
|
_checkAlive() {
|
|
7919
7953
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
7920
7954
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -7923,11 +7957,13 @@
|
|
|
7923
7957
|
roomId: this._roomId,
|
|
7924
7958
|
msg: 'send rtcping',
|
|
7925
7959
|
}));
|
|
7926
|
-
const code = yield this._sendPing();
|
|
7960
|
+
const { code, data } = yield this._sendPing();
|
|
7927
7961
|
const now = Date.now();
|
|
7928
7962
|
// ping 成功
|
|
7929
7963
|
if (code === engine.ErrorCode.SUCCESS) {
|
|
7930
7964
|
(_f = (_e = this._context) === null || _e === void 0 ? void 0 : _e.logger) === null || _f === void 0 ? void 0 : _f.info(RCLoggerTag.L_OLD_DAILY_RECORD_O, 'rtcping success ->');
|
|
7965
|
+
// 判断是否需要拉房间数据
|
|
7966
|
+
this._diffPullRTCRoomStatus(data.version);
|
|
7931
7967
|
(_h = (_g = this._context) === null || _g === void 0 ? void 0 : _g.logger) === null || _h === void 0 ? void 0 : _h.info(RCLoggerTag.L_PINGER_SEND_RTCPING_R, JSON.stringify({
|
|
7932
7968
|
roomId: this._roomId,
|
|
7933
7969
|
msg: 'send rtcping success',
|
|
@@ -14615,7 +14651,7 @@
|
|
|
14615
14651
|
'Content-Type': 'application/json;charset=UTF-8',
|
|
14616
14652
|
'Cache-Control': 'no-cache',
|
|
14617
14653
|
ClientType: `web|${browserInfo.browser}|${browserInfo.version}`,
|
|
14618
|
-
ClientVersion: "5.5.
|
|
14654
|
+
ClientVersion: "5.5.5-beem-alpha.1",
|
|
14619
14655
|
'Client-Session-Id': getUUID(),
|
|
14620
14656
|
'Request-Id': Date.now().toString(),
|
|
14621
14657
|
});
|
|
@@ -14730,8 +14766,6 @@
|
|
|
14730
14766
|
const _context = context.getPluginContext();
|
|
14731
14767
|
yield _context.refetchNaviInfo();
|
|
14732
14768
|
const naviInfo = context.getNaviInfo();
|
|
14733
|
-
// @TODO: 删除log
|
|
14734
|
-
console.log('更新后的的jwt ------>:', naviInfo === null || naviInfo === void 0 ? void 0 : naviInfo.jwt);
|
|
14735
14769
|
return {
|
|
14736
14770
|
naviInfo,
|
|
14737
14771
|
jwt: parseJWTToken(naviInfo),
|
|
@@ -14757,7 +14791,7 @@
|
|
|
14757
14791
|
'Content-Type': 'application/json;charset=UTF-8',
|
|
14758
14792
|
'Cache-Control': 'no-cache',
|
|
14759
14793
|
ClientType: `web|${browserInfo.browser}|${browserInfo.version}`,
|
|
14760
|
-
ClientVersion: "5.5.
|
|
14794
|
+
ClientVersion: "5.5.5-beem-alpha.1",
|
|
14761
14795
|
'Client-Session-Id': getUUID(),
|
|
14762
14796
|
'Request-Id': Date.now().toString(),
|
|
14763
14797
|
});
|
|
@@ -16896,10 +16930,12 @@
|
|
|
16896
16930
|
if (!transceiver) {
|
|
16897
16931
|
return;
|
|
16898
16932
|
}
|
|
16899
|
-
|
|
16900
|
-
|
|
16901
|
-
|
|
16902
|
-
|
|
16933
|
+
if (this._peer.connectionState !== 'closed') {
|
|
16934
|
+
transceiver.direction = 'inactive';
|
|
16935
|
+
this._peer.removeTrack(transceiver.sender);
|
|
16936
|
+
// 发送器 replaceTrack 参数为空/null时,则终止 RTP 发送器
|
|
16937
|
+
transceiver.sender.replaceTrack(null);
|
|
16938
|
+
}
|
|
16903
16939
|
const stream = this._outboundStreams[msid];
|
|
16904
16940
|
const msTracks = track.isAudioTrack() ? stream.getAudioTracks() : stream.getVideoTracks();
|
|
16905
16941
|
msTracks.forEach((item) => stream.removeTrack(item));
|
|
@@ -16908,15 +16944,17 @@
|
|
|
16908
16944
|
if (!tinyTransceiver || (tinyTransceiver.direction === 'inactive')) {
|
|
16909
16945
|
return;
|
|
16910
16946
|
}
|
|
16911
|
-
|
|
16912
|
-
|
|
16913
|
-
|
|
16914
|
-
|
|
16915
|
-
|
|
16916
|
-
|
|
16917
|
-
|
|
16918
|
-
|
|
16919
|
-
|
|
16947
|
+
if (this._peer.connectionState !== 'closed') {
|
|
16948
|
+
tinyTransceiver.direction = 'inactive';
|
|
16949
|
+
const { sender } = tinyTransceiver;
|
|
16950
|
+
const tinyTrack = sender.track;
|
|
16951
|
+
this._peer.removeTrack(sender);
|
|
16952
|
+
// 发送器 replaceTrack 参数为空/null时,则终止 RTP 发送器
|
|
16953
|
+
sender.replaceTrack(null);
|
|
16954
|
+
const tinyStream = this._outboundStreams[`${msid}_tiny`];
|
|
16955
|
+
tinyStream.removeTrack(tinyTrack);
|
|
16956
|
+
tinyTrack.stop();
|
|
16957
|
+
}
|
|
16920
16958
|
}
|
|
16921
16959
|
updateRecvTransceiverMap(trackId, transceiver) {
|
|
16922
16960
|
const { mediaType } = parseTrackId(trackId);
|
|
@@ -17204,9 +17242,10 @@
|
|
|
17204
17242
|
}));
|
|
17205
17243
|
}
|
|
17206
17244
|
startAutoExecute(gap = 1000) {
|
|
17245
|
+
this.stopAutoExecute();
|
|
17207
17246
|
this._reportStatsTimer = setTimeout(() => {
|
|
17208
17247
|
this._reportHandle(gap);
|
|
17209
|
-
this.
|
|
17248
|
+
this.startAutoExecute();
|
|
17210
17249
|
}, gap);
|
|
17211
17250
|
}
|
|
17212
17251
|
stopAutoExecute() {
|
|
@@ -17288,9 +17327,7 @@
|
|
|
17288
17327
|
}));
|
|
17289
17328
|
(_0 = this._logger) === null || _0 === void 0 ? void 0 : _0.__statistics(RCLoggerTag.L_QS_SUBSCRIBE_S, reportData);
|
|
17290
17329
|
// 开启 peerConnection stats 统计定时器
|
|
17291
|
-
|
|
17292
|
-
this.stopAutoExecute();
|
|
17293
|
-
}
|
|
17330
|
+
this.stopAutoExecute();
|
|
17294
17331
|
this.startAutoExecute();
|
|
17295
17332
|
}
|
|
17296
17333
|
// ICE 连接中断后,需要尝试重新走 exchange 流程以恢复
|
|
@@ -17657,10 +17694,7 @@
|
|
|
17657
17694
|
this.clearReTryExchangeTimer();
|
|
17658
17695
|
clearTimeout(this._reportR3R4ToPolarisTimer);
|
|
17659
17696
|
// 停止计时
|
|
17660
|
-
|
|
17661
|
-
this.stopAutoExecute();
|
|
17662
|
-
this._reportStatsTimer = null;
|
|
17663
|
-
}
|
|
17697
|
+
this.stopAutoExecute();
|
|
17664
17698
|
this.registerReportListener(null);
|
|
17665
17699
|
// 关闭 pc 连接
|
|
17666
17700
|
this._rtcPeerConn.close();
|
|
@@ -17750,8 +17784,6 @@
|
|
|
17750
17784
|
return RCSendCode.NOT_REPORT;
|
|
17751
17785
|
}
|
|
17752
17786
|
const rCSendCode = yield this._context.setRTCState(this._roomId, report);
|
|
17753
|
-
// @TODO: 删除log
|
|
17754
|
-
console.log('回落上报========');
|
|
17755
17787
|
if (rCSendCode === engine.ErrorCode.SUCCESS) {
|
|
17756
17788
|
return RCSendCode.REPORT_SUCCESS;
|
|
17757
17789
|
}
|
|
@@ -17900,7 +17932,7 @@
|
|
|
17900
17932
|
* 加入房间
|
|
17901
17933
|
*/
|
|
17902
17934
|
sendR1() {
|
|
17903
|
-
const rtcVersion = "5.5.
|
|
17935
|
+
const rtcVersion = "5.5.5-beem-alpha.1";
|
|
17904
17936
|
const imVersion = this._context.getCoreVersion();
|
|
17905
17937
|
const platform = 'web';
|
|
17906
17938
|
const pcName = navigator.platform;
|
|
@@ -17948,8 +17980,6 @@
|
|
|
17948
17980
|
return RCSendCode.REPORT_FAIL;
|
|
17949
17981
|
}
|
|
17950
17982
|
const code = yield this._context.setRTCStateByHttp(logServer, this._runtime, report, reportType);
|
|
17951
|
-
// @TODO: 删除 log
|
|
17952
|
-
console.log('setRTCStateByHttp code', code);
|
|
17953
17983
|
if (code === RCSendCode.REPORT_SUCCESS) {
|
|
17954
17984
|
return RCSendCode.REPORT_SUCCESS;
|
|
17955
17985
|
}
|
|
@@ -18047,10 +18077,10 @@
|
|
|
18047
18077
|
_formatR1Data() {
|
|
18048
18078
|
return {
|
|
18049
18079
|
joinTime: this._context.userJoinTime || 0,
|
|
18050
|
-
rtcVersion: "5.5.
|
|
18080
|
+
rtcVersion: "5.5.5-beem-alpha.1",
|
|
18051
18081
|
imVersion: this._context.getCoreVersion(),
|
|
18052
18082
|
platform: 'web',
|
|
18053
|
-
device:
|
|
18083
|
+
device: navigator.platform,
|
|
18054
18084
|
os: String(STAT_NONE),
|
|
18055
18085
|
browserName: browserInfo.browser,
|
|
18056
18086
|
browserVersion: String(browserInfo.version),
|
|
@@ -18130,6 +18160,7 @@
|
|
|
18130
18160
|
return {
|
|
18131
18161
|
info: {
|
|
18132
18162
|
joinTime: this._context.userJoinTime || 0,
|
|
18163
|
+
receiveTime: Date.now(),
|
|
18133
18164
|
totalBitRate,
|
|
18134
18165
|
appCPUUsage: -1,
|
|
18135
18166
|
systemCPUUsage: -1,
|
|
@@ -18149,8 +18180,6 @@
|
|
|
18149
18180
|
let senderCode = RCSendCode.REPORT_FAIL;
|
|
18150
18181
|
if (data.senders.length) {
|
|
18151
18182
|
const r3Info = this._formatReportData(RCReportType.R3, data);
|
|
18152
|
-
// @TODO: 删除log
|
|
18153
|
-
console.log('send r3Info', r3Info);
|
|
18154
18183
|
senderCode = yield this._send(r3Info, RCReportType.R3);
|
|
18155
18184
|
// 回落 R3
|
|
18156
18185
|
if (senderCode === RCSendCode.REPORT_FAIL) {
|
|
@@ -18160,8 +18189,6 @@
|
|
|
18160
18189
|
let receiverCode = RCSendCode.REPORT_FAIL;
|
|
18161
18190
|
if (data.receivers.length) {
|
|
18162
18191
|
const r4Info = this._formatReportData(RCReportType.R4, data);
|
|
18163
|
-
// @TODO: 删除log
|
|
18164
|
-
console.log('send r4Info', r4Info);
|
|
18165
18192
|
receiverCode = yield this._send(r4Info, RCReportType.R4);
|
|
18166
18193
|
// 回落 R4
|
|
18167
18194
|
if (receiverCode === RCSendCode.REPORT_FAIL) {
|
|
@@ -18181,8 +18208,6 @@
|
|
|
18181
18208
|
var _a;
|
|
18182
18209
|
return __awaiter(this, void 0, void 0, function* () {
|
|
18183
18210
|
const r1Info = this._formatReportData(RCReportType.R1);
|
|
18184
|
-
// @TODO: 删除log
|
|
18185
|
-
console.log('send r1Info', r1Info);
|
|
18186
18211
|
const sendCode = yield this._send(r1Info, RCReportType.R1);
|
|
18187
18212
|
// 回落 R1
|
|
18188
18213
|
if (sendCode === RCSendCode.REPORT_FAIL) {
|
|
@@ -18198,8 +18223,6 @@
|
|
|
18198
18223
|
var _a;
|
|
18199
18224
|
return __awaiter(this, void 0, void 0, function* () {
|
|
18200
18225
|
const r2Info = this._formatReportData(RCReportType.R2, { action, status, trackIds });
|
|
18201
|
-
// @TODO: 删除log
|
|
18202
|
-
console.log('send r2Info', r2Info);
|
|
18203
18226
|
const sendCode = yield this._send(r2Info, RCReportType.R2);
|
|
18204
18227
|
// 回落 R2
|
|
18205
18228
|
if (sendCode === RCSendCode.REPORT_FAIL) {
|
|
@@ -18249,9 +18272,10 @@
|
|
|
18249
18272
|
});
|
|
18250
18273
|
}
|
|
18251
18274
|
startAutoExecute(gap = 1000) {
|
|
18275
|
+
this.stopAutoExecute();
|
|
18252
18276
|
this._timer = setTimeout(() => {
|
|
18253
18277
|
this._audioLevelReport(gap);
|
|
18254
|
-
this.
|
|
18278
|
+
this.startAutoExecute(gap);
|
|
18255
18279
|
}, gap);
|
|
18256
18280
|
}
|
|
18257
18281
|
stopAutoExecute() {
|
|
@@ -18272,10 +18296,7 @@
|
|
|
18272
18296
|
}
|
|
18273
18297
|
}
|
|
18274
18298
|
clearAudioLevelReportTimer() {
|
|
18275
|
-
|
|
18276
|
-
this.stopAutoExecute();
|
|
18277
|
-
this._timer = null;
|
|
18278
|
-
}
|
|
18299
|
+
this.stopAutoExecute();
|
|
18279
18300
|
}
|
|
18280
18301
|
}
|
|
18281
18302
|
|
|
@@ -18285,11 +18306,11 @@
|
|
|
18285
18306
|
exports.RCRTCLiveRole = void 0;
|
|
18286
18307
|
(function (RCRTCLiveRole) {
|
|
18287
18308
|
/**
|
|
18288
|
-
*
|
|
18309
|
+
* 主播降级
|
|
18289
18310
|
*/
|
|
18290
18311
|
RCRTCLiveRole[RCRTCLiveRole["ANCHOR"] = 1] = "ANCHOR";
|
|
18291
18312
|
/**
|
|
18292
|
-
*
|
|
18313
|
+
* 观众升级
|
|
18293
18314
|
*/
|
|
18294
18315
|
RCRTCLiveRole[RCRTCLiveRole["AUDIENCE"] = 2] = "AUDIENCE";
|
|
18295
18316
|
})(exports.RCRTCLiveRole || (exports.RCRTCLiveRole = {}));
|
|
@@ -18659,6 +18680,7 @@
|
|
|
18659
18680
|
this._CDNUris = null;
|
|
18660
18681
|
this._CDNEnable = false;
|
|
18661
18682
|
this._destroyed = false;
|
|
18683
|
+
this._roomStatusVersion = 0;
|
|
18662
18684
|
}
|
|
18663
18685
|
get useMutilPeerC() {
|
|
18664
18686
|
return this.peerMgr.useMutilPeerC;
|
|
@@ -18725,6 +18747,9 @@
|
|
|
18725
18747
|
getCDNUris() {
|
|
18726
18748
|
return this._CDNUris;
|
|
18727
18749
|
}
|
|
18750
|
+
getRoomStatusVersion() {
|
|
18751
|
+
return this._roomStatusVersion;
|
|
18752
|
+
}
|
|
18728
18753
|
}
|
|
18729
18754
|
class Store extends ReadableStore {
|
|
18730
18755
|
_initRemoteTracks() {
|
|
@@ -18745,6 +18770,7 @@
|
|
|
18745
18770
|
initWithRoomData(data) {
|
|
18746
18771
|
this._sessionId = data.sessionId;
|
|
18747
18772
|
this._token = data.token;
|
|
18773
|
+
this._roomStatusVersion = int64ToTimestamp(data.version);
|
|
18748
18774
|
/**
|
|
18749
18775
|
* 解析房间数据
|
|
18750
18776
|
* 1、正常加入房间解析房间数据
|
|
@@ -18800,6 +18826,9 @@
|
|
|
18800
18826
|
resetCollectSubscribeList(collectSubscribeList) {
|
|
18801
18827
|
this._collectSubscribeList.splice(0, this._collectSubscribeList.length, ...collectSubscribeList);
|
|
18802
18828
|
}
|
|
18829
|
+
setRoomStatusVersion(version) {
|
|
18830
|
+
this._roomStatusVersion = int64ToTimestamp(version);
|
|
18831
|
+
}
|
|
18803
18832
|
}
|
|
18804
18833
|
|
|
18805
18834
|
class BaseInvoker {
|
|
@@ -19051,10 +19080,11 @@
|
|
|
19051
19080
|
* 资源发布命令
|
|
19052
19081
|
*/
|
|
19053
19082
|
class JoinRoomCommand extends BaseCommand {
|
|
19054
|
-
constructor(roomId, roomType, joinType, livingType, innerUserDatas, outerUserDatas) {
|
|
19083
|
+
constructor(roomId, roomType, context, joinType, livingType, innerUserDatas, outerUserDatas) {
|
|
19055
19084
|
super();
|
|
19056
19085
|
this.roomId = roomId;
|
|
19057
19086
|
this.roomType = roomType;
|
|
19087
|
+
this.context = context;
|
|
19058
19088
|
this.joinType = joinType;
|
|
19059
19089
|
this.livingType = livingType;
|
|
19060
19090
|
this.innerUserDatas = innerUserDatas;
|
|
@@ -19214,6 +19244,12 @@
|
|
|
19214
19244
|
}
|
|
19215
19245
|
}
|
|
19216
19246
|
|
|
19247
|
+
var RTCApiType;
|
|
19248
|
+
(function (RTCApiType) {
|
|
19249
|
+
RTCApiType[RTCApiType["ROOM"] = 1] = "ROOM";
|
|
19250
|
+
RTCApiType[RTCApiType["PERSON"] = 2] = "PERSON";
|
|
19251
|
+
})(RTCApiType || (RTCApiType = {}));
|
|
19252
|
+
|
|
19217
19253
|
/**
|
|
19218
19254
|
* 北极星上报 R2 参数
|
|
19219
19255
|
*/
|
|
@@ -19248,114 +19284,6 @@
|
|
|
19248
19284
|
RCInnerCDNBroadcast[RCInnerCDNBroadcast["NO_SPREAD"] = -1] = "NO_SPREAD";
|
|
19249
19285
|
})(RCInnerCDNBroadcast || (RCInnerCDNBroadcast = {}));
|
|
19250
19286
|
|
|
19251
|
-
var RTCApiType;
|
|
19252
|
-
(function (RTCApiType) {
|
|
19253
|
-
RTCApiType[RTCApiType["ROOM"] = 1] = "ROOM";
|
|
19254
|
-
RTCApiType[RTCApiType["PERSON"] = 2] = "PERSON";
|
|
19255
|
-
})(RTCApiType || (RTCApiType = {}));
|
|
19256
|
-
|
|
19257
|
-
/**
|
|
19258
|
-
* 获取 exchange 接口的请求体数据
|
|
19259
|
-
* @param subscribeList 订阅清单
|
|
19260
|
-
* @param iceRestart
|
|
19261
|
-
* @param pc RCRTCPeerConnection 实例
|
|
19262
|
-
* @param store: Store
|
|
19263
|
-
*/
|
|
19264
|
-
function createExchangeParams(subscribeList, iceRestart, pc, store) {
|
|
19265
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
19266
|
-
const offer = yield pc.createOffer(iceRestart);
|
|
19267
|
-
const reqBody = {
|
|
19268
|
-
sdp: offer,
|
|
19269
|
-
extend: JSON.stringify({
|
|
19270
|
-
resolutionInfo: pc.getOutboundVideoInfo(),
|
|
19271
|
-
}),
|
|
19272
|
-
subscribeList: subscribeList.filter((item) => {
|
|
19273
|
-
const trackId = item.track.getTrackId();
|
|
19274
|
-
const { userId } = parseTrackId(trackId);
|
|
19275
|
-
const res = store.getResourcesByUserId(userId);
|
|
19276
|
-
if (!res) {
|
|
19277
|
-
return false;
|
|
19278
|
-
}
|
|
19279
|
-
const isInclude = res.filter((item) => trackId === `${item.msid}_${item.mediaType}`).length;
|
|
19280
|
-
return isInclude;
|
|
19281
|
-
}).map((item) => ({
|
|
19282
|
-
simulcast: item.subTiny ? RCStreamType.TINY : RCStreamType.NORMAL,
|
|
19283
|
-
resolution: '',
|
|
19284
|
-
// uri: this._getResourceById(item.track.getTrackId())!.uri
|
|
19285
|
-
uri: store.getPublishedResourceByTrackId(item.track.getTrackId()).uri,
|
|
19286
|
-
})),
|
|
19287
|
-
switchstream: false,
|
|
19288
|
-
// switchstream: !!this._initOptions.autoSwitchStream
|
|
19289
|
-
};
|
|
19290
|
-
return reqBody;
|
|
19291
|
-
});
|
|
19292
|
-
}
|
|
19293
|
-
/**
|
|
19294
|
-
* 扩散 cdn_uris 资源
|
|
19295
|
-
*/
|
|
19296
|
-
function spreadCDNInfo(context, roomId, CDNUris) {
|
|
19297
|
-
var _a, _b;
|
|
19298
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
19299
|
-
const code = yield context.setRTCCDNUris(roomId, RCRTCMessageType.TOTAL_CONTENT_RESOURCE, JSON.stringify([CDNUris]));
|
|
19300
|
-
if (code !== engine.ErrorCode.SUCCESS) {
|
|
19301
|
-
(_a = context === null || context === void 0 ? void 0 : context.logger) === null || _a === void 0 ? void 0 : _a.error(RCLoggerTag.L_OLD_DAILY_RECORD_O, `spreadCDNInfo failed -> code: ${code}`);
|
|
19302
|
-
return { code: exports.RCRTCCode.SIGNAL_ERROR };
|
|
19303
|
-
}
|
|
19304
|
-
(_b = context === null || context === void 0 ? void 0 : context.logger) === null || _b === void 0 ? void 0 : _b.info(RCLoggerTag.L_OLD_DAILY_RECORD_O, 'spreadCDNInfo succeed');
|
|
19305
|
-
return { code: exports.RCRTCCode.SUCCESS };
|
|
19306
|
-
});
|
|
19307
|
-
}
|
|
19308
|
-
/**
|
|
19309
|
-
* 给房间设置 CDN 数据
|
|
19310
|
-
*/
|
|
19311
|
-
function setRoomCDNInfo(context, roomId, CDNUris) {
|
|
19312
|
-
var _a, _b;
|
|
19313
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
19314
|
-
const code = yield context.setRTCData(roomId, 'cdn_uris', JSON.stringify([CDNUris]), true, RTCApiType.ROOM);
|
|
19315
|
-
if (code !== engine.ErrorCode.SUCCESS) {
|
|
19316
|
-
(_a = context === null || context === void 0 ? void 0 : context.logger) === null || _a === void 0 ? void 0 : _a.error(RCLoggerTag.L_OLD_DAILY_RECORD_O, `setRoomCDNInfo failed -> code: ${code}`);
|
|
19317
|
-
return { code: exports.RCRTCCode.SIGNAL_ERROR };
|
|
19318
|
-
}
|
|
19319
|
-
(_b = context === null || context === void 0 ? void 0 : context.logger) === null || _b === void 0 ? void 0 : _b.info(RCLoggerTag.L_OLD_DAILY_RECORD_O, 'setRoomCDNInfo succeed');
|
|
19320
|
-
return { code: exports.RCRTCCode.SUCCESS };
|
|
19321
|
-
});
|
|
19322
|
-
}
|
|
19323
|
-
/**
|
|
19324
|
-
* 开启、停用 CDN 推资源后发信令
|
|
19325
|
-
*/
|
|
19326
|
-
function sendCDNInfoSignal(store) {
|
|
19327
|
-
var _a, _b, _c, _d, _e, _f;
|
|
19328
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
19329
|
-
const { context } = store;
|
|
19330
|
-
const { roomId } = store;
|
|
19331
|
-
// eslint-disable-next-line
|
|
19332
|
-
const CDNUris = Object.assign({}, store.getCDNUris(), { enableInnerCDN: store.getCDNEnable() });
|
|
19333
|
-
(_b = (_a = store.context) === null || _a === void 0 ? void 0 : _a.logger) === null || _b === void 0 ? void 0 : _b.info(RCLoggerTag.L_LIVING_ROOM_SPREAD_CDN_INFO_T, JSON.stringify({
|
|
19334
|
-
roomId,
|
|
19335
|
-
CDNUris,
|
|
19336
|
-
}));
|
|
19337
|
-
const resCodeArr = yield Promise.all([
|
|
19338
|
-
spreadCDNInfo(context, roomId, CDNUris),
|
|
19339
|
-
setRoomCDNInfo(context, roomId, CDNUris),
|
|
19340
|
-
]);
|
|
19341
|
-
const isSuccess = resCodeArr.every((item) => item.code === exports.RCRTCCode.SUCCESS);
|
|
19342
|
-
if (isSuccess) {
|
|
19343
|
-
(_d = (_c = store.context) === null || _c === void 0 ? void 0 : _c.logger) === null || _d === void 0 ? void 0 : _d.info(RCLoggerTag.L_LIVING_ROOM_SPREAD_CDN_INFO_R, JSON.stringify({
|
|
19344
|
-
status: RCLoggerStatus.SUCCESSED,
|
|
19345
|
-
CDNUris,
|
|
19346
|
-
}));
|
|
19347
|
-
}
|
|
19348
|
-
else {
|
|
19349
|
-
(_f = (_e = store.context) === null || _e === void 0 ? void 0 : _e.logger) === null || _f === void 0 ? void 0 : _f.error(RCLoggerTag.L_LIVING_ROOM_SPREAD_CDN_INFO_R, JSON.stringify({
|
|
19350
|
-
status: RCLoggerStatus.FAILED,
|
|
19351
|
-
code: exports.RCRTCCode.SIGNAL_ERROR,
|
|
19352
|
-
msg: 'signal error',
|
|
19353
|
-
}));
|
|
19354
|
-
}
|
|
19355
|
-
return isSuccess ? { code: exports.RCRTCCode.SUCCESS } : { code: exports.RCRTCCode.SIGNAL_ERROR };
|
|
19356
|
-
});
|
|
19357
|
-
}
|
|
19358
|
-
|
|
19359
19287
|
class ExchangeCommand extends BaseCommand {
|
|
19360
19288
|
constructor(headers, reqBody) {
|
|
19361
19289
|
super();
|
|
@@ -19773,101 +19701,6 @@
|
|
|
19773
19701
|
}
|
|
19774
19702
|
}
|
|
19775
19703
|
|
|
19776
|
-
class ParseUserStateCommand extends BaseCommand {
|
|
19777
|
-
constructor(msgContent, subhook) {
|
|
19778
|
-
super();
|
|
19779
|
-
this.msgContent = msgContent;
|
|
19780
|
-
this.subhook = subhook;
|
|
19781
|
-
}
|
|
19782
|
-
get priority() {
|
|
19783
|
-
return CommandPriority.NORMAL;
|
|
19784
|
-
}
|
|
19785
|
-
execute(store, invoker) {
|
|
19786
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
19787
|
-
/**
|
|
19788
|
-
* 主动加入房间
|
|
19789
|
-
*/
|
|
19790
|
-
const joined = [];
|
|
19791
|
-
/**
|
|
19792
|
-
* 主动退出房间
|
|
19793
|
-
*/
|
|
19794
|
-
const left = [];
|
|
19795
|
-
/**
|
|
19796
|
-
* 观众升级为主播加入房间
|
|
19797
|
-
*/
|
|
19798
|
-
const upgrade = [];
|
|
19799
|
-
/**
|
|
19800
|
-
* 主播降级为观众退出房间
|
|
19801
|
-
*/
|
|
19802
|
-
const downgrade = [];
|
|
19803
|
-
const res = {
|
|
19804
|
-
joined, left, upgrade, downgrade,
|
|
19805
|
-
};
|
|
19806
|
-
const { users } = this.msgContent;
|
|
19807
|
-
if (users.length === 0) {
|
|
19808
|
-
return res;
|
|
19809
|
-
}
|
|
19810
|
-
/**
|
|
19811
|
-
* 过滤掉副房间身份的人员
|
|
19812
|
-
*/
|
|
19813
|
-
for (let index = 0; index < users.length; index++) {
|
|
19814
|
-
const user = users[index];
|
|
19815
|
-
// 加入房间时
|
|
19816
|
-
if (user.extra && user.extra.roomId !== store.roomId) {
|
|
19817
|
-
// TODO return 存疑
|
|
19818
|
-
return res;
|
|
19819
|
-
}
|
|
19820
|
-
// 退出房间时
|
|
19821
|
-
if (+user.state === 1 && !store.getRemoteUserIds().includes(user.userId)) {
|
|
19822
|
-
// TODO return 存疑
|
|
19823
|
-
return res;
|
|
19824
|
-
}
|
|
19825
|
-
}
|
|
19826
|
-
users.forEach((item) => {
|
|
19827
|
-
var _a, _b, _c, _d;
|
|
19828
|
-
const { userId } = item;
|
|
19829
|
-
if (+item.state === 0) {
|
|
19830
|
-
(_b = (_a = store === null || store === void 0 ? void 0 : store.context) === null || _a === void 0 ? void 0 : _a.logger) === null || _b === void 0 ? void 0 : _b.info(RCLoggerTag.L_OLD_DAILY_RECORD_O, `user joined -> ${userId}`);
|
|
19831
|
-
// 对端 im 重连之后调加入房间信令获取最新数据,服务会给本端下发“对端加入房间”的消息,本端内存已包含对端人员,所以需过滤掉
|
|
19832
|
-
const resArr = store.getResourcesByUserId(userId);
|
|
19833
|
-
if (!resArr) {
|
|
19834
|
-
item.switchRoleType ? upgrade.push(userId) : joined.push(userId);
|
|
19835
|
-
}
|
|
19836
|
-
store.setResourcesByUserId(userId, resArr || []);
|
|
19837
|
-
}
|
|
19838
|
-
else {
|
|
19839
|
-
(_d = (_c = store.context) === null || _c === void 0 ? void 0 : _c.logger) === null || _d === void 0 ? void 0 : _d.info(RCLoggerTag.L_OLD_DAILY_RECORD_O, `user left -> ${userId}`);
|
|
19840
|
-
item.switchRoleType ? downgrade.push(userId) : left.push(userId);
|
|
19841
|
-
}
|
|
19842
|
-
});
|
|
19843
|
-
const allLeft = [...left, ...downgrade];
|
|
19844
|
-
// 用户离开房间时,自动退订对方资源
|
|
19845
|
-
if (allLeft.length) {
|
|
19846
|
-
const tracks = [];
|
|
19847
|
-
const userIds = [];
|
|
19848
|
-
allLeft.forEach((userId) => {
|
|
19849
|
-
tracks.push(...store.getRemoteTracksByUserId(userId));
|
|
19850
|
-
// 先暂存待删用户,因当前异步队列中可能存在等待中的待处理任务,需要当前房间数据状态
|
|
19851
|
-
// delete this._roomResources[userId]
|
|
19852
|
-
userIds.push(userId);
|
|
19853
|
-
});
|
|
19854
|
-
if (tracks.length) {
|
|
19855
|
-
// await this.unsubscribe(tracks)
|
|
19856
|
-
yield new UnsubscribeCommand(tracks, this.subhook).execute(store, invoker);
|
|
19857
|
-
// tracks.forEach((item) => delete this._remoteTracks[item.getTrackId()])
|
|
19858
|
-
tracks.forEach((item) => store.removeRemoteTrack(item.getTrackId()));
|
|
19859
|
-
}
|
|
19860
|
-
// 等待队列执行完成后清除内存数据
|
|
19861
|
-
if (userIds.length) {
|
|
19862
|
-
// userIds.forEach(userId => delete this._roomResources[userId])
|
|
19863
|
-
userIds.forEach((userId) => store.removeResourcesByUserId(userId));
|
|
19864
|
-
}
|
|
19865
|
-
}
|
|
19866
|
-
return res;
|
|
19867
|
-
});
|
|
19868
|
-
}
|
|
19869
|
-
}
|
|
19870
|
-
|
|
19871
19704
|
class OnRemoteUserUnpubCommand extends BaseCommand {
|
|
19872
19705
|
constructor(subhook, tracks, onTrackUnpublish) {
|
|
19873
19706
|
super();
|
|
@@ -19891,40 +19724,429 @@
|
|
|
19891
19724
|
}
|
|
19892
19725
|
}
|
|
19893
19726
|
|
|
19894
|
-
|
|
19895
|
-
|
|
19896
|
-
|
|
19897
|
-
|
|
19898
|
-
|
|
19899
|
-
|
|
19900
|
-
|
|
19901
|
-
|
|
19902
|
-
|
|
19903
|
-
|
|
19904
|
-
|
|
19905
|
-
|
|
19906
|
-
|
|
19907
|
-
|
|
19908
|
-
|
|
19909
|
-
|
|
19910
|
-
|
|
19911
|
-
|
|
19912
|
-
|
|
19913
|
-
|
|
19914
|
-
|
|
19915
|
-
|
|
19916
|
-
|
|
19917
|
-
|
|
19918
|
-
|
|
19919
|
-
|
|
19920
|
-
|
|
19921
|
-
|
|
19922
|
-
|
|
19923
|
-
|
|
19924
|
-
|
|
19925
|
-
|
|
19926
|
-
|
|
19927
|
-
|
|
19727
|
+
/**
|
|
19728
|
+
* 获取 exchange 接口的请求体数据
|
|
19729
|
+
* @param subscribeList 订阅清单
|
|
19730
|
+
* @param iceRestart
|
|
19731
|
+
* @param pc RCRTCPeerConnection 实例
|
|
19732
|
+
* @param store: Store
|
|
19733
|
+
*/
|
|
19734
|
+
function createExchangeParams(subscribeList, iceRestart, pc, store) {
|
|
19735
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
19736
|
+
const offer = yield pc.createOffer(iceRestart);
|
|
19737
|
+
const reqBody = {
|
|
19738
|
+
sdp: offer,
|
|
19739
|
+
extend: JSON.stringify({
|
|
19740
|
+
resolutionInfo: pc.getOutboundVideoInfo(),
|
|
19741
|
+
}),
|
|
19742
|
+
subscribeList: subscribeList.filter((item) => {
|
|
19743
|
+
const trackId = item.track.getTrackId();
|
|
19744
|
+
const { userId } = parseTrackId(trackId);
|
|
19745
|
+
const res = store.getResourcesByUserId(userId);
|
|
19746
|
+
if (!res) {
|
|
19747
|
+
return false;
|
|
19748
|
+
}
|
|
19749
|
+
const isInclude = res.filter((item) => trackId === `${item.msid}_${item.mediaType}`).length;
|
|
19750
|
+
return isInclude;
|
|
19751
|
+
}).map((item) => ({
|
|
19752
|
+
simulcast: item.subTiny ? RCStreamType.TINY : RCStreamType.NORMAL,
|
|
19753
|
+
resolution: '',
|
|
19754
|
+
// uri: this._getResourceById(item.track.getTrackId())!.uri
|
|
19755
|
+
uri: store.getPublishedResourceByTrackId(item.track.getTrackId()).uri,
|
|
19756
|
+
})),
|
|
19757
|
+
switchstream: false,
|
|
19758
|
+
// switchstream: !!this._initOptions.autoSwitchStream
|
|
19759
|
+
};
|
|
19760
|
+
return reqBody;
|
|
19761
|
+
});
|
|
19762
|
+
}
|
|
19763
|
+
/**
|
|
19764
|
+
* 扩散 cdn_uris 资源
|
|
19765
|
+
*/
|
|
19766
|
+
function spreadCDNInfo(context, roomId, CDNUris) {
|
|
19767
|
+
var _a, _b;
|
|
19768
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
19769
|
+
const code = yield context.setRTCCDNUris(roomId, RCRTCMessageType.TOTAL_CONTENT_RESOURCE, JSON.stringify([CDNUris]));
|
|
19770
|
+
if (code !== engine.ErrorCode.SUCCESS) {
|
|
19771
|
+
(_a = context === null || context === void 0 ? void 0 : context.logger) === null || _a === void 0 ? void 0 : _a.error(RCLoggerTag.L_OLD_DAILY_RECORD_O, `spreadCDNInfo failed -> code: ${code}`);
|
|
19772
|
+
return { code: exports.RCRTCCode.SIGNAL_ERROR };
|
|
19773
|
+
}
|
|
19774
|
+
(_b = context === null || context === void 0 ? void 0 : context.logger) === null || _b === void 0 ? void 0 : _b.info(RCLoggerTag.L_OLD_DAILY_RECORD_O, 'spreadCDNInfo succeed');
|
|
19775
|
+
return { code: exports.RCRTCCode.SUCCESS };
|
|
19776
|
+
});
|
|
19777
|
+
}
|
|
19778
|
+
/**
|
|
19779
|
+
* 给房间设置 CDN 数据
|
|
19780
|
+
*/
|
|
19781
|
+
function setRoomCDNInfo(context, roomId, CDNUris) {
|
|
19782
|
+
var _a, _b;
|
|
19783
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
19784
|
+
const code = yield context.setRTCData(roomId, 'cdn_uris', JSON.stringify([CDNUris]), true, RTCApiType.ROOM);
|
|
19785
|
+
if (code !== engine.ErrorCode.SUCCESS) {
|
|
19786
|
+
(_a = context === null || context === void 0 ? void 0 : context.logger) === null || _a === void 0 ? void 0 : _a.error(RCLoggerTag.L_OLD_DAILY_RECORD_O, `setRoomCDNInfo failed -> code: ${code}`);
|
|
19787
|
+
return { code: exports.RCRTCCode.SIGNAL_ERROR };
|
|
19788
|
+
}
|
|
19789
|
+
(_b = context === null || context === void 0 ? void 0 : context.logger) === null || _b === void 0 ? void 0 : _b.info(RCLoggerTag.L_OLD_DAILY_RECORD_O, 'setRoomCDNInfo succeed');
|
|
19790
|
+
return { code: exports.RCRTCCode.SUCCESS };
|
|
19791
|
+
});
|
|
19792
|
+
}
|
|
19793
|
+
/**
|
|
19794
|
+
* 开启、停用 CDN 推资源后发信令
|
|
19795
|
+
*/
|
|
19796
|
+
function sendCDNInfoSignal(store) {
|
|
19797
|
+
var _a, _b, _c, _d, _e, _f;
|
|
19798
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
19799
|
+
const { context } = store;
|
|
19800
|
+
const { roomId } = store;
|
|
19801
|
+
// eslint-disable-next-line
|
|
19802
|
+
const CDNUris = Object.assign({}, store.getCDNUris(), { enableInnerCDN: store.getCDNEnable() });
|
|
19803
|
+
(_b = (_a = store.context) === null || _a === void 0 ? void 0 : _a.logger) === null || _b === void 0 ? void 0 : _b.info(RCLoggerTag.L_LIVING_ROOM_SPREAD_CDN_INFO_T, JSON.stringify({
|
|
19804
|
+
roomId,
|
|
19805
|
+
CDNUris,
|
|
19806
|
+
}));
|
|
19807
|
+
const resCodeArr = yield Promise.all([
|
|
19808
|
+
spreadCDNInfo(context, roomId, CDNUris),
|
|
19809
|
+
setRoomCDNInfo(context, roomId, CDNUris),
|
|
19810
|
+
]);
|
|
19811
|
+
const isSuccess = resCodeArr.every((item) => item.code === exports.RCRTCCode.SUCCESS);
|
|
19812
|
+
if (isSuccess) {
|
|
19813
|
+
(_d = (_c = store.context) === null || _c === void 0 ? void 0 : _c.logger) === null || _d === void 0 ? void 0 : _d.info(RCLoggerTag.L_LIVING_ROOM_SPREAD_CDN_INFO_R, JSON.stringify({
|
|
19814
|
+
status: RCLoggerStatus.SUCCESSED,
|
|
19815
|
+
CDNUris,
|
|
19816
|
+
}));
|
|
19817
|
+
}
|
|
19818
|
+
else {
|
|
19819
|
+
(_f = (_e = store.context) === null || _e === void 0 ? void 0 : _e.logger) === null || _f === void 0 ? void 0 : _f.error(RCLoggerTag.L_LIVING_ROOM_SPREAD_CDN_INFO_R, JSON.stringify({
|
|
19820
|
+
status: RCLoggerStatus.FAILED,
|
|
19821
|
+
code: exports.RCRTCCode.SIGNAL_ERROR,
|
|
19822
|
+
msg: 'signal error',
|
|
19823
|
+
}));
|
|
19824
|
+
}
|
|
19825
|
+
return isSuccess ? { code: exports.RCRTCCode.SUCCESS } : { code: exports.RCRTCCode.SIGNAL_ERROR };
|
|
19826
|
+
});
|
|
19827
|
+
}
|
|
19828
|
+
/**
|
|
19829
|
+
* 处理房间全量数据
|
|
19830
|
+
* 重连或
|
|
19831
|
+
*/
|
|
19832
|
+
function handleFullRoomData(usersData, store, callbacks, invoker, subhook, CDNUris) {
|
|
19833
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
19834
|
+
const { roomId, crtUserId, roomMode } = store;
|
|
19835
|
+
// 查找新加入人员
|
|
19836
|
+
const joinedUserIds = [];
|
|
19837
|
+
// 新发布资源
|
|
19838
|
+
const published = {};
|
|
19839
|
+
// 取消发布的资源
|
|
19840
|
+
const unpublished = {};
|
|
19841
|
+
// 状态变更的资源
|
|
19842
|
+
const modified = {};
|
|
19843
|
+
// 当前最新的房间资源数据
|
|
19844
|
+
const roomData = parseRoomData(usersData, roomId);
|
|
19845
|
+
const nowUserIds = Object.keys(roomData);
|
|
19846
|
+
const prevUserIds = store.getAllUserIds();
|
|
19847
|
+
for (let i = nowUserIds.length - 1; i >= 0; i -= 1) {
|
|
19848
|
+
const userId = nowUserIds[i];
|
|
19849
|
+
const index = prevUserIds.indexOf(userId);
|
|
19850
|
+
if (index === -1) {
|
|
19851
|
+
// 新增人员
|
|
19852
|
+
joinedUserIds.push(userId);
|
|
19853
|
+
// 新增人员发布的资源
|
|
19854
|
+
published[userId] = deepCopyResources(roomData[userId]);
|
|
19855
|
+
continue;
|
|
19856
|
+
}
|
|
19857
|
+
// 房间缓存中的已发布资源
|
|
19858
|
+
const prevResources = store.getResourcesByUserId(userId);
|
|
19859
|
+
// 当前资源
|
|
19860
|
+
const nowResources = roomData[userId];
|
|
19861
|
+
// 资源比对
|
|
19862
|
+
const { publishedList, modifiedList, unpublishedList } = diffPublishResources(prevResources, nowResources, true);
|
|
19863
|
+
published[userId] = deepCopyResources(publishedList);
|
|
19864
|
+
unpublished[userId] = deepCopyResources(unpublishedList);
|
|
19865
|
+
modified[userId] = deepCopyResources(modifiedList);
|
|
19866
|
+
// 从之前的人员列表中删除已存在人员,剩余人员为已退出人员
|
|
19867
|
+
prevUserIds.splice(index, 1);
|
|
19868
|
+
}
|
|
19869
|
+
// 更新缓存资源
|
|
19870
|
+
prevUserIds.length && prevUserIds.forEach((userId) => {
|
|
19871
|
+
store.removeResourcesByUserId(userId);
|
|
19872
|
+
});
|
|
19873
|
+
store.assignRoomData(roomData);
|
|
19874
|
+
// 通知人员退出
|
|
19875
|
+
if (prevUserIds.length) {
|
|
19876
|
+
yield dealLeftUsers(prevUserIds, store, subhook, invoker);
|
|
19877
|
+
callbacks.onUserLeave(prevUserIds);
|
|
19878
|
+
}
|
|
19879
|
+
// 通知人员加入
|
|
19880
|
+
joinedUserIds.length && callbacks.onUserJoin(joinedUserIds);
|
|
19881
|
+
/**
|
|
19882
|
+
* 资源取消发布
|
|
19883
|
+
* im 重连加入房间后,服务返回的自己资源为空时,上抛资源被取消发布需过滤掉本端资源
|
|
19884
|
+
*/
|
|
19885
|
+
for (const userId in unpublished) {
|
|
19886
|
+
if (userId === crtUserId) {
|
|
19887
|
+
continue;
|
|
19888
|
+
}
|
|
19889
|
+
const resources = unpublished[userId];
|
|
19890
|
+
if (resources.length) {
|
|
19891
|
+
const tracks = resources.map((item) => store.getRemoteTrack(getTrackId(item)));
|
|
19892
|
+
yield new OnRemoteUserUnpubCommand(subhook, tracks, callbacks.onTrackUnpublish).execute(store, invoker);
|
|
19893
|
+
}
|
|
19894
|
+
}
|
|
19895
|
+
// 新发布资源
|
|
19896
|
+
Object.keys(published).forEach((userId) => {
|
|
19897
|
+
const resources = published[userId];
|
|
19898
|
+
if (resources.length === 0) {
|
|
19899
|
+
return;
|
|
19900
|
+
}
|
|
19901
|
+
const tracks = resources.map((item) => {
|
|
19902
|
+
const trackId = getTrackId(item);
|
|
19903
|
+
const { userId, tag, mediaType } = parseTrackId(trackId);
|
|
19904
|
+
const track = mediaType === exports.RCMediaType.AUDIO_ONLY ? new RCRemoteAudioTrack(tag, userId) : new RCRemoteVideoTrack(tag, userId);
|
|
19905
|
+
store.addRemoteTrack(track);
|
|
19906
|
+
track.__innerSetRemoteMuted(item.state === 0);
|
|
19907
|
+
return track;
|
|
19908
|
+
});
|
|
19909
|
+
callbacks.onTrackPublish(tracks);
|
|
19910
|
+
});
|
|
19911
|
+
// 资源状态变更
|
|
19912
|
+
Object.keys(modified).forEach((userId) => {
|
|
19913
|
+
const resources = modified[userId];
|
|
19914
|
+
// 音频与视频区分
|
|
19915
|
+
resources.forEach((item) => {
|
|
19916
|
+
const trackId = getTrackId(item);
|
|
19917
|
+
const rTrack = store.getRemoteTrack(trackId);
|
|
19918
|
+
rTrack.__innerSetRemoteMuted(item.state === 0);
|
|
19919
|
+
rTrack.isAudioTrack() ? callbacks.onAudioMuteChange(rTrack) : callbacks.onVideoMuteChange(rTrack);
|
|
19920
|
+
});
|
|
19921
|
+
});
|
|
19922
|
+
/**
|
|
19923
|
+
* 处理直播模式的 cdn_uris 数据
|
|
19924
|
+
*/
|
|
19925
|
+
if (roomMode === engine.RTCMode.LIVE) {
|
|
19926
|
+
executeInLivingRoom(callbacks, store, CDNUris);
|
|
19927
|
+
}
|
|
19928
|
+
});
|
|
19929
|
+
}
|
|
19930
|
+
/**
|
|
19931
|
+
* 获取到新的全量数据后,需更新内存中的 CDN 数据
|
|
19932
|
+
* 判断房间内 CDN 状态是否和内存数据一致,不一致时需通知到客户端
|
|
19933
|
+
*/
|
|
19934
|
+
function executeInLivingRoom(callbacks, store, CDNUris) {
|
|
19935
|
+
var _a, _b, _c;
|
|
19936
|
+
if (!CDNUris) {
|
|
19937
|
+
(_b = (_a = store.context) === null || _a === void 0 ? void 0 : _a.logger) === null || _b === void 0 ? void 0 : _b.info(RCLoggerTag.L_LIVING_ROOM_RECONNECTED_R, JSON.stringify({
|
|
19938
|
+
status: RCLoggerStatus.FAILED,
|
|
19939
|
+
code: '',
|
|
19940
|
+
msg: 'cdn_uris not found',
|
|
19941
|
+
}));
|
|
19942
|
+
return;
|
|
19943
|
+
}
|
|
19944
|
+
const parseCDNUris = JSON.parse(CDNUris);
|
|
19945
|
+
const changed = ((_c = store.getCDNUris()) === null || _c === void 0 ? void 0 : _c.enableInnerCDN) !== parseCDNUris.enableInnerCDN;
|
|
19946
|
+
store.setCDNUris(parseCDNUris);
|
|
19947
|
+
if (changed) {
|
|
19948
|
+
callbacks.onCDNEnableChange(parseCDNUris.enableInnerCDN);
|
|
19949
|
+
}
|
|
19950
|
+
}
|
|
19951
|
+
/**
|
|
19952
|
+
* 处理离开房间的人
|
|
19953
|
+
* 需取消订阅离开人员的资源、更新 store 数据
|
|
19954
|
+
* @param leftUsers 离开的人员 userId 列表
|
|
19955
|
+
*/
|
|
19956
|
+
function dealLeftUsers(leftUsers, store, subhook, invoker) {
|
|
19957
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
19958
|
+
const tracks = [];
|
|
19959
|
+
const userIds = [];
|
|
19960
|
+
leftUsers.forEach((userId) => {
|
|
19961
|
+
tracks.push(...store.getRemoteTracksByUserId(userId));
|
|
19962
|
+
// 先暂存待删用户,因当前异步队列中可能存在等待中的待处理任务,需要当前房间数据状态
|
|
19963
|
+
userIds.push(userId);
|
|
19964
|
+
});
|
|
19965
|
+
if (tracks.length) {
|
|
19966
|
+
yield new UnsubscribeCommand(tracks, subhook).execute(store, invoker);
|
|
19967
|
+
tracks.forEach((item) => store.removeRemoteTrack(item.getTrackId()));
|
|
19968
|
+
}
|
|
19969
|
+
// 等待队列执行完成后清除内存数据
|
|
19970
|
+
if (userIds.length) {
|
|
19971
|
+
userIds.forEach((userId) => store.removeResourcesByUserId(userId));
|
|
19972
|
+
}
|
|
19973
|
+
});
|
|
19974
|
+
}
|
|
19975
|
+
/**
|
|
19976
|
+
* 通知拉取到的增量房间数据格式为 IRoomStatus
|
|
19977
|
+
* 把 IRoomStatus 转化为通用处理人员方法(_stateHandle)需要的数据
|
|
19978
|
+
*/
|
|
19979
|
+
function transPullDataToStateMsgCont(data) {
|
|
19980
|
+
const { userId, extra, event: state, switchRoleType, } = data;
|
|
19981
|
+
const content = {
|
|
19982
|
+
users: [{
|
|
19983
|
+
userId,
|
|
19984
|
+
extra,
|
|
19985
|
+
state,
|
|
19986
|
+
switchRoleType,
|
|
19987
|
+
}],
|
|
19988
|
+
};
|
|
19989
|
+
return content;
|
|
19990
|
+
}
|
|
19991
|
+
/**
|
|
19992
|
+
* 通知拉取到的增量房间数据格式为 IRoomStatus
|
|
19993
|
+
* 把 IRoomStatus 转化为通用解析资源方法(ParseRemoteResCommand)需要的数据
|
|
19994
|
+
*/
|
|
19995
|
+
function transPullDataToResMsgCont(data) {
|
|
19996
|
+
var _a, _b;
|
|
19997
|
+
const { userId, userData } = data;
|
|
19998
|
+
const uris = (_a = userData.filter((item) => (item.key === 'uris'))[0]) === null || _a === void 0 ? void 0 : _a.value;
|
|
19999
|
+
const cdnUris = (_b = userData.filter((item) => (item.key === 'cdn_uris'))[0]) === null || _b === void 0 ? void 0 : _b.value;
|
|
20000
|
+
return {
|
|
20001
|
+
userId,
|
|
20002
|
+
content: {
|
|
20003
|
+
uris: uris && JSON.parse(uris),
|
|
20004
|
+
cdn_uris: cdnUris && JSON.parse(cdnUris),
|
|
20005
|
+
},
|
|
20006
|
+
};
|
|
20007
|
+
}
|
|
20008
|
+
/**
|
|
20009
|
+
* 通知拉取到的全量房间数据格式为 IPullRTCRoomUsersData
|
|
20010
|
+
* 把 IPullRTCRoomUsersData 转化为通用解析所有房间数据方法(parseRoomData)需要的数据
|
|
20011
|
+
*/
|
|
20012
|
+
function transPullFullUsersData(usersData) {
|
|
20013
|
+
const urisData = {
|
|
20014
|
+
users: {},
|
|
20015
|
+
};
|
|
20016
|
+
let CDNUris = '';
|
|
20017
|
+
usersData.forEach((item) => {
|
|
20018
|
+
var _a, _b;
|
|
20019
|
+
const { userId, userData } = item;
|
|
20020
|
+
urisData.users[userId] = {};
|
|
20021
|
+
const uris = (_a = userData.filter((item) => item.key === 'uris')[0]) === null || _a === void 0 ? void 0 : _a.value;
|
|
20022
|
+
const newCDNUris = (_b = userData.filter((item) => item.key === 'cdn_uris')[0]) === null || _b === void 0 ? void 0 : _b.value;
|
|
20023
|
+
CDNUris = newCDNUris || CDNUris;
|
|
20024
|
+
urisData.users[userId] = { uris };
|
|
20025
|
+
});
|
|
20026
|
+
return {
|
|
20027
|
+
urisData,
|
|
20028
|
+
CDNUris: CDNUris && JSON.stringify(JSON.parse(CDNUris)[0]),
|
|
20029
|
+
};
|
|
20030
|
+
}
|
|
20031
|
+
|
|
20032
|
+
class ParseUserStateCommand extends BaseCommand {
|
|
20033
|
+
constructor(msgContent, subhook) {
|
|
20034
|
+
super();
|
|
20035
|
+
this.msgContent = msgContent;
|
|
20036
|
+
this.subhook = subhook;
|
|
20037
|
+
}
|
|
20038
|
+
get priority() {
|
|
20039
|
+
return CommandPriority.NORMAL;
|
|
20040
|
+
}
|
|
20041
|
+
execute(store, invoker) {
|
|
20042
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
20043
|
+
/**
|
|
20044
|
+
* 主动加入房间
|
|
20045
|
+
*/
|
|
20046
|
+
const joined = [];
|
|
20047
|
+
/**
|
|
20048
|
+
* 主动退出房间
|
|
20049
|
+
*/
|
|
20050
|
+
const left = [];
|
|
20051
|
+
/**
|
|
20052
|
+
* 观众升级为主播加入房间
|
|
20053
|
+
*/
|
|
20054
|
+
const upgrade = [];
|
|
20055
|
+
/**
|
|
20056
|
+
* 主播降级为观众退出房间
|
|
20057
|
+
*/
|
|
20058
|
+
const downgrade = [];
|
|
20059
|
+
const res = {
|
|
20060
|
+
joined, left, upgrade, downgrade,
|
|
20061
|
+
};
|
|
20062
|
+
const { users } = this.msgContent;
|
|
20063
|
+
if (users.length === 0) {
|
|
20064
|
+
return res;
|
|
20065
|
+
}
|
|
20066
|
+
/**
|
|
20067
|
+
* 过滤掉副房间身份的人员
|
|
20068
|
+
*/
|
|
20069
|
+
for (let index = 0; index < users.length; index++) {
|
|
20070
|
+
const user = users[index];
|
|
20071
|
+
// 加入房间时
|
|
20072
|
+
if (user.extra && user.extra.roomId !== store.roomId) {
|
|
20073
|
+
// TODO return 存疑
|
|
20074
|
+
return res;
|
|
20075
|
+
}
|
|
20076
|
+
// 退出房间时
|
|
20077
|
+
if (Number(user.state) === 1 && !store.getRemoteUserIds().includes(user.userId)) {
|
|
20078
|
+
// TODO return 存疑
|
|
20079
|
+
return res;
|
|
20080
|
+
}
|
|
20081
|
+
}
|
|
20082
|
+
users.forEach((item) => {
|
|
20083
|
+
var _a, _b, _c, _d;
|
|
20084
|
+
const { userId } = item;
|
|
20085
|
+
if (Number(item.state) === 0) {
|
|
20086
|
+
(_b = (_a = store === null || store === void 0 ? void 0 : store.context) === null || _a === void 0 ? void 0 : _a.logger) === null || _b === void 0 ? void 0 : _b.info(RCLoggerTag.L_OLD_DAILY_RECORD_O, `user joined -> ${userId}`);
|
|
20087
|
+
// 对端 im 重连之后调加入房间信令获取最新数据,服务会给本端下发“对端加入房间”的消息,本端内存已包含对端人员,所以需过滤掉
|
|
20088
|
+
const resArr = store.getResourcesByUserId(userId);
|
|
20089
|
+
if (!resArr) {
|
|
20090
|
+
item.switchRoleType ? upgrade.push(userId) : joined.push(userId);
|
|
20091
|
+
}
|
|
20092
|
+
store.setResourcesByUserId(userId, resArr || []);
|
|
20093
|
+
}
|
|
20094
|
+
else {
|
|
20095
|
+
(_d = (_c = store.context) === null || _c === void 0 ? void 0 : _c.logger) === null || _d === void 0 ? void 0 : _d.info(RCLoggerTag.L_OLD_DAILY_RECORD_O, `user left -> ${userId}`);
|
|
20096
|
+
item.switchRoleType ? downgrade.push(userId) : left.push(userId);
|
|
20097
|
+
}
|
|
20098
|
+
});
|
|
20099
|
+
const allLeft = [...left, ...downgrade];
|
|
20100
|
+
// 用户离开房间时,自动退订对方资源
|
|
20101
|
+
if (allLeft.length) {
|
|
20102
|
+
yield dealLeftUsers(allLeft, store, this.subhook, invoker);
|
|
20103
|
+
}
|
|
20104
|
+
return res;
|
|
20105
|
+
});
|
|
20106
|
+
}
|
|
20107
|
+
}
|
|
20108
|
+
|
|
20109
|
+
class ParseRemoteResCommand extends BaseCommand {
|
|
20110
|
+
constructor(msgContent, messageType, senderId, subhook, callback,
|
|
20111
|
+
/**
|
|
20112
|
+
* 是否更新房间数据
|
|
20113
|
+
* 如果不更新,代表需合并处理房间数据列表
|
|
20114
|
+
* 此时只更新增量数据,对比完增量数据后,更新房间数据,再和原来的房间数据对比,一次抛出事件
|
|
20115
|
+
*/
|
|
20116
|
+
isUpdateFullRoomStatus = true) {
|
|
20117
|
+
super();
|
|
20118
|
+
this.msgContent = msgContent;
|
|
20119
|
+
this.messageType = messageType;
|
|
20120
|
+
this.senderId = senderId;
|
|
20121
|
+
this.subhook = subhook;
|
|
20122
|
+
this.callback = callback;
|
|
20123
|
+
this.isUpdateFullRoomStatus = isUpdateFullRoomStatus;
|
|
20124
|
+
}
|
|
20125
|
+
get priority() {
|
|
20126
|
+
return CommandPriority.NORMAL;
|
|
20127
|
+
}
|
|
20128
|
+
execute(store, invoker) {
|
|
20129
|
+
var _a, _b, _c, _d, _e, _f;
|
|
20130
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
20131
|
+
const { uris } = this.msgContent;
|
|
20132
|
+
const publishedList = [];
|
|
20133
|
+
const unpublishedList = [];
|
|
20134
|
+
const modifiedList = [];
|
|
20135
|
+
let parseData;
|
|
20136
|
+
const userId = this.senderId;
|
|
20137
|
+
const { messageType } = this;
|
|
20138
|
+
// 当前资源清单
|
|
20139
|
+
// const nowResources = this._roomResources[userId] || (this._roomResources[userId] = [])
|
|
20140
|
+
const nowResources = store.getResourcesByUserId(userId) || [];
|
|
20141
|
+
store.setResourcesByUserId(userId, nowResources);
|
|
20142
|
+
switch (messageType) {
|
|
20143
|
+
case RCRTCMessageType.MODIFY:
|
|
20144
|
+
modifiedList.push(...uris);
|
|
20145
|
+
break;
|
|
20146
|
+
case RCRTCMessageType.PUBLISH:
|
|
20147
|
+
publishedList.push(...uris);
|
|
20148
|
+
break;
|
|
20149
|
+
case RCRTCMessageType.UNPUBLISH:
|
|
19928
20150
|
unpublishedList.push(...uris);
|
|
19929
20151
|
break;
|
|
19930
20152
|
case RCRTCMessageType.TOTAL_CONTENT_RESOURCE:
|
|
@@ -19992,7 +20214,7 @@
|
|
|
19992
20214
|
const trackId = getTrackId(item);
|
|
19993
20215
|
return store.getRemoteTrack(trackId);
|
|
19994
20216
|
});
|
|
19995
|
-
yield new OnRemoteUserUnpubCommand(this.subhook, tracks, this.callback.
|
|
20217
|
+
yield new OnRemoteUserUnpubCommand(this.subhook, tracks, this.callback.onTrackUnpublish).execute(store, invoker);
|
|
19996
20218
|
}
|
|
19997
20219
|
if (modifiedList.length > 0) {
|
|
19998
20220
|
const resIds = nowResources.map(getTrackId);
|
|
@@ -20006,7 +20228,7 @@
|
|
|
20006
20228
|
const rTrack = store.getRemoteTrack(id);
|
|
20007
20229
|
rTrack.__innerSetRemoteMuted(item.state === 0);
|
|
20008
20230
|
// rTrack.isAudioTrack() ? this._onAudioMuteChange(rTrack) : this._onVideoMuteChange(rTrack)
|
|
20009
|
-
rTrack.isAudioTrack() ? this.callback.
|
|
20231
|
+
rTrack.isAudioTrack() ? this.callback.onAudioMuteChange(rTrack) : this.callback.onVideoMuteChange(rTrack);
|
|
20010
20232
|
}
|
|
20011
20233
|
}
|
|
20012
20234
|
if (store.roomMode !== RTCMode.LIVE) {
|
|
@@ -20100,14 +20322,61 @@
|
|
|
20100
20322
|
}
|
|
20101
20323
|
}
|
|
20102
20324
|
|
|
20325
|
+
class RetrySignaling {
|
|
20326
|
+
constructor() {
|
|
20327
|
+
/* 类的私有财产。 */
|
|
20328
|
+
this.tasks = [];
|
|
20329
|
+
}
|
|
20330
|
+
/**
|
|
20331
|
+
* 如果未设置 retryHandler,则创建一个新的并返回它。否则,返回现有的。
|
|
20332
|
+
* @returns 重试处理程序
|
|
20333
|
+
*/
|
|
20334
|
+
static handler() {
|
|
20335
|
+
if (!this.retryHandler) {
|
|
20336
|
+
this.retryHandler = new RetrySignaling();
|
|
20337
|
+
}
|
|
20338
|
+
return this.retryHandler;
|
|
20339
|
+
}
|
|
20340
|
+
/**
|
|
20341
|
+
* > `execute` 函数执行 `tasks` 数组中的所有任务,然后销毁 `TaskQueue` 实例
|
|
20342
|
+
*/
|
|
20343
|
+
execute() {
|
|
20344
|
+
for (const task of this.tasks) {
|
|
20345
|
+
task();
|
|
20346
|
+
}
|
|
20347
|
+
this.destroy();
|
|
20348
|
+
}
|
|
20349
|
+
/**
|
|
20350
|
+
* 它接受一个函数作为参数,并返回一个在函数被调用时解析的 Promise
|
|
20351
|
+
* @param {Function} fn - 功能:要执行的功能。
|
|
20352
|
+
* @returns 将解析为传入函数的结果的承诺。
|
|
20353
|
+
*/
|
|
20354
|
+
task(fn) {
|
|
20355
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
20356
|
+
return new Promise((resolve) => {
|
|
20357
|
+
this.tasks.push(() => {
|
|
20358
|
+
resolve(fn());
|
|
20359
|
+
});
|
|
20360
|
+
});
|
|
20361
|
+
});
|
|
20362
|
+
}
|
|
20363
|
+
/**
|
|
20364
|
+
* 它从任务数组中删除所有任务
|
|
20365
|
+
*/
|
|
20366
|
+
destroy() {
|
|
20367
|
+
this.tasks = [];
|
|
20368
|
+
}
|
|
20369
|
+
}
|
|
20370
|
+
|
|
20103
20371
|
/**
|
|
20104
20372
|
* 资源发布命令
|
|
20105
20373
|
*/
|
|
20106
20374
|
class PublishCommand extends BaseCommand {
|
|
20107
|
-
constructor(tracks, pubhook) {
|
|
20375
|
+
constructor(tracks, pubhook, signalRetryTime) {
|
|
20108
20376
|
super();
|
|
20109
20377
|
this.tracks = tracks;
|
|
20110
20378
|
this.pubhook = pubhook;
|
|
20379
|
+
this.signalRetryTime = signalRetryTime;
|
|
20111
20380
|
this._logger = null;
|
|
20112
20381
|
this._logger = RTCLogger.getLogger();
|
|
20113
20382
|
}
|
|
@@ -20379,7 +20648,24 @@
|
|
|
20379
20648
|
memo.publishSignalTotal = {
|
|
20380
20649
|
start: Date.now(),
|
|
20381
20650
|
};
|
|
20382
|
-
|
|
20651
|
+
let errorCode = yield store.context.setRTCTotalRes(roomId, buildPlusMessage(RCRTCMessageType.PUBLISH, plus), buildTotalURIMessageContent(allPublishList), RCRTCMessageType.TOTAL_CONTENT_RESOURCE, buildTotalURIMessageContent(crtMcuPublishList));
|
|
20652
|
+
// TIPS: 通知房间成员失败,对信息进行重试操作
|
|
20653
|
+
if (errorCode !== engine.ErrorCode.SUCCESS) {
|
|
20654
|
+
const RetrySignal = RetrySignaling.handler();
|
|
20655
|
+
const startTime = (new Date()).valueOf();
|
|
20656
|
+
const loop = () => __awaiter(this, void 0, void 0, function* () {
|
|
20657
|
+
// 如果当前时间大于 60 秒
|
|
20658
|
+
if ((new Date()).valueOf() - startTime > this.signalRetryTime) {
|
|
20659
|
+
return errorCode;
|
|
20660
|
+
}
|
|
20661
|
+
const code = yield store.context.setRTCTotalRes(roomId, buildPlusMessage(RCRTCMessageType.PUBLISH, plus), buildTotalURIMessageContent(allPublishList), RCRTCMessageType.TOTAL_CONTENT_RESOURCE, buildTotalURIMessageContent(crtMcuPublishList));
|
|
20662
|
+
if (code !== engine.ErrorCode.SUCCESS) {
|
|
20663
|
+
yield RetrySignal.task(loop);
|
|
20664
|
+
}
|
|
20665
|
+
return code;
|
|
20666
|
+
});
|
|
20667
|
+
errorCode = yield RetrySignal.task(loop);
|
|
20668
|
+
}
|
|
20383
20669
|
if (errorCode !== engine.ErrorCode.SUCCESS) {
|
|
20384
20670
|
// 连通率相关埋点-发布资源结束
|
|
20385
20671
|
const dateNow = Date.now();
|
|
@@ -20947,10 +21233,10 @@
|
|
|
20947
21233
|
return CommandPriority.HIGH;
|
|
20948
21234
|
}
|
|
20949
21235
|
execute(store, invoker) {
|
|
20950
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
21236
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
|
|
20951
21237
|
return __awaiter(this, void 0, void 0, function* () {
|
|
20952
21238
|
const { livingType } = this;
|
|
20953
|
-
const { roomId,
|
|
21239
|
+
const { roomId, roomMode } = store;
|
|
20954
21240
|
(_b = (_a = store.context) === null || _a === void 0 ? void 0 : _a.logger) === null || _b === void 0 ? void 0 : _b.info(RCLoggerTag.L_ABSTRACT_ROOM_RECONNECTED_T, JSON.stringify({
|
|
20955
21241
|
livingType,
|
|
20956
21242
|
}));
|
|
@@ -20968,7 +21254,7 @@
|
|
|
20968
21254
|
code: '',
|
|
20969
21255
|
msg: 'RTCPeerConnection closed',
|
|
20970
21256
|
}));
|
|
20971
|
-
this.callbacks.onPeerClosed();
|
|
21257
|
+
this.callbacks.onPeerClosed && this.callbacks.onPeerClosed();
|
|
20972
21258
|
return;
|
|
20973
21259
|
}
|
|
20974
21260
|
const { code, data } = yield store.context.joinRTCRoom(roomId, roomMode, livingType);
|
|
@@ -20981,148 +21267,27 @@
|
|
|
20981
21267
|
}));
|
|
20982
21268
|
return;
|
|
20983
21269
|
}
|
|
20984
|
-
|
|
20985
|
-
|
|
20986
|
-
|
|
20987
|
-
|
|
20988
|
-
|
|
20989
|
-
|
|
20990
|
-
|
|
20991
|
-
// 状态变更的资源
|
|
20992
|
-
const modified = {};
|
|
20993
|
-
// 当前最新的房间资源数据
|
|
20994
|
-
const roomData = parseRoomData(data, roomId);
|
|
20995
|
-
const nowUserIds = Object.keys(roomData);
|
|
20996
|
-
// const prevUserIds = Object.keys(this._roomResources)
|
|
20997
|
-
const prevUserIds = store.getAllUserIds();
|
|
20998
|
-
for (let i = nowUserIds.length - 1; i >= 0; i -= 1) {
|
|
20999
|
-
const userId = nowUserIds[i];
|
|
21000
|
-
const index = prevUserIds.indexOf(userId);
|
|
21001
|
-
if (index === -1) {
|
|
21002
|
-
// 新增人员
|
|
21003
|
-
joinedUserIds.push(userId);
|
|
21004
|
-
// 新增人员发布的资源
|
|
21005
|
-
published[userId] = deepCopyResources(roomData[userId]);
|
|
21006
|
-
continue;
|
|
21007
|
-
}
|
|
21008
|
-
// 房间缓存中的已发布资源
|
|
21009
|
-
// const prevResources = this._roomResources[userId]
|
|
21010
|
-
const prevResources = store.getResourcesByUserId(userId);
|
|
21011
|
-
// 当前资源
|
|
21012
|
-
const nowResources = roomData[userId];
|
|
21013
|
-
// 资源比对
|
|
21014
|
-
const { publishedList, modifiedList, unpublishedList } = diffPublishResources(prevResources, nowResources, true);
|
|
21015
|
-
published[userId] = deepCopyResources(publishedList);
|
|
21016
|
-
unpublished[userId] = deepCopyResources(unpublishedList);
|
|
21017
|
-
modified[userId] = deepCopyResources(modifiedList);
|
|
21018
|
-
// 从之前的人员列表中删除已存在人员,剩余人员为已退出人员
|
|
21019
|
-
prevUserIds.splice(index, 1);
|
|
21020
|
-
}
|
|
21021
|
-
// 更新缓存资源
|
|
21022
|
-
prevUserIds.length && prevUserIds.forEach((userId) => {
|
|
21023
|
-
store.removeResourcesByUserId(userId);
|
|
21024
|
-
});
|
|
21025
|
-
// Object.assign(this._roomResources, roomData)
|
|
21026
|
-
store.assignRoomData(roomData);
|
|
21027
|
-
// 通知人员退出
|
|
21028
|
-
// prevUserIds.length && this._callAppListener('onUserLeave', prevUserIds)
|
|
21029
|
-
prevUserIds.length && this.callbacks.onUserLeave(prevUserIds);
|
|
21030
|
-
// 通知人员加入
|
|
21031
|
-
// joinedUserIds.length && this._callAppListener('onUserJoin', joinedUserIds)
|
|
21032
|
-
joinedUserIds.length && this.callbacks.onUserJoin(joinedUserIds);
|
|
21033
|
-
/**
|
|
21034
|
-
* 资源取消发布
|
|
21035
|
-
* im 重连加入房间后,服务返回的自己资源为空时,上抛资源被取消发布需过滤掉本端资源
|
|
21036
|
-
*/
|
|
21037
|
-
for (const userId in unpublished) {
|
|
21038
|
-
if (userId === crtUserId) {
|
|
21039
|
-
continue;
|
|
21040
|
-
}
|
|
21041
|
-
const resources = unpublished[userId];
|
|
21042
|
-
if (resources.length) {
|
|
21043
|
-
const tracks = resources.map(
|
|
21044
|
-
// return this._remoteTracks[getTrackId(item)]
|
|
21045
|
-
(item) => store.getRemoteTrack(getTrackId(item)));
|
|
21046
|
-
// await this._onUserUnpublish(tracks)
|
|
21047
|
-
yield new OnRemoteUserUnpubCommand(this.subhook, tracks, this.callbacks.onTrackUnpublish).execute(store, invoker);
|
|
21048
|
-
}
|
|
21049
|
-
}
|
|
21050
|
-
// 新发布资源
|
|
21051
|
-
Object.keys(published).forEach((userId) => {
|
|
21052
|
-
const resources = published[userId];
|
|
21053
|
-
if (resources.length === 0) {
|
|
21054
|
-
return;
|
|
21055
|
-
}
|
|
21056
|
-
const tracks = resources.map((item) => {
|
|
21057
|
-
const trackId = getTrackId(item);
|
|
21058
|
-
const { userId, tag, mediaType } = parseTrackId(trackId);
|
|
21059
|
-
const track = mediaType === exports.RCMediaType.AUDIO_ONLY ? new RCRemoteAudioTrack(tag, userId) : new RCRemoteVideoTrack(tag, userId);
|
|
21060
|
-
store.addRemoteTrack(track);
|
|
21061
|
-
track.__innerSetRemoteMuted(item.state === 0);
|
|
21062
|
-
return track;
|
|
21063
|
-
});
|
|
21064
|
-
this.callbacks.onTrackPublish(tracks);
|
|
21065
|
-
});
|
|
21066
|
-
// 资源状态变更
|
|
21067
|
-
Object.keys(modified).forEach((userId) => {
|
|
21068
|
-
const resources = modified[userId];
|
|
21069
|
-
// 音频与视频区分
|
|
21070
|
-
resources.forEach((item) => {
|
|
21071
|
-
const trackId = getTrackId(item);
|
|
21072
|
-
// const rTrack = this._remoteTracks[trackId]
|
|
21073
|
-
const rTrack = store.getRemoteTrack(trackId);
|
|
21074
|
-
rTrack.__innerSetRemoteMuted(item.state === 0);
|
|
21075
|
-
rTrack.isAudioTrack() ? this.callbacks.onAudioMuteChange(rTrack) : this.callbacks.onVideoMuteChange(rTrack);
|
|
21076
|
-
});
|
|
21077
|
-
});
|
|
21078
|
-
if (store.roomMode === RTCMode.LIVE) {
|
|
21079
|
-
this.executeInLivingRoom(store, data);
|
|
21270
|
+
if (!data) {
|
|
21271
|
+
(_m = (_l = store.context) === null || _l === void 0 ? void 0 : _l.logger) === null || _m === void 0 ? void 0 : _m.info(RCLoggerTag.L_LIVING_ROOM_RECONNECTED_R, JSON.stringify({
|
|
21272
|
+
status: RCLoggerStatus.FAILED,
|
|
21273
|
+
code: '',
|
|
21274
|
+
msg: 'room not fond',
|
|
21275
|
+
}));
|
|
21276
|
+
return;
|
|
21080
21277
|
}
|
|
21081
|
-
(_p = (_o = store.context) === null || _o === void 0 ? void 0 : _o.logger) === null || _p === void 0 ? void 0 : _p.
|
|
21278
|
+
(_p = (_o = store.context) === null || _o === void 0 ? void 0 : _o.logger) === null || _p === void 0 ? void 0 : _p.debug(RCLoggerTag.L_OLD_DAILY_RECORD_O, `RTC __onReconnected getRTCRoomInfo success: ${JSON.stringify(data)}`);
|
|
21279
|
+
/**
|
|
21280
|
+
* 处理全量的房间数据
|
|
21281
|
+
*/
|
|
21282
|
+
const CDNUris = (_q = data.roomInfo.filter((item) => item.key === 'cdn_uris')[0]) === null || _q === void 0 ? void 0 : _q.value;
|
|
21283
|
+
handleFullRoomData(data, store, this.callbacks, invoker, this.subhook, CDNUris);
|
|
21284
|
+
(_s = (_r = store.context) === null || _r === void 0 ? void 0 : _r.logger) === null || _s === void 0 ? void 0 : _s.info(RCLoggerTag.L_ABSTRACT_ROOM_RECONNECTED_R, JSON.stringify({
|
|
21082
21285
|
status: RCLoggerStatus.SUCCESSED,
|
|
21083
21286
|
roomData: data,
|
|
21084
21287
|
}));
|
|
21085
21288
|
return { data };
|
|
21086
21289
|
});
|
|
21087
21290
|
}
|
|
21088
|
-
/**
|
|
21089
|
-
* 主播端断线重连后,需更新内存中的 CDN 数据
|
|
21090
|
-
* 判断房间内 CDN 状态是否和内存数据一致,不一致时需通知到客户端
|
|
21091
|
-
*/
|
|
21092
|
-
executeInLivingRoom(store, data) {
|
|
21093
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
21094
|
-
(_b = (_a = store.context) === null || _a === void 0 ? void 0 : _a.logger) === null || _b === void 0 ? void 0 : _b.error(RCLoggerTag.L_LIVING_ROOM_RECONNECTED_T, JSON.stringify({
|
|
21095
|
-
roomData: data,
|
|
21096
|
-
}));
|
|
21097
|
-
if (!data) {
|
|
21098
|
-
(_d = (_c = store.context) === null || _c === void 0 ? void 0 : _c.logger) === null || _d === void 0 ? void 0 : _d.info(RCLoggerTag.L_LIVING_ROOM_RECONNECTED_R, JSON.stringify({
|
|
21099
|
-
status: RCLoggerStatus.FAILED,
|
|
21100
|
-
code: '',
|
|
21101
|
-
msg: 'room not fond',
|
|
21102
|
-
}));
|
|
21103
|
-
return;
|
|
21104
|
-
}
|
|
21105
|
-
const { roomInfo } = data;
|
|
21106
|
-
const CDNUris = (_e = roomInfo.filter((item) => item.key === 'cdn_uris')[0]) === null || _e === void 0 ? void 0 : _e.value;
|
|
21107
|
-
if (!CDNUris) {
|
|
21108
|
-
(_g = (_f = store.context) === null || _f === void 0 ? void 0 : _f.logger) === null || _g === void 0 ? void 0 : _g.error(RCLoggerTag.L_LIVING_ROOM_RECONNECTED_R, JSON.stringify({
|
|
21109
|
-
status: RCLoggerStatus.FAILED,
|
|
21110
|
-
code: '',
|
|
21111
|
-
msg: 'cdn_uris not found',
|
|
21112
|
-
}));
|
|
21113
|
-
return;
|
|
21114
|
-
}
|
|
21115
|
-
const parseCDNUris = JSON.parse(CDNUris);
|
|
21116
|
-
const changed = ((_h = store.getCDNUris()) === null || _h === void 0 ? void 0 : _h.enableInnerCDN) !== parseCDNUris.enableInnerCDN;
|
|
21117
|
-
store.setCDNUris(parseCDNUris);
|
|
21118
|
-
(_k = (_j = store.context) === null || _j === void 0 ? void 0 : _j.logger) === null || _k === void 0 ? void 0 : _k.info(RCLoggerTag.L_LIVING_ROOM_RECONNECTED_R, JSON.stringify({
|
|
21119
|
-
status: RCLoggerStatus.SUCCESSED,
|
|
21120
|
-
roomData: data,
|
|
21121
|
-
}));
|
|
21122
|
-
if (changed) {
|
|
21123
|
-
this.callbacks.onCDNEnableChange(parseCDNUris.enableInnerCDN);
|
|
21124
|
-
}
|
|
21125
|
-
}
|
|
21126
21291
|
}
|
|
21127
21292
|
|
|
21128
21293
|
/**
|
|
@@ -21369,6 +21534,89 @@
|
|
|
21369
21534
|
}
|
|
21370
21535
|
}
|
|
21371
21536
|
|
|
21537
|
+
/**
|
|
21538
|
+
* 通知拉取到的房间增量数据列表中每一项数据的动作
|
|
21539
|
+
*/
|
|
21540
|
+
var PullRoomStatusEvent;
|
|
21541
|
+
(function (PullRoomStatusEvent) {
|
|
21542
|
+
/**
|
|
21543
|
+
* 人员加入
|
|
21544
|
+
*/
|
|
21545
|
+
PullRoomStatusEvent[PullRoomStatusEvent["JOIN"] = 0] = "JOIN";
|
|
21546
|
+
/**
|
|
21547
|
+
* 人员离开
|
|
21548
|
+
*/
|
|
21549
|
+
PullRoomStatusEvent[PullRoomStatusEvent["LEAVE"] = 1] = "LEAVE";
|
|
21550
|
+
/**
|
|
21551
|
+
* 人员离线
|
|
21552
|
+
*/
|
|
21553
|
+
PullRoomStatusEvent[PullRoomStatusEvent["OFFLINE"] = 2] = "OFFLINE";
|
|
21554
|
+
/**
|
|
21555
|
+
* 资源变动
|
|
21556
|
+
*/
|
|
21557
|
+
PullRoomStatusEvent[PullRoomStatusEvent["RESOURCECHANGE"] = 3] = "RESOURCECHANGE";
|
|
21558
|
+
})(PullRoomStatusEvent || (PullRoomStatusEvent = {}));
|
|
21559
|
+
|
|
21560
|
+
class PullRTCRoomStatusCommand extends BaseCommand {
|
|
21561
|
+
constructor(_roomId, _traceId, _context, _callbacks, _subhook, _stateHandle) {
|
|
21562
|
+
super();
|
|
21563
|
+
this._roomId = _roomId;
|
|
21564
|
+
this._traceId = _traceId;
|
|
21565
|
+
this._context = _context;
|
|
21566
|
+
this._callbacks = _callbacks;
|
|
21567
|
+
this._subhook = _subhook;
|
|
21568
|
+
this._stateHandle = _stateHandle;
|
|
21569
|
+
}
|
|
21570
|
+
execute(store, invoker) {
|
|
21571
|
+
var _a, _b;
|
|
21572
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
21573
|
+
const version = store.getRoomStatusVersion();
|
|
21574
|
+
(_a = this._context.logger) === null || _a === void 0 ? void 0 : _a.info(RCLoggerTag.L_PULL_ROOM_STATUS_T, JSON.stringify({
|
|
21575
|
+
roomId: this._roomId,
|
|
21576
|
+
version,
|
|
21577
|
+
}), this._traceId);
|
|
21578
|
+
const { code, data } = yield this._context.pullRTCRoomStatus(this._roomId, version);
|
|
21579
|
+
if (code !== engine.ErrorCode.SUCCESS) {
|
|
21580
|
+
return { code };
|
|
21581
|
+
}
|
|
21582
|
+
const { bFullStatus, version: newVersion, usersData, roomStatus, } = data;
|
|
21583
|
+
(_b = this._context.logger) === null || _b === void 0 ? void 0 : _b.info(RCLoggerTag.L_PULL_ROOM_STATUS_R, JSON.stringify({
|
|
21584
|
+
bFullStatus,
|
|
21585
|
+
version: int64ToTimestamp(newVersion),
|
|
21586
|
+
usersData,
|
|
21587
|
+
roomStatus,
|
|
21588
|
+
}), this._traceId);
|
|
21589
|
+
store.setRoomStatusVersion(newVersion);
|
|
21590
|
+
/**
|
|
21591
|
+
* 处理全量数据
|
|
21592
|
+
*/
|
|
21593
|
+
if (bFullStatus) {
|
|
21594
|
+
const { urisData, CDNUris } = transPullFullUsersData(usersData);
|
|
21595
|
+
handleFullRoomData(urisData, store, this._callbacks, invoker, this._subhook, CDNUris);
|
|
21596
|
+
return { code };
|
|
21597
|
+
}
|
|
21598
|
+
/**
|
|
21599
|
+
* 处理增量列表数据,默认不合并人员、资源变动
|
|
21600
|
+
*/
|
|
21601
|
+
for (let index = 0; index < roomStatus.length; index++) {
|
|
21602
|
+
const item = roomStatus[index];
|
|
21603
|
+
if (item.event === PullRoomStatusEvent.RESOURCECHANGE) {
|
|
21604
|
+
const { content, userId } = transPullDataToResMsgCont(item);
|
|
21605
|
+
if (userId === store.crtUserId) {
|
|
21606
|
+
continue;
|
|
21607
|
+
}
|
|
21608
|
+
yield new ParseRemoteResCommand(content, RCRTCMessageType.TOTAL_CONTENT_RESOURCE, userId, this._subhook.bind(this), this._callbacks).execute(store, invoker);
|
|
21609
|
+
}
|
|
21610
|
+
else {
|
|
21611
|
+
const content = transPullDataToStateMsgCont(item);
|
|
21612
|
+
this._stateHandle(content);
|
|
21613
|
+
}
|
|
21614
|
+
}
|
|
21615
|
+
return { code };
|
|
21616
|
+
});
|
|
21617
|
+
}
|
|
21618
|
+
}
|
|
21619
|
+
|
|
21372
21620
|
exports.RCKickReason = void 0;
|
|
21373
21621
|
(function (RCKickReason) {
|
|
21374
21622
|
/**
|
|
@@ -21416,10 +21664,43 @@
|
|
|
21416
21664
|
this._peerCManager = new RCRTCPeerCManager(this._useMutilPeerC, this._roomId, this._reTryExchange.bind(this), this._context.getCurrentId(), this._polarisReport);
|
|
21417
21665
|
this._invoker = new Invoker(this._context, this._service, this._peerCManager, _roomId, this._context.getCurrentId(), _roomMode, this._polarisReport, isUpgrade, isMainRoom);
|
|
21418
21666
|
this._store = this._invoker.store;
|
|
21667
|
+
// 注册监听 rtc_ntf 信令数据,解码后拉取指定房间数据
|
|
21668
|
+
this._context.registerRTCSignalListener((buffer) => __awaiter(this, void 0, void 0, function* () {
|
|
21669
|
+
var _a, _b, _c, _d;
|
|
21670
|
+
// 1. 拉取数据,非本房间可不拉取
|
|
21671
|
+
// 2. 拉取完成后调用原通知方法 this.singalDataChange(_roomId)
|
|
21672
|
+
const { time, type, roomId, } = this._context.decodeRtcNotify(buffer);
|
|
21673
|
+
switch (type) {
|
|
21674
|
+
case 2:
|
|
21675
|
+
// 拉取房间数据
|
|
21676
|
+
// eslint-disable-next-line no-case-declarations
|
|
21677
|
+
const tracId = (_b = (_a = this._context) === null || _a === void 0 ? void 0 : _a.logger) === null || _b === void 0 ? void 0 : _b.createTraceId();
|
|
21678
|
+
(_d = (_c = this._context) === null || _c === void 0 ? void 0 : _c.logger) === null || _d === void 0 ? void 0 : _d.info(RCLoggerTag.L_RTCNTF_PULL_ROOM_STATUS_O, null, tracId);
|
|
21679
|
+
this._startPullRTCRoomStatus(roomId, tracId);
|
|
21680
|
+
break;
|
|
21681
|
+
}
|
|
21682
|
+
}));
|
|
21683
|
+
}
|
|
21684
|
+
/**
|
|
21685
|
+
* 拉取房间数据
|
|
21686
|
+
* @param roomId 房间 id
|
|
21687
|
+
*/
|
|
21688
|
+
_startPullRTCRoomStatus(roomId, tracId) {
|
|
21689
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
21690
|
+
yield this._invoker.push(new PullRTCRoomStatusCommand(roomId, tracId, this._context, {
|
|
21691
|
+
onUserJoin: this._callAppListener.bind(this, 'onUserJoin'),
|
|
21692
|
+
onUserLeave: this._callAppListener.bind(this, 'onUserLeave'),
|
|
21693
|
+
onAudioMuteChange: this._onAudioMuteChange.bind(this),
|
|
21694
|
+
onVideoMuteChange: this._onVideoMuteChange.bind(this),
|
|
21695
|
+
onTrackPublish: this._onTrackPublish.bind(this),
|
|
21696
|
+
onTrackUnpublish: this._onTrackUnpublish.bind(this),
|
|
21697
|
+
onCDNEnableChange: this._callAppListener.bind(this, 'onCDNEnableChange'),
|
|
21698
|
+
}, this._subhook.bind(this), this._stateHandle.bind(this)));
|
|
21699
|
+
});
|
|
21419
21700
|
}
|
|
21420
21701
|
__innerInit(mode, joinType, livingType, innerUserDatas, outerUserDatas) {
|
|
21421
21702
|
return __awaiter(this, void 0, void 0, function* () {
|
|
21422
|
-
const { code, data } = yield this._invoker.push(new JoinRoomCommand(this._roomId, mode, joinType, livingType, innerUserDatas, outerUserDatas));
|
|
21703
|
+
const { code, data } = yield this._invoker.push(new JoinRoomCommand(this._roomId, mode, this._context, joinType, livingType, innerUserDatas, outerUserDatas));
|
|
21423
21704
|
if (code !== exports.RCRTCCode.SUCCESS) {
|
|
21424
21705
|
return { code };
|
|
21425
21706
|
}
|
|
@@ -21431,10 +21712,12 @@
|
|
|
21431
21712
|
_initWithRoomData(offlineKickTime) {
|
|
21432
21713
|
var _a;
|
|
21433
21714
|
// 开始心跳,心跳失败时主动退出房间
|
|
21434
|
-
|
|
21715
|
+
const readStore = this._invoker.store;
|
|
21716
|
+
this._pinger = new Pinger(readStore, this._context, this._initOptions.pingGap, offlineKickTime * 1000);
|
|
21435
21717
|
this._pinger.onFailed = this._kickoff.bind(this);
|
|
21436
21718
|
this._pinger.onPingResult = this._handlePingResult.bind(this);
|
|
21437
|
-
|
|
21719
|
+
// 给 Pinger 模块传入拉取房间数据的方法
|
|
21720
|
+
this._pinger.start(this._startPullRTCRoomStatus.bind(this));
|
|
21438
21721
|
(_a = this._polarisReport) === null || _a === void 0 ? void 0 : _a.sendR1();
|
|
21439
21722
|
}
|
|
21440
21723
|
_handlePingResult(result) {
|
|
@@ -21490,7 +21773,7 @@
|
|
|
21490
21773
|
eventType,
|
|
21491
21774
|
attrs,
|
|
21492
21775
|
})));
|
|
21493
|
-
eventType !== 'onPing' && ((_d = (_c = this._context) === null || _c === void 0 ? void 0 : _c.logger) === null || _d === void 0 ? void 0 : _d.info(RCLoggerTag.L_OLD_DAILY_RECORD_O, `${eventType} callback
|
|
21776
|
+
eventType !== 'onPing' && ((_d = (_c = this._context) === null || _c === void 0 ? void 0 : _c.logger) === null || _d === void 0 ? void 0 : _d.info(RCLoggerTag.L_OLD_DAILY_RECORD_O, `${eventType} callback ->, content: ${JSON.stringify(attrs)}`));
|
|
21494
21777
|
const handle = (_e = this._appListener) === null || _e === void 0 ? void 0 : _e[eventType];
|
|
21495
21778
|
if (!handle) {
|
|
21496
21779
|
return;
|
|
@@ -21636,10 +21919,10 @@
|
|
|
21636
21919
|
return;
|
|
21637
21920
|
}
|
|
21638
21921
|
this._invoker.push(new ParseRemoteResCommand(content, messageType, userId, this._subhook.bind(this), {
|
|
21639
|
-
|
|
21640
|
-
|
|
21922
|
+
onAudioMuteChange: this._onAudioMuteChange.bind(this),
|
|
21923
|
+
onVideoMuteChange: this._onVideoMuteChange.bind(this),
|
|
21641
21924
|
onTrackPublish: this._onTrackPublish.bind(this),
|
|
21642
|
-
|
|
21925
|
+
onTrackUnpublish: this._onTrackUnpublish.bind(this),
|
|
21643
21926
|
onCDNEnableChange: this._callAppListener.bind(this, 'onCDNEnableChange'),
|
|
21644
21927
|
}));
|
|
21645
21928
|
});
|
|
@@ -21974,7 +22257,7 @@
|
|
|
21974
22257
|
*/
|
|
21975
22258
|
publish(tracks) {
|
|
21976
22259
|
return __awaiter(this, void 0, void 0, function* () {
|
|
21977
|
-
return this._invoker.push(new PublishCommand(tracks, this._pubhook.bind(this)));
|
|
22260
|
+
return this._invoker.push(new PublishCommand(tracks, this._pubhook.bind(this), this._initOptions.signalRetryTime || 30 * 1000));
|
|
21978
22261
|
});
|
|
21979
22262
|
}
|
|
21980
22263
|
/**
|
|
@@ -26834,14 +27117,15 @@
|
|
|
26834
27117
|
return this._context.getCurrentId();
|
|
26835
27118
|
}
|
|
26836
27119
|
/**
|
|
26837
|
-
*
|
|
26838
|
-
* @param roomId
|
|
26839
|
-
* @param joinType
|
|
26840
|
-
* @param outerUserDatas
|
|
26841
|
-
* @param useMutilPeerC
|
|
26842
|
-
* @param roomType
|
|
27120
|
+
* > 加入普通音视频房间,返回房间对象、code、userIds、tracks
|
|
27121
|
+
* @param {string} roomId - 房间号
|
|
27122
|
+
* @param {RTCJoinType} [joinType] - 要加入的房间类型。
|
|
27123
|
+
* @param {IRTCUserData} [outerUserDatas] - 加入房间的用户的用户数据。
|
|
27124
|
+
* @param {boolean} [useMutilPeerC] - 是否使用多点连接,默认为false,即使用单点连接。
|
|
27125
|
+
* @param {RTCMode} roomType - RTCMode = RTCMode.RTC,
|
|
27126
|
+
* @param {number} signalRetryTime - 重新连接信令服务器的时间间隔。
|
|
26843
27127
|
*/
|
|
26844
|
-
joinRTCRoom(roomId, joinType, outerUserDatas, useMutilPeerC, roomType = RTCMode.RTC) {
|
|
27128
|
+
joinRTCRoom(roomId, joinType, outerUserDatas, useMutilPeerC, roomType = RTCMode.RTC, signalRetryTime) {
|
|
26845
27129
|
var _a, _b, _c, _d;
|
|
26846
27130
|
return __awaiter(this, void 0, void 0, function* () {
|
|
26847
27131
|
(_b = (_a = this._context) === null || _a === void 0 ? void 0 : _a.logger) === null || _b === void 0 ? void 0 : _b.info(RCLoggerTag.L_RTC_CLIENT_JOIN_RTC_ROOM_T, JSON.stringify({
|
|
@@ -26859,6 +27143,10 @@
|
|
|
26859
27143
|
}));
|
|
26860
27144
|
return { code: exports.RCRTCCode.REPERT_JOIN_ROOM };
|
|
26861
27145
|
}
|
|
27146
|
+
// 修改初始化配置中的超时时间
|
|
27147
|
+
if (signalRetryTime) {
|
|
27148
|
+
this._options.signalRetryTime = signalRetryTime;
|
|
27149
|
+
}
|
|
26862
27150
|
const room = this._crtRoom = new RCRTCRoom(this._context, this._runtime, roomId, this._service, this._options, false, false, useMutilPeerC, getUUID());
|
|
26863
27151
|
const { code } = yield room.__innerInit(roomType, joinType, undefined, undefined, outerUserDatas);
|
|
26864
27152
|
if (code !== exports.RCRTCCode.SUCCESS) {
|
|
@@ -26973,7 +27261,7 @@
|
|
|
26973
27261
|
}
|
|
26974
27262
|
_onIMStatusChange(status) {
|
|
26975
27263
|
var _a, _b, _c, _d;
|
|
26976
|
-
(_b = (_a = this._context) === null || _a === void 0 ? void 0 : _a.logger) === null || _b === void 0 ? void 0 : _b.debug(`signal server connection state change: ${status}`);
|
|
27264
|
+
(_b = (_a = this._context) === null || _a === void 0 ? void 0 : _a.logger) === null || _b === void 0 ? void 0 : _b.debug(RCLoggerTag.L_OLD_DAILY_RECORD_O, `signal server connection state change: ${status}`);
|
|
26977
27265
|
(_d = (_c = this._context) === null || _c === void 0 ? void 0 : _c.logger) === null || _d === void 0 ? void 0 : _d.info(RCLoggerTag.L_RTC_CLIENT_CONNECTION_STATE_S, JSON.stringify({
|
|
26978
27266
|
status: RCLoggerStatus.SUCCESSED,
|
|
26979
27267
|
data: status,
|
|
@@ -26990,7 +27278,16 @@
|
|
|
26990
27278
|
room.__onReconnected();
|
|
26991
27279
|
});
|
|
26992
27280
|
}
|
|
26993
|
-
|
|
27281
|
+
if (this._crtRoom) {
|
|
27282
|
+
this._crtRoom.__onReconnected().then((room) => {
|
|
27283
|
+
if (room && room.data && room.data.sessionId) {
|
|
27284
|
+
// 信令重连
|
|
27285
|
+
const RetrySignal = RetrySignaling.handler();
|
|
27286
|
+
// 重新链接后补发 之前的信令
|
|
27287
|
+
RetrySignal.execute();
|
|
27288
|
+
}
|
|
27289
|
+
});
|
|
27290
|
+
}
|
|
26994
27291
|
}
|
|
26995
27292
|
_onIMDisconnect() {
|
|
26996
27293
|
var _a, _b, _c, _d;
|
|
@@ -27310,7 +27607,7 @@
|
|
|
27310
27607
|
}
|
|
27311
27608
|
reportSDKInfo() {
|
|
27312
27609
|
this._context.reportSDKInfo({
|
|
27313
|
-
'plugin-rtc': "5.5.
|
|
27610
|
+
'plugin-rtc': "5.5.5-beem-alpha.1",
|
|
27314
27611
|
});
|
|
27315
27612
|
}
|
|
27316
27613
|
}
|
|
@@ -27352,12 +27649,17 @@
|
|
|
27352
27649
|
rtcEndInvite: 'rtcEndInvite',
|
|
27353
27650
|
/** RTC 查询用户信息(是否在房间内) */
|
|
27354
27651
|
rtcQueryJoined: 'rtcQueryJoined',
|
|
27652
|
+
/** 拉取 rtc 和 living room 的资源状态 */
|
|
27653
|
+
rtcPullRoomStatus: 'rtcPullRoomStatus',
|
|
27355
27654
|
/** 上报融云SDK信息 */
|
|
27356
27655
|
reportsdk: 'reportsdk',
|
|
27656
|
+
/** rtcping */
|
|
27657
|
+
rtcPing: 'rtcPing',
|
|
27357
27658
|
};
|
|
27358
27659
|
var RTCPB;
|
|
27359
27660
|
(function (RTCPB) {
|
|
27360
27661
|
RTCPB["RtcInput"] = "RtcInput";
|
|
27662
|
+
RTCPB["RtcOutput"] = "RtcOutput";
|
|
27361
27663
|
RTCPB["RtcUserListOutput"] = "RtcUserListOutput";
|
|
27362
27664
|
RTCPB["SetUserStatusInput"] = "SetUserStatusInput";
|
|
27363
27665
|
RTCPB["RtcSetDataInput"] = "RtcSetDataInput";
|
|
@@ -27383,6 +27685,8 @@
|
|
|
27383
27685
|
RTCPB["RtcCancelInviteInput"] = "RtcCancelInviteInput";
|
|
27384
27686
|
RTCPB["RtcInviteAnswerInput"] = "RtcInviteAnswerInput";
|
|
27385
27687
|
RTCPB["RtcEndInviteInput"] = "RtcEndInviteInput";
|
|
27688
|
+
RTCPB["RtcRoomStatusInput"] = "RtcRoomStatusInput";
|
|
27689
|
+
RTCPB["RtcRoomStatusOutput"] = "RtcRoomStatusOutput";
|
|
27386
27690
|
RTCPB["RtcReportSDKInput"] = "RtcReportSDKInput";
|
|
27387
27691
|
RTCPB["RtcPBPolaris"] = "RCRTCPBPolaris";
|
|
27388
27692
|
RTCPB["RtcPBR1Info"] = "RCRTCPBR1Info";
|
|
@@ -27393,8 +27697,9 @@
|
|
|
27393
27697
|
RTCPB["RtcPBStreamInfo"] = "RCRTCPBStreamInfo"; // R3 R4 上下行流信息
|
|
27394
27698
|
})(RTCPB || (RTCPB = {}));
|
|
27395
27699
|
const keymaps = {
|
|
27396
|
-
[RTCPB.RtcInput]: ['roomType', 'broadcastType', 'extraInnerData', 'needSysChatroom', 'identityChangeType', 'joinType', 'innerDatas', 'outerDatas'],
|
|
27397
|
-
[RTCPB.
|
|
27700
|
+
[RTCPB.RtcInput]: ['roomType', 'broadcastType', 'extraInnerData', 'needSysChatroom', 'identityChangeType', 'joinType', 'innerDatas', 'outerDatas', 'supportNtf'],
|
|
27701
|
+
[RTCPB.RtcOutput]: ['version'],
|
|
27702
|
+
[RTCPB.RtcUserListOutput]: ['users', 'token', 'sessionId', 'roomInfo', 'version'],
|
|
27398
27703
|
[RTCPB.SetUserStatusInput]: ['status'],
|
|
27399
27704
|
[RTCPB.RtcSetDataInput]: ['interior', 'target', 'key', 'value', 'objectName', 'content'],
|
|
27400
27705
|
[RTCPB.RtcUserSetDataInput]: ['valueInfo', 'objectName', 'content'],
|
|
@@ -27419,13 +27724,15 @@
|
|
|
27419
27724
|
[RTCPB.RtcCancelInviteInput]: ['invitedUserId', 'invitedRoomId', 'inviteInfo', 'inviteSessionId'],
|
|
27420
27725
|
[RTCPB.RtcInviteAnswerInput]: ['inviteUserId', 'answerCode', 'inviteRoomId', 'inviteSessionId', 'content', 'key', 'value'],
|
|
27421
27726
|
[RTCPB.RtcEndInviteInput]: ['inviteRoomId', 'inviteSessionId', 'inviteContent', 'inviteRoomKeys'],
|
|
27727
|
+
[RTCPB.RtcRoomStatusInput]: ['version'],
|
|
27728
|
+
[RTCPB.RtcRoomStatusOutput]: ['bFullStatus', 'version', 'usersData', 'roomStatus'],
|
|
27422
27729
|
[RTCPB.RtcReportSDKInput]: ['sdkInfo'],
|
|
27423
27730
|
[RTCPB.RtcPBPolaris]: ['type', 'appKey', 'sessionId', 'roomId', 'roomCreateTime', 'userId', 'userRole', 'joinTime', 'signalDataCenter', 'r1Info', 'r2Info', 'r3Info', 'r4Info'],
|
|
27424
27731
|
[RTCPB.RtcPBR1Info]: ['joinTime', 'rtcVersion', 'imVersion', 'platform', 'device', 'os', 'browserName', 'browserVersion'],
|
|
27425
27732
|
[RTCPB.RtcPBR2Info]: ['joinTime', 'sendTime', 'rtcActionType', 'rtcActionStatus', 'trackId'],
|
|
27426
27733
|
[RTCPB.RtcPBR3Info]: ['info'],
|
|
27427
27734
|
[RTCPB.RtcPBR4Info]: ['info'],
|
|
27428
|
-
[RTCPB.RtcPBStatusInfo]: ['joinTime', 'totalBitRate', 'appCPUUsage', 'systemCPUUsage', 'systemCPUFrequency', 'networkStatus', 'googleRTTNetwork', 'ipAddress', 'useReceiveBroadBand', 'useSendBroadBand', 'packetLossCount', 'streams'],
|
|
27735
|
+
[RTCPB.RtcPBStatusInfo]: ['joinTime', 'receiveTime', 'totalBitRate', 'appCPUUsage', 'systemCPUUsage', 'systemCPUFrequency', 'networkStatus', 'googleRTTNetwork', 'ipAddress', 'useReceiveBroadBand', 'useSendBroadBand', 'packetLossCount', 'streams'],
|
|
27429
27736
|
[RTCPB.RtcPBStreamInfo]: ['trackId', 'codeName', 'volume', 'samplingRate', 'bitRate', 'packetLossRate', 'frameRate', 'resolution', 'blockTime', 'jitterData', 'nAckCount', 'pliCount', 'googleRTTTotalTime', 'isReceiveFirstFrameRate', 'codeType', 'isEnabled'],
|
|
27430
27737
|
};
|
|
27431
27738
|
const desc = `
|
|
@@ -27462,6 +27769,23 @@ message probuf {
|
|
|
27462
27769
|
required string userId=1;
|
|
27463
27770
|
repeated ${RTCPB.RtcValueInfo} userData=2; //用户资源信息
|
|
27464
27771
|
}
|
|
27772
|
+
message ${RTCPB.RtcRoomStatusInput}{ // rtc 和 living room 拉房间资源状态使用的参数
|
|
27773
|
+
required int64 version =1; //当前客户端最大的房间状态的version
|
|
27774
|
+
}
|
|
27775
|
+
message ${RTCPB.RtcRoomStatusOutput}{ // rtc 和 living room 拉房间资源状态返回的数据
|
|
27776
|
+
required bool bFullStatus =1; //标识此次给的数据是否是全量数据
|
|
27777
|
+
required int64 version =2; //当前获取后房间的最大版本号
|
|
27778
|
+
repeated RtcUserInfo usersData=3;//如果是全量数据,这个不为空,给的是房间全部的人以及发布的资源
|
|
27779
|
+
repeated RtcRoomStatus roomStatus=4;//房间增量数据
|
|
27780
|
+
}
|
|
27781
|
+
message RtcRoomStatus{ //房间状态变动
|
|
27782
|
+
required string userId = 1;//用户ID
|
|
27783
|
+
required int32 event = 2;//房间状态变更的event(人员加入/退出/离线/发布资源) (0:加入;1:离开;2:离线;3:资源变动)
|
|
27784
|
+
required int64 time = 3;//本次变更的版本号
|
|
27785
|
+
repeated RtcValueInfo userData = 4;//用户变更的资源(event为0或者3时可能有值)
|
|
27786
|
+
optional int32 switchRoleType = 5;//如果是切换角色导致的加入房间或退出房间的类型
|
|
27787
|
+
optional string extra = 6;
|
|
27788
|
+
}
|
|
27465
27789
|
message ${RTCPB.RtcUserListOutput}{
|
|
27466
27790
|
repeated RtcUserInfo users=1;
|
|
27467
27791
|
optional string token=2;
|
|
@@ -27470,9 +27794,10 @@ message probuf {
|
|
|
27470
27794
|
repeated RtcKVEntity entries = 5;//直播KV属性对象集合
|
|
27471
27795
|
optional int64 syncTime = 6;//所有属性的最大时间戳(下次拉取KV时用)。
|
|
27472
27796
|
optional int32 offlineKickTime = 7;//server超时踢人时间,默认60s
|
|
27473
|
-
repeated string codeFormat = 8
|
|
27797
|
+
repeated string codeFormat = 8; //当前房间用户支持的编码交集
|
|
27474
27798
|
optional int64 roomCreateTime = 9;//房间创建时间
|
|
27475
|
-
optional int64 userJoinTime = 10
|
|
27799
|
+
optional int64 userJoinTime = 10;//用户加入房间
|
|
27800
|
+
optional int64 version = 11;//当前房间的版本号
|
|
27476
27801
|
}
|
|
27477
27802
|
message RtcRoomInfoOutput{
|
|
27478
27803
|
optional string roomId = 1;
|
|
@@ -27489,6 +27814,7 @@ message probuf {
|
|
|
27489
27814
|
optional JoinType joinType = 6; // 加入房间类型
|
|
27490
27815
|
repeated ${RTCPB.RtcValueInfo} innerDatas = 7; //用户内部inner数据,角色或者连麦信息等
|
|
27491
27816
|
repeated ${RTCPB.RtcValueInfo} outerDatas = 8; //用户内部outer数据,自定义数据结构RtcInput。
|
|
27817
|
+
optional bool supportNtf = 9; //是否支持房间状态的变更通过通知拉取的方式获取
|
|
27492
27818
|
}
|
|
27493
27819
|
message ${RTCPB.RtcQryOutput}{
|
|
27494
27820
|
repeated ${RTCPB.RtcValueInfo} outInfo=1;
|
|
@@ -27526,6 +27852,7 @@ message probuf {
|
|
|
27526
27852
|
message RtcOutput
|
|
27527
27853
|
{
|
|
27528
27854
|
optional int32 nothing=1;
|
|
27855
|
+
optional int64 version=2;
|
|
27529
27856
|
}
|
|
27530
27857
|
message ${RTCPB.RtcTokenOutput}{
|
|
27531
27858
|
required string rtcToken=1;
|
|
@@ -27671,18 +27998,18 @@ message probuf {
|
|
|
27671
27998
|
}
|
|
27672
27999
|
message ${RTCPB.RtcPBStatusInfo} {
|
|
27673
28000
|
optional int64 joinTime = 1;//用户加入房间的时间
|
|
27674
|
-
|
|
27675
|
-
optional int64 totalBitRate =
|
|
27676
|
-
optional float appCPUUsage =
|
|
27677
|
-
optional float systemCPUUsage =
|
|
27678
|
-
optional float systemCPUFrequency =
|
|
27679
|
-
optional string networkStatus =
|
|
27680
|
-
optional int32 googleRTTNetwork =
|
|
27681
|
-
optional string ipAddress =
|
|
27682
|
-
optional string useReceiveBroadBand =
|
|
27683
|
-
optional string useSendBroadBand =
|
|
27684
|
-
optional string packetLossCount =
|
|
27685
|
-
repeated ${RTCPB.RtcPBStreamInfo} streams =
|
|
28001
|
+
optional int64 receiveTime = 2;//用户发布数据流的时间(毫秒),暂时由客户端生成,后期如果有问题服务端做兜底处理
|
|
28002
|
+
optional int64 totalBitRate = 3;//总码率
|
|
28003
|
+
optional float appCPUUsage = 4;//APP CPU占用率
|
|
28004
|
+
optional float systemCPUUsage = 5;////系统 CPU占用率
|
|
28005
|
+
optional float systemCPUFrequency = 6;//系统CPU频率 (安卓8.0以上)
|
|
28006
|
+
optional string networkStatus = 7;//实时网络状态(2g、3g、4g、wifi)
|
|
28007
|
+
optional int32 googleRTTNetwork = 8;//Goog rtt 网络延迟
|
|
28008
|
+
optional string ipAddress = 9;//ip地址
|
|
28009
|
+
optional string useReceiveBroadBand = 10; //可接收带宽(单位: bit)
|
|
28010
|
+
optional string useSendBroadBand = 11;//可用发送带宽(单位: bit)
|
|
28011
|
+
optional string packetLossCount = 12;//丢包数
|
|
28012
|
+
repeated ${RTCPB.RtcPBStreamInfo} streams = 13;
|
|
27686
28013
|
}
|
|
27687
28014
|
message ${RTCPB.RtcPBStreamInfo} {
|
|
27688
28015
|
required string trackId = 1;
|
|
@@ -27706,7 +28033,7 @@ message probuf {
|
|
|
27706
28033
|
}
|
|
27707
28034
|
`;
|
|
27708
28035
|
|
|
27709
|
-
const encodeRtcInput = (codec, roomType, broadcastType, joinType, innerUserDatas, outerUserDatas) => {
|
|
28036
|
+
const encodeRtcInput = (codec, roomType, broadcastType, joinType, innerUserDatas, outerUserDatas, supportNtf) => {
|
|
27710
28037
|
const innerDatas = innerUserDatas
|
|
27711
28038
|
? Object.keys(innerUserDatas).map((key) => codec.encode(RTCPB.RtcValueInfo, { key, value: innerUserDatas[key] }, true))
|
|
27712
28039
|
: undefined;
|
|
@@ -27719,11 +28046,12 @@ message probuf {
|
|
|
27719
28046
|
joinType,
|
|
27720
28047
|
innerDatas,
|
|
27721
28048
|
outerDatas,
|
|
28049
|
+
supportNtf,
|
|
27722
28050
|
});
|
|
27723
28051
|
};
|
|
27724
28052
|
const decodeRtcUserListOutput = (codec, buffer) => {
|
|
27725
28053
|
const rtcInfos = codec.decode(RTCPB.RtcUserListOutput, buffer);
|
|
27726
|
-
const { users: list, token, sessionId, roomInfo, entries, offlineKickTime, codeFormat, roomCreateTime, userJoinTime, } = rtcInfos;
|
|
28054
|
+
const { users: list, token, sessionId, roomInfo, entries, offlineKickTime, codeFormat, roomCreateTime, userJoinTime, version, } = rtcInfos;
|
|
27727
28055
|
const users = {};
|
|
27728
28056
|
engine.forEach(list, (item) => {
|
|
27729
28057
|
const { userId, userData } = item;
|
|
@@ -27744,6 +28072,7 @@ message probuf {
|
|
|
27744
28072
|
codeFormat,
|
|
27745
28073
|
roomCreateTime: int64ToTimestamp(roomCreateTime),
|
|
27746
28074
|
userJoinTime: int64ToTimestamp(userJoinTime),
|
|
28075
|
+
version,
|
|
27747
28076
|
};
|
|
27748
28077
|
};
|
|
27749
28078
|
/**
|
|
@@ -27756,14 +28085,10 @@ message probuf {
|
|
|
27756
28085
|
};
|
|
27757
28086
|
if (reportType === RCReportType.R1 && r1Info) {
|
|
27758
28087
|
const innerR1Info = codec.encode(RTCPB.RtcPBR1Info, r1Info, true);
|
|
27759
|
-
// @TODO: 删除log
|
|
27760
|
-
console.log('innerR1Info:', innerR1Info);
|
|
27761
28088
|
return codec.encode(RTCPB.RtcPBPolaris, Object.assign(Object.assign({}, commonData), { r1Info: innerR1Info }));
|
|
27762
28089
|
}
|
|
27763
28090
|
if (reportType === RCReportType.R2 && r2Info) {
|
|
27764
28091
|
const innerR2Info = codec.encode(RTCPB.RtcPBR2Info, r2Info, true);
|
|
27765
|
-
// @TODO: 删除log
|
|
27766
|
-
console.log('innerR2Info:', innerR2Info);
|
|
27767
28092
|
return codec.encode(RTCPB.RtcPBPolaris, Object.assign(Object.assign({}, commonData), { r2Info: innerR2Info }));
|
|
27768
28093
|
}
|
|
27769
28094
|
/**
|
|
@@ -27775,8 +28100,6 @@ message probuf {
|
|
|
27775
28100
|
let innerStreams = Array.isArray(streams) && streams.map((stream) => codec.encode(RTCPB.RtcPBStreamInfo, stream, true));
|
|
27776
28101
|
let innerInfo = codec.encode(RTCPB.RtcPBStatusInfo, Object.assign(Object.assign({}, info), { streams: innerStreams }), true);
|
|
27777
28102
|
let innterR3Info = codec.encode(RTCPB.RtcPBR3Info, { info: innerInfo }, true);
|
|
27778
|
-
// @TODO: 删除log
|
|
27779
|
-
console.log('innterR3Info', innterR3Info);
|
|
27780
28103
|
return codec.encode(RTCPB.RtcPBPolaris, Object.assign(Object.assign({}, commonData), { r3Info: innterR3Info }));
|
|
27781
28104
|
}
|
|
27782
28105
|
if ((reportType === RCReportType.R4 && r4Info)) {
|
|
@@ -27785,8 +28108,6 @@ message probuf {
|
|
|
27785
28108
|
let innerStreams = Array.isArray(streams) && streams.map((stream) => codec.encode(RTCPB.RtcPBStreamInfo, stream, true));
|
|
27786
28109
|
let innerInfo = codec.encode(RTCPB.RtcPBStatusInfo, Object.assign(Object.assign({}, info), { streams: innerStreams }), true);
|
|
27787
28110
|
let innerR4Info = codec.encode(RTCPB.RtcPBR4Info, { info: innerInfo }, true);
|
|
27788
|
-
// @TODO: 删除log
|
|
27789
|
-
console.log('innerR4Info', innerR4Info);
|
|
27790
28111
|
return codec.encode(RTCPB.RtcPBPolaris, Object.assign(Object.assign({}, commonData), { r4Info: innerR4Info }));
|
|
27791
28112
|
}
|
|
27792
28113
|
return {};
|
|
@@ -27805,18 +28126,18 @@ message probuf {
|
|
|
27805
28126
|
}
|
|
27806
28127
|
joinRTCRoom(roomId, mode, broadcastType, joinType, innerUserDatas, outerUserDatas) {
|
|
27807
28128
|
return __awaiter(this, void 0, void 0, function* () {
|
|
27808
|
-
const sourceData = encodeRtcInput(this.codec, mode, broadcastType, joinType, innerUserDatas, outerUserDatas);
|
|
28129
|
+
const sourceData = encodeRtcInput(this.codec, mode, broadcastType, joinType, innerUserDatas, outerUserDatas, true);
|
|
27809
28130
|
const { code, buffer } = yield this.context.rtcSignaling(roomId, RTC_API.rtcRJoin_data, true, sourceData);
|
|
27810
28131
|
let data;
|
|
27811
28132
|
if (code === engine.ErrorCode.SUCCESS && buffer) {
|
|
27812
28133
|
data = decodeRtcUserListOutput(this.codec, buffer);
|
|
27813
|
-
const { users, token, sessionId, roomInfo, kvEntries, offlineKickTime, roomCreateTime, userJoinTime, } = data;
|
|
28134
|
+
const { users, token, sessionId, roomInfo, kvEntries, offlineKickTime, roomCreateTime, userJoinTime, version, } = data;
|
|
27814
28135
|
this.roomCreateTime = roomCreateTime;
|
|
27815
28136
|
this.userJoinTime = userJoinTime;
|
|
27816
28137
|
return {
|
|
27817
28138
|
code,
|
|
27818
28139
|
data: {
|
|
27819
|
-
users, token, sessionId, roomInfo, kvEntries, offlineKickTime,
|
|
28140
|
+
users, token, sessionId, roomInfo, kvEntries, offlineKickTime, version,
|
|
27820
28141
|
},
|
|
27821
28142
|
};
|
|
27822
28143
|
}
|
|
@@ -27975,9 +28296,6 @@ message probuf {
|
|
|
27975
28296
|
setRTCStateByHttp(logServer, runtime, report, reportType) {
|
|
27976
28297
|
return __awaiter(this, void 0, void 0, function* () {
|
|
27977
28298
|
const sourceData = encodeRtcHttp3Report(this.codec, report, reportType);
|
|
27978
|
-
// @TODO: 删除log
|
|
27979
|
-
console.log('setRTCStateByHttp encode return sourceData', sourceData);
|
|
27980
|
-
console.log('RCMediaService.jwtToken:', RCMediaService.jwtToken);
|
|
27981
28299
|
let logServerDomain = logServer;
|
|
27982
28300
|
if (!/^https:\/\//.test(logServer)) {
|
|
27983
28301
|
logServerDomain = `https://${logServer}`;
|
|
@@ -27991,8 +28309,6 @@ message probuf {
|
|
|
27991
28309
|
jwt: RCMediaService.jwtToken,
|
|
27992
28310
|
},
|
|
27993
28311
|
});
|
|
27994
|
-
// @TODO: 删除 log
|
|
27995
|
-
console.log('res.data: ', res.data);
|
|
27996
28312
|
if (!res.data) {
|
|
27997
28313
|
throw new Error('http request fail');
|
|
27998
28314
|
}
|
|
@@ -28000,8 +28316,6 @@ message probuf {
|
|
|
28000
28316
|
return status;
|
|
28001
28317
|
}
|
|
28002
28318
|
catch (error) {
|
|
28003
|
-
// @TODO: 删除log
|
|
28004
|
-
console.log(`setRTCStateByHttp error -> ${error}`);
|
|
28005
28319
|
return RCSendCode.REPORT_FAIL;
|
|
28006
28320
|
}
|
|
28007
28321
|
});
|
|
@@ -28174,6 +28488,25 @@ message probuf {
|
|
|
28174
28488
|
};
|
|
28175
28489
|
});
|
|
28176
28490
|
}
|
|
28491
|
+
/**
|
|
28492
|
+
* 通知拉取房间数据
|
|
28493
|
+
* @param roomId 房间 id
|
|
28494
|
+
* @param version 本地最大得房间数据版本号
|
|
28495
|
+
*/
|
|
28496
|
+
pullRTCRoomStatus(roomId, version) {
|
|
28497
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
28498
|
+
const sourceData = this.codec.encode(RTCPB.RtcRoomStatusInput, { version });
|
|
28499
|
+
const { code, buffer } = yield this.context.rtcSignaling(roomId, RTC_API.rtcPullRoomStatus, true, sourceData);
|
|
28500
|
+
if (code !== engine.ErrorCode.SUCCESS) {
|
|
28501
|
+
return { code };
|
|
28502
|
+
}
|
|
28503
|
+
const data = this.codec.decode(RTCPB.RtcRoomStatusOutput, buffer);
|
|
28504
|
+
return {
|
|
28505
|
+
code,
|
|
28506
|
+
data,
|
|
28507
|
+
};
|
|
28508
|
+
});
|
|
28509
|
+
}
|
|
28177
28510
|
decodeRtcNotify(buffer) {
|
|
28178
28511
|
const { time, type, roomId } = this.codec.decode(RTCPB.RtcNotifyMsg, buffer);
|
|
28179
28512
|
return { time: int64ToTimestamp(time), type, roomId };
|
|
@@ -28190,8 +28523,29 @@ message probuf {
|
|
|
28190
28523
|
getAppkey() {
|
|
28191
28524
|
return this.context.getAppkey();
|
|
28192
28525
|
}
|
|
28526
|
+
/** web 端发 rtcPing */
|
|
28527
|
+
webRtcPing(roomId, roomMode, broadcastType) {
|
|
28528
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
28529
|
+
const sourceData = this.codec.encode(RTCPB.RtcInput, { roomType: roomMode, broadcastType });
|
|
28530
|
+
const { code, buffer } = yield this.context.rtcSignaling(roomId, RTC_API.rtcPing, true, sourceData);
|
|
28531
|
+
if (code !== engine.ErrorCode.SUCCESS) {
|
|
28532
|
+
return { code };
|
|
28533
|
+
}
|
|
28534
|
+
const data = this.codec.decode(RTCPB.RtcOutput, buffer);
|
|
28535
|
+
data.version = int64ToTimestamp(data.version);
|
|
28536
|
+
return { code, data };
|
|
28537
|
+
});
|
|
28538
|
+
}
|
|
28539
|
+
/**
|
|
28540
|
+
* 协议栈 rtcping 依赖 imlib 编解码数据
|
|
28541
|
+
* web 单独走 imlib 提供的 rtcSignaling 方法,减少对 imlib 的依赖
|
|
28542
|
+
*/
|
|
28193
28543
|
rtcPing(roomId, roomMode, broadcastType) {
|
|
28194
|
-
|
|
28544
|
+
const isElectron = /Electron/.test(navigator.userAgent);
|
|
28545
|
+
if (isElectron) {
|
|
28546
|
+
return this.context.rtcPingResVersion(roomId, roomMode, broadcastType);
|
|
28547
|
+
}
|
|
28548
|
+
return this.webRtcPing(roomId, roomMode, broadcastType);
|
|
28195
28549
|
}
|
|
28196
28550
|
sendMessage(conversationType, targetId, options) {
|
|
28197
28551
|
return this.context.sendMessage(conversationType, targetId, options);
|
|
@@ -28244,21 +28598,21 @@ message probuf {
|
|
|
28244
28598
|
console.error('Please use the https protocol or use `http://localhost` to open the page!');
|
|
28245
28599
|
return false;
|
|
28246
28600
|
}
|
|
28247
|
-
engine.VersionManage.add('plugin-rtc', "5.5.
|
|
28248
|
-
if (!engine.VersionManage.validEngine("^5.
|
|
28249
|
-
console.error(`The current engine version '${engine.VersionManage.getInfo().engine}' error, plugin-rtc required engine version at least '${"^5.
|
|
28601
|
+
engine.VersionManage.add('plugin-rtc', "5.5.5-beem-alpha.1");
|
|
28602
|
+
if (!engine.VersionManage.validEngine("^5.6.0-beem-alpha.6")) {
|
|
28603
|
+
console.error(`The current engine version '${engine.VersionManage.getInfo().engine}' error, plugin-rtc required engine version at least '${"^5.6.0-beem-alpha.6"}'.`);
|
|
28250
28604
|
return false;
|
|
28251
28605
|
}
|
|
28252
28606
|
return true;
|
|
28253
28607
|
},
|
|
28254
|
-
setup(context, runtime, options = {}) {
|
|
28608
|
+
setup(context, runtime, options = { signalRetryTime: 30 * 1000 }) {
|
|
28255
28609
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
28256
28610
|
const logger = context.createLogger('rtc-logger', LogSource.RTC);
|
|
28257
28611
|
logger.setOutputLevel(options.logLevel || engine.LogL.DEBUG);
|
|
28258
28612
|
RTCLogger.setLogger(logger);
|
|
28259
28613
|
logger.warn(RCLoggerTag.L_INDEX_INSTALL_RTC_PLUGIN_O, JSON.stringify({
|
|
28260
|
-
'RCRTC Version': "5.5.
|
|
28261
|
-
Commit: "
|
|
28614
|
+
'RCRTC Version': "5.5.5-beem-alpha.1",
|
|
28615
|
+
Commit: "4807d9272db7b224e762a75df11762453a730f9e",
|
|
28262
28616
|
'browserInfo.browser': browserInfo.browser,
|
|
28263
28617
|
'browserInfo.supportsUnifiedPlan': browserInfo.supportsUnifiedPlan,
|
|
28264
28618
|
'browserInfo.version': browserInfo.version,
|