@rongcloud/plugin-rtc 5.3.12 → 5.3.13

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.
Files changed (66) hide show
  1. package/dist/async-task-queue.d.ts +15 -0
  2. package/dist/core/PolarisReporter.d.ts +35 -0
  3. package/dist/core/RCAudienceClient.d.ts +72 -0
  4. package/dist/core/RCRTCClient.d.ts +220 -0
  5. package/dist/core/constants.d.ts +2 -0
  6. package/dist/core/enums/BackgroundPictureFillMode.d.ts +14 -0
  7. package/dist/core/enums/MixLayoutMode.d.ts +18 -0
  8. package/dist/core/enums/MixVideoRenderMode.d.ts +14 -0
  9. package/dist/core/enums/RCFrameRate.d.ts +7 -0
  10. package/dist/core/enums/RCInnerCDNBroadcast.d.ts +5 -0
  11. package/dist/core/enums/RCInnerCDNModel.d.ts +5 -0
  12. package/dist/core/enums/RCInnerCDNPullIsHttps.d.ts +5 -0
  13. package/dist/core/enums/RCInnerCDNPullKind.d.ts +6 -0
  14. package/dist/core/enums/RCInnerCDNPushMode.d.ts +5 -0
  15. package/dist/core/enums/RCKickType.d.ts +11 -0
  16. package/dist/core/enums/RCLivingRoomType.d.ts +11 -0
  17. package/dist/core/enums/RCLivingType.d.ts +14 -0
  18. package/dist/core/enums/RCMediaType.d.ts +18 -0
  19. package/dist/core/enums/RCMixInputFilterMode.d.ts +35 -0
  20. package/dist/core/enums/RCRTCCode.d.ts +91 -0
  21. package/dist/core/enums/RCRTCLiveRole.d.ts +14 -0
  22. package/dist/core/enums/RCRTCPingResult.d.ts +5 -0
  23. package/dist/core/enums/RCRTCResolution.d.ts +102 -0
  24. package/dist/core/enums/RCResolution.d.ts +16 -0
  25. package/dist/core/enums/inner/PolarisRole.d.ts +14 -0
  26. package/dist/core/enums/inner/R2Action.d.ts +14 -0
  27. package/dist/core/enums/inner/R2Status.d.ts +11 -0
  28. package/dist/core/enums/inner/RCRTCMessageType.d.ts +66 -0
  29. package/dist/core/enums/inner/RCStreamType.d.ts +14 -0
  30. package/dist/core/enums/inner/TrackState.d.ts +14 -0
  31. package/dist/core/interfaces.d.ts +893 -0
  32. package/dist/core/room/Pinger.d.ts +34 -0
  33. package/dist/core/room/RCAbstractRoom.d.ts +379 -0
  34. package/dist/core/room/RCAudienceLivingRoom.d.ts +305 -0
  35. package/dist/core/room/RCAudioLevelReport.d.ts +17 -0
  36. package/dist/core/room/RCLivingPKHandler.d.ts +176 -0
  37. package/dist/core/room/RCLivingRoom.d.ts +145 -0
  38. package/dist/core/room/RCLocalMediaStream.d.ts +8 -0
  39. package/dist/core/room/RCMCUConfigBuilder.d.ts +207 -0
  40. package/dist/core/room/RCRTCRoom.d.ts +11 -0
  41. package/dist/core/service/RCMediaService.d.ts +96 -0
  42. package/dist/core/service/helper.d.ts +8 -0
  43. package/dist/core/service/index.d.ts +6 -0
  44. package/dist/core/service/interface.d.ts +311 -0
  45. package/dist/core/service/mcu-interface.d.ts +290 -0
  46. package/dist/core/tracks/RCLocalTrack.d.ts +108 -0
  47. package/dist/core/tracks/RCRemoteTrack.d.ts +23 -0
  48. package/dist/core/tracks/RCTrack.d.ts +80 -0
  49. package/dist/core/webrtc/ASdpStrategy.d.ts +43 -0
  50. package/dist/core/webrtc/PlanBStrategy.d.ts +25 -0
  51. package/dist/core/webrtc/RCRTCPeerConnection.d.ts +80 -0
  52. package/dist/core/webrtc/UnifiedPlanStrategy.d.ts +20 -0
  53. package/dist/core/webrtc/helper.d.ts +26 -0
  54. package/dist/core/webrtc/stat-parser/AbstractStatParser.d.ts +116 -0
  55. package/dist/core/webrtc/stat-parser/ChromeStatParser.d.ts +14 -0
  56. package/dist/core/webrtc/stat-parser/FirefoxStatParser.d.ts +14 -0
  57. package/dist/core/webrtc/stat-parser/IStatParser.d.ts +24 -0
  58. package/dist/core/webrtc/stat-parser/SafariStatParser.d.ts +14 -0
  59. package/dist/device.d.ts +6 -0
  60. package/dist/helper.d.ts +176 -0
  61. package/dist/index.d.ts +26 -7
  62. package/dist/index.esm.js +1 -1
  63. package/dist/index.js +1 -1
  64. package/dist/index.umd.js +1 -1
  65. package/dist/logger.d.ts +4 -0
  66. package/package.json +2 -2
