@rongcloud/plugin-rtc 5.2.2 → 5.3.0-rtc-roompk.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.2.2
3
- * CommitId - cbd066a7185af8c1b56ef6bf88f1332ec9444daa
4
- * Thu Nov 25 2021 17:52:32 GMT+0800 (China Standard Time)
2
+ * RCRTC - v5.3.0-rtc-roompk.1
3
+ * CommitId - 381b45b74bd1cee88cf1e6e79108809734bb17ea
4
+ * Sat Dec 25 2021 01:21:26 GMT+0800 (China Standard Time)
5
5
  * ©2020 RongCloud, Inc. All rights reserved.
6
6
  */
7
- import { EventEmitter, LogLevel, RTCMode, IRuntime, RTCPluginContext, IServerRTCRoomEntry, IJoinRTCRoomData, IReceivedMessage, KVString, RTCJoinType, IRTCJoinedInfo, IPluginGenerator } from '@rongcloud/engine';
7
+ import { EventEmitter, LogLevel, RTCMode, IRuntime, RTCPluginContext, IServerRTCRoomEntry, IReceivedMessage, IJoinRTCRoomData, KVString, RTCJoinType, IRTCJoinedInfo, IPluginGenerator } from '@rongcloud/engine';
8
8
  export { RTCJoinType } from '@rongcloud/engine';
9
9
 
10
10
  /**
@@ -84,7 +84,9 @@ declare enum RCRTCCode {
84
84
  /** 加入 RTC 房间 joinTYype 为 1 时,当前有其他端在房间时的应答码 */
85
85
  SIGNAL_JOIN_RTC_ROOM_REFUSED = 53028,
86
86
  /** 设置音频输出设备时,无权限使用请求的设备 */
87
- NO_PERMISSION_TO_USE_REQUESTED_DEVICE = 53029
87
+ NO_PERMISSION_TO_USE_REQUESTED_DEVICE = 53029,
88
+ /** 方法在 PK 房间上不可用 */
89
+ THE_FUNCTION_IS_DISABLED_IN_PKROOM = 53030
88
90
  }
89
91
 
90
92
  /**
@@ -910,6 +912,70 @@ interface IAudioLevelChangeHandler {
910
912
  declare type RoomData = {
911
913
  [userId: string]: IPublishedResource[];
912
914
  };
915
+ interface IReqRoomPKOptions {
916
+ autoMix?: boolean;
917
+ extra?: string;
918
+ }
919
+ interface IPKInviterBaseInfo {
920
+ /**
921
+ * 邀请者房间 ID
922
+ */
923
+ inviterRoomId: string;
924
+ /**
925
+ * 邀请者用户 ID
926
+ */
927
+ inviterUserId: string;
928
+ }
929
+ interface IPKInviteeBaseInfo {
930
+ /**
931
+ * 被邀请者房间 ID
932
+ */
933
+ inviteeRoomId: string;
934
+ /**
935
+ * 被邀请者用户 ID
936
+ */
937
+ inviteeUserId: string;
938
+ }
939
+ interface IPKInviteInfo extends IPKInviterBaseInfo {
940
+ /**
941
+ * 邀请额外信息
942
+ */
943
+ extra?: string;
944
+ }
945
+ interface IPKInviteAnswerInfo extends IPKInviterBaseInfo, IPKInviteeBaseInfo {
946
+ /**
947
+ * 是否同意邀请
948
+ */
949
+ agree: boolean;
950
+ /**
951
+ * 响应额外信息
952
+ */
953
+ extra?: string;
954
+ }
955
+ interface IPKEndInfo {
956
+ /**
957
+ * 发起结束的房间 ID
958
+ */
959
+ endRoomId: string;
960
+ /**
961
+ * 发起结束的用户 ID
962
+ */
963
+ endUserId: string;
964
+ }
965
+ /**
966
+ * 观众加房间返回给客户的数据
967
+ */
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
+ };
978
+ }
913
979
 
