@kaltura-sdk/rtc-core 1.25.0
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/README.md +237 -0
- package/index.d.ts +1 -0
- package/index.esm.js +15293 -0
- package/package.json +22 -0
- package/src/index.d.ts +6 -0
- package/src/lib/core-utils/BrowserDetector.d.ts +101 -0
- package/src/lib/core-utils/DevicesUtils.d.ts +1 -0
- package/src/lib/core-utils/GlobalEventEmitter.d.ts +1 -0
- package/src/lib/core-utils/MediaUtils.d.ts +45 -0
- package/src/lib/core-utils/Mutex.d.ts +8 -0
- package/src/lib/core-utils/SdpUtils.d.ts +25 -0
- package/src/lib/core-utils/UserBrowserUtils.d.ts +37 -0
- package/src/lib/core-utils/UtilityFunctions.d.ts +21 -0
- package/src/lib/core-utils/index.d.ts +4 -0
- package/src/lib/core-utils/webrtcAudioStats.d.ts +56 -0
- package/src/lib/core-utils/webrtcStatsTypes.d.ts +76 -0
- package/src/lib/core-utils/webrtcVideoStats.d.ts +6 -0
- package/src/lib/devices/DevicesManager.d.ts +137 -0
- package/src/lib/devices/UserMediaManager.d.ts +52 -0
- package/src/lib/devices/index.d.ts +2 -0
- package/src/lib/media/AudioAnalyzer.d.ts +60 -0
- package/src/lib/media/GetUserMediaManager.d.ts +178 -0
- package/src/lib/media/MediaSources.d.ts +105 -0
- package/src/lib/media/index.d.ts +4 -0
- package/src/lib/media/media-processing/AudioProcessing.d.ts +42 -0
- package/src/lib/media/media-processing/AudioProcessingModes.d.ts +76 -0
- package/src/lib/media/media-processing/index.d.ts +4 -0
- package/src/lib/media/media-processing/types.d.ts +83 -0
- package/src/lib/media/types.d.ts +73 -0
- package/src/lib/peer-connection/IceHandler.d.ts +60 -0
- package/src/lib/peer-connection/PeerConnection.d.ts +153 -0
- package/src/lib/peer-connection/PeerConnectionBeacon.d.ts +208 -0
- package/src/lib/peer-connection/PeerConnectionManager.d.ts +57 -0
- package/src/lib/peer-connection/PeerConnectionWebrtcStats.d.ts +32 -0
- package/src/lib/peer-connection/constants.d.ts +89 -0
- package/src/lib/peer-connection/index.d.ts +10 -0
- package/src/lib/peer-connection/types.d.ts +167 -0
- package/src/lib/session/CoreRTCSession.d.ts +215 -0
- package/src/lib/session/index.d.ts +2 -0
- package/src/lib/simulcast/simulcastCommonPublisher.d.ts +4 -0
- package/src/lib/unisphere-sample.d.ts +50 -0
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import PeerConnectionBeacon from './PeerConnectionBeacon';
|
|
2
|
+
import IceHandler from './IceHandler';
|
|
3
|
+
import PeerConnectionWebrtcStats, { PcStatsObj } from './PeerConnectionWebrtcStats';
|
|
4
|
+
import { StreamStatus, PeerConnectionConfig, ConnectionFailureInfo, IceConfiguration, IceCandidateDataObj, VideoSenderConfig } from './types';
|
|
5
|
+
export interface webrtcStreamStatsObj {
|
|
6
|
+
videoBytes: number;
|
|
7
|
+
audioInBytes: number;
|
|
8
|
+
audioOutBytes: number;
|
|
9
|
+
}
|
|
10
|
+
type OnPcConnectionFail = (failureInfo: ConnectionFailureInfo) => void;
|
|
11
|
+
type OnPcCreated = () => void;
|
|
12
|
+
type OnPcConnected = () => void;
|
|
13
|
+
type OnPcConnectedFinal = () => void;
|
|
14
|
+
type OnHandlePcTrackEvent = (streams: ReadonlyArray<MediaStream>) => void;
|
|
15
|
+
type OnStartPublishing = (localDescription: RTCSessionDescription | null) => void;
|
|
16
|
+
type OnIceCandidate = (candidate: IceCandidateDataObj | null) => void;
|
|
17
|
+
declare class PeerConnection {
|
|
18
|
+
peerConnection: RTCPeerConnection | null;
|
|
19
|
+
pcWebrtcStats: PeerConnectionWebrtcStats;
|
|
20
|
+
prevStatsInfo: webrtcStreamStatsObj | null;
|
|
21
|
+
pcBeacon: PeerConnectionBeacon;
|
|
22
|
+
iceHandler: IceHandler;
|
|
23
|
+
private logger;
|
|
24
|
+
private streamerId;
|
|
25
|
+
isPublisher: boolean;
|
|
26
|
+
isDesktop: boolean;
|
|
27
|
+
private isAudioMix;
|
|
28
|
+
private connectionStartTimer;
|
|
29
|
+
private connectDisconnectTimer;
|
|
30
|
+
SdpAnswerTimer: number | ReturnType<typeof setTimeout> | null;
|
|
31
|
+
private lastConnFailureTime;
|
|
32
|
+
private lastDisconnectionTime;
|
|
33
|
+
streamStatus: StreamStatus | undefined;
|
|
34
|
+
turnAddress: string;
|
|
35
|
+
private pcJanusPrivateIp;
|
|
36
|
+
private startedNegotiation;
|
|
37
|
+
pcCreationTime: number;
|
|
38
|
+
private onPcConnectionFail;
|
|
39
|
+
private onPcConnected;
|
|
40
|
+
private onPcConnectedFinal;
|
|
41
|
+
private onHandlePcTrackEvent;
|
|
42
|
+
private onPcCreated;
|
|
43
|
+
/**
|
|
44
|
+
* Primary callback - fires when local description (offer OR answer) is ready to send via signaling
|
|
45
|
+
*/
|
|
46
|
+
private onLocalDescriptionReady?;
|
|
47
|
+
/**
|
|
48
|
+
* @deprecated Use onLocalDescriptionReady instead. Kept for backward compatibility.
|
|
49
|
+
*/
|
|
50
|
+
private onStartPublishing;
|
|
51
|
+
/**
|
|
52
|
+
* Trickle ICE callback - fires when ICE candidate is discovered (if trickle ICE enabled)
|
|
53
|
+
*/
|
|
54
|
+
private onIceCandidate?;
|
|
55
|
+
private config;
|
|
56
|
+
private pendingIceCandidates;
|
|
57
|
+
private OnIceConnectionFail;
|
|
58
|
+
constructor(streamerId: string, config: PeerConnectionConfig, isPublisher: boolean, isDesktop: boolean, isAudioMix: boolean, onPcCreated: OnPcCreated, onPcConnected: OnPcConnected, onPcConnectedFinal: OnPcConnectedFinal, onPcConnectionFail: OnPcConnectionFail, onHandlePcTrackEvent: OnHandlePcTrackEvent, onStartPublishing: OnStartPublishing, onLocalDescriptionReady?: OnStartPublishing, onIceCandidate?: OnIceCandidate);
|
|
59
|
+
updateWebrtcStreamInfo(streamStats: webrtcStreamStatsObj): void;
|
|
60
|
+
getPeerConnectionsStatus(connectionType?: string): number;
|
|
61
|
+
isPeerConnected(): boolean;
|
|
62
|
+
private updateDisconnectsList;
|
|
63
|
+
private clearConnectionStartTimer;
|
|
64
|
+
private clearConnectDisconnectTimer;
|
|
65
|
+
private clearConnectionStreamTimers;
|
|
66
|
+
clearSdpAnswerTimer(): void;
|
|
67
|
+
clearPcStreamTimers(): void;
|
|
68
|
+
handleConnectionFail(iceFailure: boolean, reason: number, subReason: number, reasonStr: string): void;
|
|
69
|
+
connectDisconnectTimeout(reason: number, subReason: number): Promise<void>;
|
|
70
|
+
setStreamStatus(newStatus?: StreamStatus): StreamStatus;
|
|
71
|
+
collectStreamStatsAfterInit(): void;
|
|
72
|
+
getPeerConnection(): RTCPeerConnection;
|
|
73
|
+
getPeerConnectionStats(forceGet: boolean): Promise<PcStatsObj>;
|
|
74
|
+
private getLocalCandidateNetworkStats;
|
|
75
|
+
private updateLocalCandidateNetStats;
|
|
76
|
+
handleConnectionStateChangeEvent(e: any): void;
|
|
77
|
+
handleICEConnectionStateChangeEvent(e: any, nextState: RTCIceConnectionState): void;
|
|
78
|
+
private handleICEGatheringStateChangeEvent;
|
|
79
|
+
private handleTrackEvent;
|
|
80
|
+
private handleSignalingstatechange;
|
|
81
|
+
connectionStartTimeout(): Promise<void>;
|
|
82
|
+
pcCollectBeaconIceInfo(callOnReset: boolean, resetReasonStr: string): void;
|
|
83
|
+
resetPC(updateDisconnectsList: boolean, resetReasonStr: string, calcStats: boolean): void;
|
|
84
|
+
updateJanusPrivateIp(privateIp: string): void;
|
|
85
|
+
createPC(isPublisher: boolean, streamerId: string, iceConfiguration: IceConfiguration): void;
|
|
86
|
+
private handlePCNegotiationNeededEvent;
|
|
87
|
+
sdpAnswerTimeout(): Promise<void>;
|
|
88
|
+
/**
|
|
89
|
+
* Create an offer for a viewer connection (recvonly)
|
|
90
|
+
* This is called when viewer wants to receive streams
|
|
91
|
+
*/
|
|
92
|
+
/**
|
|
93
|
+
* Helper: Start negotiation timers (connection start and SDP answer)
|
|
94
|
+
*/
|
|
95
|
+
private startNegotiationTimers;
|
|
96
|
+
/**
|
|
97
|
+
* Helper: Apply SDP manipulations (codec forcing, DTX)
|
|
98
|
+
* @param sdp - The SDP string to manipulate
|
|
99
|
+
* @returns Manipulated SDP string
|
|
100
|
+
*/
|
|
101
|
+
private applySdpManipulations;
|
|
102
|
+
/**
|
|
103
|
+
* Helper: Notify callbacks when local description is ready
|
|
104
|
+
* Calls both onLocalDescriptionReady and onStartPublishing (deprecated)
|
|
105
|
+
* @param description - The local description to send
|
|
106
|
+
*/
|
|
107
|
+
private notifyLocalDescriptionReady;
|
|
108
|
+
/**
|
|
109
|
+
* Generic method to create an offer
|
|
110
|
+
* Works for both publishers and viewers - does NOT depend on isPublisher flag
|
|
111
|
+
* @param options - Optional RTCOfferOptions
|
|
112
|
+
*/
|
|
113
|
+
createOffer(options?: RTCOfferOptions): Promise<void>;
|
|
114
|
+
/**
|
|
115
|
+
* Generic method to create an answer to a remote offer
|
|
116
|
+
* Used for viewers who receive offers from the backend (KME pattern)
|
|
117
|
+
* Expects setRemoteDescription() to be called first with the offer
|
|
118
|
+
* @param options - Optional RTCAnswerOptions
|
|
119
|
+
*/
|
|
120
|
+
createAnswer(options?: RTCAnswerOptions): Promise<void>;
|
|
121
|
+
/**
|
|
122
|
+
* Set remote description (offer or answer from signaling backend)
|
|
123
|
+
* @param description - The remote session description
|
|
124
|
+
*/
|
|
125
|
+
setRemoteDescription(description: RTCSessionDescriptionInit, videoSenderConfig?: VideoSenderConfig | null): Promise<void>;
|
|
126
|
+
/**
|
|
127
|
+
* Add a remote ICE candidate to the peer connection
|
|
128
|
+
* Handles ICE candidate from remote peer received via signaling
|
|
129
|
+
* @param iceCandidate - The remote ICE candidate to add, or null to signal end of candidates
|
|
130
|
+
*/
|
|
131
|
+
addRemoteIceCandidate(iceCandidate: IceCandidateDataObj | null): Promise<void>;
|
|
132
|
+
private flushPendingIceCandidates;
|
|
133
|
+
/**
|
|
134
|
+
* Applies video sender configuration to the peer connection.
|
|
135
|
+
*
|
|
136
|
+
* Step 1: calls setParameters() with all params except bitrate
|
|
137
|
+
* (degradationPreference, maxFramerate, scaleResolutionDownBy, contentHint).
|
|
138
|
+
* Step 2: calls setParameters() with bitrate only. If that fails and offerSdp is
|
|
139
|
+
* provided, falls back to SDP bandwidth munge via sdpLimitBw.
|
|
140
|
+
*
|
|
141
|
+
* @param config - Video sender parameters to apply
|
|
142
|
+
* @param offerSdp - Optional SDP string; bandwidth will be injected on bitrate setParameters failure
|
|
143
|
+
* @returns Modified SDP if bandwidth munge was applied, original offerSdp otherwise, undefined if no SDP passed
|
|
144
|
+
*/
|
|
145
|
+
applyVideoSenderConfig(config: VideoSenderConfig, offerSdp?: string): Promise<string | undefined>;
|
|
146
|
+
/**
|
|
147
|
+
* Handle negotiation needed event
|
|
148
|
+
* Simplified to delegate to generic createOffer() method
|
|
149
|
+
* No longer checks isPublisher - applicative SDKs control the flow
|
|
150
|
+
*/
|
|
151
|
+
handleNegotiationNeededEvent(_e: any): Promise<void>;
|
|
152
|
+
}
|
|
153
|
+
export default PeerConnection;
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
type ConnectionGroupType = number | string;
|
|
2
|
+
export type ConnectionInfoObj = {
|
|
3
|
+
connId: string;
|
|
4
|
+
updateTime: number;
|
|
5
|
+
connectionGroup: ConnectionGroupType;
|
|
6
|
+
};
|
|
7
|
+
export type BeaconObj = {
|
|
8
|
+
userId: number;
|
|
9
|
+
roomId: number;
|
|
10
|
+
companyId: number;
|
|
11
|
+
msid: number;
|
|
12
|
+
mediaServerPublicIP: string;
|
|
13
|
+
mediaServerRegion: number;
|
|
14
|
+
msSessionId: number;
|
|
15
|
+
msHandleId: number;
|
|
16
|
+
streamId: string;
|
|
17
|
+
startTime: number;
|
|
18
|
+
mediaPlayTime: number;
|
|
19
|
+
duration: number;
|
|
20
|
+
direction: number;
|
|
21
|
+
isAudioMix: number;
|
|
22
|
+
setupTime: number;
|
|
23
|
+
totalVideoMuteTime: number;
|
|
24
|
+
totalAudioMuteTime: number;
|
|
25
|
+
reason: number;
|
|
26
|
+
prevReason: number;
|
|
27
|
+
subReason: number;
|
|
28
|
+
prevSubReason: number;
|
|
29
|
+
sessionId: number;
|
|
30
|
+
avgRTT: string;
|
|
31
|
+
env: string;
|
|
32
|
+
disconnections: number;
|
|
33
|
+
initSuccessful: number;
|
|
34
|
+
attempt: number;
|
|
35
|
+
isLastAttempt: number;
|
|
36
|
+
totalSetupTime: number;
|
|
37
|
+
connectionState: number;
|
|
38
|
+
iceConnectionState: number;
|
|
39
|
+
videoQuality: number;
|
|
40
|
+
framesReceived: number;
|
|
41
|
+
totalSamplesReceived: number;
|
|
42
|
+
trayMode: number;
|
|
43
|
+
turnServer: string;
|
|
44
|
+
availableBitrate: number;
|
|
45
|
+
room_session_id: string;
|
|
46
|
+
user_session_id: string;
|
|
47
|
+
region: number;
|
|
48
|
+
device_type: string;
|
|
49
|
+
logical_cores: number;
|
|
50
|
+
memory: number;
|
|
51
|
+
network_type: string;
|
|
52
|
+
isRec: number;
|
|
53
|
+
appVersion: string;
|
|
54
|
+
reconnectionsCount: number;
|
|
55
|
+
longestReconnection: number;
|
|
56
|
+
cgrp: number;
|
|
57
|
+
cgrHistory: string;
|
|
58
|
+
cgrpPrev: number;
|
|
59
|
+
cgrInitial: number;
|
|
60
|
+
thp: string;
|
|
61
|
+
cgr0Cnt: number;
|
|
62
|
+
cgr1Cnt: number;
|
|
63
|
+
cgr2Cnt: number;
|
|
64
|
+
cgr3Cnt: number;
|
|
65
|
+
cgr4Cnt: number;
|
|
66
|
+
cgr5Cnt: number;
|
|
67
|
+
cgr6Cnt: number;
|
|
68
|
+
cgr7Cnt: number;
|
|
69
|
+
localCandidateType: string;
|
|
70
|
+
localRelayProtocol: string;
|
|
71
|
+
localProtocol: string;
|
|
72
|
+
remoteNetworkPort: string;
|
|
73
|
+
iceStats: string;
|
|
74
|
+
iceNumCandidates: number;
|
|
75
|
+
iceGatherTime: number;
|
|
76
|
+
iceFirstCandTime: number;
|
|
77
|
+
iceTestDisconnectTime: number;
|
|
78
|
+
audioPlay: number;
|
|
79
|
+
videoPlay: number;
|
|
80
|
+
incomingBandwidthKB: number;
|
|
81
|
+
outgoingBandwidthKB: number;
|
|
82
|
+
smoothnessScore: number;
|
|
83
|
+
qfps: number;
|
|
84
|
+
resW: number;
|
|
85
|
+
resH: number;
|
|
86
|
+
videoQScore: number;
|
|
87
|
+
rtc_v: string;
|
|
88
|
+
rsConType: number;
|
|
89
|
+
scGQlReason?: string;
|
|
90
|
+
scGQldNone?: number;
|
|
91
|
+
scGQldBw?: number;
|
|
92
|
+
scGQldCpu?: number;
|
|
93
|
+
scGQldOther?: number;
|
|
94
|
+
scGLayersDisable?: number;
|
|
95
|
+
scGLayersEnable?: number;
|
|
96
|
+
scGTrackW?: number;
|
|
97
|
+
scGTrackH?: number;
|
|
98
|
+
scHresW?: number;
|
|
99
|
+
scHresH?: number;
|
|
100
|
+
scHbw?: number;
|
|
101
|
+
scHpli?: number;
|
|
102
|
+
scHfps?: number;
|
|
103
|
+
scMresW?: number;
|
|
104
|
+
scMresH?: number;
|
|
105
|
+
scMbw?: number;
|
|
106
|
+
scMpli?: number;
|
|
107
|
+
scMfps?: number;
|
|
108
|
+
scLresW?: number;
|
|
109
|
+
scLresH?: number;
|
|
110
|
+
scLbw?: number;
|
|
111
|
+
scLpli?: number;
|
|
112
|
+
scLfps?: number;
|
|
113
|
+
scSubstream?: number;
|
|
114
|
+
scTemporal?: number;
|
|
115
|
+
scResW?: number;
|
|
116
|
+
scResH?: number;
|
|
117
|
+
scAvalBw?: number;
|
|
118
|
+
scPli?: number;
|
|
119
|
+
scUpscales?: number;
|
|
120
|
+
scDownscales?: number;
|
|
121
|
+
audioInQuality?: number;
|
|
122
|
+
audioInPackets?: number;
|
|
123
|
+
audioInBytes?: number;
|
|
124
|
+
audioInPacketsLost?: number;
|
|
125
|
+
audioInPercentPacketsLost?: number;
|
|
126
|
+
audioInJitter?: number;
|
|
127
|
+
audioInEnergy?: number;
|
|
128
|
+
audioOutQuality?: number;
|
|
129
|
+
audioOutPackets?: number;
|
|
130
|
+
audioOutBytes?: number;
|
|
131
|
+
audioOutPacketsLost?: number;
|
|
132
|
+
audioOutPercentPacketsLost?: number;
|
|
133
|
+
audioOutJitter?: number;
|
|
134
|
+
audioOutRemoteJitter?: number;
|
|
135
|
+
audioOutEnergy?: number;
|
|
136
|
+
totalVideoPackets?: number;
|
|
137
|
+
totalVideoPacketsDropped?: number;
|
|
138
|
+
totalVideoBytes?: number;
|
|
139
|
+
percentTotalVideoPacketsDropped?: string;
|
|
140
|
+
nacks?: number;
|
|
141
|
+
videoJitter?: number;
|
|
142
|
+
concealedSamples?: number;
|
|
143
|
+
silentConcealedSamples?: number;
|
|
144
|
+
framesDropped?: number;
|
|
145
|
+
sdpTime: number;
|
|
146
|
+
remoteVideoPlay: number;
|
|
147
|
+
remoteAudioPlay: number;
|
|
148
|
+
};
|
|
149
|
+
declare class PeerConnectionBeacon {
|
|
150
|
+
startTime: number;
|
|
151
|
+
reason: number;
|
|
152
|
+
prevReason: number;
|
|
153
|
+
subReason: number;
|
|
154
|
+
prevSubReason: number;
|
|
155
|
+
publisherSDPStartTime: number;
|
|
156
|
+
publisherSDPAcceptTime: number;
|
|
157
|
+
viewerSDPStartTime: number;
|
|
158
|
+
viewerSDPAcceptTime: number;
|
|
159
|
+
mediaPlayTime: number;
|
|
160
|
+
lastVideoMuteTime: number;
|
|
161
|
+
lastAudioMuteTime: number;
|
|
162
|
+
totalVideoMuteTime: number;
|
|
163
|
+
totalAudioMuteTime: number;
|
|
164
|
+
samplesCount: number;
|
|
165
|
+
rttSum: number;
|
|
166
|
+
totalRTT: number;
|
|
167
|
+
responsesReceived: number;
|
|
168
|
+
successful: number;
|
|
169
|
+
attempt: number;
|
|
170
|
+
isLastAttempt: number;
|
|
171
|
+
totalSetupTime: number;
|
|
172
|
+
videoQuality: number;
|
|
173
|
+
audioInQuality: number;
|
|
174
|
+
audioOutQuality: number;
|
|
175
|
+
totalSamplesReceived: number;
|
|
176
|
+
framesReceived: number;
|
|
177
|
+
videoJitterPrevTransit: number;
|
|
178
|
+
videoJitterSum: number;
|
|
179
|
+
firstReportTime: number;
|
|
180
|
+
lastReportTime: number;
|
|
181
|
+
availableBitrate: number;
|
|
182
|
+
localNetworkType: string;
|
|
183
|
+
setupTime: number;
|
|
184
|
+
firstTrackEventTime: number;
|
|
185
|
+
disconnectionsCount: number;
|
|
186
|
+
longestReconnection: number;
|
|
187
|
+
cgr: number;
|
|
188
|
+
cgrHistory: string;
|
|
189
|
+
cgrPrev: number;
|
|
190
|
+
cgrInitial: number;
|
|
191
|
+
cgr0Cnt: number;
|
|
192
|
+
cgr1Cnt: number;
|
|
193
|
+
cgr2Cnt: number;
|
|
194
|
+
cgr3Cnt: number;
|
|
195
|
+
cgr4Cnt: number;
|
|
196
|
+
cgr5Cnt: number;
|
|
197
|
+
cgr6Cnt: number;
|
|
198
|
+
cgr7Cnt: number;
|
|
199
|
+
localCandidateType: string;
|
|
200
|
+
localRelayProtocol: string;
|
|
201
|
+
localProtocol: string;
|
|
202
|
+
remoteNetworkPort: string;
|
|
203
|
+
resetAll(): void;
|
|
204
|
+
restart(): void;
|
|
205
|
+
constructor();
|
|
206
|
+
updatecgHistoryStr(): void;
|
|
207
|
+
}
|
|
208
|
+
export default PeerConnectionBeacon;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import PeerConnection from './PeerConnection';
|
|
2
|
+
import { UnisphereLoggerType } from '@unisphere/core';
|
|
3
|
+
export declare class PeerConnectionManager {
|
|
4
|
+
private connections;
|
|
5
|
+
private logger;
|
|
6
|
+
constructor(logger: UnisphereLoggerType);
|
|
7
|
+
/**
|
|
8
|
+
* Add a peer connection to the registry
|
|
9
|
+
* @param connectionId - Unique identifier for this connection
|
|
10
|
+
* @param connection - PeerConnection instance
|
|
11
|
+
*/
|
|
12
|
+
addConnection(connectionId: string, connection: PeerConnection): void;
|
|
13
|
+
/**
|
|
14
|
+
* Remove a peer connection from the registry
|
|
15
|
+
* @param connectionId - Unique identifier for the connection to remove
|
|
16
|
+
* @returns true if connection was removed, false if not found
|
|
17
|
+
*/
|
|
18
|
+
removeConnection(connectionId: string): boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Get a peer connection by ID
|
|
21
|
+
* @param connectionId - Unique identifier for the connection
|
|
22
|
+
* @returns PeerConnection instance or undefined if not found
|
|
23
|
+
*/
|
|
24
|
+
getConnection(connectionId: string): PeerConnection | undefined;
|
|
25
|
+
/**
|
|
26
|
+
* Check if a connection exists
|
|
27
|
+
* @param connectionId - Unique identifier for the connection
|
|
28
|
+
* @returns true if connection exists
|
|
29
|
+
*/
|
|
30
|
+
hasConnection(connectionId: string): boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Get all connection IDs
|
|
33
|
+
* @returns Array of connection IDs
|
|
34
|
+
*/
|
|
35
|
+
getConnectionIds(): string[];
|
|
36
|
+
/**
|
|
37
|
+
* Get all peer connections
|
|
38
|
+
* @returns Array of PeerConnection instances
|
|
39
|
+
*/
|
|
40
|
+
getAllConnections(): PeerConnection[];
|
|
41
|
+
/**
|
|
42
|
+
* Get the number of active connections
|
|
43
|
+
* @returns Number of connections in the registry
|
|
44
|
+
*/
|
|
45
|
+
getConnectionCount(): number;
|
|
46
|
+
/**
|
|
47
|
+
* Clear all connections from the registry
|
|
48
|
+
* Note: Does NOT close the connections - caller must handle cleanup
|
|
49
|
+
*/
|
|
50
|
+
clear(): void;
|
|
51
|
+
/**
|
|
52
|
+
* Execute a callback for each connection
|
|
53
|
+
* @param callback - Function to execute for each connection
|
|
54
|
+
*/
|
|
55
|
+
forEach(callback: (connection: PeerConnection, connectionId: string) => void): void;
|
|
56
|
+
}
|
|
57
|
+
export default PeerConnectionManager;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export type PcStatsObj = {
|
|
2
|
+
id: string;
|
|
3
|
+
stats?: RTCStatsReport | null;
|
|
4
|
+
reason?: string;
|
|
5
|
+
err?: any;
|
|
6
|
+
};
|
|
7
|
+
declare class PeerConnectionWebrtcStats {
|
|
8
|
+
private logger;
|
|
9
|
+
private streamerId;
|
|
10
|
+
private peerConnection;
|
|
11
|
+
private lastCaptureTime;
|
|
12
|
+
private statsReport;
|
|
13
|
+
private viewerQualityTimer;
|
|
14
|
+
private publisherQualityTimer;
|
|
15
|
+
private isPublisher;
|
|
16
|
+
private hasVideo;
|
|
17
|
+
private prevViewerStats;
|
|
18
|
+
private prevPublisherStats;
|
|
19
|
+
constructor(streamerId: string);
|
|
20
|
+
updatePeerConnection(peerConnection: RTCPeerConnection | null): void;
|
|
21
|
+
private getPcStats;
|
|
22
|
+
getPeerConnectionStats(forceGet: boolean): Promise<PcStatsObj>;
|
|
23
|
+
startStatsTimer(isPublisher: boolean): void;
|
|
24
|
+
stopStatsTimer(): void;
|
|
25
|
+
private viewerCheckQuality;
|
|
26
|
+
private publisherCheckQuality;
|
|
27
|
+
private prepareViewerSimulcastStats;
|
|
28
|
+
private logViewerSimStats;
|
|
29
|
+
private preparePublisherStreamSimulcastStats;
|
|
30
|
+
private logPublisherSimStats;
|
|
31
|
+
}
|
|
32
|
+
export default PeerConnectionWebrtcStats;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
export declare enum IceCandidateType {
|
|
2
|
+
NA = "na",
|
|
3
|
+
RELAY = "relay",
|
|
4
|
+
SRFLX = "srflx",
|
|
5
|
+
PRFLX = "prflx",
|
|
6
|
+
HOST = "host"
|
|
7
|
+
}
|
|
8
|
+
export declare enum IceRelayType {
|
|
9
|
+
NA = "na",
|
|
10
|
+
UDP = "udp",
|
|
11
|
+
TCP = "tcp",
|
|
12
|
+
TLS = "tls",
|
|
13
|
+
DTLS = "dtls"
|
|
14
|
+
}
|
|
15
|
+
export declare enum PcCloseReason {
|
|
16
|
+
CONNECTION_DISCONNECTED = 101,
|
|
17
|
+
CONNECTION_FAILED = 102,
|
|
18
|
+
CONNECTION_START_TIMEOUT = 103,
|
|
19
|
+
NEGOTIATION_FAILED = 104,
|
|
20
|
+
NO_PEER_CONNECTION = 105,
|
|
21
|
+
NO_SDP_ANSWER_TIMEOUT = 106
|
|
22
|
+
}
|
|
23
|
+
export declare enum DisconnectSubReason {
|
|
24
|
+
NONE = 0
|
|
25
|
+
}
|
|
26
|
+
export declare enum PeerConnectionState {
|
|
27
|
+
NEW = "new",
|
|
28
|
+
CONNECTING = "connecting",
|
|
29
|
+
CONNECTED = "connected",
|
|
30
|
+
DISCONNECTED = "disconnected",
|
|
31
|
+
FAILED = "failed",
|
|
32
|
+
CLOSED = "closed"
|
|
33
|
+
}
|
|
34
|
+
export declare enum SettingValue {
|
|
35
|
+
ON = "on",
|
|
36
|
+
OFF = "off"
|
|
37
|
+
}
|
|
38
|
+
export declare const IceTimerConfig: {
|
|
39
|
+
readonly IceStatsTimerMsec: 1000;
|
|
40
|
+
readonly iceStatsDurationMsec: 30000;
|
|
41
|
+
readonly durationForNoCandsCheckMsec: 3000;
|
|
42
|
+
readonly DisconnectsSecDuration: 60;
|
|
43
|
+
readonly connectionStartTimerMsec: 20000;
|
|
44
|
+
readonly disconnectCheckTimerMsec: 10000;
|
|
45
|
+
readonly sdpAnswerTimerMsec: 30000;
|
|
46
|
+
readonly connectCheckTimerMsec: 5000;
|
|
47
|
+
};
|
|
48
|
+
export declare const Constants: {
|
|
49
|
+
iceCandidateType: {
|
|
50
|
+
na: IceCandidateType;
|
|
51
|
+
relay: IceCandidateType;
|
|
52
|
+
srflx: IceCandidateType;
|
|
53
|
+
host: IceCandidateType;
|
|
54
|
+
};
|
|
55
|
+
pcCloseReason: {
|
|
56
|
+
CONNECTION_DISCONNECTED: PcCloseReason;
|
|
57
|
+
CONNECTION_FAILED: PcCloseReason;
|
|
58
|
+
CONNECTION_START_TIMEOUT: PcCloseReason;
|
|
59
|
+
NEGOTIATION_FAILED: PcCloseReason;
|
|
60
|
+
NO_PEER_CONNECTION: PcCloseReason;
|
|
61
|
+
NO_SDP_ANSWER_TIMEOUT: PcCloseReason;
|
|
62
|
+
};
|
|
63
|
+
disconnectSubReasons: {
|
|
64
|
+
none: DisconnectSubReason;
|
|
65
|
+
};
|
|
66
|
+
iceConf: {
|
|
67
|
+
readonly IceStatsTimerMsec: 1000;
|
|
68
|
+
readonly iceStatsDurationMsec: 30000;
|
|
69
|
+
readonly durationForNoCandsCheckMsec: 3000;
|
|
70
|
+
readonly DisconnectsSecDuration: 60;
|
|
71
|
+
readonly connectionStartTimerMsec: 20000;
|
|
72
|
+
readonly disconnectCheckTimerMsec: 10000;
|
|
73
|
+
readonly sdpAnswerTimerMsec: 30000;
|
|
74
|
+
readonly connectCheckTimerMsec: 5000;
|
|
75
|
+
};
|
|
76
|
+
peerConnectionConnectionStates: {
|
|
77
|
+
new: PeerConnectionState;
|
|
78
|
+
connecting: PeerConnectionState;
|
|
79
|
+
connected: PeerConnectionState;
|
|
80
|
+
disconnected: PeerConnectionState;
|
|
81
|
+
failed: PeerConnectionState;
|
|
82
|
+
closed: PeerConnectionState;
|
|
83
|
+
};
|
|
84
|
+
settingValues: {
|
|
85
|
+
ON: SettingValue;
|
|
86
|
+
OFF: SettingValue;
|
|
87
|
+
};
|
|
88
|
+
};
|
|
89
|
+
export default Constants;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { default as PeerConnection } from './PeerConnection';
|
|
2
|
+
export { default as PeerConnectionBeacon } from './PeerConnectionBeacon';
|
|
3
|
+
export { default as PeerConnectionWebrtcStats } from './PeerConnectionWebrtcStats';
|
|
4
|
+
export { default as PeerConnectionManager } from './PeerConnectionManager';
|
|
5
|
+
export { default as IceHandler } from './IceHandler';
|
|
6
|
+
export * from './types';
|
|
7
|
+
export * from './constants';
|
|
8
|
+
export type { PcStatsObj } from './PeerConnectionWebrtcStats';
|
|
9
|
+
export type { BeaconObj, ConnectionInfoObj } from './PeerConnectionBeacon';
|
|
10
|
+
export type { IceDisconnectionObj } from './IceHandler';
|