@rongcloud/plugin-rtc 5.5.4-alpha.1 → 5.5.4-alpha.2

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 CHANGED
@@ -1,11 +1,10 @@
1
1
  /*
2
- * RCRTC - v5.5.4-alpha.1
3
- * CommitId - 5979242633209b9a8830d449c1d7a425a1868f7b
4
- * Fri Sep 30 2022 20:48:58 GMT+0800 (China Standard Time)
2
+ * RCRTC - v5.5.4-alpha.2
3
+ * CommitId - 6a4ddd72afc98e179707633218f3c02265a15869
4
+ * Sat Oct 08 2022 23:09:53 GMT+0800 (China Standard Time)
5
5
  * ©2020 RongCloud, Inc. All rights reserved.
6
6
  */
7
- import * as _rongcloud_engine from '@rongcloud/engine';
8
- import { EventEmitter, RTCPluginContext, AbsCodec, IPromiseResult, ErrorCode, KVString, IAsyncRes, ConnectionStatus, ConversationType, ISendMsgOptions, IReceivedMessage, IRuntime, LogLevel, IPluginGenerator } from '@rongcloud/engine';
7
+ import { EventEmitter, INaviInfo, RTCPluginContext, AbsCodec, IPromiseResult, ErrorCode, KVString, IRuntime, IAsyncRes, ConnectionStatus, ConversationType, ISendMsgOptions, IReceivedMessage, LogLevel, IPluginGenerator } from '@rongcloud/engine';
9
8
 
10
9
  /**
11
10
  * 错误码,与移动端对齐
@@ -20,6 +19,8 @@ import { EventEmitter, RTCPluginContext, AbsCodec, IPromiseResult, ErrorCode, KV
20
19
  declare enum RCRTCCode {
21
20
  /** 成功 */
22
21
  SUCCESS = 10000,
22
+ /** PB 错误 */
23
+ PB_ERROR = 40001,
23
24
  /** IM 服务未连接 */
24
25
  SIGNAL_DISCONNECTED = 50000,
25
26
  /** 参数错误 */
@@ -1279,6 +1280,13 @@ declare const keymaps: {
1279
1280
  readonly RtcInviteAnswerInput: readonly ["inviteUserId", "answerCode", "inviteRoomId", "inviteSessionId", "content", "key", "value"];
1280
1281
  readonly RtcEndInviteInput: readonly ["inviteRoomId", "inviteSessionId", "inviteContent", "inviteRoomKeys"];
1281
1282
  readonly RtcReportSDKInput: readonly ["sdkInfo"];
1283
+ readonly RCRTCPBPolaris: readonly ["type", "appKey", "sessionId", "roomId", "roomCreateTime", "userId", "userRole", "joinTime", "signalDataCenter", "r1Info", "r2Info", "r3Info", "r4Info"];
1284
+ readonly RCRTCPBR1Info: readonly ["joinTime", "rtcVersion", "imVersion", "platform", "device", "os", "browserName", "browserVersion"];
1285
+ readonly RCRTCPBR2Info: readonly ["joinTime", "sendTime", "rtcActionType", "rtcActionStatus", "trackId"];
1286
+ readonly RCRTCPBR3Info: readonly ["info"];
1287
+ readonly RCRTCPBR4Info: readonly ["info"];
1288
+ readonly RCRTCPBStatusInfo: readonly ["joinTime", "totalBitRate", "appCPUUsage", "systemCPUUsage", "systemCPUFrequency", "networkStatus", "googleRTTNetwork", "ipAddress", "useReceiveBroadBand", "useSendBroadBand", "packetLossCount", "streams"];
1289
+ readonly RCRTCPBStreamInfo: readonly ["trackId", "codeName", "volume", "samplingRate", "bitRate", "packetLossRate", "frameRate", "resolution", "blockTime", "jitterData", "nAckCount", "pliCount", "googleRTTTotalTime", "isReceiveFirstFrameRate", "codeType", "isEnabled"];
1282
1290
  };
1283
1291
  declare type RTCKeyMaps = typeof keymaps;
1284
1292
 
@@ -1344,6 +1352,9 @@ interface IJoinRTCRoomData extends IRTCUsers {
1344
1352
  }[];
1345
1353
  kvEntries: IServerRTCRoomEntry[];
1346
1354
  offlineKickTime: number;
1355
+ codeFormat?: string;
1356
+ roomCreateTime?: number;
1357
+ userJoinTime?: number;
1347
1358
  }
