@rongcloud/plugin-rtc 5.3.0-rtc-roompk.1 → 5.3.2-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 CHANGED
@@ -1,10 +1,10 @@
1
1
  /*
2
- * RCRTC - v5.3.0-rtc-roompk.1
3
- * CommitId - 381b45b74bd1cee88cf1e6e79108809734bb17ea
4
- * Sat Dec 25 2021 01:21:26 GMT+0800 (China Standard Time)
2
+ * RCRTC - v5.3.2-alpha.1
3
+ * CommitId - db999e233480c8537357ef17495b0bbb67c692fe
4
+ * Mon Feb 14 2022 20:24:02 GMT+0800 (China Standard Time)
5
5
  * ©2020 RongCloud, Inc. All rights reserved.
6
6
  */
7
- import { EventEmitter, LogLevel, RTCMode, IRuntime, RTCPluginContext, IServerRTCRoomEntry, IReceivedMessage, IJoinRTCRoomData, KVString, RTCJoinType, IRTCJoinedInfo, IPluginGenerator } from '@rongcloud/engine';
7
+ import { EventEmitter, LogLevel, RTCMode, IRuntime, RTCPluginContext, IServerRTCRoomEntry, IReceivedMessage, ErrorCode, IJoinRTCRoomData, KVString, RTCJoinType, IRTCJoinedInfo, IPluginGenerator } from '@rongcloud/engine';
8
8
  export { RTCJoinType } from '@rongcloud/engine';
9
9
 
10
10
  /**
@@ -912,7 +912,23 @@ interface IAudioLevelChangeHandler {
912
912
  declare type RoomData = {
913
913
  [userId: string]: IPublishedResource[];
914
914
  };
915
- interface IReqRoomPKOptions {
915
+ /**
916
+ * pkInfo 接口
917
+ */
918
+ interface IPKInfo {
919
+ [roomId: string]: {
920
+ inviteSessionId: string;
921
+ inviterRoomId: string;
922
+ inviterUserId: string;
923
+ inviterUserAutoMix?: boolean;
924
+ inviteeRoomId: string;
925
+ inviteeUserAutoMix?: boolean;
926
+ };
927
+ }
928
+ /**
929
+ * 业务层发起连麦、响应连麦可选参数定义
930
+ */
931
+ interface IReqResPKOptions {
916
932
  autoMix?: boolean;
917
933
  extra?: string;
918
934
  }
@@ -936,12 +952,18 @@ interface IPKInviteeBaseInfo {
936
952
  */
937
953
  inviteeUserId: string;
938
954
  }
955
+ /**
956
+ * 业务层监听收到连麦邀请、取消连麦的字段
957
+ */
939
958
  interface IPKInviteInfo extends IPKInviterBaseInfo {
940
959
  /**
941
960
  * 邀请额外信息
942
961
  */
943
962
  extra?: string;
944
963
  }
964
+ /**
965
+ * 业务层监听收到连麦应答的字段
966
+ */
945
967
  interface IPKInviteAnswerInfo extends IPKInviterBaseInfo, IPKInviteeBaseInfo {
946
968
  /**
947
969
  * 是否同意邀请
@@ -952,6 +974,9 @@ interface IPKInviteAnswerInfo extends IPKInviterBaseInfo, IPKInviteeBaseInfo {
952
974
  */
953
975
  extra?: string;
954
976
  }