914
980
  declare enum RCInnerCDNPushMode {
915
981
  AUTOMATIC = 0,
@@ -999,7 +1065,7 @@ interface IExchangeReqBody {
999
1065
  /**
1000
1066
  * 是否默认合流
1001
1067
  */
1002
- automix: boolean;
1068
+ autoMix: boolean;
1003
1069
  /**
1004
1070
  * 房间 Id 对应的 SessionId
1005
1071
  */
@@ -1686,9 +1752,21 @@ declare class RCAudienceLivingRoom {
1686
1752
  private readonly _joinResData;
1687
1753
  readonly _livingType: RCLivingType;
1688
1754
  private readonly _service;
1755
+ /**
1756
+ * 主播列表
1757
+ */
1689
1758
  private _roomAnchorList;
1759
+ /**
1760
+ * 合流、分流资源
1761
+ */
1690
1762
  private _roomRes;
1763
+ /**
1764
+ * 主播分流资源
1765
+ */
1691
1766
  private _roomAnchorRes;
1767
+ /**
1768
+ * 合流、分流 remoteTracks
1769
+ */
1692
1770
  private _remoteTracks;
1693
1771
  private _appListener;
1694
1772
  private _pc;
@@ -1709,8 +1787,12 @@ declare class RCAudienceLivingRoom {
1709
1787
  private _CDNUris;
1710
1788
  constructor(_context: RTCPluginContext, _runtime: IRuntime, _initOptions: IRCRTCInitOptions, _roomId: string, _joinResData: {
1711
1789
  token: string;
1712
- kvEntries?: IServerRTCRoomEntry[];
1790
+ kvEntries: IServerRTCRoomEntry[];
1713
1791
  }, _livingType: RCLivingType);
1792
+ /**
1793
+ * 解析服务端返回的 KV 数据,赋值 room 内数据
1794
+ */
1795
+ private _setInitData;
1714
1796
  protected _assertRoomDestroyed(): RCRTCCode | undefined;
1715
1797
  /**
1716
1798
  * @description 信令数据处理
@@ -1769,8 +1851,7 @@ declare class RCAudienceLivingRoom {
1769
1851
  private _diffCDNUris;
1770
1852
  /**
1771
1853
  * 获取 CDN 资源对应的拉流地址
1772
- * 首次获取 CDNPlayUrl 时,需传入 url,
1773
- * 业务层调用时使用内存中 _CDNUris 的 url,无 _CDNUris 时说明观众端未赋值过 _CDNUris
1854
+ * _CDNUris url 时,说明未开启 CDN 推送
1774
1855
  * @returns CDNPlayUrl
1775
1856
  */
1776
1857
  private _getCDNPlayUrl;
@@ -1864,6 +1945,26 @@ declare class RCAudienceLivingRoom {
1864
1945
  * @returns
1865
1946
  */
1866
1947
  getRemoteTracks(): RCRemoteTrack[];
1948
+ /**
1949
+ * 获取远端 RTC tracks
1950
+ */
1951
+ getRemoteRTCTracks(): RCRemoteTrack[];
1952
+ /**
1953
+ * 获取远端 MCU tracks
1954
+ */
1955
+ getRemoteMCUTracks(): RCRemoteTrack[];
1956
+ /**
1957
+ * 获取房间内 CDN 信息
1958
+ */
1959
+ getCDNInfo(): {
1960
+ resolution: RCResolution;
1961
+ fps: RCFrameRate;
1962
+ CDNEnable: boolean | undefined;
1963
+ } | {
1964
+ CDNEnable: boolean;
1965
+ resolution?: undefined;
1966
+ fps?: undefined;
1967
+ };
1867
1968
  }
1868
1969
 
1869
1970
  /**
@@ -1984,6 +2085,149 @@ declare class RCRTCPeerConnection extends EventEmitter {
1984
2085
  clearReTryExchangeTimer(): void;
1985
2086
  }
1986
2087
 
2088
+ declare type IOnRecvPKMsg = (msg: IReceivedMessage) => void;
2089
+ interface IRoomPKEventListener {
2090
+ /**
2091
+ * 收到连麦 PK 邀请
2092
+ */
2093
+ onRequestJoinOtherRoom: (info: IPKInviteInfo) => {};
2094
+ /**
2095
+ * 收到连麦 PK 邀请取消
2096
+ */
2097
+ onCancelRequestOtherRoom: (info: IPKInviteInfo) => {};
2098
+ /**
2099
+ * 收到连麦 PK 请求响应结果
2100
+ */
2101
+ onResponseJoinOtherRoom: (info: IPKInviteAnswerInfo) => {};
2102
+ /**
2103
+ * 收到 PK 结束
2104
+ */
2105
+ onFinishOtherRoom: (info: IPKEndInfo) => {};
2106
+ }
2107
+ declare class RCLivingPKHandler {
2108
+ private readonly _context;
2109
+ private readonly _runtime;
2110
+ private readonly _service;
2111
+ private readonly _initOptions;
2112
+ /**
2113
+ * 主直播房间
2114
+ */
2115
+ private readonly _mainLivingRoom;
2116
+ private readonly _registerPKMsgListener;
2117
+ /**
2118
+ * 加入 PK 房间回调
2119
+ */
2120
+ private readonly _onJoinedPKRoom;
2121
+ /**
2122
+ * 退出 PK 房间回调
2123
+ */
2124
+ private readonly _onLeavePKRoom;
2125
+ /**
2126
+ * PK 邀请超时时间
2127
+ */
2128
+ private readonly _inviteTimeout;
2129
+ /**
2130
+ * PK 房间信息
2131
+ */
2132
+ private _PKInfo;
2133
+ private _appListener;
2134
+ private _mainRoomId;
2135
+ /**
2136
+ * 跨房间连麦加入的 PK 房间
2137
+ */
2138
+ private _joinedPKRooms;
2139
+ constructor(_context: RTCPluginContext, _runtime: IRuntime, _service: RCMediaService, _initOptions: IRCRTCInitOptions,
2140
+ /**
2141
+ * 主直播房间
2142
+ */
2143
+ _mainLivingRoom: RCLivingRoom, _registerPKMsgListener: (listener: IOnRecvPKMsg) => void,
2144
+ /**
2145
+ * 加入 PK 房间回调
2146
+ */
2147
+ _onJoinedPKRoom: (roomId: string, room: RCLivingRoom) => void,
2148
+ /**
2149
+ * 退出 PK 房间回调
2150
+ */
2151
+ _onLeavePKRoom: (roomId: string) => void);
2152
+ private _callAppListener;
2153
+ private _onInvite;
2154
+ private _onCancelInvite;
2155
+ private _onInviteTimeout;
2156
+ private _onInviteAnswer;
2157
+ private _onPKEnd;
2158
+ /**
2159
+ * 处理跨房间连麦相关消息
2160
+ */
2161
+ private _onRecvPKMsg;
2162
+ /**
2163
+ * 跨房间连麦 PK 事件注册
2164
+ */
2165
+ registerRoomPKEventListener(listener: IRoomPKEventListener): void;
2166
+ /**
2167
+ * 发起跨房间连麦请求
2168
+ * @param inviteeRoomId 被邀请者所处的房间 ID
2169
+ * @param inviteeUserId 被邀请者 ID
2170
+ * @param options.autoMix 被邀请者的发布的资源在服务侧是否自动合流
2171
+ * @param options.extra 拓展字段,用于邀请数据透传
2172
+ */
2173
+ requestJoinOtherRoom(inviteeRoomId: string, inviteeUserId: string, options?: IReqRoomPKOptions): Promise<{
2174
+ code: RCRTCCode;
2175
+ }>;
2176
+ /**
2177
+ * 取消跨房间连麦 PK 请求
2178
+ */
2179
+ cancelRequestJoinOtherRoom(inviteeRoomId: string, inviteeUserId: string, extra?: string): Promise<{
2180
+ code: RCRTCCode;
2181
+ }>;
2182
+ /**
2183
+ * 跨房间连麦 PK 响应
2184
+ */
2185
+ responseJoinOtherRoom(inviterRoomId: string, inviterUserId: string, agree: boolean, options?: IReqRoomPKOptions): Promise<{
2186
+ code: RCRTCCode;
2187
+ }>;
2188
+ /**
2189
+ * 结束跨房间连麦 PK
2190
+ * @param roomId 需要退出 PK 的房间 ID
2191
+ */
2192
+ private _quitRoomPK;
2193
+ private _relaseCrtRoom;
2194
+ /**
2195
+ * 加入 PK 直播房间
2196
+ * @roomId PK 房间 ID
2197
+ */
2198
+ joinOtherRoom(roomId: string): Promise<{
2199
+ code: RCRTCCode;
2200
+ room?: RCLivingRoom;
2201
+ userIds?: string[];
2202
+ tracks?: RCRemoteTrack[];
2203
+ CDNEnable?: boolean;
2204
+ }>;
2205
+ /**
2206
+ * 退出 PK 直播房间房间
2207
+ * @param room 要离开的 PK 房间 room 实例
2208
+ */
2209
+ leaveOtherRoom(room: RCLivingRoom, isQuitPK?: boolean): Promise<{
2210
+ code: RCRTCCode;
2211
+ }>;
2212
+ /**
2213
+ * 获取 _PKInfo
2214
+ */
2215
+ getPKInfo(roomId: string): {
2216
+ inviteSessionId: string;
2217
+ inviterRoomId: string;
2218
+ inviterUserId: string;
2219
+ inviterUserAutoMix?: boolean | undefined;
2220
+ inviteeRoomId: string;
2221
+ inviteeUserAutoMix?: boolean | undefined;
2222
+ };
2223
+ /**
2224
+ * 获取已加入的 PK 房间
2225
+ */
2226
+ getJoinedPKRooms(): {
2227
+ [roomId: string]: RCLivingRoom;
2228
+ };
2229
+ }
2230
+
1987
2231
  /**
1988
2232
  * 房间抽象基类
1989
2233
  */
@@ -1995,6 +2239,7 @@ declare abstract class RCAbstractRoom {
1995
2239
  protected readonly _service: RCMediaService;
1996
2240
  protected readonly _initOptions: IRCRTCInitOptions;
1997
2241
  private readonly _ntfClearRoomItem;
2242
+ protected _isMainRoom?: boolean | undefined;
1998
2243
  /**
1999
2244
  * 房间资源数据
2000
2245
  */
@@ -2006,7 +2251,7 @@ declare abstract class RCAbstractRoom {
2006
2251
  /**
2007
2252
  * 已订阅参数
2008
2253
  */
2009
- private readonly _subscribedList;
2254
+ protected readonly _subscribedList: ISubscribeAttr[];
2010
2255
  /**
2011
2256
  * 房间保活 rtcPing
2012
2257
  */
@@ -2022,7 +2267,7 @@ declare abstract class RCAbstractRoom {
2022
2267
  /**
2023
2268
  * PeerConnection 连接实例
2024
2269
  */
2025
- private readonly _pc;
2270
+ protected readonly _pc: RCRTCPeerConnection;
2026
2271
  private _destroyed;
2027
2272
  /**
2028
2273
  * 北极星上报实例
@@ -2032,7 +2277,7 @@ declare abstract class RCAbstractRoom {
2032
2277
  * 音量上报实例
2033
2278
  */
2034
2279
  private _audioLevelReport;
2035
- constructor(_context: RTCPluginContext, _runtime: IRuntime, _roomId: string, data: IJoinRTCRoomData, _roomMode: RTCMode, _service: RCMediaService, _initOptions: IRCRTCInitOptions, _ntfClearRoomItem: Function, isUpgrade?: boolean);
2280
+ constructor(_context: RTCPluginContext, _runtime: IRuntime, _roomId: string, data: IJoinRTCRoomData, _roomMode: RTCMode, _service: RCMediaService, _initOptions: IRCRTCInitOptions, _ntfClearRoomItem: Function, isUpgrade?: boolean, _isMainRoom?: boolean | undefined);
2036
2281
  private _initRemoteTracks;
2037
2282
  private _handlePingResult;
2038
2283
  /**
@@ -2324,6 +2569,15 @@ declare abstract class RCAbstractRoom {
2324
2569
  * 销毁远端资源
2325
2570
  */
2326
2571
  private _removeRemoteTracks;
2572
+ private _onRecvPKMsg;
2573
+ /**
2574
+ * 注册 PK 业务监听方法
2575
+ */
2576
+ protected _registerPKMsgListener(listener: IOnRecvPKMsg): void;
2577
+ /**
2578
+ * 退出 PK 房间
2579
+ */
2580
+ protected _quitPKRoom(): void;
2327
2581
  }
2328
2582
 
2329
2583
  /**
@@ -2501,13 +2755,25 @@ declare class RCMCUConfigBuilder {
2501
2755
  */
2502
2756
  declare class RCLivingRoom extends RCAbstractRoom {
2503
2757
  private _livingType;
2758
+ /**
2759
+ * 是否是主房间
2760
+ */
2761
+ protected _isMainRoom: boolean;
2504
2762
  readonly _mcuConfigBuilder: RCMCUConfigBuilder;
2505
2763
  /**
2506
2764
  * cdn_uris 信令扩散数据
2507
2765
  */
2508
2766
  private _CDNUris;
2509
2767
  private _CDNEnable;
2510
- constructor(context: RTCPluginContext, runtime: IRuntime, roomId: string, data: IJoinRTCRoomData, service: RCMediaService, initOptions: IRCRTCInitOptions, clientEvent: Function, _livingType: RCLivingType, isUpgrage?: boolean);
2768
+ /**
2769
+ * 跨房间连麦管理器
2770
+ */
2771
+ private readonly _roomPKHandler;
2772
+ constructor(context: RTCPluginContext, runtime: IRuntime, roomId: string, data: IJoinRTCRoomData, service: RCMediaService, initOptions: IRCRTCInitOptions, clientEvent: Function, _livingType: RCLivingType, isUpgrage: boolean | undefined,
2773
+ /**
2774
+ * 是否是主房间
2775
+ */
2776
+ _isMainRoom: boolean);
2511
2777
  getLivingType(): RCLivingType;
2512
2778
  /**
2513
2779
  * 获取 MCU 配置构建对象
@@ -2579,6 +2845,27 @@ declare class RCLivingRoom extends RCAbstractRoom {
2579
2845
  * @returns boolean
2580
2846
  */
2581
2847
  __getCDNPushMode(): RCInnerCDNPushMode | undefined;
2848
+ /**
2849
+ * 加入 PK 房间回调
2850
+ */
2851
+ private _onJoinedPKRoom;
2852
+ private _onLeavePKRoom;
2853
+ /**
2854
+ * 携带 pushOtherRooms 与 mediaServer 重新交互
2855
+ * @param roomId 副房间 roomId
2856
+ */
2857
+ private _exchangeWithPushOtherRoom;
2858
+ /**
2859
+ * 获取 PK 业务处理器
2860
+ */
2861
+ getRoomPKHandler(): {
2862
+ code: RCRTCCode;
2863
+ roomPKHandler?: RCLivingPKHandler;
2864
+ };
2865
+ /**
2866
+ * 退出 PK 房间
2867
+ */
2868
+ protected _quitPKRoom(): void;
2582
2869
  }
2583
2870
 
2584
2871
  /**
@@ -2700,6 +2987,7 @@ declare class RCRTCClient {
2700
2987
  * 获取直播观众客户端
2701
2988
  */
2702
2989
  getAudienceClient(): RCAudienceClient;
2990
+ private _getJoinedPKRooms;
2703
2991
  private _onIMStatusChange;
2704
2992
  private _onIMDisconnect;
2705
2993
  private _onIMUninit;
@@ -2810,6 +3098,7 @@ declare class RCRTCClient {
2810
3098
  joinLivingRoomAsAudience(roomId: string, livingType: RCLivingType): Promise<{
2811
3099
  room?: RCAudienceLivingRoom;
2812
3100
  code: RCRTCCode;
3101
+ remoteInfo?: IAudienceJoinRoomResInfo;
2813
3102
  }>;
2814
3103
  /**
2815
3104
  * 观众退出并销毁当前房间实例,退出后该房间的所有方法将不可用
@@ -2832,6 +3121,7 @@ declare class RCRTCClient {
2832
3121
  downgradeToAudienceRoom(room: RCLivingRoom): Promise<{
2833
3122
  room?: RCAudienceLivingRoom;
2834
3123
  code: RCRTCCode;
3124
+ remoteInfo?: IAudienceJoinRoomResInfo;
2835
3125
  }>;
2836
3126
  /**
2837
3127
  * 获取在房间内用户信息
@@ -2890,4 +3180,4 @@ declare const helper: {
2890
3180
  ifSupportScreenShare: typeof ifSupportScreenShare;
2891
3181
  };
2892
3182
 
2893
- export { BackgroundPictureFillMode, ICameraVideoProfile, IMCUOutputConfig, IMCUOutputVideoConfig, IMicphoneAudioProfile, IPublishAttrs, IPublishedResource, IRCCandidatePairStat, IRCRTCInitOptions, IRCRTCReportListener, IRCRTCStateReport, IRCTrackStat, IRoomEventListener, 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 };
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 };