@@ -0,0 +1,116 @@
1
+ import IStatParser from './IStatParser';
2
+ import { IInnerRCRTCStateReport } from '../../interfaces';
3
+ export default abstract class AbstractStatParser implements IStatParser {
4
+ protected readonly _rtcPeerConn: RTCPeerConnection;
5
+ protected readonly _sdpSemantics: string;
6
+ constructor(_rtcPeerConn: RTCPeerConnection, _sdpSemantics: string);
7
+ /**
8
+ * 最近的上行发送包数据统计
9
+ */
10
+ protected _latestPacketsSent: {
11
+ [resourceId: string]: {
12
+ packetsLost?: number;
13
+ packetsSent?: number;
14
+ crtPacketsSent?: number;
15
+ };
16
+ };
17
+ /**
18
+ * 最近的上行发送字节数统计
19
+ */
20
+ protected _latestBytesSent: {
21
+ [resourceId: string]: {
22
+ bytesSent: number;
23
+ timestamp: number;
24
+ };
25
+ };
26
+ /**
27
+ * 最近的下行接收字节数统计
28
+ */
29
+ protected _latestBytesRecv: {
30
+ [resourceId: string]: {
31
+ bytesRecv: number;
32
+ timestamp: number;
33
+ };
34
+ };
35
+ /**
36
+ * 最近的下行接收包数据统计
37
+ */
38
+ protected _latestPacketsRecv: {
39
+ [resourceId: string]: {
40
+ packetsLost: number;
41
+ packetsRecv: number;
42
+ };
43
+ };
44
+ /**
45
+ * 更新上行码率存储,返回计算出的码率
46
+ * @param resourceId
47
+ * @param bytesSent 本次发送的字节数
48
+ * @param timestamp
49
+ * @returns bitrate
50
+ */
51
+ protected updateBytesSent(resourceId: string, bytesSent: number, timestamp: number): number;
52
+ /**
53
+ * 更新下行码率存储,返回计算出的码率
54
+ * @param resourceId
55
+ * @param bytesRecv
56
+ * @param timestamp
57
+ * @returns bitrate
58
+ */
59
+ protected updateBytesRecv(resourceId: string, bytesRecv: number, timestamp: number): number;
60
+ /**
61
+ * 更新上行丢包总数,返回计算出的丢包率
62
+ * 计算丢包率
63
+ * 上行数据统计中,packageLost 的统计具有延时性
64
+ * 会导致瞬时的 packetsLost - prePacketsLost 值大于 packetsSent - prePacketsSent,从而丢包率可能大于 1
65
+ * 因此此处计算只在 packetsLost - prePacketsLost !== 0 时计算丢包率,其他时间丢包为 0
66
+ * packetsSent 只在 packetsLost 有变化时更新
67
+ */
68
+ protected updateSenderPacketsLost(resourceId: string, packetsLost: number, packetsSent: number): number;
69
+ /**
70
+ * 更新下行丢包总数,返回计算出的丢包率
71
+ */
72
+ protected updateReceiverPacketsLost(resourceId: string, packetsLost: number, packetsReceived: number): number;
73
+ /**
74
+ * 取消发布后,需把 _latestPacketsSent 中 key 为 resourceId 存储的数据清除掉
75
+ */
76
+ clearLatestpacketsSent(resourceIds: string[]): void;
77
+ /**
78
+ * 取消订阅后,需把 _latestPacketsRecv 中 key 为 resourceId 存储的数据清除掉
79
+ */
80
+ clearLatestPacketsRecv(resourceIds: string[]): void;
81
+ parseRTCStatsReport(reports: RTCStatsReport): {
82
+ [key: string]: any;
83
+ };
84
+ formatRCRTCStateReport(stats: {
85
+ [key: string]: any;
86
+ }): IInnerRCRTCStateReport;
87
+ getAudioLevelList(stats: {
88
+ [key: string]: any;
89
+ }): {
90
+ trackId: string;
91
+ audioLevel: number | null;
92
+ }[];
93
+ /**
94
+ * 从 offer 和 answer 的 sdp 中获取 ssrc 对应的 msid
95
+ * @param statInfo outbound 和 inbound 对应值
96
+ * @returns resourceId
97
+ */
98
+ protected getResourceIdByParseSdp(statInfo: {
99
+ [key: string]: any;
100
+ }): string;
101
+ /**
102
+ * 从 offer sdp 中查找 ssrc 对应的通道是否可用
103
+ * @param outboundInfo
104
+ */
105
+ protected isValidSender(outboundInfo: {
106
+ [key: string]: any;
107
+ }): boolean;
108
+ /**
109
+ * 从 answer sdp 中查找 ssrc 对应的通道是否可用
110
+ * @param inboundInfo
111
+ */
112
+ protected isValidReceiver(inboundInfo: {
113
+ [key: string]: any;
114
+ }): boolean;
115
+ }
116
+ //# sourceMappingURL=AbstractStatParser.d.ts.map
@@ -0,0 +1,14 @@
1
+ import { IInnerRCRTCStateReport } from '../../interfaces';
2
+ import AbstractStatParser from './AbstractStatParser';
3
+ export default class RTCReportParser extends AbstractStatParser {
4
+ formatRCRTCStateReport(stats: {
5
+ [key: string]: any;
6
+ }): IInnerRCRTCStateReport;
7
+ getAudioLevelList(stats: {
8
+ [key: string]: any;
9
+ }): {
10
+ trackId: string;
11
+ audioLevel: number | null;
12
+ }[];
13
+ }
14
+ //# sourceMappingURL=ChromeStatParser.d.ts.map
@@ -0,0 +1,14 @@
1
+ import { IInnerRCRTCStateReport } from '../../interfaces';
2
+ import AbstractStatParser from './AbstractStatParser';
3
+ export default class RTCReportParser extends AbstractStatParser {
4
+ formatRCRTCStateReport(stats: {
5
+ [key: string]: any;
6
+ }): IInnerRCRTCStateReport;
7
+ getAudioLevelList(stats: {
8
+ [key: string]: any;
9
+ }): {
10
+ trackId: string;
11
+ audioLevel: number | null;
12
+ }[];
13
+ }
14
+ //# sourceMappingURL=FirefoxStatParser.d.ts.map
@@ -0,0 +1,24 @@
1
+ import { IInnerRCRTCStateReport } from '../../interfaces';
2
+ export default interface IStatParser {
3
+ /**
4
+ * 取消发布后,需把 _latestPacketsSent 中 key 为 resourceId 存储的数据清除掉
5
+ */
6
+ clearLatestpacketsSent(resourceIds: string[]): void;
7
+ /**
8
+ * 取消订阅后,需把 _latestPacketsRecv 中 key 为 resourceId 存储的数据清除掉
9
+ */
10
+ clearLatestPacketsRecv(resourceIds: string[]): void;
11
+ parseRTCStatsReport(reports: RTCStatsReport): {
12
+ [key: string]: any;
13
+ };
14
+ formatRCRTCStateReport(stats: {
15
+ [key: string]: any;
16
+ }): IInnerRCRTCStateReport;
17
+ getAudioLevelList(stats: {
18
+ [key: string]: any;
19
+ }): {
20
+ trackId: string;
21
+ audioLevel: number | null;
22
+ }[];
23
+ }
24
+ //# sourceMappingURL=IStatParser.d.ts.map
@@ -0,0 +1,14 @@
1
+ import { IInnerRCRTCStateReport } from '../../interfaces';
2
+ import AbstractStatParser from './AbstractStatParser';
3
+ export default class RTCReportParser extends AbstractStatParser {
4
+ formatRCRTCStateReport(stats: {
5
+ [key: string]: any;
6
+ }): IInnerRCRTCStateReport;
7
+ getAudioLevelList(stats: {
8
+ [key: string]: any;
9
+ }): {
10
+ trackId: string;
11
+ audioLevel: number | null;
12
+ }[];
13
+ }
14
+ //# sourceMappingURL=SafariStatParser.d.ts.map
@@ -0,0 +1,6 @@
1
+ export declare const device: {
2
+ getCameras: () => Promise<MediaDeviceInfo[]>;
3
+ getMicrophones: () => Promise<MediaDeviceInfo[]>;
4
+ getSpeakers: () => Promise<MediaDeviceInfo[]>;
5
+ };
6
+ //# sourceMappingURL=device.d.ts.map
@@ -0,0 +1,176 @@
1
+ import { INaviInfo, IRTCUsers, IServerRTCRoomEntry } from '@rongcloud/engine';
2
+ import { RCFrameRate } from './core/enums/RCFrameRate';
3
+ import { RCResolution } from './core/enums/RCResolution';
4
+ import { RCRTCMessageType } from './core/enums/inner/RCRTCMessageType';
5
+ import { IPKInfo, IPublishAttrs, IPublishedResource, IResource, RoomData } from './core/interfaces';
6
+ import { RCMediaType } from './core/enums/RCMediaType';
7
+ import { RCLocalTrack } from './core/tracks/RCLocalTrack';
8
+ import { RCRemoteTrack } from './core/tracks/RCRemoteTrack';
9
+ /**
10
+ * 构建增量消息内容
11
+ * @param objectname 消息名
12
+ * @param uris 增量变更资源
13
+ */
14
+ export declare const buildPlusMessage: (messageName: RCRTCMessageType, uris: IPublishedResource[]) => {
15
+ name: RCRTCMessageType;
16
+ content: string;
17
+ };
18
+ /**
19
+ * 构建预发布的全量资源变更消息
20
+ * @param uris 全量资源数据
21
+ */
22
+ export declare const buildTotalURIMessageContent: (uris: IPublishedResource[]) => string;
23
+ /**
24
+ * roomId 有效性验证
25
+ * @param roomId
26
+ */
27
+ export declare const isValidRoomId: (roomId: string) => boolean;
28
+ /**
29
+ * 验证 tag 是否有效
30
+ * @param tag
31
+ * @returns
32
+ */
33
+ export declare const isValidTag: (tag: string) => boolean;
34
+ /**
35
+ * 页面地址有效性检测
36
+ */
37
+ export declare const isValidLocation: boolean;
38
+ /**
39
+ * 获取视频流的分辨率及帧率数据,若无法获取真实值,则返回 0
40
+ * @param track
41
+ */
42
+ export declare const getVideoTrackInfo: (track: MediaStreamTrack) => {
43
+ width: number;
44
+ height: number;
45
+ frameRate: number;
46
+ };
47
+ /**
48
+ * 取视频流动态码率
49
+ * @param track
50
+ * @returns
51
+ */
52
+ export declare const getDynamicBitrate: (track: MediaStreamTrack) => {
53
+ min: number;
54
+ max: number;
55
+ };
56
+ /**
57
+ * 获取资源唯一性标识
58
+ * @param item
59
+ */
60
+ export declare const getTrackId: (item: IResource) => string;
61
+ /**
62
+ * 解析 trackId 以获取资源信息
63
+ * @param trackId
64
+ */
65
+ export declare const parseTrackId: (trackId: string) => {
66
+ mediaType: RCMediaType;
67
+ tag: string;
68
+ userId: string;
69
+ };
70
+ export declare const parseStreamId: (streamId: string) => {
71
+ tag: string;
72
+ userId: string;
73
+ };
74
+ export declare const formatStreamId: (userId: string, tag: string) => string;
75
+ export declare const deepCopyResources: <T>(resources: T[]) => T[];
76
+ /**
77
+ * 比对资源找出新增、状态变更及取消发布的资源
78
+ * @param prevResources 原资源数据
79
+ * @param resources 变更的全量资源
80
+ */
81
+ export declare const diffPublishResources: (prevResources: IPublishedResource[], resources: IPublishedResource[], isReconnect?: boolean) => {
82
+ publishedList: IPublishedResource[];
83
+ unpublishedList: IPublishedResource[];
84
+ modifiedList: IPublishedResource[];
85
+ };
86
+ export declare const diffPubResOnReconnect: (prevResources: IPublishedResource[], resources: IPublishedResource[]) => {
87
+ publishedList: IPublishedResource[];
88
+ unpublishedList: IPublishedResource[];
89
+ modifiedList: IPublishedResource[];
90
+ };
91
+ export declare const getUUID22: () => string;
92
+ /**
93
+ * 转化 RCResolution 枚举值为分辨率宽高
94
+ * @param resolution
95
+ * @returns
96
+ */
97
+ export declare const transResolution: (resolution: RCResolution) => {
98
+ width: number;
99
+ height: number;
100
+ };
101
+ /**
102
+ * 判断枚举值有效性
103
+ * @param resolution
104
+ * @returns
105
+ */
106
+ export declare const isValidResolution: (resolution?: RCResolution) => boolean;
107
+ /**
108
+ * 判断帧率枚举值有效性
109
+ * @param fps
110
+ * @returns
111
+ */
112
+ export declare const isValidFPS: (fps?: RCFrameRate) => boolean;
113
+ /**
114
+ * 获取枚举值对应的帧率
115
+ * @param fps
116
+ * @returns
117
+ */
118
+ export declare const transFrameRate: (fps: RCFrameRate) => number;
119
+ export type IBrowserDetails = {
120
+ browser: string;
121
+ version?: number;
122
+ supportsUnifiedPlan: boolean;
123
+ };
124
+ export declare const browserInfo: IBrowserDetails;
125
+ /**
126
+ * 验证浏览器是否支持创建自定义文件流
127
+ * @returns
128
+ */
129
+ export declare function ifSupportLocalFileTrack(): boolean;
130
+ /**
131
+ * 验证浏览器是否支持屏幕共享
132
+ * @returns
133
+ */
134
+ export declare function ifSupportScreenShare(): boolean;
135
+ /**
136
+ * 检查参数是否为 null
137
+ */
138
+ export declare const isNull: (val: any) => boolean;
139
+ /**
140
+ * 公有云连接私有云 SDK 为非法连接
141
+ */
142
+ export declare const isIllegalConnection: (navi: INaviInfo) => boolean;
143
+ /**
144
+ * 获取将要发布的 track 数量
145
+ * 需要发布小流的算两个 track
146
+ */
147
+ export declare const calcTracksNum: (tracks: (RCLocalTrack | IPublishAttrs)[]) => number;
148
+ /**
149
+ * 解析房间数据
150
+ */
151
+ export declare const parseRoomData: (data: IRTCUsers, mainRoomId: string) => RoomData;
152
+ /**
153
+ * 从加房间返回的数据中获取加入的副房间
154
+ */
155
+ export declare const getPKInfoByRoomData: (mainRoomId: string, roomInfo: {
156
+ key: string;
157
+ value: string;
158
+ }[]) => IPKInfo;
159
+ /**
160
+ * 解析观众加房间 kv 数据
161
+ * 远端无人员时,kvEntries 的 key 不包含 RC_ANCHOR_LIST
162
+ * 远端无资源时,key 不包含 RC_RES_、RC_CDN
163
+ * 远端有资源、无 CDN 资源时,key 不包含 RC_CDN
164
+ * 服务端 bug,偶现无 RC_RTC_SESSIONID
165
+ */
166
+ export declare const parseAudienceRoomData: (roomId: string, kvEntries: IServerRTCRoomEntry[]) => {
167
+ sessionId: string;
168
+ remoteUserIds: string[];
169
+ remoteRTCUris: IPublishedResource[];
170
+ remoteMUCUris: IPublishedResource[];
171
+ remoteRTCTracks: RCRemoteTrack[];
172
+ remoteMCUTracks: RCRemoteTrack[];
173
+ remoteTracks: RCRemoteTrack[];
174
+ CDNUris: any;
175
+ };
176
+ //# sourceMappingURL=helper.d.ts.map
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  /*
2
- * RCRTC - v5.3.12
3
- * CommitId - 567f104279e4a211af4cf0145b67f50faf481848
4
- * Mon May 30 2022 14:26:02 GMT+0800 (China Standard Time)
2
+ * RCRTC - v5.3.13
3
+ * CommitId - 367040ff8de440fde7e136452ae17b1eeea24c97
4
+ * Mon Nov 28 2022 15:48:19 GMT+0800 (China Standard Time)
5
5
  * ©2020 RongCloud, Inc. All rights reserved.
6
6
  */
