-
-
Notifications
You must be signed in to change notification settings - Fork 61
/
Copy pathindex.ts
175 lines (161 loc) · 6.39 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
import nodeDataChannel from './node-datachannel';
import _DataChannelStream from './datachannel-stream';
import { WebSocketServer } from './websocket-server';
import { Channel, DataChannelInitConfig, DescriptionType, Direction, LogLevel, RtcConfig, RTCIceConnectionState, RTCIceGatheringState, RTCPeerConnectionState, RTCSignalingState, SctpSettings, SelectedCandidateInfo } from './types';
import { WebSocket } from './websocket';
export function preload(): void { nodeDataChannel.preload(); }
export function initLogger(level: LogLevel): void { nodeDataChannel.initLogger(level); }
export function cleanup(): void { nodeDataChannel.cleanup(); }
export function setSctpSettings(settings: SctpSettings): void { nodeDataChannel.setSctpSettings(settings); }
export interface Audio {
addAudioCodec(payloadType: number, codec: string, profile?: string): void;
addOpusCodec(payloadType: number, profile?: string): string;
direction(): Direction;
generateSdp(eol: string, addr: string, port: number): string;
mid(): string;
setDirection(dir: Direction): void;
description(): string;
removeFormat(fmt: string): void;
addSSRC(ssrc: number, name?: string, msid?: string, trackID?: string): void;
removeSSRC(ssrc: number): void;
replaceSSRC(oldSsrc: number, ssrc: number, name?: string, msid?: string, trackID?: string): void;
hasSSRC(ssrc: number): boolean;
getSSRCs(): number[];
getCNameForSsrc(ssrc: number): string;
setBitrate(bitRate: number): void;
getBitrate(): number;
hasPayloadType(payloadType: number): boolean;
addRTXCodec(payloadType: number, originalPayloadType: number, clockRate: number): void;
addRTPMap(): void;
parseSdpLine(line: string): void;
}
export const Audio: {
new(mid: string, dir: Direction): Audio
} = nodeDataChannel.Audio
export interface Video {
addVideoCodec(payloadType: number, codec: string, profile?: string): void;
addH264Codec(payloadType: number, profile?: string): void;
addVP8Codec(payloadType: number): void;
addVP9Codec(payloadType: number): void;
direction(): Direction;
generateSdp(eol: string, addr: string, port: number): string;
mid(): string;
setDirection(dir: Direction): void;
description(): string;
removeFormat(fmt: string): void;
addSSRC(ssrc: number, name?: string, msid?: string, trackID?: string): void;
removeSSRC(ssrc: number): void;
replaceSSRC(oldSsrc: number, ssrc: number, name?: string, msid?: string, trackID?: string): void;
hasSSRC(ssrc: number): boolean;
getSSRCs(): number[];
getCNameForSsrc(ssrc: number): string;
setBitrate(bitRate: number): void;
getBitrate(): number;
hasPayloadType(payloadType: number): boolean;
addRTXCodec(payloadType: number, originalPayloadType: number, clockRate: number): void;
addRTPMap(): void;
parseSdpLine(line: string): void;
}
export const Video: {
new(mid: string, dir: Direction): Video
} = nodeDataChannel.Video
export interface Track {
direction(): Direction;
mid(): string;
type(): string;
close(): void;
sendMessage(msg: string): boolean;
sendMessageBinary(buffer: Buffer): boolean;
isOpen(): boolean;
isClosed(): boolean;
bufferedAmount(): number;
maxMessageSize(): number;
requestBitrate(bitRate: number): boolean;
setBufferedAmountLowThreshold(newSize: number): void;
requestKeyframe(): boolean;
setMediaHandler(handler: RtcpReceivingSession): void;
onOpen(cb: () => void): void;
onClosed(cb: () => void): void;
onError(cb: (err: string) => void): void;
onMessage(cb: (msg: Buffer) => void): void;
}
export const Track: {
new(): Track
} = nodeDataChannel.Track
export interface DataChannel extends Channel {
getLabel(): string;
getId(): number;
getProtocol(): string;
// Channel implementation
close(): void;
sendMessage(msg: string): boolean;
sendMessageBinary(buffer: Uint8Array): boolean;
isOpen(): boolean;
bufferedAmount(): number;
maxMessageSize(): number;
setBufferedAmountLowThreshold(newSize: number): void;
onOpen(cb: () => void): void;
onClosed(cb: () => void): void;
onError(cb: (err: string) => void): void;
onBufferedAmountLow(cb: () => void): void;
onMessage(cb: (msg: string | Buffer | ArrayBuffer) => void): void;
}
export const DataChannel: {
// DataChannel implementation
} = nodeDataChannel.DataChannel
export interface PeerConnection {
close(): void;
setLocalDescription(type?: DescriptionType): void;
setRemoteDescription(sdp: string, type: DescriptionType): void;
localDescription(): { type: DescriptionType; sdp: string } | null;
remoteDescription(): { type: DescriptionType; sdp: string } | null;
addRemoteCandidate(candidate: string, mid: string): void;
createDataChannel(label: string, config?: DataChannelInitConfig): DataChannel;
addTrack(media: Video | Audio): Track;
hasMedia(): boolean;
state(): RTCPeerConnectionState;
iceState(): RTCIceConnectionState;
signalingState(): RTCSignalingState;
gatheringState(): RTCIceGatheringState;
onLocalDescription(cb: (sdp: string, type: DescriptionType) => void): void;
onLocalCandidate(cb: (candidate: string, mid: string) => void): void;
onStateChange(cb: (state: string) => void): void;
onIceStateChange(cb: (state: string) => void): void;
onSignalingStateChange(cb: (state: string) => void): void;
onGatheringStateChange(cb: (state: string) => void): void;
onDataChannel(cb: (dc: DataChannel) => void): void;
onTrack(cb: (track: Track) => void): void;
bytesSent(): number;
bytesReceived(): number;
rtt(): number;
getSelectedCandidatePair(): { local: SelectedCandidateInfo; remote: SelectedCandidateInfo } | null;
maxDataChannelId(): number;
maxMessageSize(): number;
}
export const PeerConnection: {
new(peerName: string, config: RtcConfig): PeerConnection
} = nodeDataChannel.PeerConnection
export class RtcpReceivingSession {
//
}
export { WebSocketServer } from './websocket-server';
export { WebSocket } from './websocket';
export const DataChannelStream = _DataChannelStream;
export default {
initLogger,
cleanup,
preload,
setSctpSettings,
RtcpReceivingSession,
Track,
Video,
Audio,
DataChannel,
PeerConnection,
WebSocket,
WebSocketServer,
DataChannelStream
};
// Types
// https://github.com/murat-dogan/node-datachannel/issues/300
export * from './types';