@rongcloud/plugin-rtc 5.5.3 → 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.3
3
- * CommitId - 07c9cc6a285a9f5cd59a94126514dc54495a17c2
4
- * Fri Sep 30 2022 19:05:33 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
  /** 参数错误 */
@@ -646,7 +647,19 @@ declare enum RTCMode {
646
647
  /**
647
648
  * 跨应用直播
648
649
  */
649
- CROSS_LIVE = 8
650
+ CROSS_LIVE = 8,
651
+ /**
652
+ * sip呼叫
653
+ */
654
+ SIP = 4,
655
+ /**
656
+ * 呼叫模式.包括单呼和群呼
657
+ */
658
+ CALL = 5,
659
+ /**
660
+ * 会议
661
+ */
662
+ MEETING = 6
650
663
  }
651
664
 
652
665
  /**
@@ -1267,6 +1280,13 @@ declare const keymaps: {
1267
1280
  readonly RtcInviteAnswerInput: readonly ["inviteUserId", "answerCode", "inviteRoomId", "inviteSessionId", "content", "key", "value"];
1268
1281
  readonly RtcEndInviteInput: readonly ["inviteRoomId", "inviteSessionId", "inviteContent", "inviteRoomKeys"];
1269
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"];
1270
1290
  };
1271
1291
  declare type RTCKeyMaps = typeof keymaps;
1272
1292
 
@@ -1332,6 +1352,9 @@ interface IJoinRTCRoomData extends IRTCUsers {
1332
1352
  }[];
1333
1353
  kvEntries: IServerRTCRoomEntry[];
1334
1354
  offlineKickTime: number;
1355
+ codeFormat?: string;
1356
+ roomCreateTime?: number;
1357
+ userJoinTime?: number;
1335
1358
  }
1336
1359
  interface IReqRoomPKOptions {
1337
1360
  /**
@@ -1437,10 +1460,40 @@ interface IEndRoomPKOptions {
1437
1460
  */
1438
1461
  keys: string[];
1439
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
+ }
1440
1491
 