977
+ /**
978
+ * 业务层监听收到连麦结束的字段
979
+ */
955
980
  interface IPKEndInfo {
956
981
  /**
957
982
  * 发起结束的房间 ID
@@ -963,18 +988,12 @@ interface IPKEndInfo {
963
988
  endUserId: string;
964
989
  }
965
990
  /**
966
- * 观众加房间返回给客户的数据
991
+ * 观众加房间返回给客户的 CDN 信息
967
992
  */
968
- interface IAudienceJoinRoomResInfo {
969
- remoteUserIds: string[];
970
- remoteRTCTracks: RCRemoteTrack[];
971
- remoteMCUTracks: RCRemoteTrack[];
972
- remoteTracks: RCRemoteTrack[];
973
- CDNUris: {
974
- resolution?: RCResolution;
975
- fps?: RCFrameRate;
976
- CDNEnable?: boolean;
977
- };
993
+ interface IJoinResCDNInfo {
994
+ resolution?: RCResolution;
995
+ fps?: RCFrameRate;
996
+ CDNEnable?: boolean;
978
997
  }
979
998
 
980
999
  declare enum RCInnerCDNPushMode {
@@ -2088,11 +2107,11 @@ declare class RCRTCPeerConnection extends EventEmitter {
2088
2107
  declare type IOnRecvPKMsg = (msg: IReceivedMessage) => void;
2089
2108
  interface IRoomPKEventListener {
2090
2109
  /**
2091
- * 收到连麦 PK 邀请
2110
+ * 收到连麦邀请
2092
2111
  */
2093
2112
  onRequestJoinOtherRoom: (info: IPKInviteInfo) => {};
2094
2113
  /**
2095
- * 收到连麦 PK 邀请取消
2114
+ * 收到取消连麦邀请
2096
2115
  */
2097
2116
  onCancelRequestOtherRoom: (info: IPKInviteInfo) => {};
2098
2117
  /**
@@ -2105,6 +2124,7 @@ interface IRoomPKEventListener {
2105
2124
  onFinishOtherRoom: (info: IPKEndInfo) => {};
2106
2125
  }
2107
2126
  declare class RCLivingPKHandler {
2127
+ private _PKInfo;
2108
2128
  private readonly _context;
2109
2129
  private readonly _runtime;
2110
2130
  private readonly _service;
@@ -2123,20 +2143,19 @@ declare class RCLivingPKHandler {
2123
2143
  */
2124
2144
  private readonly _onLeavePKRoom;
2125
2145
  /**
2126
- * PK 邀请超时时间
2146
+ * PK 邀请超时时间,默认 30s
2127
2147
  */
2128
2148
  private readonly _inviteTimeout;
2129
2149
  /**
2130
2150
  * PK 房间信息
2131
2151
  */
2132
- private _PKInfo;
2133
2152
  private _appListener;
2134
2153
  private _mainRoomId;
2135
2154
  /**
2136
2155
  * 跨房间连麦加入的 PK 房间
2137
2156
  */
2138
2157
  private _joinedPKRooms;
2139
- constructor(_context: RTCPluginContext, _runtime: IRuntime, _service: RCMediaService, _initOptions: IRCRTCInitOptions,
2158
+ constructor(_PKInfo: IPKInfo, _context: RTCPluginContext, _runtime: IRuntime, _service: RCMediaService, _initOptions: IRCRTCInitOptions,
2140
2159
  /**
2141
2160
  * 主直播房间
2142
2161
  */
@@ -2150,50 +2169,70 @@ declare class RCLivingPKHandler {
2150
2169
  */
2151
2170
  _onLeavePKRoom: (roomId: string) => void);
2152
2171
  private _callAppListener;
2172
+ /**
2173
+ * 收到连麦邀请
2174
+ */
2153
2175
  private _onInvite;
2176
+ /**
2177
+ * 收到取消连麦
2178
+ */
2154
2179
  private _onCancelInvite;
2155
2180
  private _onInviteTimeout;
2181
+ /**
2182
+ * 收到响应连麦
2183
+ */
2156
2184
  private _onInviteAnswer;
2185
+ /**
2186
+ * 收到连麦结束
2187
+ */
2157
2188
  private _onPKEnd;
2158
2189
  /**
2159
2190
  * 处理跨房间连麦相关消息
2160
2191
  */
2161
2192
  private _onRecvPKMsg;
2162
2193
  /**
2163
- * 跨房间连麦 PK 事件注册
2194
+ * 注册跨房间连麦监听事件
2164
2195
  */
2165
2196
  registerRoomPKEventListener(listener: IRoomPKEventListener): void;
2166
2197
  /**
2167
2198
  * 发起跨房间连麦请求
2168
- * @param inviteeRoomId 被邀请者所处的房间 ID
2169
- * @param inviteeUserId 被邀请者 ID
2170
- * @param options.autoMix 被邀请者的发布的资源在服务侧是否自动合流
2171
- * @param options.extra 拓展字段,用于邀请数据透传
2199
+ * @param inviteeRoomId 被邀请者所处的房间 roomId
2200
+ * @param inviteeUserId 被邀请者 userId
2201
+ * @param options.autoMix 是否要把邀请者发布的资源,合并到被邀请者房间内的 MCU 流中
2202
+ * @param options.extra 拓展字段,可随邀请连麦消息透传给被邀请者
2172
2203
  */
2173
- requestJoinOtherRoom(inviteeRoomId: string, inviteeUserId: string, options?: IReqRoomPKOptions): Promise<{
2174
- code: RCRTCCode;
2204
+ requestJoinOtherRoom(inviteeRoomId: string, inviteeUserId: string, options?: IReqResPKOptions): Promise<{
2205
+ code: RCRTCCode | ErrorCode;
2175
2206
  }>;
2176
2207
  /**
2177
- * 取消跨房间连麦 PK 请求
2208
+ * 取消跨房间连麦请求
2209
+ * @param inviteeRoomId 被邀请者所处的房间 roomId
2210
+ * @param inviteeUserId 被邀请者 userId
2211
+ * @param extra 附加信息,可随取消邀请连麦消息透传给被邀请者
2178
2212
  */
2179
2213
  cancelRequestJoinOtherRoom(inviteeRoomId: string, inviteeUserId: string, extra?: string): Promise<{
2180
- code: RCRTCCode;
2214
+ code: RCRTCCode | ErrorCode;
2181
2215
  }>;
2182
2216
  /**
2183
- * 跨房间连麦 PK 响应
2217
+ * 响应跨房间连麦请求
2218
+ * @param inviterRoomId 邀请者所处的房间 roomId
2219
+ * @param inviterUserId 邀请者 userId
2220
+ * @param agree 是否同意连麦
2221
+ * @param options.autoMix 是否要把被邀请者发布的资源,合并到邀请者房间内的 MCU 流中
2222
+ * @param options.extra 附加信息,可随响应连麦消息透传给邀请者
2184
2223
  */
2185
- responseJoinOtherRoom(inviterRoomId: string, inviterUserId: string, agree: boolean, options?: IReqRoomPKOptions): Promise<{
2186
- code: RCRTCCode;
2224
+ responseJoinOtherRoom(inviterRoomId: string, inviterUserId: string, agree: boolean, options?: IReqResPKOptions): Promise<{
2225
+ code: RCRTCCode | ErrorCode;
2187
2226
  }>;
2188
2227
  /**
2189
- * 结束跨房间连麦 PK
2190
- * @param roomId 需要退出 PK 的房间 ID
2228
+ * 结束跨房间连麦
2229
+ * @param roomId 需要结束连麦的房间 roomId
2191
2230
  */
2192
2231
  private _quitRoomPK;
2193
2232
  private _relaseCrtRoom;
2194
2233
  /**
2195
- * 加入 PK 直播房间
2196
- * @roomId PK 房间 ID
2234
+ * 加入副直播房间
2235
+ * @roomId 副房间的 roomId
2197
2236
  */
2198
2237
  joinOtherRoom(roomId: string): Promise<{
2199
2238
  code: RCRTCCode;
@@ -2203,14 +2242,16 @@ declare class RCLivingPKHandler {
2203
2242
  CDNEnable?: boolean;
2204
2243
  }>;
2205
2244
  /**
2206
- * 退出 PK 直播房间房间
2207
- * @param room 要离开的 PK 房间 room 实例
2245
+ * 退出副房间
2246
+ * @param room 要退出的副房间的 room 实例
2247
+ * @param isQuitPK 是否要结束连麦
2208
2248
  */
2209
2249
  leaveOtherRoom(room: RCLivingRoom, isQuitPK?: boolean): Promise<{
2210
2250
  code: RCRTCCode;
2211
2251
  }>;
2212
2252
  /**
2213
- * 获取 _PKInfo
2253
+ * 获取连麦信息
2254
+ * @param roomId 连麦房间的 roomId
2214
2255
  */
2215
2256
  getPKInfo(roomId: string): {
2216
2257
  inviteSessionId: string;
@@ -2221,7 +2262,11 @@ declare class RCLivingPKHandler {
2221
2262
  inviteeUserAutoMix?: boolean | undefined;
2222
2263
  };
2223
2264
  /**
2224
- * 获取已加入的 PK 房间
2265
+ * 获取所有连麦信息
2266
+ */
2267
+ getAllPKInfo(): IPKInfo;
2268
+ /**
2269
+ * 获取已加入的副房间
2225
2270
  */
2226
2271
  getJoinedPKRooms(): {
2227
2272
  [roomId: string]: RCLivingRoom;
@@ -2453,6 +2498,14 @@ declare abstract class RCAbstractRoom {
2453
2498
  liveUrl?: string;
2454
2499
  }>;
2455
2500
  private __publish;
2501
+ /**
2502
+ * 获取跨房间连麦需携带参数 pushOtherRooms 的值
2503
+ */
2504
+ protected _getPushOtherRoomsParams(): {
2505
+ roomId: string;
2506
+ sessionId: string;
2507
+ autoMix: boolean;
2508
+ }[] | undefined;
2456
2509
  /**
2457
2510
  * ice 断线后,尝试重新走 exchange
2458
2511
  */
@@ -2569,15 +2622,18 @@ declare abstract class RCAbstractRoom {
2569
2622
  * 销毁远端资源
2570
2623
  */
2571
2624
  private _removeRemoteTracks;
2625
+ /**
2626
+ * 存储连麦监听事件
2627
+ */
2572
2628
  private _onRecvPKMsg;
2573
2629
  /**
2574
2630
  * 注册 PK 业务监听方法
2575
2631
  */
2576
- protected _registerPKMsgListener(listener: IOnRecvPKMsg): void;
2632
+ protected _registerPKMsgListener(listener: IOnRecvPKMsg | null): void;
2577
2633
  /**
2578
2634
  * 退出 PK 房间
2579
2635
  */
2580
- protected _quitPKRoom(): void;
2636
+ protected _quitAllPKRoom(): void;
2581
2637
  }
2582
2638
 
2583
2639
  /**
@@ -2774,11 +2830,18 @@ declare class RCLivingRoom extends RCAbstractRoom {
2774
2830
  * 是否是主房间
2775
2831
  */
2776
2832
  _isMainRoom: boolean);
2833
+ /**
2834
+ * resourceId 有效性验证
2835
+ * @param resourceId
2836
+ */
2837
+ protected _isValidResourceId(resourceId: string): boolean;
2777
2838
  getLivingType(): RCLivingType;
2778
2839
  /**
2779
2840
  * 获取 MCU 配置构建对象
2780
2841
  */
2781
- getMCUConfigBuilder(): RCMCUConfigBuilder;
2842
+ getMCUConfigBuilder(): RCMCUConfigBuilder | {
2843
+ code: RCRTCCode;
2844
+ };
2782
2845
  /**
2783
2846
  * 接收 MCU 配置并向 MediaServer 提交
2784
2847
  * @param data
@@ -2849,23 +2912,26 @@ declare class RCLivingRoom extends RCAbstractRoom {
2849
2912
  * 加入 PK 房间回调
2850
2913
  */
2851
2914
  private _onJoinedPKRoom;
2915
+ /**
2916
+ * 离开 PK 房间后,如果参与过连麦,pushOtherRooms 需去掉退出的连麦房间配置,重新和 mediaServer 交互
2917
+ */
2852
2918
  private _onLeavePKRoom;
2853
2919
  /**
2854
2920
  * 携带 pushOtherRooms 与 mediaServer 重新交互
2855
- * @param roomId 副房间 roomId
2856
2921
  */
2857
2922
  private _exchangeWithPushOtherRoom;
2858
2923
  /**
2859
2924
  * 获取 PK 业务处理器
2925
+ * @since version 5.3.0
2860
2926
  */
2861
2927
  getRoomPKHandler(): {
2862
2928
  code: RCRTCCode;
2863
2929
  roomPKHandler?: RCLivingPKHandler;
2864
2930
  };
2865
2931
  /**
2866
- * 退出 PK 房间
2932
+ * 退出所有连麦房间
2867
2933
  */
2868
- protected _quitPKRoom(): void;
2934
+ protected _quitAllPKRoom(): void;
2869
2935
  }
2870
2936
 
2871
2937
  /**
@@ -2952,6 +3018,11 @@ declare class RCRTCClient {
2952
3018
  private readonly _service;
2953
3019
  constructor(_context: RTCPluginContext, _runtime: IRuntime, _options: IRCRTCInitOptions);
2954
3020
  private _handleMessage;
3021
+ /**
3022
+ * 获取加入的连麦房间
3023
+ */
3024
+ private _getJoinedPKRoomList;
3025
+ private _getPKRoomIds;
2955
3026
  /**
2956
3027
  * 获取当前用户 Id,若 IM 未连接,这返回 `''`
2957
3028
  * @returns
@@ -2987,7 +3058,6 @@ declare class RCRTCClient {
2987
3058
  * 获取直播观众客户端
2988
3059
  */
2989
3060
  getAudienceClient(): RCAudienceClient;
2990
- private _getJoinedPKRooms;
2991
3061
  private _onIMStatusChange;
2992
3062
  private _onIMDisconnect;
2993
3063
  private _onIMUninit;
@@ -3041,7 +3111,7 @@ declare class RCRTCClient {
3041
3111
  * @param tag 屏幕共享视轨数据标识
3042
3112
  * @param options
3043
3113
  * @description
3044
- * 支持 Electron 平台下通过制定 `chromeMediaSrouceId` 的方式获取屏幕共享视频。
3114
+ * 支持 Electron 平台下通过制定 `chromeMediaSourceId` 的方式获取屏幕共享视频。
3045
3115
  * 参考:https://www.electronjs.org/docs/api/desktop-capturer
3046
3116
  */
3047
3117
  createScreenVideoTrack(tag?: string, options?: IScreenVideoProfile): Promise<{
@@ -3098,7 +3168,10 @@ declare class RCRTCClient {
3098
3168
  joinLivingRoomAsAudience(roomId: string, livingType: RCLivingType): Promise<{
3099
3169
  room?: RCAudienceLivingRoom;
3100
3170
  code: RCRTCCode;
3101
- remoteInfo?: IAudienceJoinRoomResInfo;
3171
+ userIds?: string[];
3172
+ RTCTracks?: RCRemoteTrack[];
3173
+ MCUTracks?: RCRemoteTrack[];
3174
+ CDNUris?: IJoinResCDNInfo;
3102
3175
  }>;
3103
3176
  /**
3104
3177
  * 观众退出并销毁当前房间实例,退出后该房间的所有方法将不可用
@@ -3113,6 +3186,8 @@ declare class RCRTCClient {
3113
3186
  upgradeToAnchorRoom(room: RCAudienceLivingRoom): Promise<{
3114
3187
  room?: RCLivingRoom;
3115
3188
  code: RCRTCCode;
3189
+ userIds?: string[];
3190
+ tracks?: RCRemoteTrack[];
3116
3191
  }>;
3117
3192
  /**
3118
3193
  * 降级为观众房间
@@ -3121,7 +3196,10 @@ declare class RCRTCClient {
3121
3196
  downgradeToAudienceRoom(room: RCLivingRoom): Promise<{
3122
3197
  room?: RCAudienceLivingRoom;
3123
3198
  code: RCRTCCode;
3124
- remoteInfo?: IAudienceJoinRoomResInfo;
3199
+ userIds?: string[];
3200
+ RTCTracks?: RCRemoteTrack[];
3201
+ MCUTracks?: RCRemoteTrack[];
3202
+ CDNUris?: IJoinResCDNInfo;
3125
3203
  }>;
3126
3204
  /**
3127
3205
  * 获取在房间内用户信息
@@ -3180,4 +3258,4 @@ declare const helper: {
3180
3258
  ifSupportScreenShare: typeof ifSupportScreenShare;
3181
3259
  };
3182
3260
 
3183
- export { BackgroundPictureFillMode, ICameraVideoProfile, IMCUOutputConfig, IMCUOutputVideoConfig, IMicphoneAudioProfile, IPKEndInfo, IPKInviteAnswerInfo, IPKInviteInfo, IPublishAttrs, IPublishedResource, IRCCandidatePairStat, IRCRTCInitOptions, IRCRTCReportListener, IRCRTCStateReport, IRCTrackStat, IRoomEventListener, IRoomPKEventListener, ISubscribeAttr, IVideoProfile, MixLayoutMode, MixVideoRenderMode, RCAbstractRoom, RCAudienceClient, RCAudienceLivingRoom, RCCameraVideoTrack, RCFrameRate, RCInnerCDNPullIsHttps, RCInnerCDNPullKind, RCKickReason, RCLivingRoom, RCLivingType, RCLocalAudioTrack, RCLocalFileAudioTrack, RCLocalFileTrack, RCLocalFileVideoTrack, RCLocalTrack, RCLocalVideoTrack, RCMCUConfigBuilder, RCMediaType, RCMicphoneAudioTrack, RCRTCClient, RCRTCCode, RCRTCLiveRole, RCRTCPingResult, RCRTCRoom, RCRemoteAudioTrack, RCRemoteTrack, RCRemoteVideoTrack, RCResolution, RCScreenVideoTrack, RCTag, RCTrack, device, helper, installer };
3261
+ export { BackgroundPictureFillMode, ICameraVideoProfile, IMCUOutputConfig, IMCUOutputVideoConfig, IMicphoneAudioProfile, IPKEndInfo, IPKInviteAnswerInfo, IPKInviteInfo, IPublishAttrs, IPublishedResource, IRCCandidatePairStat, IRCRTCInitOptions, IRCRTCReportListener, IRCRTCStateReport, IRCTrackStat, IReqResPKOptions, IRoomEventListener, IRoomPKEventListener, ISubscribeAttr, IVideoProfile, MixLayoutMode, MixVideoRenderMode, RCAbstractRoom, RCAudienceClient, RCAudienceLivingRoom, RCCameraVideoTrack, RCFrameRate, RCInnerCDNPullIsHttps, RCInnerCDNPullKind, RCKickReason, RCLivingRoom, RCLivingType, RCLocalAudioTrack, RCLocalFileAudioTrack, RCLocalFileTrack, RCLocalFileVideoTrack, RCLocalTrack, RCLocalVideoTrack, RCMCUConfigBuilder, RCMediaType, RCMicphoneAudioTrack, RCRTCClient, RCRTCCode, RCRTCLiveRole, RCRTCPingResult, RCRTCRoom, RCRemoteAudioTrack, RCRemoteTrack, RCRemoteVideoTrack, RCResolution, RCScreenVideoTrack, RCTag, RCTrack, device, helper, installer };