@lng2004/node-datachannel 0.32.0-20260202 → 0.32.3-20260813
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/CMakeLists.txt +4 -2
- package/README.md +12 -0
- package/binding-options.js +7 -0
- package/cmake/toolchain/ci.cmake +23 -0
- package/dist/cjs/lib/index.cjs +4 -2
- package/dist/cjs/lib/index.cjs.map +1 -1
- package/dist/cjs/lib/node-datachannel.cjs +4 -1
- package/dist/cjs/lib/node-datachannel.cjs.map +1 -1
- package/dist/esm/lib/index.mjs +4 -2
- package/dist/esm/lib/index.mjs.map +1 -1
- package/dist/esm/lib/node-datachannel.mjs +4 -1
- package/dist/esm/lib/node-datachannel.mjs.map +1 -1
- package/dist/types/lib/index.d.ts +17 -3
- package/dist/types/lib/types.d.ts +1 -0
- package/package.json +12 -5
- package/src/cpp/ice-udp-mux-listener-wrapper.cpp +1 -0
- package/src/cpp/main.cpp +4 -0
- package/src/cpp/media-mediahandler-helper.cpp +6 -0
- package/src/cpp/media-pacinghandler-wrapper.cpp +18 -0
- package/src/cpp/media-pacinghandler-wrapper.h +1 -0
- package/src/cpp/media-vp8rtppacketizer-wrapper.cpp +110 -0
- package/src/cpp/media-vp8rtppacketizer-wrapper.h +30 -0
- package/src/cpp/media-vp9rtppacketizer-wrapper.cpp +110 -0
- package/src/cpp/media-vp9rtppacketizer-wrapper.h +30 -0
- package/.clang-format +0 -17
- package/.editorconfig +0 -12
- package/.eslintignore +0 -8
- package/.eslintrc.json +0 -27
- package/.gitmodules +0 -3
- package/.prettierignore +0 -7
- package/.prettierrc +0 -13
- package/API.md +0 -247
- package/BULDING.md +0 -33
- package/jest.config.ts +0 -14
- package/rollup.config.mjs +0 -72
- package/src/index.ts +0 -9
- package/src/lib/datachannel-stream.ts +0 -100
- package/src/lib/index.ts +0 -290
- package/src/lib/node-datachannel.ts +0 -3
- package/src/lib/types.ts +0 -168
- package/src/lib/websocket-server.ts +0 -37
- package/src/lib/websocket.ts +0 -26
- package/src/polyfill/Events.ts +0 -82
- package/src/polyfill/Exception.ts +0 -37
- package/src/polyfill/README.md +0 -41
- package/src/polyfill/RTCCertificate.ts +0 -21
- package/src/polyfill/RTCDataChannel.ts +0 -225
- package/src/polyfill/RTCDtlsTransport.ts +0 -46
- package/src/polyfill/RTCError.ts +0 -78
- package/src/polyfill/RTCIceCandidate.ts +0 -128
- package/src/polyfill/RTCIceTransport.ts +0 -90
- package/src/polyfill/RTCPeerConnection.ts +0 -527
- package/src/polyfill/RTCSctpTransport.ts +0 -51
- package/src/polyfill/RTCSessionDescription.ts +0 -41
- package/src/polyfill/index.ts +0 -38
- package/tsconfig.json +0 -21
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
#include "media-vp9rtppacketizer-wrapper.h"
|
|
2
|
+
#include "media-rtppacketizationconfig-wrapper.h"
|
|
3
|
+
#include "media-mediahandler-helper.h"
|
|
4
|
+
|
|
5
|
+
Napi::FunctionReference VP9RtpPacketizerWrapper::constructor = Napi::FunctionReference();
|
|
6
|
+
|
|
7
|
+
Napi::Object VP9RtpPacketizerWrapper::Init(Napi::Env env, Napi::Object exports)
|
|
8
|
+
{
|
|
9
|
+
Napi::HandleScope scope(env);
|
|
10
|
+
|
|
11
|
+
Napi::Function func = Napi::ObjectWrap<VP9RtpPacketizerWrapper>::DefineClass(env, "VP9RtpPacketizer",
|
|
12
|
+
{
|
|
13
|
+
// Instance Methods
|
|
14
|
+
InstanceMethod("addToChain", &VP9RtpPacketizerWrapper::addToChain),
|
|
15
|
+
// Accessors
|
|
16
|
+
InstanceAccessor("rtpConfig", &VP9RtpPacketizerWrapper::getRtpPacketizationConfig, nullptr),
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
// If this is not the first call, we don't want to reassign the constructor (hot-reload problem)
|
|
20
|
+
if (constructor.IsEmpty())
|
|
21
|
+
{
|
|
22
|
+
constructor = Napi::Persistent(func);
|
|
23
|
+
constructor.SuppressDestruct();
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
exports.Set("VP9RtpPacketizer", func);
|
|
27
|
+
return exports;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
VP9RtpPacketizerWrapper::VP9RtpPacketizerWrapper(const Napi::CallbackInfo &info)
|
|
31
|
+
: Napi::ObjectWrap<VP9RtpPacketizerWrapper>(info)
|
|
32
|
+
{
|
|
33
|
+
Napi::Env env = info.Env();
|
|
34
|
+
|
|
35
|
+
if (info.Length() < 2)
|
|
36
|
+
{
|
|
37
|
+
Napi::Error::New(env, "Expected 2 parameters").ThrowAsJavaScriptException();
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (!info[0].IsObject())
|
|
42
|
+
{
|
|
43
|
+
Napi::TypeError::New(env, "rtpConfig must be a RtpPacketizationConfig instance").ThrowAsJavaScriptException();
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
auto obj = info[0].As<Napi::Object>();
|
|
47
|
+
if (!obj.InstanceOf(RtpPacketizationConfigWrapper::constructor.Value()))
|
|
48
|
+
{
|
|
49
|
+
Napi::TypeError::New(env, "rtpConfig must be a RtpPacketizationConfig instance").ThrowAsJavaScriptException();
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
// store original JS object so we can return it later
|
|
53
|
+
mRtpConfigObject = Napi::Persistent(obj);
|
|
54
|
+
mRtpConfigObject.SuppressDestruct();
|
|
55
|
+
auto rtpConfig = RtpPacketizationConfigWrapper::Unwrap(obj)->getConfigInstance();
|
|
56
|
+
|
|
57
|
+
size_t maxFragmentSize = rtc::RtpPacketizer::DefaultMaxFragmentSize;
|
|
58
|
+
if (info.Length() >= 2)
|
|
59
|
+
{
|
|
60
|
+
if (!info[1].IsNumber())
|
|
61
|
+
{
|
|
62
|
+
Napi::TypeError::New(env, "maxFragmentSize must be a number").ThrowAsJavaScriptException();
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
maxFragmentSize = info[1].As<Napi::Number>().Uint32Value();
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
mPacketizerPtr = std::make_unique<rtc::VP9RtpPacketizer>(rtpConfig, maxFragmentSize);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
VP9RtpPacketizerWrapper::~VP9RtpPacketizerWrapper()
|
|
72
|
+
{
|
|
73
|
+
mPacketizerPtr.reset();
|
|
74
|
+
mRtpConfigObject.Reset();
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
std::shared_ptr<rtc::VP9RtpPacketizer> VP9RtpPacketizerWrapper::getPacketizerInstance() { return mPacketizerPtr; }
|
|
78
|
+
|
|
79
|
+
void VP9RtpPacketizerWrapper::addToChain(const Napi::CallbackInfo &info)
|
|
80
|
+
{
|
|
81
|
+
auto env = info.Env();
|
|
82
|
+
if (info.Length() < 1 || !info[0].IsObject())
|
|
83
|
+
{
|
|
84
|
+
Napi::TypeError::New(env, "Expected a MediaHandler instance").ThrowAsJavaScriptException();
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
auto mediaHandler = asMediaHandler(info[0].As<Napi::Object>());
|
|
88
|
+
if (!mediaHandler)
|
|
89
|
+
{
|
|
90
|
+
Napi::TypeError::New(env, "Expected a MediaHandler instance. If this error is unexpected, please report a bug!")
|
|
91
|
+
.ThrowAsJavaScriptException();
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
mPacketizerPtr->addToChain(mediaHandler);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
Napi::Value VP9RtpPacketizerWrapper::getRtpPacketizationConfig(const Napi::CallbackInfo &info)
|
|
98
|
+
{
|
|
99
|
+
Napi::Env env = info.Env();
|
|
100
|
+
if (!mPacketizerPtr)
|
|
101
|
+
{
|
|
102
|
+
Napi::Error::New(env, "getRtpPacketizationConfig() called on destroyed packetizer").ThrowAsJavaScriptException();
|
|
103
|
+
return env.Null();
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
if (mRtpConfigObject.IsEmpty())
|
|
107
|
+
return env.Null();
|
|
108
|
+
|
|
109
|
+
return mRtpConfigObject.Value();
|
|
110
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
#ifndef MEDIA_VP9RTPPACKETIZER_WRAPPER_H
|
|
2
|
+
#define MEDIA_VP9RTPPACKETIZER_WRAPPER_H
|
|
3
|
+
|
|
4
|
+
#include <memory>
|
|
5
|
+
#include <unordered_set>
|
|
6
|
+
|
|
7
|
+
#include <napi.h>
|
|
8
|
+
#include <rtc/rtc.hpp>
|
|
9
|
+
|
|
10
|
+
class VP9RtpPacketizerWrapper : public Napi::ObjectWrap<VP9RtpPacketizerWrapper>
|
|
11
|
+
{
|
|
12
|
+
public:
|
|
13
|
+
static Napi::FunctionReference constructor;
|
|
14
|
+
static Napi::Object Init(Napi::Env env, Napi::Object exports);
|
|
15
|
+
VP9RtpPacketizerWrapper(const Napi::CallbackInfo &info);
|
|
16
|
+
~VP9RtpPacketizerWrapper();
|
|
17
|
+
std::shared_ptr<rtc::VP9RtpPacketizer> getPacketizerInstance();
|
|
18
|
+
|
|
19
|
+
// Functions
|
|
20
|
+
Napi::Value getRtpPacketizationConfig(const Napi::CallbackInfo &info);
|
|
21
|
+
void addToChain(const Napi::CallbackInfo &info);
|
|
22
|
+
|
|
23
|
+
// Callbacks
|
|
24
|
+
|
|
25
|
+
private:
|
|
26
|
+
std::shared_ptr<rtc::VP9RtpPacketizer> mPacketizerPtr = nullptr;
|
|
27
|
+
Napi::ObjectReference mRtpConfigObject;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
#endif // MEDIA_VP9RTPPACKETIZER_WRAPPER_H
|
package/.clang-format
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
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
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
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
DELETED
package/.eslintrc.json
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
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
DELETED
package/.prettierignore
DELETED
package/.prettierrc
DELETED
package/API.md
DELETED
|
@@ -1,247 +0,0 @@
|
|
|
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
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
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 i
|
|
14
|
-
```
|
|
15
|
-
|
|
16
|
-
Other Options
|
|
17
|
-
|
|
18
|
-
```sh
|
|
19
|
-
# Use GnuTLS instead of OpenSSL (Default False)
|
|
20
|
-
> npm run install-gnu-tls
|
|
21
|
-
|
|
22
|
-
# Use libnice instead of libjuice (Default False)
|
|
23
|
-
# libnice-dev packet should be installed. (eg. sudo apt install libnice-dev)
|
|
24
|
-
> npm run install-nice
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
Compile without Media and Websocket
|
|
28
|
-
|
|
29
|
-
```sh
|
|
30
|
-
npx cmake-js clean
|
|
31
|
-
npx cmake-js configure --CDNO_MEDIA=ON --CDNO_WEBSOCKET=ON
|
|
32
|
-
npx cmake-js build
|
|
33
|
-
```
|
package/jest.config.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { Config } from 'jest';
|
|
2
|
-
|
|
3
|
-
const config: Config = {
|
|
4
|
-
clearMocks: true,
|
|
5
|
-
collectCoverage: false,
|
|
6
|
-
coverageDirectory: 'coverage',
|
|
7
|
-
coverageProvider: 'v8',
|
|
8
|
-
preset: 'ts-jest',
|
|
9
|
-
testEnvironment: 'jest-environment-node',
|
|
10
|
-
testRegex: '(/test/jest-tests/.*|(\\.|/)(test|spec))\\.(m)?ts$',
|
|
11
|
-
testPathIgnorePatterns: ['node_modules', 'multiple-run.test'],
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
export default config;
|
package/rollup.config.mjs
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import dts from 'rollup-plugin-dts';
|
|
2
|
-
import esbuild from 'rollup-plugin-esbuild';
|
|
3
|
-
import esmShim from '@rollup/plugin-esm-shim';
|
|
4
|
-
import replace from '@rollup/plugin-replace';
|
|
5
|
-
|
|
6
|
-
const external = (id) => {
|
|
7
|
-
return !/^[./]/.test(id);
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
const bundle = (config) => ({
|
|
11
|
-
...config,
|
|
12
|
-
input: 'src/index.ts',
|
|
13
|
-
external: ['events','stream'] // <-- suppresses the warning for these built-in modules
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
export default [
|
|
17
|
-
bundle({
|
|
18
|
-
plugins: [
|
|
19
|
-
replace({
|
|
20
|
-
include: 'src/lib/node-datachannel.ts',
|
|
21
|
-
preventAssignment: true,
|
|
22
|
-
"require('../../build": "require('../../../build",
|
|
23
|
-
}),
|
|
24
|
-
esmShim(),
|
|
25
|
-
esbuild(),
|
|
26
|
-
],
|
|
27
|
-
output: [
|
|
28
|
-
{
|
|
29
|
-
dir: 'dist/esm',
|
|
30
|
-
format: 'es',
|
|
31
|
-
exports: 'named',
|
|
32
|
-
sourcemap: true,
|
|
33
|
-
entryFileNames: '[name].mjs',
|
|
34
|
-
preserveModules: true, // Keep directory structure and files
|
|
35
|
-
},
|
|
36
|
-
{
|
|
37
|
-
dir: 'dist/cjs',
|
|
38
|
-
format: 'cjs',
|
|
39
|
-
exports: 'named',
|
|
40
|
-
sourcemap: true,
|
|
41
|
-
entryFileNames: '[name].cjs',
|
|
42
|
-
preserveModules: true, // Keep directory structure and files
|
|
43
|
-
},
|
|
44
|
-
],
|
|
45
|
-
}),
|
|
46
|
-
// types
|
|
47
|
-
{
|
|
48
|
-
plugins: [dts()],
|
|
49
|
-
input: 'src/lib/index.ts',
|
|
50
|
-
external,
|
|
51
|
-
output: {
|
|
52
|
-
dir: 'dist/types/lib',
|
|
53
|
-
format: 'cjs',
|
|
54
|
-
exports: 'named',
|
|
55
|
-
preserveModules: true, // Keep directory structure and files
|
|
56
|
-
},
|
|
57
|
-
},
|
|
58
|
-
{
|
|
59
|
-
plugins: [dts()],
|
|
60
|
-
input: 'src/polyfill/index.ts',
|
|
61
|
-
external: (id) => {
|
|
62
|
-
if (id.startsWith('../lib')) return true;
|
|
63
|
-
return !/^[./]/.test(id);
|
|
64
|
-
},
|
|
65
|
-
output: {
|
|
66
|
-
dir: 'dist/types/polyfill',
|
|
67
|
-
format: 'cjs',
|
|
68
|
-
exports: 'named',
|
|
69
|
-
preserveModules: true, // Keep directory structure and files
|
|
70
|
-
},
|
|
71
|
-
},
|
|
72
|
-
];
|
package/src/index.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
// This file is created for builder process
|
|
2
|
-
// So builder can find and compile all files and folders
|
|
3
|
-
// Not intended to be imported directly
|
|
4
|
-
|
|
5
|
-
import n from './lib/index';
|
|
6
|
-
import p from './polyfill/index';
|
|
7
|
-
|
|
8
|
-
export const nodeDataChannel = n;
|
|
9
|
-
export const polyfill = p;
|