@lng2004/node-datachannel 0.32.3-20260815.5 → 0.33.2-20260825
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/.clang-format +17 -0
- package/.editorconfig +12 -0
- package/.eslintignore +8 -0
- package/.eslintrc.json +27 -0
- package/.gitmodules +3 -0
- package/.prettierignore +7 -0
- package/.prettierrc +13 -0
- package/API.md +247 -0
- package/BULDING.md +26 -0
- package/CMakeLists.txt +23 -9
- package/README.md +5 -18
- package/dist/cjs/lib/index.cjs +6 -2
- package/dist/cjs/lib/index.cjs.map +1 -1
- package/dist/cjs/lib/node-datachannel.cjs +87 -4
- package/dist/cjs/lib/node-datachannel.cjs.map +1 -1
- package/dist/esm/lib/index.mjs +5 -3
- package/dist/esm/lib/index.mjs.map +1 -1
- package/dist/esm/lib/node-datachannel.mjs +67 -4
- package/dist/esm/lib/node-datachannel.mjs.map +1 -1
- package/dist/types/lib/index.d.ts +4 -2
- package/jest.config.ts +14 -0
- package/package.json +18 -15
- package/rollup.config.mjs +67 -0
- package/src/cpp/ice-udp-mux-listener-wrapper.cpp +16 -2
- package/src/index.ts +9 -0
- package/src/lib/datachannel-stream.ts +100 -0
- package/src/lib/index.ts +306 -0
- package/src/lib/node-datachannel.ts +84 -0
- package/src/lib/types.ts +169 -0
- package/src/lib/websocket-server.ts +37 -0
- package/src/lib/websocket.ts +26 -0
- package/src/polyfill/Events.ts +82 -0
- package/src/polyfill/Exception.ts +37 -0
- package/src/polyfill/README.md +41 -0
- package/src/polyfill/RTCCertificate.ts +21 -0
- package/src/polyfill/RTCDataChannel.ts +225 -0
- package/src/polyfill/RTCDtlsTransport.ts +46 -0
- package/src/polyfill/RTCError.ts +78 -0
- package/src/polyfill/RTCIceCandidate.ts +128 -0
- package/src/polyfill/RTCIceTransport.ts +90 -0
- package/src/polyfill/RTCPeerConnection.ts +527 -0
- package/src/polyfill/RTCSctpTransport.ts +51 -0
- package/src/polyfill/RTCSessionDescription.ts +41 -0
- package/src/polyfill/index.ts +38 -0
- package/tsconfig.json +21 -0
- package/binding-options.js +0 -7
- package/cmake/toolchain/ci.cmake +0 -23
- package/prebuilds/node_datachannel-darwin-arm64/node-napi-v8.node +0 -0
- package/prebuilds/node_datachannel-darwin-x64/node-napi-v8.node +0 -0
- package/prebuilds/node_datachannel-linux-arm64/node-napi-v8.node +0 -0
- package/prebuilds/node_datachannel-linux-arm64-musl/node-napi-v8.node +0 -0
- package/prebuilds/node_datachannel-linux-x64/node-napi-v8.node +0 -0
- package/prebuilds/node_datachannel-linux-x64-musl/node-napi-v8.node +0 -0
- package/prebuilds/node_datachannel-win32-arm64/node-napi-v8.node +0 -0
- package/prebuilds/node_datachannel-win32-x64/node-napi-v8.node +0 -0
package/.clang-format
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
BasedOnStyle: LLVM
|
|
2
|
+
|
|
3
|
+
# Indentation
|
|
4
|
+
NamespaceIndentation: All
|
|
5
|
+
|
|
6
|
+
# Braces
|
|
7
|
+
BreakBeforeBraces: Allman
|
|
8
|
+
|
|
9
|
+
#include
|
|
10
|
+
SortIncludes: false
|
|
11
|
+
|
|
12
|
+
# Line Length
|
|
13
|
+
ColumnLimit: 120
|
|
14
|
+
|
|
15
|
+
# Line Breaks
|
|
16
|
+
AlwaysBreakTemplateDeclarations: true
|
|
17
|
+
LambdaBodyIndentation: OuterScope
|
package/.editorconfig
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# EditorConfig helps developers define and maintain consistent
|
|
2
|
+
# coding styles between different editors and IDEs
|
|
3
|
+
# http://editorconfig.org
|
|
4
|
+
|
|
5
|
+
root = true
|
|
6
|
+
|
|
7
|
+
[*]
|
|
8
|
+
indent_style = space
|
|
9
|
+
end_of_line = lf
|
|
10
|
+
charset = utf-8
|
|
11
|
+
trim_trailing_whitespace = true
|
|
12
|
+
insert_final_newline = true
|
package/.eslintignore
ADDED
package/.eslintrc.json
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"env": {
|
|
3
|
+
"browser": false,
|
|
4
|
+
"es6": true,
|
|
5
|
+
"node": true
|
|
6
|
+
},
|
|
7
|
+
"parser": "@typescript-eslint/parser",
|
|
8
|
+
"parserOptions": {
|
|
9
|
+
"project": "tsconfig.json",
|
|
10
|
+
"sourceType": "module",
|
|
11
|
+
"ecmaVersion": 2020
|
|
12
|
+
},
|
|
13
|
+
"plugins": ["@typescript-eslint", "jest"],
|
|
14
|
+
"extends": [
|
|
15
|
+
"eslint:recommended",
|
|
16
|
+
"plugin:@typescript-eslint/recommended",
|
|
17
|
+
"plugin:jest/recommended",
|
|
18
|
+
"prettier"
|
|
19
|
+
],
|
|
20
|
+
"rules": {
|
|
21
|
+
// The following rule is enabled only to supplement the inline suppression
|
|
22
|
+
// examples, and because it is not a recommended rule, you should either
|
|
23
|
+
// disable it, or understand what it enforces.
|
|
24
|
+
// https://typescript-eslint.io/rules/explicit-function-return-type/
|
|
25
|
+
"@typescript-eslint/explicit-function-return-type": "warn"
|
|
26
|
+
}
|
|
27
|
+
}
|
package/.gitmodules
ADDED
package/.prettierignore
ADDED
package/.prettierrc
ADDED
package/API.md
ADDED
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
# API
|
|
2
|
+
|
|
3
|
+
## PeerConnection Class
|
|
4
|
+
|
|
5
|
+
**Constructor**
|
|
6
|
+
|
|
7
|
+
let pc = new PeerConnection(peerName[,options])
|
|
8
|
+
|
|
9
|
+
- peerName `<string>` Peer name to use for logs etc..
|
|
10
|
+
- options `<Object>` WebRTC Config Options
|
|
11
|
+
|
|
12
|
+
```
|
|
13
|
+
export interface RtcConfig {
|
|
14
|
+
iceServers: (string | IceServer)[];
|
|
15
|
+
proxyServer?: ProxyServer;
|
|
16
|
+
bindAddress?: string;
|
|
17
|
+
enableIceTcp?: boolean;
|
|
18
|
+
enableIceUdpMux?: boolean;
|
|
19
|
+
disableAutoNegotiation?: boolean;
|
|
20
|
+
disableFingerprintVerification?: boolean;
|
|
21
|
+
disableAutoGathering?: boolean;
|
|
22
|
+
forceMediaTransport?: boolean;
|
|
23
|
+
portRangeBegin?: number;
|
|
24
|
+
portRangeEnd?: number;
|
|
25
|
+
maxMessageSize?: number;
|
|
26
|
+
mtu?: number;
|
|
27
|
+
iceTransportPolicy?: TransportPolicy;
|
|
28
|
+
disableFingerprintVerification?: boolean;
|
|
29
|
+
certificatePemFile?: string;
|
|
30
|
+
keyPemFile?: string;
|
|
31
|
+
keyPemPass?: string;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export const enum RelayType {
|
|
35
|
+
TurnUdp = 'TurnUdp',
|
|
36
|
+
TurnTcp = 'TurnTcp',
|
|
37
|
+
TurnTls = 'TurnTls'
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export interface IceServer {
|
|
41
|
+
hostname: string;
|
|
42
|
+
port: number;
|
|
43
|
+
username?: string;
|
|
44
|
+
password?: string;
|
|
45
|
+
relayType?: RelayType;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export type TransportPolicy = 'all' | 'relay';
|
|
49
|
+
|
|
50
|
+
"iceServers" option is an array of stun/turn server urls
|
|
51
|
+
Examples;
|
|
52
|
+
STUN Server Example : stun:stun.l.google.com:19302
|
|
53
|
+
TURN Server Example : turn:USERNAME:PASSWORD@TURN_IP_OR_ADDRESS:PORT
|
|
54
|
+
TURN Server Example (TCP) : turn:USERNAME:PASSWORD@TURN_IP_OR_ADDRESS:PORT?transport=tcp
|
|
55
|
+
TURN Server Example (TLS) : turns:USERNAME:PASSWORD@TURN_IP_OR_ADDRESS:PORT
|
|
56
|
+
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
**close: () => void**
|
|
60
|
+
|
|
61
|
+
Close Peer Connection
|
|
62
|
+
|
|
63
|
+
**destroy: () => void**
|
|
64
|
+
|
|
65
|
+
Close Peer Connection & Clear all callbacks
|
|
66
|
+
|
|
67
|
+
**setRemoteDescription: (sdp: string, type: DescriptionType) => void**
|
|
68
|
+
|
|
69
|
+
Set Remote Description
|
|
70
|
+
|
|
71
|
+
```
|
|
72
|
+
export const enum DescriptionType {
|
|
73
|
+
Unspec = 'Unspec',
|
|
74
|
+
Offer = 'Offer',
|
|
75
|
+
Answer = 'Answer'
|
|
76
|
+
}
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
**setLocalDescription: (sdp: string, init?: LocalDescriptionInit) => void**
|
|
80
|
+
|
|
81
|
+
Set Local Description and optionally the ICE ufrag/pwd to use. These should not
|
|
82
|
+
be set as they will be generated automatically as per the spec.
|
|
83
|
+
|
|
84
|
+
```
|
|
85
|
+
export interface LocalDescriptionInit {
|
|
86
|
+
iceUfrag?: string;
|
|
87
|
+
icePwd?: string;
|
|
88
|
+
}
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
**remoteFingerprint: () => CertificateFingerprint**
|
|
92
|
+
|
|
93
|
+
Returns the certificate fingerprint used by the remote peer
|
|
94
|
+
|
|
95
|
+
```
|
|
96
|
+
export interface CertificateFingerprint {
|
|
97
|
+
value: string;
|
|
98
|
+
algorithm: 'sha-1' | 'sha-224' | 'sha-256' | 'sha-384' | 'sha-512' | 'md5' | 'md2';
|
|
99
|
+
}
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
**addRemoteCandidate: (candidate: string, mid: string) => void**
|
|
103
|
+
|
|
104
|
+
Add remote candidate info
|
|
105
|
+
|
|
106
|
+
**createDataChannel: (label: string, config?: DataChannelInitConfig) => DataChannel**
|
|
107
|
+
|
|
108
|
+
Create new data-channel
|
|
109
|
+
|
|
110
|
+
- label `<string>` Data channel name
|
|
111
|
+
- config `<Object>` Data channel options
|
|
112
|
+
|
|
113
|
+
```
|
|
114
|
+
export interface DataChannelInitConfig {
|
|
115
|
+
protocol?: string;
|
|
116
|
+
negotiated?: boolean;
|
|
117
|
+
id?: number;
|
|
118
|
+
unordered?: boolean; // Reliability
|
|
119
|
+
maxPacketLifeTime?: number; // Reliability
|
|
120
|
+
maxRetransmits?: number; // Reliability
|
|
121
|
+
}
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
**state: () => string**
|
|
125
|
+
|
|
126
|
+
Get current state
|
|
127
|
+
|
|
128
|
+
**signalingState: () => string**
|
|
129
|
+
|
|
130
|
+
Get current signaling state
|
|
131
|
+
|
|
132
|
+
**gatheringState: () => string**
|
|
133
|
+
|
|
134
|
+
Get current gathering state
|
|
135
|
+
|
|
136
|
+
**onLocalDescription: (cb: (sdp: string, type: DescriptionType) => void) => void**
|
|
137
|
+
|
|
138
|
+
Local Description Callback
|
|
139
|
+
|
|
140
|
+
```
|
|
141
|
+
export const enum DescriptionType {
|
|
142
|
+
Unspec = 'Unspec',
|
|
143
|
+
Offer = 'Offer',
|
|
144
|
+
Answer = 'Answer'
|
|
145
|
+
}
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
**onLocalCandidate: (cb: (candidate: string, mid: string) => void) => void**
|
|
149
|
+
|
|
150
|
+
Local Candidate Callback
|
|
151
|
+
|
|
152
|
+
**onStateChange: (cb: (state: string) => void) => void**
|
|
153
|
+
|
|
154
|
+
State Change Callback
|
|
155
|
+
|
|
156
|
+
**onSignalingStateChange: (state: (sdp: string) => void) => void**
|
|
157
|
+
|
|
158
|
+
Signaling State Change Callback
|
|
159
|
+
|
|
160
|
+
**onGatheringStateChange: (state: (sdp: string) => void) => void**
|
|
161
|
+
|
|
162
|
+
Gathering State Change Callback
|
|
163
|
+
|
|
164
|
+
**onDataChannel: (cb: (dc: DataChannel) => void) => void**
|
|
165
|
+
|
|
166
|
+
New Data Channel Callback
|
|
167
|
+
|
|
168
|
+
**bytesSent: () => number**
|
|
169
|
+
|
|
170
|
+
Get bytes sent stat
|
|
171
|
+
|
|
172
|
+
**bytesReceived: () => number**
|
|
173
|
+
|
|
174
|
+
Get bytes received stat
|
|
175
|
+
|
|
176
|
+
**rtt: () => number**
|
|
177
|
+
|
|
178
|
+
Get rtt stat
|
|
179
|
+
|
|
180
|
+
**getSelectedCandidatePair: () => { local: SelectedCandidateInfo, remote: SelectedCandidateInfo }**
|
|
181
|
+
|
|
182
|
+
Get info about selected candidate pair
|
|
183
|
+
|
|
184
|
+
```
|
|
185
|
+
export interface SelectedCandidateInfo {
|
|
186
|
+
address: string;
|
|
187
|
+
port: number;
|
|
188
|
+
type: string;
|
|
189
|
+
transportType: string;
|
|
190
|
+
}
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
## DataChannel Class
|
|
194
|
+
|
|
195
|
+
> You can create a new Datachannel instance by calling `PeerConnection.createDataChannel` function.
|
|
196
|
+
|
|
197
|
+
**close: () => void**
|
|
198
|
+
|
|
199
|
+
Close data channel
|
|
200
|
+
|
|
201
|
+
**getLabel: () => string**
|
|
202
|
+
|
|
203
|
+
Get label of data-channel
|
|
204
|
+
|
|
205
|
+
**sendMessage: (msg: string) => boolean**
|
|
206
|
+
|
|
207
|
+
Send Message as string
|
|
208
|
+
|
|
209
|
+
**sendMessageBinary: (buffer: Buffer) => boolean**
|
|
210
|
+
|
|
211
|
+
Send Message as binary
|
|
212
|
+
|
|
213
|
+
**isOpen: () => boolean**
|
|
214
|
+
|
|
215
|
+
Query data-channel
|
|
216
|
+
|
|
217
|
+
**bufferedAmount: () => number**
|
|
218
|
+
|
|
219
|
+
Get current buffered amount level
|
|
220
|
+
|
|
221
|
+
**maxMessageSize: () => number**
|
|
222
|
+
|
|
223
|
+
Get max message size of the data-channel, that could be sent
|
|
224
|
+
|
|
225
|
+
**setBufferedAmountLowThreshold: (newSize: number) => void**
|
|
226
|
+
|
|
227
|
+
Set buffer level of the `onBufferedAmountLow` callback
|
|
228
|
+
|
|
229
|
+
**onOpen: (cb: () => void) => void**
|
|
230
|
+
|
|
231
|
+
Open callback
|
|
232
|
+
|
|
233
|
+
**onClosed: (cb: () => void) => void**
|
|
234
|
+
|
|
235
|
+
Closed callback
|
|
236
|
+
|
|
237
|
+
**onError: (cb: (err: string) => void) => void**
|
|
238
|
+
|
|
239
|
+
Error callback
|
|
240
|
+
|
|
241
|
+
**onBufferedAmountLow: (cb: () => void) => void**
|
|
242
|
+
|
|
243
|
+
Buffer level low callback
|
|
244
|
+
|
|
245
|
+
**onMessage: (cb: (msg: string | Buffer) => void) => void**
|
|
246
|
+
|
|
247
|
+
New Message callback
|
package/BULDING.md
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# Build
|
|
2
|
+
|
|
3
|
+
## Requirements
|
|
4
|
+
|
|
5
|
+
- cmake >= V3.21
|
|
6
|
+
- [libdatachannel dependencies](https://github.com/paullouisageneau/libdatachannel/blob/master/README.md#dependencies)
|
|
7
|
+
|
|
8
|
+
## Building from source
|
|
9
|
+
|
|
10
|
+
```sh
|
|
11
|
+
> git clone https://github.com/murat-dogan/node-datachannel.git
|
|
12
|
+
> cd node-datachannel
|
|
13
|
+
> npm install --ignore-scripts
|
|
14
|
+
> npm run compile
|
|
15
|
+
> npm run build:tsc
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
### Compile Options
|
|
19
|
+
|
|
20
|
+
Compile without Media and WebSocket:
|
|
21
|
+
|
|
22
|
+
```sh
|
|
23
|
+
npx cmake-js clean
|
|
24
|
+
npx cmake-js configure --CDNO_MEDIA=ON --CDNO_WEBSOCKET=ON
|
|
25
|
+
npx cmake-js build
|
|
26
|
+
```
|
package/CMakeLists.txt
CHANGED
|
@@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.15)
|
|
|
2
2
|
cmake_policy(SET CMP0091 NEW)
|
|
3
3
|
cmake_policy(SET CMP0042 NEW)
|
|
4
4
|
|
|
5
|
-
project(node_datachannel VERSION 0.
|
|
5
|
+
project(node_datachannel VERSION 0.33.0)
|
|
6
6
|
|
|
7
7
|
# compile_commands.json
|
|
8
8
|
# -----------------------------------
|
|
@@ -14,12 +14,13 @@ add_definitions(-DNAPI_VERSION=8)
|
|
|
14
14
|
include_directories(${CMAKE_JS_INC})
|
|
15
15
|
|
|
16
16
|
if(WIN32)
|
|
17
|
-
set(OPENSSL_MSVC_STATIC_RT TRUE)
|
|
18
17
|
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
|
|
18
|
+
else()
|
|
19
|
+
set(OPENSSL_USE_STATIC_LIBS TRUE)
|
|
19
20
|
endif()
|
|
20
21
|
|
|
21
|
-
if(
|
|
22
|
-
set(CMAKE_C_FLAGS "-Wno-error=unused-but-set-variable -Wno-error=strict-prototypes")
|
|
22
|
+
if(ANDROID OR CMAKE_SYSTEM_NAME STREQUAL "Android")
|
|
23
|
+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-error=unused-but-set-variable -Wno-error=strict-prototypes")
|
|
23
24
|
endif()
|
|
24
25
|
|
|
25
26
|
# Add -frtti only for Linux and macOS
|
|
@@ -27,7 +28,6 @@ if (NOT CMAKE_SYSTEM_NAME STREQUAL "Windows")
|
|
|
27
28
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -frtti")
|
|
28
29
|
endif()
|
|
29
30
|
|
|
30
|
-
set(OPENSSL_USE_STATIC_LIBS TRUE)
|
|
31
31
|
find_package(OpenSSL REQUIRED)
|
|
32
32
|
|
|
33
33
|
include(FetchContent)
|
|
@@ -36,7 +36,7 @@ include(FetchContent)
|
|
|
36
36
|
FetchContent_Declare(
|
|
37
37
|
libdatachannel
|
|
38
38
|
GIT_REPOSITORY https://github.com/paullouisageneau/libdatachannel.git
|
|
39
|
-
GIT_TAG
|
|
39
|
+
GIT_TAG "51085b8de4e6185dc019e3705c88b87933d7c3f6"
|
|
40
40
|
)
|
|
41
41
|
|
|
42
42
|
option(NO_MEDIA "Disable media transport support in libdatachannel" OFF)
|
|
@@ -103,8 +103,19 @@ set_target_properties(${PROJECT_NAME} PROPERTIES PREFIX "" SUFFIX ".node")
|
|
|
103
103
|
# ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/binary
|
|
104
104
|
# )
|
|
105
105
|
|
|
106
|
+
if(NOT CMAKE_JS_INC)
|
|
107
|
+
execute_process(
|
|
108
|
+
COMMAND node -e "console.log(require('path').resolve(process.execPath, '..', '..', 'include', 'node'))"
|
|
109
|
+
OUTPUT_VARIABLE CMAKE_JS_INC
|
|
110
|
+
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
111
|
+
ERROR_QUIET
|
|
112
|
+
)
|
|
113
|
+
endif()
|
|
114
|
+
|
|
106
115
|
target_include_directories(${PROJECT_NAME} PRIVATE
|
|
116
|
+
${CMAKE_JS_INC}
|
|
107
117
|
${CMAKE_SOURCE_DIR}/node_modules/node-addon-api
|
|
118
|
+
${CMAKE_SOURCE_DIR}/node_modules/node-api-headers/include
|
|
108
119
|
${CMAKE_BINARY_DIR}/_deps/libdatachannel-src/include
|
|
109
120
|
${CMAKE_BINARY_DIR}/_deps/libdatachannel-src/deps/plog
|
|
110
121
|
)
|
|
@@ -117,8 +128,8 @@ set(LINK_LIBRARIES
|
|
|
117
128
|
|
|
118
129
|
if(APPLE)
|
|
119
130
|
#
|
|
120
|
-
elseif(
|
|
121
|
-
|
|
131
|
+
elseif(ANDROID OR CMAKE_SYSTEM_NAME STREQUAL "Android")
|
|
132
|
+
# Android NDK uses libc++_static with -DANDROID_STL=c++_static
|
|
122
133
|
elseif(UNIX)
|
|
123
134
|
list(APPEND LINK_LIBRARIES -static-libgcc -static-libstdc++)
|
|
124
135
|
endif()
|
|
@@ -130,7 +141,10 @@ endif()
|
|
|
130
141
|
|
|
131
142
|
target_link_libraries(${PROJECT_NAME} PRIVATE ${LINK_LIBRARIES})
|
|
132
143
|
|
|
133
|
-
if(
|
|
144
|
+
if(ANDROID OR CMAKE_SYSTEM_NAME STREQUAL "Android")
|
|
145
|
+
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-z,undefs -Wl,--allow-shlib-undefined")
|
|
146
|
+
target_link_options(${PROJECT_NAME} PRIVATE -Wl,-z,undefs -Wl,--allow-shlib-undefined)
|
|
147
|
+
elseif(UNIX AND NOT APPLE)
|
|
134
148
|
target_compile_options(${PROJECT_NAME} PRIVATE -fvisibility=hidden -fvisibility-inlines-hidden)
|
|
135
149
|
target_link_options(${PROJECT_NAME} PRIVATE -Wl,--exclude-libs,ALL)
|
|
136
150
|
endif()
|
package/README.md
CHANGED
|
@@ -16,27 +16,14 @@ This project is Node.js bindings for [libdatachannel](https://github.com/paullou
|
|
|
16
16
|
npm install node-datachannel
|
|
17
17
|
```
|
|
18
18
|
|
|
19
|
-
On install, the package first checks for a prebuilt binary matching your
|
|
20
|
-
platform/architecture (shipped inside the package under `prebuilds/`). If no
|
|
21
|
-
matching prebuild is found, it falls back to building from source using
|
|
22
|
-
`cmake-js`, which requires the build dependencies listed in
|
|
23
|
-
[BULDING.md](./BULDING.md).
|
|
24
|
-
|
|
25
|
-
To force a build from source, set `npm_config_build_from_source=true`:
|
|
26
|
-
|
|
27
|
-
```sh
|
|
28
|
-
npm install node-datachannel --build-from-source
|
|
29
|
-
```
|
|
30
|
-
|
|
31
19
|
## Supported Platforms
|
|
32
20
|
|
|
33
|
-
`node-datachannel` targets N-API version 8 and supports Node.js v18.20 and above
|
|
34
|
-
|
|
35
|
-
| | Linux [x64,armv7,arm64] (1) | Windows [x86,x64] | Mac [M1,x64] |
|
|
36
|
-
| ------------------------- | :-------------------------: | :---------------: | :----------: |
|
|
37
|
-
| N-API v8 (>= Node.js v18) | + | + | + |
|
|
21
|
+
`node-datachannel` targets N-API version 8 and supports Node.js **v18.20 and above** (including Node.js 20, 22, and 24+). Prebuilt binaries are distributed automatically via platform-specific npm packages (`optionalDependencies`).
|
|
38
22
|
|
|
39
|
-
|
|
23
|
+
| Architecture | Linux (glibc) | Linux (musl / Alpine) | macOS (Apple Silicon / Intel) | Windows | Android (Termux / Bionic) |
|
|
24
|
+
| :--- | :---: | :---: | :---: | :---: | :---: |
|
|
25
|
+
| **x64** | `@node-datachannel/linux-x64-gnu` | `@node-datachannel/linux-x64-musl` | `@node-datachannel/darwin-x64` | `@node-datachannel/win32-x64-msvc` | - |
|
|
26
|
+
| **arm64** | `@node-datachannel/linux-arm64-gnu` | `@node-datachannel/linux-arm64-musl` | `@node-datachannel/darwin-arm64` | `@node-datachannel/win32-arm64-msvc` | `@node-datachannel/android-arm64` |
|
|
40
27
|
|
|
41
28
|
## Electron
|
|
42
29
|
|
package/dist/cjs/lib/index.cjs
CHANGED
|
@@ -36,8 +36,8 @@ const RtcpSrReporter = nodeDatachannel.default.RtcpSrReporter;
|
|
|
36
36
|
const RtpPacketizer = nodeDatachannel.default.RtpPacketizer;
|
|
37
37
|
const H264RtpPacketizer = nodeDatachannel.default.H264RtpPacketizer;
|
|
38
38
|
const H265RtpPacketizer = nodeDatachannel.default.H265RtpPacketizer;
|
|
39
|
-
nodeDatachannel.default.VP8RtpPacketizer;
|
|
40
|
-
nodeDatachannel.default.VP9RtpPacketizer;
|
|
39
|
+
const VP8RtpPacketizer = nodeDatachannel.default.VP8RtpPacketizer;
|
|
40
|
+
const VP9RtpPacketizer = nodeDatachannel.default.VP9RtpPacketizer;
|
|
41
41
|
const AV1RtpPacketizer = nodeDatachannel.default.AV1RtpPacketizer;
|
|
42
42
|
const DataChannelStream = datachannelStream.default;
|
|
43
43
|
var n = {
|
|
@@ -54,6 +54,8 @@ var n = {
|
|
|
54
54
|
RtpPacketizer,
|
|
55
55
|
H264RtpPacketizer,
|
|
56
56
|
H265RtpPacketizer,
|
|
57
|
+
VP8RtpPacketizer,
|
|
58
|
+
VP9RtpPacketizer,
|
|
57
59
|
AV1RtpPacketizer,
|
|
58
60
|
Track,
|
|
59
61
|
Video,
|
|
@@ -83,6 +85,8 @@ exports.RtcpSrReporter = RtcpSrReporter;
|
|
|
83
85
|
exports.RtpPacketizationConfig = RtpPacketizationConfig;
|
|
84
86
|
exports.RtpPacketizer = RtpPacketizer;
|
|
85
87
|
exports.Track = Track;
|
|
88
|
+
exports.VP8RtpPacketizer = VP8RtpPacketizer;
|
|
89
|
+
exports.VP9RtpPacketizer = VP9RtpPacketizer;
|
|
86
90
|
exports.Video = Video;
|
|
87
91
|
exports.cleanup = cleanup;
|
|
88
92
|
exports.default = n;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../../src/lib/index.ts"],"sourcesContent":["import nodeDataChannel from './node-datachannel';\nimport _DataChannelStream from './datachannel-stream';\nimport { WebSocketServer } from './websocket-server';\nimport {\n Channel,\n DataChannelInitConfig,\n DescriptionType,\n Direction,\n LogLevel,\n NalUnitSeparator,\n ObuPacketization,\n RtcConfig,\n RTCIceConnectionState,\n RTCIceGatheringState,\n RTCPeerConnectionState,\n RTCSignalingState,\n SctpSettings,\n SelectedCandidateInfo,\n} from './types';\nimport { WebSocket } from './websocket';\nimport type { CertificateFingerprint, IceUdpMuxRequest, LocalDescriptionInit } from './types';\n\nexport function preload(): void {\n nodeDataChannel.preload();\n}\nexport function initLogger(level: LogLevel, cb?: (level: LogLevel, message: string) => void): void {\n nodeDataChannel.initLogger(level, cb);\n}\nexport function cleanup(): void {\n nodeDataChannel.cleanup();\n}\nexport function setSctpSettings(settings: SctpSettings): void {\n nodeDataChannel.setSctpSettings(settings);\n}\nexport function getLibraryVersion(): string {\n return nodeDataChannel.getLibraryVersion();\n}\n\nexport interface Audio {\n addAudioCodec(payloadType: number, codec: string, profile?: string): void;\n addOpusCodec(payloadType: number, profile?: string): string;\n direction(): Direction;\n generateSdp(eol: string, addr: string, port: number): string;\n mid(): string;\n setDirection(dir: Direction): void;\n description(): string;\n removeFormat(fmt: string): void;\n addSSRC(ssrc: number, name?: string, msid?: string, trackID?: string): void;\n removeSSRC(ssrc: number): void;\n replaceSSRC(oldSsrc: number, ssrc: number, name?: string, msid?: string, trackID?: string): void;\n hasSSRC(ssrc: number): boolean;\n getSSRCs(): number[];\n getCNameForSsrc(ssrc: number): string;\n setBitrate(bitRate: number): void;\n getBitrate(): number;\n hasPayloadType(payloadType: number): boolean;\n addRTXCodec(payloadType: number, originalPayloadType: number, clockRate: number): void;\n addRTPMap(): void;\n parseSdpLine(line: string): void;\n}\nexport const Audio: {\n new (mid: string, dir: Direction): Audio;\n} = nodeDataChannel.Audio;\n\nexport interface Video {\n addVideoCodec(payloadType: number, codec: string, profile?: string): void;\n addH264Codec(payloadType: number, profile?: string): void;\n addH265Codec(payloadType: number): void;\n addVP8Codec(payloadType: number): void;\n addVP9Codec(payloadType: number): void;\n addAV1Codec(payloadType: number): void;\n direction(): Direction;\n generateSdp(eol: string, addr: string, port: number): string;\n mid(): string;\n setDirection(dir: Direction): void;\n description(): string;\n removeFormat(fmt: string): void;\n addSSRC(ssrc: number, name?: string, msid?: string, trackID?: string): void;\n removeSSRC(ssrc: number): void;\n replaceSSRC(oldSsrc: number, ssrc: number, name?: string, msid?: string, trackID?: string): void;\n hasSSRC(ssrc: number): boolean;\n getSSRCs(): number[];\n getCNameForSsrc(ssrc: number): string;\n setBitrate(bitRate: number): void;\n getBitrate(): number;\n hasPayloadType(payloadType: number): boolean;\n addRTXCodec(payloadType: number, originalPayloadType: number, clockRate: number): void;\n addRTPMap(): void;\n parseSdpLine(line: string): void;\n}\nexport const Video: {\n new (mid: string, dir: Direction): Video;\n} = nodeDataChannel.Video;\n\nexport interface Track {\n direction(): Direction;\n mid(): string;\n type(): string;\n close(): void;\n sendMessage(msg: string): boolean;\n sendMessageBinary(buffer: Buffer): boolean;\n isOpen(): boolean;\n isClosed(): boolean;\n bufferedAmount(): number;\n maxMessageSize(): number;\n requestBitrate(bitRate: number): boolean;\n setBufferedAmountLowThreshold(newSize: number): void;\n requestKeyframe(): boolean;\n setMediaHandler(handler: MediaHandler): void;\n onOpen(cb: () => void): void;\n onClosed(cb: () => void): void;\n onError(cb: (err: string) => void): void;\n onMessage(cb: (msg: Buffer) => void): void;\n}\nexport const Track: {\n new (): Track;\n} = nodeDataChannel.Track;\n\nexport interface DataChannel extends Channel {\n getLabel(): string;\n getId(): number;\n getProtocol(): string;\n\n // Channel implementation\n close(): void;\n sendMessage(msg: string): boolean;\n sendMessageBinary(buffer: Buffer | Uint8Array): boolean;\n isOpen(): boolean;\n bufferedAmount(): number;\n maxMessageSize(): number;\n setBufferedAmountLowThreshold(newSize: number): void;\n onOpen(cb: () => void): void;\n onClosed(cb: () => void): void;\n onError(cb: (err: string) => void): void;\n onBufferedAmountLow(cb: () => void): void;\n onMessage(cb: (msg: string | Buffer | ArrayBuffer) => void): void;\n}\nexport const DataChannel: {\n // DataChannel implementation\n} = nodeDataChannel.DataChannel;\n\nexport interface PeerConnection {\n close(): void;\n setLocalDescription(type?: DescriptionType, init?: LocalDescriptionInit): void;\n setRemoteDescription(sdp: string, type: DescriptionType): void;\n localDescription(): { type: DescriptionType; sdp: string } | null;\n remoteDescription(): { type: DescriptionType; sdp: string } | null;\n remoteFingerprint(): CertificateFingerprint;\n addRemoteCandidate(candidate: string, mid: string): void;\n createDataChannel(label: string, config?: DataChannelInitConfig): DataChannel;\n addTrack(media: Video | Audio): Track;\n hasMedia(): boolean;\n state(): RTCPeerConnectionState;\n iceState(): RTCIceConnectionState;\n signalingState(): RTCSignalingState;\n gatheringState(): RTCIceGatheringState;\n onLocalDescription(cb: (sdp: string, type: DescriptionType) => void): void;\n onLocalCandidate(cb: (candidate: string, mid: string) => void): void;\n onStateChange(cb: (state: string) => void): void;\n onIceStateChange(cb: (state: string) => void): void;\n onSignalingStateChange(cb: (state: string) => void): void;\n onGatheringStateChange(cb: (state: string) => void): void;\n onDataChannel(cb: (dc: DataChannel) => void): void;\n onTrack(cb: (track: Track) => void): void;\n bytesSent(): number;\n bytesReceived(): number;\n rtt(): number;\n getSelectedCandidatePair(): {\n local: SelectedCandidateInfo;\n remote: SelectedCandidateInfo;\n } | null;\n maxDataChannelId(): number;\n maxMessageSize(): number;\n}\nexport const PeerConnection: {\n new (peerName: string, config: RtcConfig): PeerConnection;\n} = nodeDataChannel.PeerConnection;\n\nexport interface IceUdpMuxListener {\n address?: string;\n port: number;\n stop(): void;\n onUnhandledStunRequest(cb: (req: IceUdpMuxRequest) => void): void;\n}\nexport const IceUdpMuxListener: {\n new (port: number, address?: string): IceUdpMuxListener;\n} = nodeDataChannel.IceUdpMuxListener;\n\nexport interface RtpPacketizationConfig {\n playoutDelayId: number,\n playoutDelayMin: number,\n playoutDelayMax: number,\n timestamp: number,\n get clockRate(): number\n}\n\nexport const RtpPacketizationConfig: {\n new(ssrc: number, cname: string, payloadType: number, clockRate: number, videoOrientationId?: number): RtpPacketizationConfig\n} = nodeDataChannel.RtpPacketizationConfig\n\nexport interface MediaHandler {\n addToChain(handler: MediaHandler): void\n}\n\nexport interface PacingHandler extends MediaHandler {\n setBitrate(bitsPerSecond: number): void;\n}\n\nexport const PacingHandler: {\n new (bitsPerSecond: number, sendInterval: number): PacingHandler;\n} = nodeDataChannel.PacingHandler;\n\nexport interface RtcpReceivingSession extends MediaHandler {}\n\nexport const RtcpReceivingSession: {\n new (): RtcpReceivingSession;\n} = nodeDataChannel.RtcpReceivingSession;\n\nexport interface RtcpNackResponder extends MediaHandler {}\n\nexport const RtcpNackResponder: {\n new (maxSize?: number): RtcpNackResponder\n} = nodeDataChannel.RtcpNackResponder;\n\nexport interface RtcpSrReporter extends MediaHandler {\n get rtpConfig(): RtpPacketizationConfig\n}\n\nexport const RtcpSrReporter: {\n new (rtpConfig: RtpPacketizationConfig): RtcpSrReporter\n} = nodeDataChannel.RtcpSrReporter;\n\nexport interface RtpPacketizer extends MediaHandler {\n get rtpConfig(): RtpPacketizationConfig\n}\n\nexport const RtpPacketizer: {\n new (rtpConfig: RtpPacketizationConfig): RtpPacketizer\n} = nodeDataChannel.RtpPacketizer;\n\nexport interface H264RtpPacketizer extends RtpPacketizer {}\n\nexport const H264RtpPacketizer: {\n new (separator: NalUnitSeparator, rtpConfig: RtpPacketizationConfig, maxFragmentSize?: number): H264RtpPacketizer\n} = nodeDataChannel.H264RtpPacketizer\n\nexport interface H265RtpPacketizer extends RtpPacketizer {}\n\nexport const H265RtpPacketizer: {\n new (separator: NalUnitSeparator, rtpConfig: RtpPacketizationConfig, maxFragmentSize?: number): H265RtpPacketizer\n} = nodeDataChannel.H265RtpPacketizer\n\nexport interface VP8RtpPacketizer extends RtpPacketizer {}\n\nexport const VP8RtpPacketizer: {\n new (rtpConfig: RtpPacketizationConfig, maxFragmentSize?: number): VP8RtpPacketizer\n} = nodeDataChannel.VP8RtpPacketizer\n\nexport interface VP9RtpPacketizer extends RtpPacketizer {}\n\nexport const VP9RtpPacketizer: {\n new (rtpConfig: RtpPacketizationConfig, maxFragmentSize?: number): VP9RtpPacketizer\n} = nodeDataChannel.VP9RtpPacketizer\n\nexport interface AV1RtpPacketizer extends RtpPacketizer {}\n\nexport const AV1RtpPacketizer: {\n new (packetization: ObuPacketization, rtpConfig: RtpPacketizationConfig, maxFragmentSize?: number): AV1RtpPacketizer\n} = nodeDataChannel.AV1RtpPacketizer\n\nexport { WebSocketServer } from './websocket-server';\nexport { WebSocket } from './websocket';\n\nexport const DataChannelStream = _DataChannelStream;\n\nexport default {\n initLogger,\n cleanup,\n preload,\n setSctpSettings,\n getLibraryVersion,\n PacingHandler,\n RtcpReceivingSession,\n RtcpNackResponder,\n RtcpSrReporter,\n RtpPacketizationConfig,\n RtpPacketizer,\n H264RtpPacketizer,\n H265RtpPacketizer,\n AV1RtpPacketizer,\n Track,\n Video,\n Audio,\n DataChannel,\n PeerConnection,\n WebSocket,\n WebSocketServer,\n DataChannelStream,\n IceUdpMuxListener,\n};\n\n// Types\n// https://github.com/murat-dogan/node-datachannel/issues/300\nexport * from './types';\n"],"names":["nodeDataChannel","_DataChannelStream","WebSocket","WebSocketServer"],"mappings":";;;;;;;;;AAsBO,SAAS,OAAgB,GAAA;AAC9B,EAAAA,uBAAA,CAAgB,OAAQ,EAAA,CAAA;AAC1B,CAAA;AACgB,SAAA,UAAA,CAAW,OAAiB,EAAuD,EAAA;AACjG,EAAgBA,uBAAA,CAAA,UAAA,CAAW,OAAO,EAAE,CAAA,CAAA;AACtC,CAAA;AACO,SAAS,OAAgB,GAAA;AAC9B,EAAAA,uBAAA,CAAgB,OAAQ,EAAA,CAAA;AAC1B,CAAA;AACO,SAAS,gBAAgB,QAA8B,EAAA;AAC5D,EAAAA,uBAAA,CAAgB,gBAAgB,QAAQ,CAAA,CAAA;AAC1C,CAAA;AACO,SAAS,iBAA4B,GAAA;AAC1C,EAAA,OAAOA,wBAAgB,iBAAkB,EAAA,CAAA;AAC3C,CAAA;AAwBO,MAAM,QAETA,uBAAgB,CAAA,MAAA;AA4Bb,MAAM,QAETA,uBAAgB,CAAA,MAAA;AAsBb,MAAM,QAETA,uBAAgB,CAAA,MAAA;AAqBb,MAAM,cAETA,uBAAgB,CAAA,YAAA;AAmCb,MAAM,iBAETA,uBAAgB,CAAA,eAAA;AAQb,MAAM,oBAETA,uBAAgB,CAAA,kBAAA;AAUb,MAAM,yBAETA,uBAAgB,CAAA,uBAAA;AAUb,MAAM,gBAETA,uBAAgB,CAAA,cAAA;AAIb,MAAM,uBAETA,uBAAgB,CAAA,qBAAA;AAIb,MAAM,oBAETA,uBAAgB,CAAA,kBAAA;AAMb,MAAM,iBAETA,uBAAgB,CAAA,eAAA;AAMb,MAAM,gBAETA,uBAAgB,CAAA,cAAA;AAIb,MAAM,oBAETA,uBAAgB,CAAA,kBAAA;AAIb,MAAM,oBAETA,uBAAgB,CAAA,kBAAA;AAMhBA,uBAAgB,CAAA,iBAAA;AAMhBA,uBAAgB,CAAA,iBAAA;AAIb,MAAM,mBAETA,uBAAgB,CAAA,iBAAA;AAKb,MAAM,iBAAoB,GAAAC,0BAAA;AAEjC,QAAe;AAAA,EACb,UAAA;AAAA,EACA,OAAA;AAAA,EACA,OAAA;AAAA,EACA,eAAA;AAAA,EACA,iBAAA;AAAA,EACA,aAAA;AAAA,EACA,oBAAA;AAAA,EACA,iBAAA;AAAA,EACA,cAAA;AAAA,EACA,sBAAA;AAAA,EACA,aAAA;AAAA,EACA,iBAAA;AAAA,EACA,iBAAA;AAAA,EACA,gBAAA;AAAA,EACA,KAAA;AAAA,EACA,KAAA;AAAA,EACA,KAAA;AAAA,EACA,WAAA;AAAA,EACA,cAAA;AAAA,aACAC,mBAAA;AAAA,mBACAC,+BAAA;AAAA,EACA,iBAAA;AAAA,EACA,iBAAA;AACF,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../../src/lib/index.ts"],"sourcesContent":["import nodeDataChannel from './node-datachannel';\nimport _DataChannelStream from './datachannel-stream';\nimport { WebSocketServer } from './websocket-server';\nimport {\n Channel,\n DataChannelInitConfig,\n DescriptionType,\n Direction,\n LogLevel,\n NalUnitSeparator,\n ObuPacketization,\n RtcConfig,\n RTCIceConnectionState,\n RTCIceGatheringState,\n RTCPeerConnectionState,\n RTCSignalingState,\n SctpSettings,\n SelectedCandidateInfo,\n} from './types';\nimport { WebSocket } from './websocket';\nimport type { CertificateFingerprint, IceUdpMuxRequest, LocalDescriptionInit } from './types';\n\nexport function preload(): void {\n nodeDataChannel.preload();\n}\nexport function initLogger(level: LogLevel, cb?: (level: LogLevel, message: string) => void): void {\n nodeDataChannel.initLogger(level, cb);\n}\nexport function cleanup(): void {\n nodeDataChannel.cleanup();\n}\nexport function setSctpSettings(settings: SctpSettings): void {\n nodeDataChannel.setSctpSettings(settings);\n}\nexport function getLibraryVersion(): string {\n return nodeDataChannel.getLibraryVersion();\n}\n\nexport interface Audio {\n addAudioCodec(payloadType: number, codec: string, profile?: string): void;\n addOpusCodec(payloadType: number, profile?: string): string;\n direction(): Direction;\n generateSdp(eol: string, addr: string, port: number): string;\n mid(): string;\n setDirection(dir: Direction): void;\n description(): string;\n removeFormat(fmt: string): void;\n addSSRC(ssrc: number, name?: string, msid?: string, trackID?: string): void;\n removeSSRC(ssrc: number): void;\n replaceSSRC(oldSsrc: number, ssrc: number, name?: string, msid?: string, trackID?: string): void;\n hasSSRC(ssrc: number): boolean;\n getSSRCs(): number[];\n getCNameForSsrc(ssrc: number): string;\n setBitrate(bitRate: number): void;\n getBitrate(): number;\n hasPayloadType(payloadType: number): boolean;\n addRTXCodec(payloadType: number, originalPayloadType: number, clockRate: number): void;\n addRTPMap(): void;\n parseSdpLine(line: string): void;\n}\nexport const Audio: {\n new (mid: string, dir: Direction): Audio;\n} = nodeDataChannel.Audio;\n\nexport interface Video {\n addVideoCodec(payloadType: number, codec: string, profile?: string): void;\n addH264Codec(payloadType: number, profile?: string): void;\n addH265Codec(payloadType: number): void;\n addVP8Codec(payloadType: number): void;\n addVP9Codec(payloadType: number): void;\n addAV1Codec(payloadType: number): void;\n direction(): Direction;\n generateSdp(eol: string, addr: string, port: number): string;\n mid(): string;\n setDirection(dir: Direction): void;\n description(): string;\n removeFormat(fmt: string): void;\n addSSRC(ssrc: number, name?: string, msid?: string, trackID?: string): void;\n removeSSRC(ssrc: number): void;\n replaceSSRC(oldSsrc: number, ssrc: number, name?: string, msid?: string, trackID?: string): void;\n hasSSRC(ssrc: number): boolean;\n getSSRCs(): number[];\n getCNameForSsrc(ssrc: number): string;\n setBitrate(bitRate: number): void;\n getBitrate(): number;\n hasPayloadType(payloadType: number): boolean;\n addRTXCodec(payloadType: number, originalPayloadType: number, clockRate: number): void;\n addRTPMap(): void;\n parseSdpLine(line: string): void;\n}\nexport const Video: {\n new (mid: string, dir: Direction): Video;\n} = nodeDataChannel.Video;\n\nexport interface Track {\n direction(): Direction;\n mid(): string;\n type(): string;\n close(): void;\n sendMessage(msg: string): boolean;\n sendMessageBinary(buffer: Buffer): boolean;\n isOpen(): boolean;\n isClosed(): boolean;\n bufferedAmount(): number;\n maxMessageSize(): number;\n requestBitrate(bitRate: number): boolean;\n setBufferedAmountLowThreshold(newSize: number): void;\n requestKeyframe(): boolean;\n setMediaHandler(handler: MediaHandler): void;\n onOpen(cb: () => void): void;\n onClosed(cb: () => void): void;\n onError(cb: (err: string) => void): void;\n onMessage(cb: (msg: Buffer) => void): void;\n}\nexport const Track: {\n new (): Track;\n} = nodeDataChannel.Track;\n\nexport interface DataChannel extends Channel {\n getLabel(): string;\n getId(): number;\n getProtocol(): string;\n\n // Channel implementation\n close(): void;\n sendMessage(msg: string): boolean;\n sendMessageBinary(buffer: Buffer | Uint8Array): boolean;\n isOpen(): boolean;\n bufferedAmount(): number;\n maxMessageSize(): number;\n setBufferedAmountLowThreshold(newSize: number): void;\n onOpen(cb: () => void): void;\n onClosed(cb: () => void): void;\n onError(cb: (err: string) => void): void;\n onBufferedAmountLow(cb: () => void): void;\n onMessage(cb: (msg: string | Buffer | ArrayBuffer) => void): void;\n}\nexport const DataChannel: {\n // DataChannel implementation\n} = nodeDataChannel.DataChannel;\n\nexport interface PeerConnection {\n close(): void;\n setLocalDescription(type?: DescriptionType, init?: LocalDescriptionInit): void;\n setRemoteDescription(sdp: string, type: DescriptionType): void;\n localDescription(): { type: DescriptionType; sdp: string } | null;\n remoteDescription(): { type: DescriptionType; sdp: string } | null;\n remoteFingerprint(): CertificateFingerprint;\n addRemoteCandidate(candidate: string, mid: string): void;\n createDataChannel(label: string, config?: DataChannelInitConfig): DataChannel;\n addTrack(media: Video | Audio): Track;\n hasMedia(): boolean;\n state(): RTCPeerConnectionState;\n iceState(): RTCIceConnectionState;\n signalingState(): RTCSignalingState;\n gatheringState(): RTCIceGatheringState;\n onLocalDescription(cb: (sdp: string, type: DescriptionType) => void): void;\n onLocalCandidate(cb: (candidate: string, mid: string) => void): void;\n onStateChange(cb: (state: string) => void): void;\n onIceStateChange(cb: (state: string) => void): void;\n onSignalingStateChange(cb: (state: string) => void): void;\n onGatheringStateChange(cb: (state: string) => void): void;\n onDataChannel(cb: (dc: DataChannel) => void): void;\n onTrack(cb: (track: Track) => void): void;\n bytesSent(): number;\n bytesReceived(): number;\n rtt(): number;\n getSelectedCandidatePair(): {\n local: SelectedCandidateInfo;\n remote: SelectedCandidateInfo;\n } | null;\n maxDataChannelId(): number;\n maxMessageSize(): number;\n}\nexport const PeerConnection: {\n new (peerName: string, config: RtcConfig): PeerConnection;\n} = nodeDataChannel.PeerConnection;\n\nexport interface IceUdpMuxListener {\n address(): string | undefined;\n port(): number;\n stop(): void;\n onUnhandledStunRequest(cb: (req: IceUdpMuxRequest) => void): void;\n}\nexport const IceUdpMuxListener: {\n new (port: number, address?: string): IceUdpMuxListener;\n} = nodeDataChannel.IceUdpMuxListener;\n\nexport interface RtpPacketizationConfig {\n playoutDelayId: number,\n playoutDelayMin: number,\n playoutDelayMax: number,\n timestamp: number,\n get clockRate(): number\n}\n\nexport const RtpPacketizationConfig: {\n new(ssrc: number, cname: string, payloadType: number, clockRate: number, videoOrientationId?: number): RtpPacketizationConfig\n} = nodeDataChannel.RtpPacketizationConfig\n\nexport interface MediaHandler {\n addToChain(handler: MediaHandler): void\n}\n\nexport interface PacingHandler extends MediaHandler {\n setBitrate(bitsPerSecond: number): void;\n}\n\nexport const PacingHandler: {\n new (bitsPerSecond: number, sendInterval: number): PacingHandler;\n} = nodeDataChannel.PacingHandler;\n\nexport interface RtcpReceivingSession extends MediaHandler {}\n\nexport const RtcpReceivingSession: {\n new (): RtcpReceivingSession;\n} = nodeDataChannel.RtcpReceivingSession;\n\nexport interface RtcpNackResponder extends MediaHandler {}\n\nexport const RtcpNackResponder: {\n new (maxSize?: number): RtcpNackResponder\n} = nodeDataChannel.RtcpNackResponder;\n\nexport interface RtcpSrReporter extends MediaHandler {\n get rtpConfig(): RtpPacketizationConfig\n}\n\nexport const RtcpSrReporter: {\n new (rtpConfig: RtpPacketizationConfig): RtcpSrReporter\n} = nodeDataChannel.RtcpSrReporter;\n\nexport interface RtpPacketizer extends MediaHandler {\n get rtpConfig(): RtpPacketizationConfig\n}\n\nexport const RtpPacketizer: {\n new (rtpConfig: RtpPacketizationConfig): RtpPacketizer\n} = nodeDataChannel.RtpPacketizer;\n\nexport interface H264RtpPacketizer extends RtpPacketizer {}\n\nexport const H264RtpPacketizer: {\n new (separator: NalUnitSeparator, rtpConfig: RtpPacketizationConfig, maxFragmentSize?: number): H264RtpPacketizer\n} = nodeDataChannel.H264RtpPacketizer\n\nexport interface H265RtpPacketizer extends RtpPacketizer {}\n\nexport const H265RtpPacketizer: {\n new (separator: NalUnitSeparator, rtpConfig: RtpPacketizationConfig, maxFragmentSize?: number): H265RtpPacketizer\n} = nodeDataChannel.H265RtpPacketizer\n\nexport interface VP8RtpPacketizer extends RtpPacketizer {}\n\nexport const VP8RtpPacketizer: {\n new (rtpConfig: RtpPacketizationConfig, maxFragmentSize?: number): VP8RtpPacketizer\n} = nodeDataChannel.VP8RtpPacketizer\n\nexport interface VP9RtpPacketizer extends RtpPacketizer {}\n\nexport const VP9RtpPacketizer: {\n new (rtpConfig: RtpPacketizationConfig, maxFragmentSize?: number): VP9RtpPacketizer\n} = nodeDataChannel.VP9RtpPacketizer\n\nexport interface AV1RtpPacketizer extends RtpPacketizer {}\n\nexport const AV1RtpPacketizer: {\n new (packetization: ObuPacketization, rtpConfig: RtpPacketizationConfig, maxFragmentSize?: number): AV1RtpPacketizer\n} = nodeDataChannel.AV1RtpPacketizer\n\nexport { WebSocketServer } from './websocket-server';\nexport { WebSocket } from './websocket';\n\nexport const DataChannelStream = _DataChannelStream;\n\nexport default {\n initLogger,\n cleanup,\n preload,\n setSctpSettings,\n getLibraryVersion,\n PacingHandler,\n RtcpReceivingSession,\n RtcpNackResponder,\n RtcpSrReporter,\n RtpPacketizationConfig,\n RtpPacketizer,\n H264RtpPacketizer,\n H265RtpPacketizer,\n VP8RtpPacketizer,\n VP9RtpPacketizer,\n AV1RtpPacketizer,\n Track,\n Video,\n Audio,\n DataChannel,\n PeerConnection,\n WebSocket,\n WebSocketServer,\n DataChannelStream,\n IceUdpMuxListener,\n};\n\n// Types\n// https://github.com/murat-dogan/node-datachannel/issues/300\nexport * from './types';\n"],"names":["nodeDataChannel","_DataChannelStream","WebSocket","WebSocketServer"],"mappings":";;;;;;;;;AAsBO,SAAS,OAAgB,GAAA;AAC9B,EAAAA,uBAAA,CAAgB,OAAQ,EAAA,CAAA;AAC1B,CAAA;AACgB,SAAA,UAAA,CAAW,OAAiB,EAAuD,EAAA;AACjG,EAAgBA,uBAAA,CAAA,UAAA,CAAW,OAAO,EAAE,CAAA,CAAA;AACtC,CAAA;AACO,SAAS,OAAgB,GAAA;AAC9B,EAAAA,uBAAA,CAAgB,OAAQ,EAAA,CAAA;AAC1B,CAAA;AACO,SAAS,gBAAgB,QAA8B,EAAA;AAC5D,EAAAA,uBAAA,CAAgB,gBAAgB,QAAQ,CAAA,CAAA;AAC1C,CAAA;AACO,SAAS,iBAA4B,GAAA;AAC1C,EAAA,OAAOA,wBAAgB,iBAAkB,EAAA,CAAA;AAC3C,CAAA;AAwBO,MAAM,QAETA,uBAAgB,CAAA,MAAA;AA4Bb,MAAM,QAETA,uBAAgB,CAAA,MAAA;AAsBb,MAAM,QAETA,uBAAgB,CAAA,MAAA;AAqBb,MAAM,cAETA,uBAAgB,CAAA,YAAA;AAmCb,MAAM,iBAETA,uBAAgB,CAAA,eAAA;AAQb,MAAM,oBAETA,uBAAgB,CAAA,kBAAA;AAUb,MAAM,yBAETA,uBAAgB,CAAA,uBAAA;AAUb,MAAM,gBAETA,uBAAgB,CAAA,cAAA;AAIb,MAAM,uBAETA,uBAAgB,CAAA,qBAAA;AAIb,MAAM,oBAETA,uBAAgB,CAAA,kBAAA;AAMb,MAAM,iBAETA,uBAAgB,CAAA,eAAA;AAMb,MAAM,gBAETA,uBAAgB,CAAA,cAAA;AAIb,MAAM,oBAETA,uBAAgB,CAAA,kBAAA;AAIb,MAAM,oBAETA,uBAAgB,CAAA,kBAAA;AAIb,MAAM,mBAETA,uBAAgB,CAAA,iBAAA;AAIb,MAAM,mBAETA,uBAAgB,CAAA,iBAAA;AAIb,MAAM,mBAETA,uBAAgB,CAAA,iBAAA;AAKb,MAAM,iBAAoB,GAAAC,0BAAA;AAEjC,QAAe;AAAA,EACb,UAAA;AAAA,EACA,OAAA;AAAA,EACA,OAAA;AAAA,EACA,eAAA;AAAA,EACA,iBAAA;AAAA,EACA,aAAA;AAAA,EACA,oBAAA;AAAA,EACA,iBAAA;AAAA,EACA,cAAA;AAAA,EACA,sBAAA;AAAA,EACA,aAAA;AAAA,EACA,iBAAA;AAAA,EACA,iBAAA;AAAA,EACA,gBAAA;AAAA,EACA,gBAAA;AAAA,EACA,gBAAA;AAAA,EACA,KAAA;AAAA,EACA,KAAA;AAAA,EACA,KAAA;AAAA,EACA,WAAA;AAAA,EACA,cAAA;AAAA,aACAC,mBAAA;AAAA,mBACAC,+BAAA;AAAA,EACA,iBAAA;AAAA,EACA,iBAAA;AACF,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -2,10 +2,93 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
var fs = require('fs');
|
|
6
|
+
var path = require('path');
|
|
7
|
+
var detectLibc = require('detect-libc');
|
|
8
|
+
|
|
9
|
+
function _interopNamespaceDefault(e) {
|
|
10
|
+
var n = Object.create(null);
|
|
11
|
+
if (e) {
|
|
12
|
+
Object.keys(e).forEach(function (k) {
|
|
13
|
+
if (k !== 'default') {
|
|
14
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
15
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
get: function () { return e[k]; }
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
n.default = e;
|
|
23
|
+
return Object.freeze(n);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
var fs__namespace = /*#__PURE__*/_interopNamespaceDefault(fs);
|
|
27
|
+
var path__namespace = /*#__PURE__*/_interopNamespaceDefault(path);
|
|
28
|
+
|
|
29
|
+
function getPackageName() {
|
|
30
|
+
const { platform, arch } = process;
|
|
31
|
+
if (platform === "linux") {
|
|
32
|
+
const libc = detectLibc.familySync();
|
|
33
|
+
if (libc === detectLibc.MUSL) {
|
|
34
|
+
if (arch === "x64") return "@lng2004/ndc-linux-x64-musl";
|
|
35
|
+
if (arch === "arm64") return "@lng2004/ndc-linux-arm64-musl";
|
|
36
|
+
} else {
|
|
37
|
+
if (arch === "x64") return "@lng2004/ndc-linux-x64-gnu";
|
|
38
|
+
if (arch === "arm64") return "@lng2004/ndc-linux-arm64-gnu";
|
|
39
|
+
}
|
|
40
|
+
} else if (platform === "darwin") {
|
|
41
|
+
if (arch === "arm64") return "@lng2004/ndc-darwin-arm64";
|
|
42
|
+
if (arch === "x64") return "@lng2004/ndc-darwin-x64";
|
|
43
|
+
} else if (platform === "win32") {
|
|
44
|
+
if (arch === "x64") return "@lng2004/ndc-win32-x64-msvc";
|
|
45
|
+
if (arch === "arm64") return "@lng2004/ndc-win32-arm64-msvc";
|
|
46
|
+
} else if (platform === "android") {
|
|
47
|
+
if (arch === "arm64") return "@lng2004/ndc-android-arm64";
|
|
48
|
+
}
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
function loadBinding() {
|
|
52
|
+
const candidateLocalPaths = [
|
|
53
|
+
path__namespace.resolve(__dirname, "../../build/node_datachannel.node"),
|
|
54
|
+
path__namespace.resolve(__dirname, "../../../build/node_datachannel.node"),
|
|
55
|
+
path__namespace.resolve(__dirname, "../../build/Release/node_datachannel.node"),
|
|
56
|
+
path__namespace.resolve(__dirname, "../../../build/Release/node_datachannel.node"),
|
|
57
|
+
path__namespace.resolve(__dirname, "../../build/Debug/node_datachannel.node"),
|
|
58
|
+
path__namespace.resolve(__dirname, "../../../build/Debug/node_datachannel.node")
|
|
59
|
+
];
|
|
60
|
+
let localLoadError = null;
|
|
61
|
+
for (const candidate of candidateLocalPaths) {
|
|
62
|
+
if (fs__namespace.existsSync(candidate)) {
|
|
63
|
+
try {
|
|
64
|
+
return require(candidate);
|
|
65
|
+
} catch (err) {
|
|
66
|
+
localLoadError = err instanceof Error ? err : new Error(String(err));
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
if (localLoadError) {
|
|
71
|
+
throw new Error(
|
|
72
|
+
`Failed to load local native addon build: ${localLoadError.message}
|
|
73
|
+
Stack: ${localLoadError.stack}`
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
const pkgName = getPackageName();
|
|
77
|
+
if (pkgName) {
|
|
78
|
+
try {
|
|
79
|
+
return require(pkgName);
|
|
80
|
+
} catch (err) {
|
|
81
|
+
const errorMsg = err instanceof Error ? err.message : String(err);
|
|
82
|
+
throw new Error(
|
|
83
|
+
`Cannot load native addon for node-datachannel on ${process.platform} (${process.arch}). Attempted to require "${pkgName}". Please ensure optionalDependencies are installed (avoid --no-optional / --omit=optional) or compile locally with "npm run compile". (Error: ${errorMsg})`
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
throw new Error(
|
|
88
|
+
`Unsupported platform/architecture for node-datachannel: ${process.platform} (${process.arch}). Please compile from source using "npm run compile".`
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
const nodeDataChannel = loadBinding();
|
|
9
92
|
|
|
10
93
|
exports.default = nodeDataChannel;
|
|
11
94
|
//# sourceMappingURL=node-datachannel.cjs.map
|