@rongcloud/plugin-rtc 5.4.2 → 5.4.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/async-task-queue.d.ts +9 -0
- package/dist/core/Invoker.d.ts +46 -0
- package/dist/core/PolarisReporter.d.ts +35 -0
- package/dist/core/RCAudienceClient.d.ts +89 -0
- package/dist/core/RCMediaStreamCapture.d.ts +124 -0
- package/dist/core/RCRTCClient.d.ts +126 -0
- package/dist/core/Store.d.ts +80 -0
- package/dist/core/command/BaseCommand.d.ts +22 -0
- package/dist/core/command/EnabelInnerCDNCommand.d.ts +16 -0
- package/dist/core/command/ExchangeCommand.d.ts +18 -0
- package/dist/core/command/ExchangeWithPushOtherRoomCommand.d.ts +22 -0
- package/dist/core/command/JoinRoomCommand.d.ts +26 -0
- package/dist/core/command/LeaveOtherRoomCommand.d.ts +30 -0
- package/dist/core/command/LocalTrackMuteCommand.d.ts +10 -0
- package/dist/core/command/MCUConfigFlushCommand.d.ts +18 -0
- package/dist/core/command/OnRemoteUserUnpubCommand.d.ts +13 -0
- package/dist/core/command/OnSignalReconnectedCommand.d.ts +38 -0
- package/dist/core/command/ParseRemoteResCommand.d.ts +38 -0
- package/dist/core/command/ParseUserStateCommand.d.ts +57 -0
- package/dist/core/command/PubCommand.d.ts +34 -0
- package/dist/core/command/RTCIdentityChangeCommand.d.ts +17 -0
- package/dist/core/command/RetryExchangeCommand.d.ts +18 -0
- package/dist/core/command/SubCommand.d.ts +21 -0
- package/dist/core/command/UnpubCommand.d.ts +20 -0
- package/dist/core/command/UnpubPrevCommand.d.ts +6 -0
- package/dist/core/command/UnsubCommand.d.ts +20 -0
- package/dist/core/command/UpdateSubListCommand.d.ts +28 -0
- package/dist/core/command/helper.d.ts +20 -0
- package/dist/core/constants.d.ts +2 -0
- package/dist/core/enums/BackgroundPictureFillMode.d.ts +14 -0
- package/dist/core/enums/MixLayoutMode.d.ts +18 -0
- package/dist/core/enums/MixVideoRenderMode.d.ts +14 -0
- package/dist/core/enums/RCBitrate.d.ts +48 -0
- package/dist/core/enums/RCFrameRate.d.ts +7 -0
- package/dist/core/enums/RCInnerCDNBroadcast.d.ts +5 -0
- package/dist/core/enums/RCInnerCDNModel.d.ts +5 -0
- package/dist/core/enums/RCInnerCDNPullIsHttps.d.ts +5 -0
- package/dist/core/enums/RCInnerCDNPullKind.d.ts +6 -0
- package/dist/core/enums/RCInnerCDNPushMode.d.ts +5 -0
- package/dist/core/enums/RCKickType.d.ts +11 -0
- package/dist/core/enums/RCLivingType.d.ts +14 -0
- package/dist/core/enums/RCLoggerTag.d.ts +629 -0
- package/dist/core/enums/RCMediaType.d.ts +18 -0
- package/dist/core/enums/RCMixInputFilterMode.d.ts +35 -0
- package/dist/core/enums/RCRTCCode.d.ts +88 -0
- package/dist/core/enums/RCRTCLiveRole.d.ts +14 -0
- package/dist/core/enums/RCRTCPingResult.d.ts +5 -0
- package/dist/core/enums/RCRTCResolution.d.ts +102 -0
- package/dist/core/enums/RCResolution.d.ts +16 -0
- package/dist/core/enums/inner/PolarisRole.d.ts +14 -0
- package/dist/core/enums/inner/R2Action.d.ts +14 -0
- package/dist/core/enums/inner/R2Status.d.ts +11 -0
- package/dist/core/enums/inner/RCRTCMessageType.d.ts +66 -0
- package/dist/core/enums/inner/RCStreamType.d.ts +14 -0
- package/dist/core/enums/inner/TrackState.d.ts +14 -0
- package/dist/core/interfaces.d.ts +912 -0
- package/dist/core/room/Pinger.d.ts +35 -0
- package/dist/core/room/RCAbstractRoom.d.ts +327 -0
- package/dist/core/room/RCAudienceLivingRoom.d.ts +321 -0
- package/dist/core/room/RCAudioLevelReport.d.ts +16 -0
- package/dist/core/room/RCLivingPKHandler.d.ts +164 -0
- package/dist/core/room/RCLivingRoom.d.ts +108 -0
- package/dist/core/room/RCLocalMediaStream.d.ts +8 -0
- package/dist/core/room/RCMCUConfigBuilder.d.ts +211 -0
- package/dist/core/room/RCRTCRoom.d.ts +15 -0
- package/dist/core/service/RCMediaService.d.ts +96 -0
- package/dist/core/service/helper.d.ts +8 -0
- package/dist/core/service/index.d.ts +6 -0
- package/dist/core/service/interface.d.ts +323 -0
- package/dist/core/service/mcu-interface.d.ts +293 -0
- package/dist/core/tracks/RCLocalTrack.d.ts +121 -0
- package/dist/core/tracks/RCRemoteTrack.d.ts +29 -0
- package/dist/core/tracks/RCTrack.d.ts +90 -0
- package/dist/core/webrtc/RCRTCPeerCManager.d.ts +159 -0
- package/dist/core/webrtc/RCRTCPeerConnection.d.ts +112 -0
- package/dist/core/webrtc/helper.d.ts +26 -0
- package/dist/core/webrtc/sdp/ASdpBuilder.d.ts +98 -0
- package/dist/core/webrtc/sdp/ASdpStrategy.d.ts +48 -0
- package/dist/core/webrtc/sdp/PlanBSdpBuilder.d.ts +20 -0
- package/dist/core/webrtc/sdp/PlanBStrategy.d.ts +26 -0
- package/dist/core/webrtc/sdp/UnifiedPlanSdpBuilder.d.ts +11 -0
- package/dist/core/webrtc/sdp/UnifiedPlanStrategy.d.ts +21 -0
- package/dist/core/webrtc/stat-parser/AbstractStatParser.d.ts +117 -0
- package/dist/core/webrtc/stat-parser/ChromeStatParser.d.ts +14 -0
- package/dist/core/webrtc/stat-parser/FirefoxStatParser.d.ts +14 -0
- package/dist/core/webrtc/stat-parser/IStatParser.d.ts +24 -0
- package/dist/core/webrtc/stat-parser/SafariStatParser.d.ts +14 -0
- package/dist/device.d.ts +6 -0
- package/dist/helper.d.ts +189 -0
- package/dist/index.d.ts +205 -158
- package/dist/index.esm.js +18244 -15
- package/dist/index.js +18276 -15
- package/dist/index.umd.js +18280 -15
- package/dist/logger.d.ts +4 -0
- package/package.json +3 -3
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import { ExchangeHooks } from '../command/ExchangeWithPushOtherRoomCommand';
|
|
2
|
+
import { ErrorCode, IReceivedMessage, IRuntime, RTCPluginContext } from '@rongcloud/engine';
|
|
3
|
+
import { RCRTCCode } from '../enums/RCRTCCode';
|
|
4
|
+
import { IPKInfo, IPKEndInfo, IPKInviteAnswerInfo, IPKInviteInfo, IRCRTCInitOptions, IReqResPKOptions } from '../interfaces';
|
|
5
|
+
import { Invoker } from '../Invoker';
|
|
6
|
+
import RCMediaService from '../service/RCMediaService';
|
|
7
|
+
import { RCRemoteTrack } from '../tracks/RCRemoteTrack';
|
|
8
|
+
import RCLivingRoom from './RCLivingRoom';
|
|
9
|
+
export declare type IOnRecvPKMsg = (msg: IReceivedMessage) => void;
|
|
10
|
+
export interface IRoomPKEventListener {
|
|
11
|
+
/**
|
|
12
|
+
* 收到连麦邀请
|
|
13
|
+
*/
|
|
14
|
+
onRequestJoinOtherRoom: (info: IPKInviteInfo) => {};
|
|
15
|
+
/**
|
|
16
|
+
* 收到取消连麦邀请
|
|
17
|
+
*/
|
|
18
|
+
onCancelRequestOtherRoom: (info: IPKInviteInfo) => {};
|
|
19
|
+
/**
|
|
20
|
+
* 收到连麦 PK 请求响应结果
|
|
21
|
+
*/
|
|
22
|
+
onResponseJoinOtherRoom: (info: IPKInviteAnswerInfo) => {};
|
|
23
|
+
/**
|
|
24
|
+
* 收到 PK 结束
|
|
25
|
+
*/
|
|
26
|
+
onFinishOtherRoom: (info: IPKEndInfo) => {};
|
|
27
|
+
}
|
|
28
|
+
export declare class RCLivingPKHandler {
|
|
29
|
+
private _invoker;
|
|
30
|
+
private _PKInfo;
|
|
31
|
+
private _hooks;
|
|
32
|
+
private readonly _context;
|
|
33
|
+
private readonly _runtime;
|
|
34
|
+
private readonly _service;
|
|
35
|
+
private readonly _initOptions;
|
|
36
|
+
/**
|
|
37
|
+
* 主直播房间
|
|
38
|
+
*/
|
|
39
|
+
private readonly _mainLivingRoom;
|
|
40
|
+
private readonly _registerPKMsgListener;
|
|
41
|
+
/**
|
|
42
|
+
* 加入 PK 房间回调
|
|
43
|
+
*/
|
|
44
|
+
private readonly _onJoinedPKRoom;
|
|
45
|
+
protected readonly _clientSessionId?: string | undefined;
|
|
46
|
+
/**
|
|
47
|
+
* PK 邀请超时时间,默认 30s
|
|
48
|
+
*/
|
|
49
|
+
private readonly _inviteTimeout;
|
|
50
|
+
private _appListener;
|
|
51
|
+
private _mainRoomId;
|
|
52
|
+
/**
|
|
53
|
+
* 跨房间连麦加入的 PK 房间
|
|
54
|
+
*/
|
|
55
|
+
private _joinedPKRooms;
|
|
56
|
+
constructor(_invoker: Invoker, _PKInfo: IPKInfo, _hooks: ExchangeHooks, _context: RTCPluginContext, _runtime: IRuntime, _service: RCMediaService, _initOptions: IRCRTCInitOptions,
|
|
57
|
+
/**
|
|
58
|
+
* 主直播房间
|
|
59
|
+
*/
|
|
60
|
+
_mainLivingRoom: RCLivingRoom, _registerPKMsgListener: (listener: IOnRecvPKMsg) => void,
|
|
61
|
+
/**
|
|
62
|
+
* 加入 PK 房间回调
|
|
63
|
+
*/
|
|
64
|
+
_onJoinedPKRoom: (roomId: string, room: RCLivingRoom) => void, _clientSessionId?: string | undefined);
|
|
65
|
+
private _callAppListener;
|
|
66
|
+
/**
|
|
67
|
+
* 收到连麦邀请
|
|
68
|
+
*/
|
|
69
|
+
private _onInvite;
|
|
70
|
+
/**
|
|
71
|
+
* 收到取消连麦
|
|
72
|
+
*/
|
|
73
|
+
private _onCancelInvite;
|
|
74
|
+
private _onInviteTimeout;
|
|
75
|
+
/**
|
|
76
|
+
* 收到响应连麦
|
|
77
|
+
*/
|
|
78
|
+
private _onInviteAnswer;
|
|
79
|
+
private createLeaveOtherRoomCommand;
|
|
80
|
+
/**
|
|
81
|
+
* 收到连麦结束
|
|
82
|
+
*/
|
|
83
|
+
private _onPKEnd;
|
|
84
|
+
/**
|
|
85
|
+
* 处理跨房间连麦相关消息
|
|
86
|
+
*/
|
|
87
|
+
private _onRecvPKMsg;
|
|
88
|
+
/**
|
|
89
|
+
* 注册跨房间连麦监听事件
|
|
90
|
+
*/
|
|
91
|
+
registerRoomPKEventListener(listener: IRoomPKEventListener): void;
|
|
92
|
+
/**
|
|
93
|
+
* 发起跨房间连麦请求
|
|
94
|
+
* @param inviteeRoomId 被邀请者所处的房间 roomId
|
|
95
|
+
* @param inviteeUserId 被邀请者 userId
|
|
96
|
+
* @param options.autoMix 是否要把邀请者发布的资源,合并到被邀请者房间内的 MCU 流中
|
|
97
|
+
* @param options.extra 拓展字段,可随邀请连麦消息透传给被邀请者
|
|
98
|
+
*/
|
|
99
|
+
requestJoinOtherRoom(inviteeRoomId: string, inviteeUserId: string, options?: IReqResPKOptions): Promise<{
|
|
100
|
+
code: RCRTCCode | ErrorCode;
|
|
101
|
+
}>;
|
|
102
|
+
/**
|
|
103
|
+
* 取消跨房间连麦请求
|
|
104
|
+
* @param inviteeRoomId 被邀请者所处的房间 roomId
|
|
105
|
+
* @param inviteeUserId 被邀请者 userId
|
|
106
|
+
* @param extra 附加信息,可随取消邀请连麦消息透传给被邀请者
|
|
107
|
+
*/
|
|
108
|
+
cancelRequestJoinOtherRoom(inviteeRoomId: string, inviteeUserId: string, extra?: string): Promise<{
|
|
109
|
+
code: RCRTCCode | ErrorCode;
|
|
110
|
+
}>;
|
|
111
|
+
/**
|
|
112
|
+
* 响应跨房间连麦请求
|
|
113
|
+
* @param inviterRoomId 邀请者所处的房间 roomId
|
|
114
|
+
* @param inviterUserId 邀请者 userId
|
|
115
|
+
* @param agree 是否同意连麦
|
|
116
|
+
* @param options.autoMix 是否要把被邀请者发布的资源,合并到邀请者房间内的 MCU 流中
|
|
117
|
+
* @param options.extra 附加信息,可随响应连麦消息透传给邀请者
|
|
118
|
+
*/
|
|
119
|
+
responseJoinOtherRoom(inviterRoomId: string, inviterUserId: string, agree: boolean, options?: IReqResPKOptions): Promise<{
|
|
120
|
+
code: RCRTCCode | ErrorCode;
|
|
121
|
+
}>;
|
|
122
|
+
/**
|
|
123
|
+
* 加入副直播房间
|
|
124
|
+
* @roomId 副房间的 roomId
|
|
125
|
+
*/
|
|
126
|
+
joinOtherRoom(roomId: string): Promise<{
|
|
127
|
+
code: RCRTCCode;
|
|
128
|
+
room?: RCLivingRoom;
|
|
129
|
+
userIds?: string[];
|
|
130
|
+
tracks?: RCRemoteTrack[];
|
|
131
|
+
CDNEnable?: boolean;
|
|
132
|
+
}>;
|
|
133
|
+
/**
|
|
134
|
+
* 退出副房间
|
|
135
|
+
* @param room 要退出的副房间的 room 实例
|
|
136
|
+
* @param isQuitPK 是否要结束连麦
|
|
137
|
+
*/
|
|
138
|
+
leaveOtherRoom(room: RCLivingRoom, isQuitPK?: boolean): Promise<{
|
|
139
|
+
code: RCRTCCode;
|
|
140
|
+
}>;
|
|
141
|
+
/**
|
|
142
|
+
* 获取连麦信息
|
|
143
|
+
* @param roomId 连麦房间的 roomId
|
|
144
|
+
*/
|
|
145
|
+
getPKInfo(roomId: string): {
|
|
146
|
+
inviteSessionId: string;
|
|
147
|
+
inviterRoomId: string;
|
|
148
|
+
inviterUserId: string;
|
|
149
|
+
inviterUserAutoMix?: boolean | undefined;
|
|
150
|
+
inviteeRoomId: string;
|
|
151
|
+
inviteeUserAutoMix?: boolean | undefined;
|
|
152
|
+
};
|
|
153
|
+
/**
|
|
154
|
+
* 获取所有连麦信息
|
|
155
|
+
*/
|
|
156
|
+
getAllPKInfo(): IPKInfo;
|
|
157
|
+
/**
|
|
158
|
+
* 获取已加入的副房间
|
|
159
|
+
*/
|
|
160
|
+
getJoinedPKRooms(): {
|
|
161
|
+
[roomId: string]: RCLivingRoom;
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
//# sourceMappingURL=RCLivingPKHandler.d.ts.map
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { IJoinRTCRoomData, RTCMode, RTCPluginContext, IRuntime, ErrorCode, IRTCUserData, RTCJoinType } from '@rongcloud/engine';
|
|
2
|
+
import { RCRTCCode } from '../enums/RCRTCCode';
|
|
3
|
+
import { IRCRTCInitOptions, IPublishAttrs, IPubSuccessRes } from '../interfaces';
|
|
4
|
+
import { RCMediaService, ICDNUris, IPushOtherRooms } from '../service';
|
|
5
|
+
import RCAbstractRoom from './RCAbstractRoom';
|
|
6
|
+
import RCMCUConfigBuilder from './RCMCUConfigBuilder';
|
|
7
|
+
import { RCLivingType } from '../enums/RCLivingType';
|
|
8
|
+
import { RCRTCMessageType } from '../enums/inner/RCRTCMessageType';
|
|
9
|
+
import { RCInnerCDNPushMode } from '../enums/RCInnerCDNPushMode';
|
|
10
|
+
import { RCLivingPKHandler } from './RCLivingPKHandler';
|
|
11
|
+
import { RCLocalTrack } from '../tracks/RCLocalTrack';
|
|
12
|
+
import { ResourceMsgContent } from '../command/ParseRemoteResCommand';
|
|
13
|
+
/**
|
|
14
|
+
* 直播房间
|
|
15
|
+
*/
|
|
16
|
+
export default class RCLivingRoom extends RCAbstractRoom {
|
|
17
|
+
private _livingType;
|
|
18
|
+
readonly _mcuConfigBuilder: RCMCUConfigBuilder;
|
|
19
|
+
/**
|
|
20
|
+
* 跨房间连麦管理器
|
|
21
|
+
*/
|
|
22
|
+
private _roomPKHandler;
|
|
23
|
+
constructor(context: RTCPluginContext, runtime: IRuntime, roomId: string, service: RCMediaService, initOptions: IRCRTCInitOptions, _livingType: RCLivingType, isUpgrade?: boolean, isMainRoom?: boolean,
|
|
24
|
+
/**
|
|
25
|
+
* 是否使用多 peerConnection
|
|
26
|
+
*/
|
|
27
|
+
useMutilPeerC?: boolean, _clientSessionId?: string);
|
|
28
|
+
private _initAfterCatchRoomData;
|
|
29
|
+
/**
|
|
30
|
+
* @override
|
|
31
|
+
*/
|
|
32
|
+
__innerInit(mode: RTCMode, joinType?: RTCJoinType, livingType?: RCLivingType, innerUserDatas?: IRTCUserData, outerUserDatas?: IRTCUserData): Promise<{
|
|
33
|
+
code: RCRTCCode | ErrorCode;
|
|
34
|
+
data?: IJoinRTCRoomData;
|
|
35
|
+
}>;
|
|
36
|
+
__innerInitByIdentityChange(): Promise<ErrorCode>;
|
|
37
|
+
/**
|
|
38
|
+
* 增量发布资源,若发布的资源 tag 及媒体类型重复,后者将覆盖前者进行发布。
|
|
39
|
+
* @param tracks 待发布的 RCLocalTrack 实例
|
|
40
|
+
* @returns
|
|
41
|
+
*/
|
|
42
|
+
publish(tracks: (RCLocalTrack | IPublishAttrs)[]): Promise<IPubSuccessRes>;
|
|
43
|
+
unpublish(tracks: RCLocalTrack[]): Promise<IPubSuccessRes>;
|
|
44
|
+
/**
|
|
45
|
+
* resourceId 有效性验证
|
|
46
|
+
* @param resourceId
|
|
47
|
+
*/
|
|
48
|
+
protected _isValidResourceId(resourceId: string): boolean;
|
|
49
|
+
getLivingType(): RCLivingType;
|
|
50
|
+
/**
|
|
51
|
+
* 获取 MCU 配置构建对象
|
|
52
|
+
*/
|
|
53
|
+
getMCUConfigBuilder(): RCMCUConfigBuilder | {
|
|
54
|
+
code: RCRTCCode;
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* 开启/停用推 CDN
|
|
58
|
+
*/
|
|
59
|
+
enableInnerCDN(enable: boolean): Promise<{
|
|
60
|
+
code: RCRTCCode;
|
|
61
|
+
}>;
|
|
62
|
+
/**
|
|
63
|
+
* 资源变化时触发
|
|
64
|
+
* 直播房间需单独处理 cdn_uris
|
|
65
|
+
*/
|
|
66
|
+
protected _resourceHandle(content: ResourceMsgContent & {
|
|
67
|
+
cdn_uris?: ICDNUris[];
|
|
68
|
+
}, messageType: RCRTCMessageType.PUBLISH | RCRTCMessageType.UNPUBLISH | RCRTCMessageType.MODIFY | RCRTCMessageType.TOTAL_CONTENT_RESOURCE, userId: string): Promise<void>;
|
|
69
|
+
/**
|
|
70
|
+
* 观众切换为主播后直接处理人员变更及资源变更
|
|
71
|
+
*/
|
|
72
|
+
protected _afterChangedRole(data: IJoinRTCRoomData): void;
|
|
73
|
+
/**
|
|
74
|
+
* 返回 CDN 是否可用
|
|
75
|
+
* @returns boolean
|
|
76
|
+
*/
|
|
77
|
+
__getCDNEnable(): boolean;
|
|
78
|
+
/**
|
|
79
|
+
* 返回 CDN 推送模式: 自动 or 手动
|
|
80
|
+
*/
|
|
81
|
+
__getCDNPushMode(): RCInnerCDNPushMode | undefined;
|
|
82
|
+
/**
|
|
83
|
+
* @override
|
|
84
|
+
* 加入 PK 房间回调
|
|
85
|
+
*/
|
|
86
|
+
private _onJoinedPKRoom;
|
|
87
|
+
/**
|
|
88
|
+
* @override
|
|
89
|
+
*/
|
|
90
|
+
protected _getPushOtherRoomsParams(): IPushOtherRooms[];
|
|
91
|
+
/**
|
|
92
|
+
* 获取 PK 业务处理器
|
|
93
|
+
* @since version 5.3.0
|
|
94
|
+
*/
|
|
95
|
+
getRoomPKHandler(): {
|
|
96
|
+
code: RCRTCCode;
|
|
97
|
+
roomPKHandler?: RCLivingPKHandler;
|
|
98
|
+
};
|
|
99
|
+
/**
|
|
100
|
+
* 退出所有连麦房间
|
|
101
|
+
*/
|
|
102
|
+
protected _quitAllPKRoom(): Promise<void>;
|
|
103
|
+
/**
|
|
104
|
+
* 是否是主房间
|
|
105
|
+
*/
|
|
106
|
+
isMainRoom(): boolean | undefined;
|
|
107
|
+
}
|
|
108
|
+
//# sourceMappingURL=RCLivingRoom.d.ts.map
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
import { BackgroundPictureFillMode } from '../enums/BackgroundPictureFillMode';
|
|
2
|
+
import { MixLayoutMode } from '../enums/MixLayoutMode';
|
|
3
|
+
import { MixVideoRenderMode } from '../enums/MixVideoRenderMode';
|
|
4
|
+
import { RCFrameRate } from '../enums/RCFrameRate';
|
|
5
|
+
import { RCResolution } from '../enums/RCResolution';
|
|
6
|
+
import { RCRTCCode } from '../enums/RCRTCCode';
|
|
7
|
+
import { Invoker } from '../Invoker';
|
|
8
|
+
import { IMCUConfig } from '../service';
|
|
9
|
+
export default class RCMCUConfigBuilder {
|
|
10
|
+
private _invoker;
|
|
11
|
+
/**
|
|
12
|
+
* flush 提交回调
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* trackId 有效性验证方法
|
|
16
|
+
*/
|
|
17
|
+
private readonly _isValidTrackId;
|
|
18
|
+
/**
|
|
19
|
+
* mcu 配置数据,每次向服务器提交全量数据
|
|
20
|
+
*/
|
|
21
|
+
private _values;
|
|
22
|
+
constructor(_invoker: Invoker,
|
|
23
|
+
/**
|
|
24
|
+
* flush 提交回调
|
|
25
|
+
*/
|
|
26
|
+
/**
|
|
27
|
+
* trackId 有效性验证方法
|
|
28
|
+
*/
|
|
29
|
+
_isValidTrackId: (trackId: string) => boolean);
|
|
30
|
+
/**
|
|
31
|
+
* 设置合流后的主位置显示的视频流
|
|
32
|
+
* @param videoTrackId 视频流资源 Id
|
|
33
|
+
*/
|
|
34
|
+
setHostVideoTrack(videoTrackId: string): RCMCUConfigBuilder;
|
|
35
|
+
/**
|
|
36
|
+
* 设置合流布局模式,当使用 `MixLayoutMode.CUSTOMIZE` 模式时,需自定义合流结构
|
|
37
|
+
* @param mode
|
|
38
|
+
* * `MixLayoutMode.CUSTOMIZE`: 自定义布局,需用户设置布局结构
|
|
39
|
+
* * `MixLayoutMode.SUSPENSION`: 悬浮布局(默认)
|
|
40
|
+
* * `MixLayoutMode.ADAPTATION`: 自适应布局
|
|
41
|
+
*/
|
|
42
|
+
setMixLayoutMode(mode: MixLayoutMode): RCMCUConfigBuilder;
|
|
43
|
+
private _addOutputValue;
|
|
44
|
+
/**
|
|
45
|
+
* 设置合流输出视频流的分辨率
|
|
46
|
+
* @param resulution 有效值为 `RCResolution` 定义的枚举值
|
|
47
|
+
*/
|
|
48
|
+
setOutputVideoResolution(resolution: RCResolution): RCMCUConfigBuilder;
|
|
49
|
+
/**
|
|
50
|
+
* 设置合流输出视频流的帧率
|
|
51
|
+
* @param fps 其有效值为 `RCFrameRate` 中定义的枚举值
|
|
52
|
+
*/
|
|
53
|
+
setOutputVideoFPS(fps: RCFrameRate): RCMCUConfigBuilder;
|
|
54
|
+
/**
|
|
55
|
+
* 设置合流输出视频流的码率(不推荐主动修改)
|
|
56
|
+
* @param bitrate
|
|
57
|
+
*/
|
|
58
|
+
setOutputVideoBitrate(bitrate: number): RCMCUConfigBuilder;
|
|
59
|
+
/**
|
|
60
|
+
* 设置合流后输出视频流小流的分辨率
|
|
61
|
+
* @param resulution 有效值为 `RCResolution` 定义的枚举值
|
|
62
|
+
*/
|
|
63
|
+
setOutputTinyVideoResolution(resolution: RCResolution): RCMCUConfigBuilder;
|
|
64
|
+
/**
|
|
65
|
+
* 设置合流输出视频流小流的帧率
|
|
66
|
+
* @param fps 其有效值为 `RCFrameRate` 中定义的枚举值
|
|
67
|
+
*/
|
|
68
|
+
setOutputTinyVideoFPS(fps: RCFrameRate): RCMCUConfigBuilder;
|
|
69
|
+
/**
|
|
70
|
+
* 设置合流输出视频流小流的码率(不推荐主动修改)
|
|
71
|
+
* @param bitrate
|
|
72
|
+
*/
|
|
73
|
+
setOutputTinyVideoBitrate(bitrate: number): RCMCUConfigBuilder;
|
|
74
|
+
/**
|
|
75
|
+
* 设置合流后的视频流渲染方式
|
|
76
|
+
* @param renderMode
|
|
77
|
+
*/
|
|
78
|
+
setOutputVideoRenderMode(renderMode: MixVideoRenderMode): RCMCUConfigBuilder;
|
|
79
|
+
/**
|
|
80
|
+
* 设置合流后音频流的编码参数(不推荐主动修改)
|
|
81
|
+
* @param bitrate 音频码率
|
|
82
|
+
*/
|
|
83
|
+
setOutputAudioBitrate(bitrate: number): RCMCUConfigBuilder;
|
|
84
|
+
/**
|
|
85
|
+
* 设置合流后的视频流的背景色,默认为 `0x000000`
|
|
86
|
+
* @param color 颜色参数,为 16 进制标识法,如 '0x000000'
|
|
87
|
+
*/
|
|
88
|
+
setOutputBackgroundColor(color: string): RCMCUConfigBuilder;
|
|
89
|
+
/**
|
|
90
|
+
* 向合流后的视频流中增加背景图片
|
|
91
|
+
* @param uri 图片资源的完整下载地址
|
|
92
|
+
* @param x 相对于整体画布的起始位置 x 坐标(百分比),有效值 `0.0` - `1.0`
|
|
93
|
+
* @param y 相对于整体画布的起始位置 y 坐标(百分比),有效值 `0.0` - `1.0`
|
|
94
|
+
* @param w 相对于整体画布的宽(百分比),有效值 `0.0` - `1.0`
|
|
95
|
+
* @param h 相对于整体画布的高(百分比),有效值 `0.0` - `1.0`
|
|
96
|
+
*/
|
|
97
|
+
addOutputBackgroundPicture(uri: string, x: number, y: number, w: number, h: number): RCMCUConfigBuilder;
|
|
98
|
+
/**
|
|
99
|
+
* 移除对合流后的视频流中添加的指定背景图片
|
|
100
|
+
* @param uri
|
|
101
|
+
*/
|
|
102
|
+
removeOutputBackgroundPicture(uri: string): RCMCUConfigBuilder;
|
|
103
|
+
/**
|
|
104
|
+
* 清理对合流后的视频流中添加的所有背景图片
|
|
105
|
+
*/
|
|
106
|
+
clearOutputBackgroundPicture(): RCMCUConfigBuilder;
|
|
107
|
+
/**
|
|
108
|
+
* 设置合流后的视频流中添加的背景图片的填充方式:
|
|
109
|
+
* 1. 按比例裁剪
|
|
110
|
+
* 2. 不裁剪,按比例压缩
|
|
111
|
+
* @param fillMode
|
|
112
|
+
*/
|
|
113
|
+
setOutputBackgroundPictureFillMode(fillMode: BackgroundPictureFillMode): RCMCUConfigBuilder;
|
|
114
|
+
/**
|
|
115
|
+
* 设置直播 CDN 旁路推流地址,最多支持 5 个推流地址
|
|
116
|
+
* @param urls 地址列表
|
|
117
|
+
*/
|
|
118
|
+
addPublishStreamUrls(urls: string[]): RCMCUConfigBuilder;
|
|
119
|
+
/**
|
|
120
|
+
* 移除直播 CDN 旁路推流地址
|
|
121
|
+
* @param urls
|
|
122
|
+
*/
|
|
123
|
+
removePublishStreamUrls(urls: string[]): RCMCUConfigBuilder;
|
|
124
|
+
/**
|
|
125
|
+
* 清理已添加的 CDN 旁路推流地址
|
|
126
|
+
*/
|
|
127
|
+
clearPublishStreamUrls(): RCMCUConfigBuilder;
|
|
128
|
+
/**
|
|
129
|
+
* 在自定义布局中增加视频流配置
|
|
130
|
+
* @param trackId 资源 Id
|
|
131
|
+
* @param x 在画布中的坐标 x
|
|
132
|
+
* @param y 在画布中的坐标 y
|
|
133
|
+
* @param width 分辨率宽度
|
|
134
|
+
* @param height 分辨率高度
|
|
135
|
+
*/
|
|
136
|
+
addCustomizeLayoutVideo(trackId: string, x: number, y: number, width: number, height: number): RCMCUConfigBuilder;
|
|
137
|
+
/**
|
|
138
|
+
* 移除自定义布局中的视频流配置
|
|
139
|
+
* @param trackId
|
|
140
|
+
*/
|
|
141
|
+
removeCustomizeLayoutVideo(trackId: string): RCMCUConfigBuilder;
|
|
142
|
+
/**
|
|
143
|
+
* 清除已添加的自定义布局中的视频流配置
|
|
144
|
+
*/
|
|
145
|
+
clearCustomizeLayoutVideo(): RCMCUConfigBuilder;
|
|
146
|
+
/**
|
|
147
|
+
* 覆盖设置合流媒体中的音频流
|
|
148
|
+
* @param trackIds 音频流 trackId 数组,当数组长度为 0 时,则合流媒体中将无音频输出
|
|
149
|
+
* @returns
|
|
150
|
+
*/
|
|
151
|
+
setCustomizeInputAudio(trackIds: string[]): RCMCUConfigBuilder;
|
|
152
|
+
/**
|
|
153
|
+
* 向既有的音频流合流配置中增加一道音频流
|
|
154
|
+
* @param trackId 音频 trackId
|
|
155
|
+
* @since v5.3.7
|
|
156
|
+
*/
|
|
157
|
+
addCustomizeInputAudio(trackId: string): RCMCUConfigBuilder;
|
|
158
|
+
/**
|
|
159
|
+
* 从既有的音频流合流配置中删除一道音频流
|
|
160
|
+
* @param trackId 音频对应的 trackId
|
|
161
|
+
* @since v5.3.7
|
|
162
|
+
*/
|
|
163
|
+
removeCustomizeInputAudio(trackId: string): RCMCUConfigBuilder;
|
|
164
|
+
/**
|
|
165
|
+
* 清除音频流合流配置,恢复房间内的全音频流合流输出
|
|
166
|
+
* @since v5.3.7
|
|
167
|
+
*/
|
|
168
|
+
clearCustomizeInputAudio(): RCMCUConfigBuilder;
|
|
169
|
+
/**
|
|
170
|
+
* 给单道流添加水印
|
|
171
|
+
*/
|
|
172
|
+
addPictureWaterMark(trackId: string, uri: string, x: number, y: number, w: number, h: number): RCMCUConfigBuilder;
|
|
173
|
+
/**
|
|
174
|
+
* 删除所有水印
|
|
175
|
+
*/
|
|
176
|
+
clearPictureWaterMark(): RCMCUConfigBuilder;
|
|
177
|
+
/**
|
|
178
|
+
* 移除对合流后的某个视频流中添加的指定水印图片
|
|
179
|
+
* @param uri
|
|
180
|
+
*/
|
|
181
|
+
removePictureWaterMark(trackId: string, uri: string): RCMCUConfigBuilder;
|
|
182
|
+
/**
|
|
183
|
+
* 设置 MCU 混流配置
|
|
184
|
+
* @param videoList 视频输入混流列表,为 null 代表视频全混流,为空集合代表视频全不混流,否则按照输入列表进行混流
|
|
185
|
+
* @param audioList 音频输入混流列表,为 null 代表音频全混流,为空集合代表音频全不混流,否则按照输入列表进行混流
|
|
186
|
+
*/
|
|
187
|
+
/**
|
|
188
|
+
* 设置 MCU 混流配置
|
|
189
|
+
* @param roomIds 混流房间列表
|
|
190
|
+
* @param mediaType 混流媒体类型
|
|
191
|
+
* @param isAppend 是否为增量混流
|
|
192
|
+
* * true 为增量混流
|
|
193
|
+
* * false 为全量覆盖混流
|
|
194
|
+
*/
|
|
195
|
+
/**
|
|
196
|
+
* 重置所有合流配置
|
|
197
|
+
* @since v5.3.7
|
|
198
|
+
* @returns
|
|
199
|
+
*/
|
|
200
|
+
reset(): RCMCUConfigBuilder;
|
|
201
|
+
/**
|
|
202
|
+
* 使已修改的配置生效,在调用该方法前,所有数据只会对本地配置进行修改,不会产生实际效果
|
|
203
|
+
* @param reset 调用完成后清空当前配置记录,默认为 `true`(v5.3.7 版本开始启用)
|
|
204
|
+
* @returns
|
|
205
|
+
*/
|
|
206
|
+
flush(reset?: boolean): Promise<{
|
|
207
|
+
code: RCRTCCode;
|
|
208
|
+
}>;
|
|
209
|
+
__innerGetValues(): IMCUConfig;
|
|
210
|
+
}
|
|
211
|
+
//# sourceMappingURL=RCMCUConfigBuilder.d.ts.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { RTCPluginContext, IRuntime } from '@rongcloud/engine';
|
|
2
|
+
import { IRCRTCInitOptions } from '../interfaces';
|
|
3
|
+
import RCMediaService from '../service/RCMediaService';
|
|
4
|
+
import RCAbstractRoom from './RCAbstractRoom';
|
|
5
|
+
/**
|
|
6
|
+
* 普通音视频房间
|
|
7
|
+
*/
|
|
8
|
+
export default class RCRTCRoom extends RCAbstractRoom {
|
|
9
|
+
constructor(context: RTCPluginContext, runtime: IRuntime, roomId: string, service: RCMediaService, initOptions: IRCRTCInitOptions, isUpgrade?: boolean, isMainRoom?: boolean,
|
|
10
|
+
/**
|
|
11
|
+
* 是否使用多 peerConnection
|
|
12
|
+
*/
|
|
13
|
+
useMutilPeerC?: boolean, _clientSessionId?: string);
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=RCRTCRoom.d.ts.map
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { IRuntime, RTCPluginContext } from '@rongcloud/engine';
|
|
2
|
+
import { RCRTCCode } from '../enums/RCRTCCode';
|
|
3
|
+
import { IRTCReqHeader, IExchangeReqBody, IExchangeResponse, IMCUReqHeaders, IBroadcastSubReqBody, IBroadcastSubRespBody, ICDNPlayUrlReqHeaders, ICDNPlayUrlResponse } from './interface';
|
|
4
|
+
import { IMCUConfig, ISetEnableCDN } from './mcu-interface';
|
|
5
|
+
export default class RCMediaService {
|
|
6
|
+
private readonly _runtime;
|
|
7
|
+
private readonly _context;
|
|
8
|
+
/**
|
|
9
|
+
* 自定义 MediaServer 地址,当有值时,不再使用导航内的地址
|
|
10
|
+
*/
|
|
11
|
+
private readonly _msUrl?;
|
|
12
|
+
/**
|
|
13
|
+
* 请求超时时长
|
|
14
|
+
*/
|
|
15
|
+
private readonly _timeout;
|
|
16
|
+
/**
|
|
17
|
+
* navi 中获取的媒体服务地址
|
|
18
|
+
*/
|
|
19
|
+
private readonly _msInNavi;
|
|
20
|
+
/**
|
|
21
|
+
* 已失败的请求地址
|
|
22
|
+
*/
|
|
23
|
+
private readonly _failedMs;
|
|
24
|
+
/**
|
|
25
|
+
* 服务器指纹数据,客户端不得修改,直接透传
|
|
26
|
+
*/
|
|
27
|
+
private _rtcFinger;
|
|
28
|
+
/**
|
|
29
|
+
* 服务器接口返回的 clusterId 数据,当此数据有值时,后续所有请求向此服务发送
|
|
30
|
+
*/
|
|
31
|
+
private _clusterId;
|
|
32
|
+
/**
|
|
33
|
+
* MCU 服务地址
|
|
34
|
+
*/
|
|
35
|
+
private _configUrl;
|
|
36
|
+
constructor(_runtime: IRuntime, _context: RTCPluginContext,
|
|
37
|
+
/**
|
|
38
|
+
* 自定义 MediaServer 地址,当有值时,不再使用导航内的地址
|
|
39
|
+
*/
|
|
40
|
+
_msUrl?: string | undefined,
|
|
41
|
+
/**
|
|
42
|
+
* 请求超时时长
|
|
43
|
+
*/
|
|
44
|
+
_timeout?: number);
|
|
45
|
+
getNaviMS(): string[];
|
|
46
|
+
/**
|
|
47
|
+
* 发送请求,请求发送若失败,会继续尝试使用后续可用地址直到无地址可用,此时认为请求失败
|
|
48
|
+
* @param path
|
|
49
|
+
* @param header
|
|
50
|
+
* @param body
|
|
51
|
+
*/
|
|
52
|
+
private _request;
|
|
53
|
+
/**
|
|
54
|
+
* 资源协商接口,订阅、发布、变更资源均可以使用此接口。该接口通过 sdp 字段交换 SDP 信息,
|
|
55
|
+
* 并通过 subscribeList 和 publishList 表明最终发布和订阅的资源。本端产出 offer,服务器产出 answer
|
|
56
|
+
* 每次接口调用,都会全量覆盖发布和订阅的资源。
|
|
57
|
+
* @param header
|
|
58
|
+
* @param body
|
|
59
|
+
*/
|
|
60
|
+
exchange(headers: IRTCReqHeader, body: IExchangeReqBody): Promise<{
|
|
61
|
+
code: RCRTCCode;
|
|
62
|
+
data?: IExchangeResponse | undefined;
|
|
63
|
+
}>;
|
|
64
|
+
/**
|
|
65
|
+
* 退出房间
|
|
66
|
+
*/
|
|
67
|
+
exit(headers: IRTCReqHeader): Promise<RCRTCCode>;
|
|
68
|
+
/**
|
|
69
|
+
* 观众端订阅主播资源
|
|
70
|
+
*/
|
|
71
|
+
broadcastSubscribe(headers: IRTCReqHeader, body: IBroadcastSubReqBody): Promise<{
|
|
72
|
+
code: RCRTCCode;
|
|
73
|
+
data?: IBroadcastSubRespBody | undefined;
|
|
74
|
+
}>;
|
|
75
|
+
/**
|
|
76
|
+
* 观众端退出订阅
|
|
77
|
+
*/
|
|
78
|
+
broadcastExit(headers: IRTCReqHeader): Promise<{
|
|
79
|
+
code: RCRTCCode;
|
|
80
|
+
}>;
|
|
81
|
+
/**
|
|
82
|
+
* 直播推流、自定义布局配置
|
|
83
|
+
*/
|
|
84
|
+
setMcuConfig(headers: IMCUReqHeaders, body: IMCUConfig | ISetEnableCDN): Promise<{
|
|
85
|
+
code: RCRTCCode;
|
|
86
|
+
res?: any;
|
|
87
|
+
}>;
|
|
88
|
+
/**
|
|
89
|
+
* 房间内观众获取 CDN 资源信息、拉流地址
|
|
90
|
+
*/
|
|
91
|
+
getCDNResourceInfo(headers: ICDNPlayUrlReqHeaders, url: string): Promise<{
|
|
92
|
+
code: RCRTCCode;
|
|
93
|
+
res?: ICDNPlayUrlResponse;
|
|
94
|
+
}>;
|
|
95
|
+
}
|
|
96
|
+
//# sourceMappingURL=RCMediaService.d.ts.map
|