1348
1359
  interface IReqRoomPKOptions {
1349
1360
  /**
@@ -1449,10 +1460,40 @@ interface IEndRoomPKOptions {
1449
1460
  */
1450
1461
  keys: string[];
1451
1462
  }
1463
+ interface IRTCNaviInfo extends INaviInfo {
1464
+ /**
1465
+ * jwt token
1466
+ */
1467
+ jwt?: string;
1468
+ /**
1469
+ * http3 上报域名
1470
+ */
1471
+ logServer?: string;
1472
+ /**
1473
+ * 数据中心
1474
+ */
1475
+ dc?: string;
1476
+ /**
1477
+ * openGzip 开启标识,默认是false,开启使用true
1478
+ */
1479
+ openGzip?: boolean;
1480
+ }
1481
+
1482
+ /**
1483
+ * 自定义上报北极星数据响应 code
1484
+ */
1485
+ declare enum RCSendCode {
1486
+ NOT_REPORT = -1,
1487
+ REPORT_SUCCESS = 10000,
1488
+ REPORT_FAIL = 0,
1489
+ PB_ERROR = 40001
1490
+ }
1452
1491
 
1453
1492
  declare class RTCContext {
1454
1493
  private context;
1455
1494
  private codec;
1495
+ roomCreateTime: number | undefined;
1496
+ userJoinTime: number | undefined;
1456
1497
  constructor(context: RTCPluginContext, codec: AbsCodec<RTCKeyMaps>);
1457
1498
  joinRTCRoom(roomId: string, mode: RTCMode, broadcastType?: number, joinType?: RTCJoinType, innerUserDatas?: IRTCUserData, outerUserDatas?: IRTCUserData): IPromiseResult<IJoinRTCRoomData>;
1458
1499
  quitRTCRoom(roomId: string): Promise<ErrorCode>;
@@ -1485,6 +1526,10 @@ declare class RTCContext {
1485
1526
  getRTCOutData(roomId: string, userIds: string[]): IPromiseResult<unknown>;
1486
1527
  getRTCToken(roomId: string, mode: number, broadcastType?: number): IPromiseResult<IRtcTokenData>;
1487
1528
  setRTCState(roomId: string, report: string): Promise<ErrorCode>;
1529
+ /**
1530
+ * 通过 http 方式上报 rtc state
1531
+ */
1532
+ setRTCStateByHttp(logServer: string, runtime: IRuntime, report: IRCRTCReportData, reportType: string): Promise<RCSendCode | RCRTCCode>;
1488
1533
  getRTCUserList(roomId: string): IPromiseResult<IRTCUsers>;
1489
1534
  joinLivingRoomAsAudience(roomId: string, mode: RTCMode, broadcastType?: number): Promise<IAsyncRes<{
1490
1535
  token: string;
@@ -1504,7 +1549,7 @@ declare class RTCContext {
1504
1549
  roomId: any;
1505
1550
  };
1506
1551
  getCurrentId(): string;
1507
- getNaviInfo(): _rongcloud_engine.INaviInfo | null;
1552
+ getNaviInfo(): IRTCNaviInfo | null;
1508
1553
  getConnectionStatus(): ConnectionStatus;
1509
1554
  getAppkey(): string;
1510
1555
  rtcPing(roomId: string, roomMode: number, broadcastType?: number): Promise<ErrorCode>;
@@ -1562,7 +1607,7 @@ declare class RCMediaService {
1562
1607
  private static msInDetector;
1563
1608
  private static detectorTime;
1564
1609
  private static detectValidMinute;
1565
- private static naviRefetchCount;
1610
+ static jwtToken: string;
1566
1611
  private _msList;
1567
1612
  constructor(_runtime: IRuntime, _context: RTCContext,
1568
1613
  /**
@@ -1573,7 +1618,7 @@ declare class RCMediaService {
1573
1618
  * 请求超时时长
1574
1619
  */
1575
1620
  _timeout?: number);
1576
- detectorMediaSever(): void;
1621
+ detectorMediaSever(newNaviInfo?: INaviInfo | null): void;
1577
1622
  /**
1578
1623
  * 地址探测
1579
1624
  * RTC 初始化时检测是否可以拿到 navi,可以拿到开始嗅探
@@ -1708,7 +1753,7 @@ declare class RCRTCPeerCManager {
1708
1753
  /**
1709
1754
  * 北极星上报模块
1710
1755
  */
1711
- _polarisReport?: PolarisReporter | undefined);
1756
+ _polarisReport?: PolarisHttpReporter | undefined);
1712
1757
  get useMutilPeerC(): boolean;
1713
1758
  /**
1714
1759
  * 根据 track 判断是否为上行
@@ -1828,7 +1873,7 @@ declare abstract class ReadableStore {
1828
1873
  readonly roomId: string;
1829
1874
  readonly crtUserId: string;
1830
1875
  readonly roomMode: RTCMode;
1831
- readonly polarisReport: PolarisReporter;
1876
+ readonly polarisReport: PolarisHttpReporter;
1832
1877
  readonly isUpgrade?: boolean | undefined;
1833
1878
  readonly isMainRoom?: boolean | undefined;
1834
1879
  /**
@@ -1860,7 +1905,7 @@ declare abstract class ReadableStore {
1860
1905
  protected _CDNUris: ICDNUris | null;
1861
1906
  protected _CDNEnable: boolean;
1862
1907
  protected _destroyed: boolean;
1863
- constructor(context: RTCContext, service: RCMediaService, peerMgr: RCRTCPeerCManager, roomId: string, crtUserId: string, roomMode: RTCMode, polarisReport: PolarisReporter, isUpgrade?: boolean | undefined, isMainRoom?: boolean | undefined);
1908
+ constructor(context: RTCContext, service: RCMediaService, peerMgr: RCRTCPeerCManager, roomId: string, crtUserId: string, roomMode: RTCMode, polarisReport: PolarisHttpReporter, isUpgrade?: boolean | undefined, isMainRoom?: boolean | undefined);
1864
1909
  get useMutilPeerC(): boolean;
1865
1910
  getResourcesByUserId(userId: string): IPublishedResource[] | undefined;
1866
1911
  getRemoteTrack(trackId: string): RCRemoteTrack | undefined;
@@ -1960,7 +2005,7 @@ declare class BaseInvoker<STORE> {
1960
2005
  * 房间任务队列管理
1961
2006
  */
1962
2007
  declare class Invoker extends BaseInvoker<Store> {
1963
- constructor(context: RTCContext, service: RCMediaService, peerMrg: RCRTCPeerCManager, roomId: string, crtUserId: string, mode: RTCMode, reporter: PolarisReporter, isUpgrade?: boolean, isMainRoom?: boolean);
2008
+ constructor(context: RTCContext, service: RCMediaService, peerMrg: RCRTCPeerCManager, roomId: string, crtUserId: string, mode: RTCMode, reporter: PolarisHttpReporter, isUpgrade?: boolean, isMainRoom?: boolean);
1964
2009
  /**
1965
2010
  * 获取 store 存储实例,返回值类型 `ReadableStore`,避免非 command 定义中修改内存
1966
2011
  */
@@ -2165,7 +2210,7 @@ declare abstract class RCAbstractRoom extends EventEmitter {
2165
2210
  /**
2166
2211
  * 北极星上报实例
2167
2212
  */
2168
- protected _polarisReport: PolarisReporter | null;
2213
+ protected _polarisReport: PolarisHttpReporter | null;
2169
2214
  /**
2170
2215
  * 音量上报实例
2171
2216
  */
@@ -2589,7 +2634,7 @@ declare class RCAudienceLivingRoom {
2589
2634
  /**
2590
2635
  * 北极星上报实例
2591
2636
  */
2592
- protected _polarisReport: PolarisReporter | null;
2637
+ protected _polarisReport: PolarisHttpReporter | null;
2593
2638
  /**
2594
2639
  * 音量上报实例
2595
2640
  */
@@ -2837,7 +2882,7 @@ declare class PolarisReporter {
2837
2882
  * @param resourceId userId_11_1_tiny 改为 userId_11_tiny_video
2838
2883
  */
2839
2884
  private _getPolarisTrackId;
2840
- sendR3R4Data(data: IInnerRCRTCStateReport): Promise<boolean>;
2885
+ sendR3R4Data(data: IInnerRCRTCStateReport): Promise<RCSendCode>;
2841
2886
  /**
2842
2887
  * 加入房间
2843
2888
  */
@@ -2849,6 +2894,42 @@ declare class PolarisReporter {
2849
2894
  sendR2(action: string, status: string, trackIds: string[]): void;
2850
2895
  }
2851
2896
 
2897
+ declare class PolarisHttpReporter {
2898
+ private readonly _context;
2899
+ private readonly _runtime;
2900
+ private readonly _roomId;
2901
+ private readonly _crtRTCRoom;
2902
+ private readonly _userRole;
2903
+ protected _polarisSignalReporter: PolarisReporter | null;
2904
+ private _useHttp;
2905
+ constructor(_context: RTCContext, _runtime: IRuntime, _roomId: string, _crtRTCRoom: RCAbstractRoom | RCAudienceLivingRoom, _userRole?: PolarisRole);
2906
+ private _send;
2907
+ /**
2908
+ * 小流需去掉 _tiny,小流 resourceId 为 userId_tag_mediaType_tiny
2909
+ */
2910
+ private _getRealResourceId;
2911
+ /**
2912
+ * 生成北极星上报的 trackId
2913
+ * @param resourceId userId_11_1_tiny 改为 userId_11_tiny_video
2914
+ */
2915
+ private _getPolarisTrackId;
2916
+ private _formatReportBaseData;
2917
+ private _formatReportData;
2918
+ private _formatR1Data;
2919
+ private _formatR2Data;
2920
+ private _formatR3R4Data;
2921
+ sendR3R4Data(data: IInnerRCRTCStateReport): Promise<RCSendCode>;
2922
+ /**
2923
+ * 加入房间
2924
+ */
2925
+ sendR1(): Promise<void>;
2926
+ /**
2927
+ * RTC 和 LIVE 发布、取消发布
2928
+ * RTC 订阅、取消订阅
2929
+ */
2930
+ sendR2(action: string, status: string, trackIds: string[]): Promise<void>;
2931
+ }
2932
+
2852
2933
  /**
2853
2934
  * PC 实例管理类
2854
2935
  */
@@ -2896,7 +2977,7 @@ declare class RCRTCPeerConnection extends EventEmitter {
2896
2977
  /**
2897
2978
  * 北极星上传实例
2898
2979
  */
2899
- _polarisReport?: PolarisReporter | undefined);
2980
+ _polarisReport?: PolarisHttpReporter | undefined);
2900
2981
  getName(): string;
2901
2982
  getLocalTracks(): RCLocalTrack[];
2902
2983
  private _onConnectionStateChange;
@@ -3260,6 +3341,216 @@ interface IRCRTCStateReport {
3260
3341
  */
3261
3342
  receivers: IRCTrackStat[];
3262
3343
  }
3344
+ /**
3345
+ * http3 北极星上报基础数据
3346
+ */
3347
+ interface IRCRTCReportBaseData {
3348
+ /**
3349
+ * 上报数据类型 R1-R4
3350
+ */
3351
+ type: string;
3352
+ appKey: string;
3353
+ /**
3354
+ * 房间通话id
3355
+ */
3356
+ sessionId: string;
3357
+ roomId: string;
3358
+ /**
3359
+ * 房间创建时间
3360
+ */
3361
+ roomCreateTime: number;
3362
+ userId: string;
3363
+ userRole: number;
3364
+ joinTime: number;
3365
+ /**
3366
+ * signal 数据中心
3367
+ * */
3368
+ signalDataCenter: string;
3369
+ }
3370
+ /**
3371
+ * http3 北极星上报 R1 数据
3372
+ */
3373
+ interface IR1Info {
3374
+ /**
3375
+ * 用户加入房间的时间
3376
+ */
3377
+ joinTime: number;
3378
+ /**
3379
+ * RTC 版本号
3380
+ */
3381
+ rtcVersion: string;
3382
+ /**
3383
+ * IM SDK 版本
3384
+ */
3385
+ imVersion: string;
3386
+ /**
3387
+ * 平台(如:Android、iOS、Web)
3388
+ */
3389
+ platform: string;
3390
+ /**
3391
+ * 设备信息(手机名称+型号)
3392
+ */
3393
+ device: string;
3394
+ /**
3395
+ * 系统版本(手机系统版本)
3396
+ */
3397
+ os: string;
3398
+ /**
3399
+ * 浏览器名称, 没有用 -1 表示
3400
+ */
3401
+ browserName?: string;
3402
+ /**
3403
+ * 浏览器版本, 没有用 -1 表示
3404
+ */
3405
+ browserVersion?: string;
3406
+ }
3407
+ /**
3408
+ * http3 北极星上报 R2 数据
3409
+ */
3410
+ interface IR2Info {
3411
+ /**
3412
+ * 用户加入房间的时间
3413
+ */
3414
+ joinTime: number;
3415
+ /**
3416
+ * 客户端 发布/取消发布 订阅/取消订阅 资源的时间
3417
+ */
3418
+ sendTime: number;
3419
+ /**
3420
+ * 发布类型 subscribe : 订阅 publish : 发布
3421
+ */
3422
+ rtcActionType: string;
3423
+ /**
3424
+ * 发布状态 begin : 开始 tend : 结束
3425
+ */
3426
+ rtcActionStatus: string;
3427
+ trackId: string[];
3428
+ }
3429
+ /**
3430
+ * http3 北极星上报 R3 数据
3431
+ */
3432
+ interface IR3R4Info {
3433
+ info: IR3R4CommonInfo;
3434
+ }
3435
+ interface IR3R4CommonInfo {
3436
+ /**
3437
+ * 用户加入房间的时间
3438
+ */
3439
+ joinTime?: number;
3440
+ /**
3441
+ * 总码率
3442
+ */
3443
+ totalBitRate?: number;
3444
+ /**
3445
+ * APP CPU占用率
3446
+ */
3447
+ appCPUUsage?: number;
3448
+ /**
3449
+ * 系统 CPU占用率
3450
+ */
3451
+ systemCPUUsage?: number;
3452
+ /**
3453
+ * 系统CPU频率 (安卓8.0以上)
3454
+ */
3455
+ systemCPUFrequency?: number;
3456
+ /**
3457
+ * 实时网络状态(2g、3g、4g、wifi)
3458
+ */
3459
+ networkStatus?: string;
3460
+ /**
3461
+ * Goog rtt 网络延迟
3462
+ */
3463
+ googleRTTNetwork?: number;
3464
+ /**
3465
+ * ip地址
3466
+ */
3467
+ ipAddress?: string;
3468
+ /**
3469
+ * 可接收带宽(单位: bit)
3470
+ */
3471
+ useReceiveBroadBand?: string;
3472
+ /**
3473
+ * 可用发送带宽(单位: bit)
3474
+ */
3475
+ useSendBroadBand?: string;
3476
+ /**
3477
+ * 丢包数
3478
+ */
3479
+ packetLossCount?: string;
3480
+ streams?: IR3R4StreamInfo[];
3481
+ }
3482
+ /**
3483
+ * http3 北极星上报 R3、R4 streamInfo 数据
3484
+ */
3485
+ interface IR3R4StreamInfo {
3486
+ trackId: string;
3487
+ /**
3488
+ * 编解码名称
3489
+ */
3490
+ codeName?: string;
3491
+ /**
3492
+ * 音频播放音量
3493
+ */
3494
+ volume?: string;
3495
+ /**
3496
+ * 音频采样率
3497
+ */
3498
+ samplingRate: number;
3499
+ /**
3500
+ * 下行码率
3501
+ */
3502
+ bitRate?: number;
3503
+ packetLossRate?: number;
3504
+ /**
3505
+ * 视频接收帧率(单位:fps)
3506
+ */
3507
+ frameRate?: number;
3508
+ /**
3509
+ * 视频分辨率(格式:640*480)
3510
+ */
3511
+ resolution?: string;
3512
+ /**
3513
+ * 接收卡顿(间隔时间, 单位: ms)
3514
+ */
3515
+ blockTime?: number;
3516
+ /**
3517
+ * jitter数据抖动
3518
+ */
3519
+ jitterData?: number;
3520
+ /**
3521
+ * nack数量
3522
+ */
3523
+ nAckCount?: string;
3524
+ /**
3525
+ * PLI请求数
3526
+ */
3527
+ pliCount?: string;
3528
+ /**
3529
+ * googRtt往返时长
3530
+ */
3531
+ googleRTTTotalTime?: number;
3532
+ /**
3533
+ * 第一个关键帧是否正常收到
3534
+ */
3535
+ isReceiveFirstFrameRate?: number;
3536
+ /**
3537
+ * 编码方式
3538
+ */
3539
+ codeType?: string;
3540
+ /**
3541
+ * 当前流的状态是否可用
3542
+ */
3543
+ isEnabled?: number;
3544
+ }
3545
+ /**
3546
+ * http3 北极星上报总数据
3547
+ */
3548
+ interface IRCRTCReportData extends IRCRTCReportBaseData {
3549
+ r1Info?: IR1Info;
3550
+ r2Info?: IR2Info;
3551
+ r3Info?: IR3R4Info;
3552
+ r4Info?: IR3R4Info;
3553
+ }
3263
3554
  interface IRCRTCReportListener {
3264
3555
  /**
3265
3556
  * RTCPeerConnection 的详细状态数据