@rongcloud/plugin-rtc 5.2.4 → 5.2.5

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 (63) 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 +208 -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/RCLivingType.d.ts +14 -0
  17. package/dist/core/enums/RCMediaType.d.ts +18 -0
  18. package/dist/core/enums/RCRTCCode.d.ts +89 -0
  19. package/dist/core/enums/RCRTCLiveRole.d.ts +14 -0
  20. package/dist/core/enums/RCRTCPingResult.d.ts +5 -0
  21. package/dist/core/enums/RCRTCResolution.d.ts +100 -0
  22. package/dist/core/enums/RCResolution.d.ts +16 -0
  23. package/dist/core/enums/inner/PolarisRole.d.ts +14 -0
  24. package/dist/core/enums/inner/R2Action.d.ts +14 -0
  25. package/dist/core/enums/inner/R2Status.d.ts +11 -0
  26. package/dist/core/enums/inner/RCRTCMessageType.d.ts +42 -0
  27. package/dist/core/enums/inner/RCStreamType.d.ts +14 -0
  28. package/dist/core/enums/inner/TrackState.d.ts +14 -0
  29. package/dist/core/interfaces.d.ts +673 -0
  30. package/dist/core/room/Pinger.d.ts +32 -0
  31. package/dist/core/room/RCAbstractRoom.d.ts +351 -0
  32. package/dist/core/room/RCAudienceLivingRoom.d.ts +305 -0
  33. package/dist/core/room/RCAudioLevelReport.d.ts +17 -0
  34. package/dist/core/room/RCLivingRoom.d.ts +93 -0
  35. package/dist/core/room/RCLocalMediaStream.d.ts +8 -0
  36. package/dist/core/room/RCMCUConfigBuilder.d.ts +163 -0
  37. package/dist/core/room/RCRTCRoom.d.ts +11 -0
  38. package/dist/core/service/RCMediaService.d.ts +96 -0
  39. package/dist/core/service/helper.d.ts +8 -0
  40. package/dist/core/service/index.d.ts +6 -0
  41. package/dist/core/service/interface.d.ts +311 -0
  42. package/dist/core/service/mcu-interface.d.ts +263 -0
  43. package/dist/core/tracks/RCLocalTrack.d.ts +108 -0
  44. package/dist/core/tracks/RCRemoteTrack.d.ts +23 -0
  45. package/dist/core/tracks/RCTrack.d.ts +80 -0
  46. package/dist/core/webrtc/ASdpStrategy.d.ts +43 -0
  47. package/dist/core/webrtc/PlanBStrategy.d.ts +25 -0
  48. package/dist/core/webrtc/RCRTCPeerConnection.d.ts +80 -0
  49. package/dist/core/webrtc/UnifiedPlanStrategy.d.ts +20 -0
  50. package/dist/core/webrtc/helper.d.ts +26 -0
  51. package/dist/core/webrtc/stat-parser/AbstractStatParser.d.ts +116 -0
  52. package/dist/core/webrtc/stat-parser/ChromeStatParser.d.ts +14 -0
  53. package/dist/core/webrtc/stat-parser/FirefoxStatParser.d.ts +14 -0
  54. package/dist/core/webrtc/stat-parser/IStatParser.d.ts +24 -0
  55. package/dist/core/webrtc/stat-parser/SafariStatParser.d.ts +14 -0
  56. package/dist/device.d.ts +6 -0
  57. package/dist/helper.d.ts +168 -0
  58. package/dist/index.d.ts +3 -3
  59. package/dist/index.esm.js +1 -1
  60. package/dist/index.js +1 -1
  61. package/dist/index.umd.js +1 -1
  62. package/dist/logger.d.ts +4 -0
  63. 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,168 @@
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 { 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 declare 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) => RoomData;
152
+ /**
153
+ * 解析观众加房间 kv 数据
154
+ * 远端无人员时,kvEntries 的 key 不包含 RC_ANCHOR_LIST
155
+ * 远端无资源时,key 不包含 RC_RES_、RC_CDN
156
+ * 远端有资源、无 CDN 资源时,key 不包含 RC_CDN
157
+ */
158
+ export declare const parseAudienceRoomData: (roomId: string, kvEntries: IServerRTCRoomEntry[]) => {
159
+ sessionId: string;
160
+ remoteUserIds: string[];
161
+ remoteRTCUris: IPublishedResource[];
162
+ remoteMUCUris: IPublishedResource[];
163
+ remoteRTCTracks: RCRemoteTrack[];
164
+ remoteMCUTracks: RCRemoteTrack[];
165
+ remoteTracks: RCRemoteTrack[];
166
+ CDNUris: any;
167
+ };
168
+ //# sourceMappingURL=helper.d.ts.map
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  /*
2
- * RCRTC - v5.2.4
3
- * CommitId - d2c309074e678b96ebd403c0967994360e8b389c
4
- * Fri Jan 28 2022 10:39:56 GMT+0800 (China Standard Time)
2
+ * RCRTC - v5.2.5
3
+ * CommitId - f6dea75bffc2ab49636bb0d23f94878d22a3a450
4
+ * Tue Sep 27 2022 18:16:18 GMT+0800 (China Standard Time)
5
5
  * ©2020 RongCloud, Inc. All rights reserved.
6
6
  */
7
7
  import { EventEmitter, LogLevel, RTCMode, IRuntime, RTCPluginContext, IServerRTCRoomEntry, IJoinRTCRoomData, IReceivedMessage, KVString, RTCJoinType, IRTCJoinedInfo, IPluginGenerator } from '@rongcloud/engine';