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

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.3
3
+ * CommitId - 3f61ac223f73eedac265c308f3a0f311af3985a7
4
+ * Sun Oct 09 2022 21:12:19 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, BasicLogger, INaviInfo, RTCPluginContext, AbsCodec, IPromiseResult, ErrorCode, KVString, IRuntime, IAsyncRes, ConnectionStatus, ConversationType, ISendMsgOptions, IReceivedMessage, EnableLogL, 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
  /** 参数错误 */
@@ -172,6 +173,7 @@ declare abstract class RCTrack extends EventEmitter {
172
173
  protected readonly _streamId: string;
173
174
  protected _msTrack?: MediaStreamTrack;
174
175
  private _msStream;
176
+ protected _logger: BasicLogger | null;
175
177
  constructor(_tag: string, _userId: string, _kind: 'audio' | 'video', _isLocalTrack: boolean, _roomId?: string | undefined);
176
178
  /**
177
179
  * 获取音视轨所属的 streamId,streamId 相同的音轨和视轨可认为属于统一道流
@@ -1279,6 +1281,13 @@ declare const keymaps: {
1279
1281
  readonly RtcInviteAnswerInput: readonly ["inviteUserId", "answerCode", "inviteRoomId", "inviteSessionId", "content", "key", "value"];
1280
1282
  readonly RtcEndInviteInput: readonly ["inviteRoomId", "inviteSessionId", "inviteContent", "inviteRoomKeys"];
1281
1283
  readonly RtcReportSDKInput: readonly ["sdkInfo"];
1284
+ readonly RCRTCPBPolaris: readonly ["type", "appKey", "sessionId", "roomId", "roomCreateTime", "userId", "userRole", "joinTime", "signalDataCenter", "r1Info", "r2Info", "r3Info", "r4Info"];
1285
+ readonly RCRTCPBR1Info: readonly ["joinTime", "rtcVersion", "imVersion", "platform", "device", "os", "browserName", "browserVersion"];
1286
+ readonly RCRTCPBR2Info: readonly ["joinTime", "sendTime", "rtcActionType", "rtcActionStatus", "trackId"];
1287
+ readonly RCRTCPBR3Info: readonly ["info"];
1288
+ readonly RCRTCPBR4Info: readonly ["info"];
1289
+ readonly RCRTCPBStatusInfo: readonly ["joinTime", "totalBitRate", "appCPUUsage", "systemCPUUsage", "systemCPUFrequency", "networkStatus", "googleRTTNetwork", "ipAddress", "useReceiveBroadBand", "useSendBroadBand", "packetLossCount", "streams"];
1290
+ readonly RCRTCPBStreamInfo: readonly ["trackId", "codeName", "volume", "samplingRate", "bitRate", "packetLossRate", "frameRate", "resolution", "blockTime", "jitterData", "nAckCount", "pliCount", "googleRTTTotalTime", "isReceiveFirstFrameRate", "codeType", "isEnabled"];
1282
1291
  };
1283
1292
  declare type RTCKeyMaps = typeof keymaps;
1284
1293
 
@@ -1344,6 +1353,9 @@ interface IJoinRTCRoomData extends IRTCUsers {
1344
1353
  }[];
1345
1354
  kvEntries: IServerRTCRoomEntry[];
1346
1355
  offlineKickTime: number;
1356
+ codeFormat?: string;
1357
+ roomCreateTime?: number;
1358
+ userJoinTime?: number;
1347
1359
  }
1348
1360
  interface IReqRoomPKOptions {
1349
1361
  /**
@@ -1449,11 +1461,42 @@ interface IEndRoomPKOptions {
1449
1461
  */
1450
1462
  keys: string[];
1451
1463
  }
1464
+ interface IRTCNaviInfo extends INaviInfo {
1465
+ /**
1466
+ * jwt token
1467
+ */
1468
+ jwt?: string;
1469
+ /**
1470
+ * http3 上报域名
1471
+ */
1472
+ logServer?: string;
1473
+ /**
1474
+ * 数据中心
1475
+ */
1476
+ dc?: string;
1477
+ /**
1478
+ * openGzip 开启标识,默认是false,开启使用true
1479
+ */
1480
+ openGzip?: boolean;
1481
+ }
1482
+
1483
+ /**
1484
+ * 自定义上报北极星数据响应 code
1485
+ */
1486
+ declare enum RCSendCode {
1487
+ NOT_REPORT = -1,
1488
+ REPORT_SUCCESS = 10000,
1489
+ REPORT_FAIL = 0,
1490
+ PB_ERROR = 40001
1491
+ }
1452
1492
 
