node-rtc-connection 1.0.3 → 1.0.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.
- package/dist/index.cjs +3978 -50
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +3978 -50
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -1
- package/src/RTCPeerConnection.js +12 -1
- package/src/index.d.ts +229 -0
- package/src/index.js +1 -0
package/src/index.d.ts
ADDED
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
// Type definitions for node-rtc-connection
|
|
2
|
+
// Project: https://github.com/nmhung1210/nodertc
|
|
3
|
+
// Definitions by: nmhung1210
|
|
4
|
+
|
|
5
|
+
/// <reference types="node" />
|
|
6
|
+
|
|
7
|
+
import { EventEmitter } from 'events';
|
|
8
|
+
|
|
9
|
+
// RTCConfiguration
|
|
10
|
+
export interface RTCIceServer {
|
|
11
|
+
urls: string | string[];
|
|
12
|
+
username?: string;
|
|
13
|
+
credential?: string;
|
|
14
|
+
credentialType?: 'password' | 'oauth';
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface RTCConfiguration {
|
|
18
|
+
iceServers?: RTCIceServer[];
|
|
19
|
+
iceTransportPolicy?: 'all' | 'relay';
|
|
20
|
+
bundlePolicy?: 'balanced' | 'max-compat' | 'max-bundle';
|
|
21
|
+
rtcpMuxPolicy?: 'negotiate' | 'require';
|
|
22
|
+
iceCandidatePoolSize?: number;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// RTCSessionDescription
|
|
26
|
+
export type RTCSdpType = 'offer' | 'answer' | 'pranswer' | 'rollback';
|
|
27
|
+
|
|
28
|
+
export interface RTCSessionDescriptionInit {
|
|
29
|
+
type: RTCSdpType;
|
|
30
|
+
sdp?: string;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export class RTCSessionDescription {
|
|
34
|
+
constructor(descriptionInitDict?: RTCSessionDescriptionInit);
|
|
35
|
+
readonly type: RTCSdpType;
|
|
36
|
+
readonly sdp: string;
|
|
37
|
+
toJSON(): RTCSessionDescriptionInit;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// RTCIceCandidate
|
|
41
|
+
export type RTCIceCandidateType = 'host' | 'srflx' | 'prflx' | 'relay';
|
|
42
|
+
export type RTCIceProtocol = 'udp' | 'tcp';
|
|
43
|
+
export type RTCIceTcpCandidateType = 'active' | 'passive' | 'so';
|
|
44
|
+
|
|
45
|
+
export interface RTCIceCandidateInit {
|
|
46
|
+
candidate?: string;
|
|
47
|
+
sdpMid?: string | null;
|
|
48
|
+
sdpMLineIndex?: number | null;
|
|
49
|
+
usernameFragment?: string | null;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export class RTCIceCandidate {
|
|
53
|
+
constructor(candidateInitDict?: RTCIceCandidateInit);
|
|
54
|
+
readonly candidate: string;
|
|
55
|
+
readonly sdpMid: string | null;
|
|
56
|
+
readonly sdpMLineIndex: number | null;
|
|
57
|
+
readonly foundation: string | null;
|
|
58
|
+
readonly component: 'rtp' | 'rtcp' | null;
|
|
59
|
+
readonly priority: number | null;
|
|
60
|
+
readonly address: string | null;
|
|
61
|
+
readonly protocol: RTCIceProtocol | null;
|
|
62
|
+
readonly port: number | null;
|
|
63
|
+
readonly type: RTCIceCandidateType | null;
|
|
64
|
+
readonly tcpType: RTCIceTcpCandidateType | null;
|
|
65
|
+
readonly relatedAddress: string | null;
|
|
66
|
+
readonly relatedPort: number | null;
|
|
67
|
+
readonly usernameFragment: string | null;
|
|
68
|
+
toJSON(): RTCIceCandidateInit;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// RTCDataChannel
|
|
72
|
+
export type RTCDataChannelState = 'connecting' | 'open' | 'closing' | 'closed';
|
|
73
|
+
export type RTCBinaryType = 'blob' | 'arraybuffer';
|
|
74
|
+
|
|
75
|
+
export interface RTCDataChannelInit {
|
|
76
|
+
ordered?: boolean;
|
|
77
|
+
maxPacketLifeTime?: number;
|
|
78
|
+
maxRetransmits?: number;
|
|
79
|
+
protocol?: string;
|
|
80
|
+
negotiated?: boolean;
|
|
81
|
+
id?: number;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export interface RTCDataChannelEventMap {
|
|
85
|
+
open: Event;
|
|
86
|
+
message: MessageEvent;
|
|
87
|
+
error: RTCErrorEvent;
|
|
88
|
+
close: Event;
|
|
89
|
+
bufferedamountlow: Event;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export class RTCDataChannel extends EventEmitter {
|
|
93
|
+
readonly label: string;
|
|
94
|
+
readonly ordered: boolean;
|
|
95
|
+
readonly maxPacketLifeTime: number | null;
|
|
96
|
+
readonly maxRetransmits: number | null;
|
|
97
|
+
readonly protocol: string;
|
|
98
|
+
readonly negotiated: boolean;
|
|
99
|
+
readonly id: number | null;
|
|
100
|
+
readonly readyState: RTCDataChannelState;
|
|
101
|
+
readonly bufferedAmount: number;
|
|
102
|
+
bufferedAmountLowThreshold: number;
|
|
103
|
+
binaryType: RTCBinaryType;
|
|
104
|
+
|
|
105
|
+
close(): void;
|
|
106
|
+
send(data: string | ArrayBuffer | ArrayBufferView): void;
|
|
107
|
+
|
|
108
|
+
on<K extends keyof RTCDataChannelEventMap>(event: K, listener: (ev: RTCDataChannelEventMap[K]) => void): this;
|
|
109
|
+
once<K extends keyof RTCDataChannelEventMap>(event: K, listener: (ev: RTCDataChannelEventMap[K]) => void): this;
|
|
110
|
+
off<K extends keyof RTCDataChannelEventMap>(event: K, listener: (ev: RTCDataChannelEventMap[K]) => void): this;
|
|
111
|
+
emit<K extends keyof RTCDataChannelEventMap>(event: K, ...args: any[]): boolean;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// RTCPeerConnection
|
|
115
|
+
export type RTCSignalingState = 'stable' | 'have-local-offer' | 'have-remote-offer' |
|
|
116
|
+
'have-local-pranswer' | 'have-remote-pranswer' | 'closed';
|
|
117
|
+
|
|
118
|
+
export type RTCIceGatheringState = 'new' | 'gathering' | 'complete';
|
|
119
|
+
|
|
120
|
+
export type RTCIceConnectionState = 'new' | 'checking' | 'connected' | 'completed' |
|
|
121
|
+
'failed' | 'disconnected' | 'closed';
|
|
122
|
+
|
|
123
|
+
export type RTCPeerConnectionState = 'new' | 'connecting' | 'connected' |
|
|
124
|
+
'disconnected' | 'failed' | 'closed';
|
|
125
|
+
|
|
126
|
+
export interface RTCOfferOptions {
|
|
127
|
+
iceRestart?: boolean;
|
|
128
|
+
offerToReceiveAudio?: boolean;
|
|
129
|
+
offerToReceiveVideo?: boolean;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
export interface RTCAnswerOptions {
|
|
133
|
+
iceRestart?: boolean;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
export interface RTCDataChannelEventInit {
|
|
137
|
+
channel: RTCDataChannel;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
export class RTCDataChannelEvent extends Event {
|
|
141
|
+
constructor(type: string, eventInitDict: RTCDataChannelEventInit);
|
|
142
|
+
readonly channel: RTCDataChannel;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
export interface RTCPeerConnectionIceEventInit {
|
|
146
|
+
candidate?: RTCIceCandidate | null;
|
|
147
|
+
url?: string | null;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
export class RTCPeerConnectionIceEvent extends Event {
|
|
151
|
+
constructor(type: string, eventInitDict?: RTCPeerConnectionIceEventInit);
|
|
152
|
+
readonly candidate: RTCIceCandidate | null;
|
|
153
|
+
readonly url: string | null;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
export interface RTCPeerConnectionEventMap {
|
|
157
|
+
connectionstatechange: Event;
|
|
158
|
+
datachannel: RTCDataChannelEvent;
|
|
159
|
+
icecandidate: RTCPeerConnectionIceEvent;
|
|
160
|
+
icecandidateerror: Event;
|
|
161
|
+
iceconnectionstatechange: Event;
|
|
162
|
+
icegatheringstatechange: Event;
|
|
163
|
+
negotiationneeded: Event;
|
|
164
|
+
signalingstatechange: Event;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
export class RTCPeerConnection extends EventEmitter {
|
|
168
|
+
constructor(configuration?: RTCConfiguration, factory?: NativePeerConnectionFactory);
|
|
169
|
+
|
|
170
|
+
readonly signalingState: RTCSignalingState;
|
|
171
|
+
readonly iceGatheringState: RTCIceGatheringState;
|
|
172
|
+
readonly iceConnectionState: RTCIceConnectionState;
|
|
173
|
+
readonly connectionState: RTCPeerConnectionState;
|
|
174
|
+
readonly localDescription: RTCSessionDescription | null;
|
|
175
|
+
readonly remoteDescription: RTCSessionDescription | null;
|
|
176
|
+
readonly pendingLocalDescription: RTCSessionDescription | null;
|
|
177
|
+
readonly pendingRemoteDescription: RTCSessionDescription | null;
|
|
178
|
+
readonly currentLocalDescription: RTCSessionDescription | null;
|
|
179
|
+
readonly currentRemoteDescription: RTCSessionDescription | null;
|
|
180
|
+
|
|
181
|
+
createOffer(options?: RTCOfferOptions): Promise<RTCSessionDescription>;
|
|
182
|
+
createAnswer(options?: RTCAnswerOptions): Promise<RTCSessionDescription>;
|
|
183
|
+
setLocalDescription(description: RTCSessionDescriptionInit): Promise<void>;
|
|
184
|
+
setRemoteDescription(description: RTCSessionDescriptionInit): Promise<void>;
|
|
185
|
+
addIceCandidate(candidate?: RTCIceCandidateInit | null): Promise<void>;
|
|
186
|
+
createDataChannel(label: string, dataChannelDict?: RTCDataChannelInit): RTCDataChannel;
|
|
187
|
+
getConfiguration(): RTCConfiguration;
|
|
188
|
+
setConfiguration(configuration: RTCConfiguration): void;
|
|
189
|
+
close(): void;
|
|
190
|
+
getStats(): Promise<any>;
|
|
191
|
+
|
|
192
|
+
on<K extends keyof RTCPeerConnectionEventMap>(event: K, listener: (ev: RTCPeerConnectionEventMap[K]) => void): this;
|
|
193
|
+
once<K extends keyof RTCPeerConnectionEventMap>(event: K, listener: (ev: RTCPeerConnectionEventMap[K]) => void): this;
|
|
194
|
+
off<K extends keyof RTCPeerConnectionEventMap>(event: K, listener: (ev: RTCPeerConnectionEventMap[K]) => void): this;
|
|
195
|
+
emit<K extends keyof RTCPeerConnectionEventMap>(event: K, ...args: any[]): boolean;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
// RTCError
|
|
199
|
+
export class RTCError extends Error {
|
|
200
|
+
constructor(message: string, errorDetail?: string);
|
|
201
|
+
readonly errorDetail: string;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
export interface RTCErrorEventInit {
|
|
205
|
+
error: RTCError;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
export class RTCErrorEvent extends Event {
|
|
209
|
+
constructor(type: string, eventInitDict: RTCErrorEventInit);
|
|
210
|
+
readonly error: RTCError;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
// NativePeerConnectionFactory
|
|
214
|
+
export class NativePeerConnectionFactory {
|
|
215
|
+
constructor();
|
|
216
|
+
initialize(): void;
|
|
217
|
+
createPeerConnection(configuration: RTCConfiguration): any;
|
|
218
|
+
dispose(): void;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
// Factory functions
|
|
222
|
+
export function createPeerConnection(configuration?: RTCConfiguration): RTCPeerConnection;
|
|
223
|
+
export function createPeerConnectionWithFactory(configuration: RTCConfiguration, factory: NativePeerConnectionFactory): RTCPeerConnection;
|
|
224
|
+
|
|
225
|
+
// Alias
|
|
226
|
+
export { RTCPeerConnection as RTCConnection };
|
|
227
|
+
|
|
228
|
+
// Default factory instance
|
|
229
|
+
export const defaultFactory: NativePeerConnectionFactory;
|
package/src/index.js
CHANGED