7
7
  import { EventEmitter, LogLevel, RTCMode, IRuntime, RTCPluginContext, IServerRTCRoomEntry, IReceivedMessage, ErrorCode, IJoinRTCRoomData, KVString, RTCJoinType, IRTCUserData, IRTCJoinedInfo, IPluginGenerator } from '@rongcloud/engine';
@@ -386,13 +386,13 @@ interface IStatParser {
386
386
  }[];
387
387
  }
388
388
 
389
- declare type ISdpSemantics = 'plan-b' | 'unified-plan';
389
+ type ISdpSemantics = 'plan-b' | 'unified-plan';
390
390
  interface IOfferInfo {
391
391
  type: 'offer';
392
392
  sdp: string;
393
393
  semantics: ISdpSemantics;
394
394
  }
395
- declare type OutboundVideoInfo = {
395
+ type OutboundVideoInfo = {
396
396
  trackId: string;
397
397
  simulcast: RCStreamType;
398
398
  resolution: string;
@@ -884,8 +884,26 @@ interface ICameraVideoProfile extends IVideoProfile {
884
884
  faceMode?: 'user' | 'environment';
885
885
  }
886
886
  interface IMicphoneAudioProfile {
887
+ /**
888
+ * 指定采录的 AudioInputDevice
889
+ */
887
890
  micphoneId?: string;
891
+ /**
892
+ * 音频采样率
893
+ */
888
894
  sampleRate?: number;
895
+ /**
896
+ * 噪声抑制开关,未配置时以浏览器默认行为为准
897
+ */
898
+ noiseSuppression?: boolean;
899
+ /**
900
+ * 回声消除开关,未配置时以浏览器默认行为为准
901
+ */
902
+ echoCancellation?: boolean;
903
+ /**
904
+ * 自动增益开关,未配置时以浏览器默认行为为准
905
+ */
906
+ autoGainControl?: boolean;
889
907
  }
890
908
  interface ICreateLocalTrackOptions {
891
909
  /**
@@ -909,7 +927,7 @@ interface IAudioLevelChangeHandler {
909
927
  /**
910
928
  * 房间资源数据
911
929
  */
912
- declare type RoomData = {
930
+ type RoomData = {
913
931
  [userId: string]: IPublishedResource[];
914
932
  };
915
933
  /**
@@ -2155,7 +2173,7 @@ declare class RCRTCPeerConnection extends EventEmitter {
2155
2173
  clearReTryExchangeTimer(): void;
2156
2174
  }
2157
2175
 
2158
- declare type IOnRecvPKMsg = (msg: IReceivedMessage) => void;
2176
+ type IOnRecvPKMsg = (msg: IReceivedMessage) => void;
2159
2177
  interface IRoomPKEventListener {
2160
2178
  /**
2161
2179
  * 收到连麦邀请
@@ -3207,6 +3225,7 @@ declare class RCRTCClient {
3207
3225
  code: RCRTCCode;
3208
3226
  track?: RCCameraVideoTrack;
3209
3227
  }>;
3228
+ private _formatAudioProfile;
3210
3229
  /**
3211
3230
  * 通过摄像头与麦克风采集音视频轨道数据
3212
3231
  * @param tag