1441
1492
  declare class RTCContext {
1442
1493
  private context;
1443
1494
  private codec;
1495
+ roomCreateTime: number | undefined;
1496
+ userJoinTime: number | undefined;
1444
1497
  constructor(context: RTCPluginContext, codec: AbsCodec<RTCKeyMaps>);
1445
1498
  joinRTCRoom(roomId: string, mode: RTCMode, broadcastType?: number, joinType?: RTCJoinType, innerUserDatas?: IRTCUserData, outerUserDatas?: IRTCUserData): IPromiseResult<IJoinRTCRoomData>;
1446
1499
  quitRTCRoom(roomId: string): Promise<ErrorCode>;
@@ -1473,6 +1526,10 @@ declare class RTCContext {
1473
1526
  getRTCOutData(roomId: string, userIds: string[]): IPromiseResult<unknown>;
1474
1527
  getRTCToken(roomId: string, mode: number, broadcastType?: number): IPromiseResult<IRtcTokenData>;
1475
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>;
1476
1533
  getRTCUserList(roomId: string): IPromiseResult<IRTCUsers>;
1477
1534
  joinLivingRoomAsAudience(roomId: string, mode: RTCMode, broadcastType?: number): Promise<IAsyncRes<{
1478
1535
  token: string;
@@ -1492,7 +1549,7 @@ declare class RTCContext {
1492
1549
  roomId: any;
1493
1550
  };
1494
1551
  getCurrentId(): string;
1495
- getNaviInfo(): _rongcloud_engine.INaviInfo | null;
1552
+ getNaviInfo(): IRTCNaviInfo | null;
1496
1553
  getConnectionStatus(): ConnectionStatus;
1497
1554
  getAppkey(): string;
1498
1555
  rtcPing(roomId: string, roomMode: number, broadcastType?: number): Promise<ErrorCode>;
@@ -1550,7 +1607,7 @@ declare class RCMediaService {
1550
1607
  private static msInDetector;
1551
1608
  private static detectorTime;
1552
1609
  private static detectValidMinute;
1553
- private static naviRefetchCount;
1610
+ static jwtToken: string;
1554
1611
  private _msList;
1555
1612
  constructor(_runtime: IRuntime, _context: RTCContext,
1556
1613
  /**
@@ -1561,7 +1618,7 @@ declare class RCMediaService {
1561
1618
  * 请求超时时长
1562
1619
  */
1563
1620
  _timeout?: number);
1564
- detectorMediaSever(): void;
1621
+ detectorMediaSever(newNaviInfo?: INaviInfo | null): void;
1565
1622
  /**
1566
1623
  * 地址探测
1567
1624
  * RTC 初始化时检测是否可以拿到 navi,可以拿到开始嗅探
@@ -1696,7 +1753,7 @@ declare class RCRTCPeerCManager {
1696
1753
  /**
1697
1754
  * 北极星上报模块
1698
1755
  */
1699
- _polarisReport?: PolarisReporter | undefined);
1756
+ _polarisReport?: PolarisHttpReporter | undefined);
1700
1757
  get useMutilPeerC(): boolean;
1701
1758
  /**
1702
1759
  * 根据 track 判断是否为上行
@@ -1816,7 +1873,7 @@ declare abstract class ReadableStore {
1816
1873
  readonly roomId: string;
1817
1874
  readonly crtUserId: string;
1818
1875
  readonly roomMode: RTCMode;
1819
- readonly polarisReport: PolarisReporter;
1876
+ readonly polarisReport: PolarisHttpReporter;
1820
1877
  readonly isUpgrade?: boolean | undefined;
1821
1878
  readonly isMainRoom?: boolean | undefined;
1822
1879
  /**
@@ -1848,7 +1905,7 @@ declare abstract class ReadableStore {
1848
1905
  protected _CDNUris: ICDNUris | null;
1849
1906
  protected _CDNEnable: boolean;
1850
1907
  protected _destroyed: boolean;
1851
- 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);
1852
1909
  get useMutilPeerC(): boolean;
1853
1910
  getResourcesByUserId(userId: string): IPublishedResource[] | undefined;
1854
1911
  getRemoteTrack(trackId: string): RCRemoteTrack | undefined;
@@ -1948,7 +2005,7 @@ declare class BaseInvoker<STORE> {
1948
2005
  * 房间任务队列管理
1949
2006
  */
1950
2007
  declare class Invoker extends BaseInvoker<Store> {
1951
- 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);
1952
2009
  /**
1953
2010
  * 获取 store 存储实例,返回值类型 `ReadableStore`,避免非 command 定义中修改内存
1954
2011
  */
@@ -2153,7 +2210,7 @@ declare abstract class RCAbstractRoom extends EventEmitter {
2153
2210
  /**
2154
2211
  * 北极星上报实例
2155
2212
  */
2156
- protected _polarisReport: PolarisReporter | null;
2213
+ protected _polarisReport: PolarisHttpReporter | null;
2157
2214
  /**
2158
2215
  * 音量上报实例
2159
2216
  */
@@ -2577,7 +2634,7 @@ declare class RCAudienceLivingRoom {
2577
2634
  /**
2578
2635
  * 北极星上报实例
2579
2636
  */
2580
- protected _polarisReport: PolarisReporter | null;
2637
+ protected _polarisReport: PolarisHttpReporter | null;
2581
2638
  /**
2582
2639
  * 音量上报实例
2583
2640
  */
@@ -2825,7 +2882,7 @@ declare class PolarisReporter {
2825
2882
  * @param resourceId userId_11_1_tiny 改为 userId_11_tiny_video
2826
2883
  */
2827
2884
  private _getPolarisTrackId;
2828
- sendR3R4Data(data: IInnerRCRTCStateReport): Promise<boolean>;
2885
+ sendR3R4Data(data: IInnerRCRTCStateReport): Promise<RCSendCode>;
2829
2886
  /**
2830
2887
  * 加入房间
2831
2888
  */
@@ -2837,6 +2894,42 @@ declare class PolarisReporter {
2837
2894
  sendR2(action: string, status: string, trackIds: string[]): void;
2838
2895
  }
2839
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
+
2840
2933
  /**
2841
2934
  * PC 实例管理类
2842
2935
  */
@@ -2884,7 +2977,7 @@ declare class RCRTCPeerConnection extends EventEmitter {
2884
2977
  /**
2885
2978
  * 北极星上传实例
2886
2979
  */
2887
- _polarisReport?: PolarisReporter | undefined);
2980
+ _polarisReport?: PolarisHttpReporter | undefined);
2888
2981
  getName(): string;
2889
2982
  getLocalTracks(): RCLocalTrack[];
2890
2983
  private _onConnectionStateChange;
@@ -3248,6 +3341,216 @@ interface IRCRTCStateReport {
3248
3341
  */
3249
3342
  receivers: IRCTrackStat[];
3250
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
+ }
3251
3554
  interface IRCRTCReportListener {
3252
3555
  /**
3253
3556
  * RTCPeerConnection 的详细状态数据