1453
1493
  declare class RTCContext {
1454
1494
  private context;
1455
1495
  private codec;
1496
+ roomCreateTime: number | undefined;
1497
+ userJoinTime: number | undefined;
1456
1498
  constructor(context: RTCPluginContext, codec: AbsCodec<RTCKeyMaps>);
1499
+ logger: BasicLogger | null;
1457
1500
  joinRTCRoom(roomId: string, mode: RTCMode, broadcastType?: number, joinType?: RTCJoinType, innerUserDatas?: IRTCUserData, outerUserDatas?: IRTCUserData): IPromiseResult<IJoinRTCRoomData>;
1458
1501
  quitRTCRoom(roomId: string): Promise<ErrorCode>;
1459
1502
  getRTCRoomInfo(roomId: string): IPromiseResult<IRTCRoomInfo>;
@@ -1485,6 +1528,10 @@ declare class RTCContext {
1485
1528
  getRTCOutData(roomId: string, userIds: string[]): IPromiseResult<unknown>;
1486
1529
  getRTCToken(roomId: string, mode: number, broadcastType?: number): IPromiseResult<IRtcTokenData>;
1487
1530
  setRTCState(roomId: string, report: string): Promise<ErrorCode>;
1531
+ /**
1532
+ * 通过 http 方式上报 rtc state
1533
+ */
1534
+ setRTCStateByHttp(logServer: string, runtime: IRuntime, report: IRCRTCReportData, reportType: string): Promise<RCSendCode | RCRTCCode>;
1488
1535
  getRTCUserList(roomId: string): IPromiseResult<IRTCUsers>;
1489
1536
  joinLivingRoomAsAudience(roomId: string, mode: RTCMode, broadcastType?: number): Promise<IAsyncRes<{
1490
1537
  token: string;
@@ -1504,7 +1551,7 @@ declare class RTCContext {
1504
1551
  roomId: any;
1505
1552
  };
1506
1553
  getCurrentId(): string;
1507
- getNaviInfo(): _rongcloud_engine.INaviInfo | null;
1554
+ getNaviInfo(): IRTCNaviInfo | null;
1508
1555
  getConnectionStatus(): ConnectionStatus;
1509
1556
  getAppkey(): string;
1510
1557
  rtcPing(roomId: string, roomMode: number, broadcastType?: number): Promise<ErrorCode>;
@@ -1562,7 +1609,7 @@ declare class RCMediaService {
1562
1609
  private static msInDetector;
1563
1610
  private static detectorTime;
1564
1611
  private static detectValidMinute;
1565
- private static naviRefetchCount;
1612
+ static jwtToken: string;
1566
1613
  private _msList;
1567
1614
  constructor(_runtime: IRuntime, _context: RTCContext,
1568
1615
  /**
@@ -1708,7 +1755,7 @@ declare class RCRTCPeerCManager {
1708
1755
  /**
1709
1756
  * 北极星上报模块
1710
1757
  */
1711
- _polarisReport?: PolarisReporter | undefined);
1758
+ _polarisReport?: PolarisHttpReporter | undefined);
1712
1759
  get useMutilPeerC(): boolean;
1713
1760
  /**
1714
1761
  * 根据 track 判断是否为上行
@@ -1828,7 +1875,7 @@ declare abstract class ReadableStore {
1828
1875
  readonly roomId: string;
1829
1876
  readonly crtUserId: string;
1830
1877
  readonly roomMode: RTCMode;
1831
- readonly polarisReport: PolarisReporter;
1878
+ readonly polarisReport: PolarisHttpReporter;
1832
1879
  readonly isUpgrade?: boolean | undefined;
1833
1880
  readonly isMainRoom?: boolean | undefined;
1834
1881
  /**
@@ -1860,7 +1907,7 @@ declare abstract class ReadableStore {
1860
1907
  protected _CDNUris: ICDNUris | null;
1861
1908
  protected _CDNEnable: boolean;
1862
1909
  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);
1910
+ constructor(context: RTCContext, service: RCMediaService, peerMgr: RCRTCPeerCManager, roomId: string, crtUserId: string, roomMode: RTCMode, polarisReport: PolarisHttpReporter, isUpgrade?: boolean | undefined, isMainRoom?: boolean | undefined);
1864
1911
  get useMutilPeerC(): boolean;
1865
1912
  getResourcesByUserId(userId: string): IPublishedResource[] | undefined;
1866
1913
  getRemoteTrack(trackId: string): RCRemoteTrack | undefined;
@@ -1960,7 +2007,7 @@ declare class BaseInvoker<STORE> {
1960
2007
  * 房间任务队列管理
1961
2008
  */
1962
2009
  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);
2010
+ constructor(context: RTCContext, service: RCMediaService, peerMrg: RCRTCPeerCManager, roomId: string, crtUserId: string, mode: RTCMode, reporter: PolarisHttpReporter, isUpgrade?: boolean, isMainRoom?: boolean);
1964
2011
  /**
1965
2012
  * 获取 store 存储实例,返回值类型 `ReadableStore`,避免非 command 定义中修改内存
1966
2013
  */
@@ -2165,7 +2212,7 @@ declare abstract class RCAbstractRoom extends EventEmitter {
2165
2212
  /**
2166
2213
  * 北极星上报实例
2167
2214
  */
2168
- protected _polarisReport: PolarisReporter | null;
2215
+ protected _polarisReport: PolarisHttpReporter | null;
2169
2216
  /**
2170
2217
  * 音量上报实例
2171
2218
  */
@@ -2589,7 +2636,7 @@ declare class RCAudienceLivingRoom {
2589
2636
  /**
2590
2637
  * 北极星上报实例
2591
2638
  */
2592
- protected _polarisReport: PolarisReporter | null;
2639
+ protected _polarisReport: PolarisHttpReporter | null;
2593
2640
  /**
2594
2641
  * 音量上报实例
2595
2642
  */
@@ -2837,7 +2884,7 @@ declare class PolarisReporter {
2837
2884
  * @param resourceId userId_11_1_tiny 改为 userId_11_tiny_video
2838
2885
  */
2839
2886
  private _getPolarisTrackId;
2840
- sendR3R4Data(data: IInnerRCRTCStateReport): Promise<boolean>;
2887
+ sendR3R4Data(data: IInnerRCRTCStateReport): Promise<RCSendCode>;
2841
2888
  /**
2842
2889
  * 加入房间
2843
2890
  */
@@ -2849,6 +2896,43 @@ declare class PolarisReporter {
2849
2896
  sendR2(action: string, status: string, trackIds: string[]): void;
2850
2897
  }
2851
2898
 
2899
+ declare class PolarisHttpReporter {
2900
+ private readonly _context;
2901
+ private readonly _runtime;
2902
+ private readonly _roomId;
2903
+ private readonly _crtRTCRoom;
2904
+ private readonly _userRole;
2905
+ protected _polarisSignalReporter: PolarisReporter | null;
2906
+ private _useHttp;
2907
+ constructor(_context: RTCContext, _runtime: IRuntime, _roomId: string, _crtRTCRoom: RCAbstractRoom | RCAudienceLivingRoom, _userRole?: PolarisRole);
2908
+ private _send;
2909
+ private _refetchNaviInfo;
2910
+ /**
2911
+ * 小流需去掉 _tiny,小流 resourceId 为 userId_tag_mediaType_tiny
2912
+ */
2913
+ private _getRealResourceId;
2914
+ /**
2915
+ * 生成北极星上报的 trackId
2916
+ * @param resourceId userId_11_1_tiny 改为 userId_11_tiny_video
2917
+ */
2918
+ private _getPolarisTrackId;
2919
+ private _formatReportBaseData;
2920
+ private _formatReportData;
2921
+ private _formatR1Data;
2922
+ private _formatR2Data;
2923
+ private _formatR3R4Data;
2924
+ sendR3R4Data(data: IInnerRCRTCStateReport): Promise<RCSendCode>;
2925
+ /**
2926
+ * 加入房间
2927
+ */
2928
+ sendR1(): Promise<void>;
2929
+ /**
2930
+ * RTC 和 LIVE 发布、取消发布
2931
+ * RTC 订阅、取消订阅
2932
+ */
2933
+ sendR2(action: string, status: string, trackIds: string[]): Promise<void>;
2934
+ }
2935
+
2852
2936
  /**
2853
2937
  * PC 实例管理类
2854
2938
  */
@@ -2880,6 +2964,7 @@ declare class RCRTCPeerConnection extends EventEmitter {
2880
2964
  private _isDestroyed;
2881
2965
  private _reportStatsData?;
2882
2966
  private _originReportStatsData?;
2967
+ private _logger;
2883
2968
  constructor(
2884
2969
  /**
2885
2970
  * peerConnection 对应名称
@@ -2896,7 +2981,7 @@ declare class RCRTCPeerConnection extends EventEmitter {
2896
2981
  /**
2897
2982
  * 北极星上传实例
2898
2983
  */
2899
- _polarisReport?: PolarisReporter | undefined);
2984
+ _polarisReport?: PolarisHttpReporter | undefined);
2900
2985
  getName(): string;
2901
2986
  getLocalTracks(): RCLocalTrack[];
2902
2987
  private _onConnectionStateChange;
@@ -3260,6 +3345,216 @@ interface IRCRTCStateReport {
3260
3345
  */
3261
3346
  receivers: IRCTrackStat[];
3262
3347
  }
3348
+ /**
3349
+ * http3 北极星上报基础数据
3350
+ */
3351
+ interface IRCRTCReportBaseData {
3352
+ /**
3353
+ * 上报数据类型 R1-R4
3354
+ */
3355
+ type: string;
3356
+ appKey: string;
3357
+ /**
3358
+ * 房间通话id
3359
+ */
3360
+ sessionId: string;
3361
+ roomId: string;
3362
+ /**
3363
+ * 房间创建时间
3364
+ */
3365
+ roomCreateTime: number;
3366
+ userId: string;
3367
+ userRole: number;
3368
+ joinTime: number;
3369
+ /**
3370
+ * signal 数据中心
3371
+ * */
3372
+ signalDataCenter: string;
3373
+ }
3374
+ /**
3375
+ * http3 北极星上报 R1 数据
3376
+ */
3377
+ interface IR1Info {
3378
+ /**
3379
+ * 用户加入房间的时间
3380
+ */
3381
+ joinTime: number;
3382
+ /**
3383
+ * RTC 版本号
3384
+ */
3385
+ rtcVersion: string;
3386
+ /**
3387
+ * IM SDK 版本
3388
+ */
3389
+ imVersion: string;
3390
+ /**
3391
+ * 平台(如:Android、iOS、Web)
3392
+ */
3393
+ platform: string;
3394
+ /**
3395
+ * 设备信息(手机名称+型号)
3396
+ */
3397
+ device: string;
3398
+ /**
3399
+ * 系统版本(手机系统版本)
3400
+ */
3401
+ os: string;
3402
+ /**
3403
+ * 浏览器名称, 没有用 -1 表示
3404
+ */
3405
+ browserName?: string;
3406
+ /**
3407
+ * 浏览器版本, 没有用 -1 表示
3408
+ */
3409
+ browserVersion?: string;
3410
+ }
3411
+ /**
3412
+ * http3 北极星上报 R2 数据
3413
+ */
3414
+ interface IR2Info {
3415
+ /**
3416
+ * 用户加入房间的时间
3417
+ */
3418
+ joinTime: number;
3419
+ /**
3420
+ * 客户端 发布/取消发布 订阅/取消订阅 资源的时间
3421
+ */
3422
+ sendTime: number;
3423
+ /**
3424
+ * 发布类型 subscribe : 订阅 publish : 发布
3425
+ */
3426
+ rtcActionType: string;
3427
+ /**
3428
+ * 发布状态 begin : 开始 tend : 结束
3429
+ */
3430
+ rtcActionStatus: string;
3431
+ trackId: string[];
3432
+ }
3433
+ /**
3434
+ * http3 北极星上报 R3 数据
3435
+ */
3436
+ interface IR3R4Info {
3437
+ info: IR3R4CommonInfo;
3438
+ }
3439
+ interface IR3R4CommonInfo {
3440
+ /**
3441
+ * 用户加入房间的时间
3442
+ */
3443
+ joinTime?: number;
3444
+ /**
3445
+ * 总码率
3446
+ */
3447
+ totalBitRate?: number;
3448
+ /**
3449
+ * APP CPU占用率
3450
+ */
3451
+ appCPUUsage?: number;
3452
+ /**
3453
+ * 系统 CPU占用率
3454
+ */
3455
+ systemCPUUsage?: number;
3456
+ /**
3457
+ * 系统CPU频率 (安卓8.0以上)
3458
+ */
3459
+ systemCPUFrequency?: number;
3460
+ /**
3461
+ * 实时网络状态(2g、3g、4g、wifi)
3462
+ */
3463
+ networkStatus?: string;
3464
+ /**
3465
+ * Goog rtt 网络延迟
3466
+ */
3467
+ googleRTTNetwork?: number;
3468
+ /**
3469
+ * ip地址
3470
+ */
3471
+ ipAddress?: string;
3472
+ /**
3473
+ * 可接收带宽(单位: bit)
3474
+ */
3475
+ useReceiveBroadBand?: string;
3476
+ /**
3477
+ * 可用发送带宽(单位: bit)
3478
+ */
3479
+ useSendBroadBand?: string;
3480
+ /**
3481
+ * 丢包数
3482
+ */
3483
+ packetLossCount?: string;
3484
+ streams?: IR3R4StreamInfo[];
3485
+ }
3486
+ /**
3487
+ * http3 北极星上报 R3、R4 streamInfo 数据
3488
+ */
3489
+ interface IR3R4StreamInfo {
3490
+ trackId: string;
3491
+ /**
3492
+ * 编解码名称
3493
+ */
3494
+ codeName?: string;
3495
+ /**
3496
+ * 音频播放音量
3497
+ */
3498
+ volume?: string;
3499
+ /**
3500
+ * 音频采样率
3501
+ */
3502
+ samplingRate: number;
3503
+ /**
3504
+ * 下行码率
3505
+ */
3506
+ bitRate?: number;
3507
+ packetLossRate?: number;
3508
+ /**
3509
+ * 视频接收帧率(单位:fps)
3510
+ */
3511
+ frameRate?: number;
3512
+ /**
3513
+ * 视频分辨率(格式:640*480)
3514
+ */
3515
+ resolution?: string;
3516
+ /**
3517
+ * 接收卡顿(间隔时间, 单位: ms)
3518
+ */
3519
+ blockTime?: number;
3520
+ /**
3521
+ * jitter数据抖动
3522
+ */
3523
+ jitterData?: number;
3524
+ /**
3525
+ * nack数量
3526
+ */
3527
+ nAckCount?: string;
3528
+ /**
3529
+ * PLI请求数
3530
+ */
3531
+ pliCount?: string;
3532
+ /**
3533
+ * googRtt往返时长
3534
+ */
3535
+ googleRTTTotalTime?: number;
3536
+ /**
3537
+ * 第一个关键帧是否正常收到
3538
+ */
3539
+ isReceiveFirstFrameRate?: number;
3540
+ /**
3541
+ * 编码方式
3542
+ */
3543
+ codeType?: string;
3544
+ /**
3545
+ * 当前流的状态是否可用
3546
+ */
3547
+ isEnabled?: number;
3548
+ }
3549
+ /**
3550
+ * http3 北极星上报总数据
3551
+ */
3552
+ interface IRCRTCReportData extends IRCRTCReportBaseData {
3553
+ r1Info?: IR1Info;
3554
+ r2Info?: IR2Info;
3555
+ r3Info?: IR3R4Info;
3556
+ r4Info?: IR3R4Info;
3557
+ }
3263
3558
  interface IRCRTCReportListener {
3264
3559
  /**
3265
3560
  * RTCPeerConnection 的详细状态数据
@@ -3379,16 +3674,16 @@ interface IRCRTCInitOptions {
3379
3674
  /**
3380
3675
  * 输出日志等级,生产环境默认使用 WARN,开发环境默认为 DEBUG
3381
3676
  * @description
3382
- * * 0 - DEBUG
3383
- * * 1 - INFO
3677
+ * * 4 - DEBUG
3678
+ * * 3 - INFO
3384
3679
  * * 2 - WARN
3385
- * * 3 - ERROR
3680
+ * * 1 - ERROR
3386
3681
  */
3387
- logLevel?: LogLevel;
3682
+ logLevel?: EnableLogL;
3388
3683
  /**
3389
3684
  * 修改默认的 log 输出函数
3390
3685
  */
3391
- logStdout?: (logLevel: LogLevel, content: string) => void;
3686
+ logStdout?: (logLevel: EnableLogL, content: string) => void;
3392
3687
  /**
3393
3688
  * 与 MediaServer 的 http 请求超时时间,单位为毫秒,默认值为 `5000`,有效值 `5000-30000`。
3394
3689
  * 优先级:用户配置 > 导航配置 > 默认时间。