node-datachannel 0.9.2 → 0.10.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/.github/workflows/build-linux.yml +75 -82
- package/API.md +17 -20
- package/CMakeLists.txt +1 -1
- package/README.md +5 -9
- package/build-containers/Dockerfile.alpine +6 -0
- package/build-containers/Dockerfile.debian +7 -0
- package/cmake/toolchain/ci.cmake +23 -0
- package/examples/client-server/package-lock.json +6 -6
- package/lib/index.d.cts +4 -18
- package/lib/index.d.ts +4 -18
- package/package.json +1 -1
- package/src/media-rtcpreceivingsession-wrapper.cpp +1 -23
- package/src/media-rtcpreceivingsession-wrapper.h +2 -5
- package/src/peer-connection-wrapper.cpp +6 -70
- package/cmake/toolchain/arm64.cmake +0 -17
- package/cmake/toolchain/armv7.cmake +0 -17
|
@@ -14,98 +14,91 @@ jobs:
|
|
|
14
14
|
runs-on: ubuntu-20.04
|
|
15
15
|
strategy:
|
|
16
16
|
matrix:
|
|
17
|
-
node-version: [
|
|
17
|
+
node-version: [16]
|
|
18
|
+
arch: [amd64, arm64, arm]
|
|
19
|
+
platform: [debian, alpine]
|
|
20
|
+
include:
|
|
21
|
+
# Set baselines per platform
|
|
22
|
+
- triple: "alpine-linux-musl"
|
|
23
|
+
platform: alpine
|
|
24
|
+
version: 3.16
|
|
25
|
+
libc: musl
|
|
26
|
+
gcc_install: clang lld
|
|
27
|
+
gcc: clang
|
|
28
|
+
# libc is intentionally not set here, as prebuild-install requires libc to not be set for glibc builds
|
|
29
|
+
- triple: "linux-gnu"
|
|
30
|
+
platform: debian
|
|
31
|
+
version: bullseye
|
|
32
|
+
# Set baselines per architecture
|
|
33
|
+
- triple_arch: x86_64
|
|
34
|
+
node_arch: x64
|
|
35
|
+
arch: amd64
|
|
36
|
+
- triple_arch: armv7
|
|
37
|
+
node_arch: arm
|
|
38
|
+
triple_postfix: eabihf
|
|
39
|
+
arch: arm
|
|
40
|
+
flags: -march=armv7-a -mfpu=neon-vfpv4 -mfloat-abi=hard -fPIC
|
|
41
|
+
- triple_arch: aarch64
|
|
42
|
+
node_arch: arm64
|
|
43
|
+
arch: arm64
|
|
44
|
+
flags: -march=armv8-a -fPIC
|
|
45
|
+
# Set edge case overrides for specific platform + architecture
|
|
46
|
+
# also define gcc commands for each architecture
|
|
47
|
+
- arch: amd64
|
|
48
|
+
platform: debian
|
|
49
|
+
gcc_install: gcc g++
|
|
50
|
+
gcc: gcc
|
|
51
|
+
- arch: arm64
|
|
52
|
+
platform: debian
|
|
53
|
+
gcc_install: gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
|
|
54
|
+
gcc: aarch64-linux-gnu-gcc
|
|
55
|
+
# debian uses the triple `arm-linux-gnueabihf` instead of alpine's `armv7-alpine-linux-musleabihf`
|
|
56
|
+
# because of this, we explicitly override triple_arch for debian arm
|
|
57
|
+
- triple_arch: arm
|
|
58
|
+
arch: arm
|
|
59
|
+
platform: debian
|
|
60
|
+
gcc_install: gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf
|
|
61
|
+
gcc: arm-linux-gnueabihf-gcc
|
|
18
62
|
|
|
19
63
|
steps:
|
|
20
|
-
- uses: actions/checkout@
|
|
64
|
+
- uses: actions/checkout@v4
|
|
21
65
|
- name: Use Node.js ${{ matrix.node-version }}
|
|
22
|
-
uses: actions/setup-node@
|
|
66
|
+
uses: actions/setup-node@v4
|
|
23
67
|
with:
|
|
24
68
|
node-version: ${{ matrix.node-version }}
|
|
25
|
-
- name:
|
|
26
|
-
run: npm install --
|
|
69
|
+
- name: Install node dependencies
|
|
70
|
+
run: npm install --ignore-scripts
|
|
27
71
|
env:
|
|
28
72
|
CI: true
|
|
29
|
-
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
CI: true
|
|
33
|
-
- name: Upload
|
|
34
|
-
run: node_modules/.bin/prebuild -r napi --upload -u ${{ secrets.GITHUB_TOKEN }}
|
|
35
|
-
env:
|
|
36
|
-
CI: true
|
|
37
|
-
|
|
38
|
-
build-linux-armv7:
|
|
39
|
-
runs-on: ubuntu-20.04
|
|
40
|
-
|
|
41
|
-
strategy:
|
|
42
|
-
matrix:
|
|
43
|
-
node-version: [16.x]
|
|
44
|
-
steps:
|
|
45
|
-
- uses: actions/checkout@v2
|
|
46
|
-
- name: Prepare Cross Compile
|
|
47
|
-
run: |
|
|
48
|
-
sudo apt update
|
|
49
|
-
sudo apt install -y g++-arm-linux-gnueabihf gcc-arm-linux-gnueabihf
|
|
50
|
-
mkdir sysroot && cd sysroot
|
|
51
|
-
wget https://commondatastorage.googleapis.com/chrome-linux-sysroot/toolchain/ef5c4f84bcafb7a3796d36bb1db7826317dde51c/debian_sid_arm_sysroot.tar.xz
|
|
52
|
-
tar xf debian_sid_arm_sysroot.tar.xz
|
|
53
|
-
echo "ARM_SYSROOT=$(pwd)" >> $GITHUB_ENV
|
|
54
|
-
ls -l
|
|
55
|
-
- name: Use Node.js ${{ matrix.node-version }}
|
|
56
|
-
uses: actions/setup-node@v1
|
|
73
|
+
- if: matrix.arch != 'amd64'
|
|
74
|
+
name: Set up QEMU
|
|
75
|
+
uses: docker/setup-qemu-action@v3
|
|
57
76
|
with:
|
|
58
|
-
|
|
59
|
-
- name:
|
|
77
|
+
platforms: ${{ matrix.arch }}
|
|
78
|
+
- name: Install system dependencies
|
|
60
79
|
run: |
|
|
61
|
-
|
|
62
|
-
|
|
80
|
+
sudo apt update
|
|
81
|
+
sudo apt install -y podman ninja-build ${{ matrix.gcc_install }}
|
|
82
|
+
- name: List installed libc
|
|
83
|
+
run: apt list --installed | grep libc6-dev
|
|
84
|
+
- name: Build sysroot
|
|
85
|
+
run: sudo podman build --isolation=chroot -t ndc-buildroot:${{ matrix.platform }}-${{ matrix.arch }} ./build-containers --file Dockerfile.${{ matrix.platform }} --platform linux/${{ matrix.arch }} --build-arg="version=${{ matrix.version }}" --build-arg="node_version=${{ matrix.node-version }}"
|
|
86
|
+
- name: Mount sysroot
|
|
87
|
+
id: sysroot
|
|
88
|
+
run: echo "sysroot=$(sudo podman image mount ndc-buildroot:${{ matrix.platform }}-${{ matrix.arch }})" >> $GITHUB_OUTPUT
|
|
89
|
+
- name: Build
|
|
90
|
+
run: sudo --preserve-env=SYSROOT,TRIPLE,COMPILER_FLAGS,LIBC,GCC,CI,PATH node_modules/.bin/prebuild --arch ${{ matrix.node_arch }} -r napi --backend cmake-js -- --CDCMAKE_TOOLCHAIN_FILE:FILEPATH=./cmake/toolchain/ci.cmake
|
|
63
91
|
env:
|
|
92
|
+
SYSROOT: ${{ steps.sysroot.outputs.sysroot }}
|
|
93
|
+
TRIPLE: ${{ matrix.triple_arch }}-${{ matrix.triple }}${{ matrix.triple_postfix }}
|
|
94
|
+
COMPILER_FLAGS: ${{ matrix.flags }}
|
|
95
|
+
LIBC: ${{ matrix.libc }}
|
|
96
|
+
GCC: ${{ matrix.gcc }}
|
|
64
97
|
CI: true
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
strategy:
|
|
70
|
-
matrix:
|
|
71
|
-
node-version: [16.x]
|
|
72
|
-
steps:
|
|
73
|
-
- uses: actions/checkout@v2
|
|
74
|
-
- name: Prepare Cross Compile
|
|
75
|
-
run: |
|
|
76
|
-
sudo apt update
|
|
77
|
-
sudo apt install -y g++-aarch64-linux-gnu gcc-aarch64-linux-gnu
|
|
78
|
-
mkdir sysroot && cd sysroot
|
|
79
|
-
wget https://commondatastorage.googleapis.com/chrome-linux-sysroot/toolchain/41a6c8dec4c4304d6509e30cbaf9218dffb4438e/debian_bullseye_arm64_sysroot.tar.xz
|
|
80
|
-
tar xf debian_bullseye_arm64_sysroot.tar.xz
|
|
81
|
-
echo "ARM64_SYSROOT=$(pwd)" >> $GITHUB_ENV
|
|
82
|
-
ls -l
|
|
83
|
-
- name: Use Node.js ${{ matrix.node-version }}
|
|
84
|
-
uses: actions/setup-node@v1
|
|
85
|
-
with:
|
|
86
|
-
node-version: ${{ matrix.node-version }}
|
|
87
|
-
- name: Build & Upload
|
|
88
|
-
run: |
|
|
89
|
-
npm install --ignore-scripts
|
|
90
|
-
node_modules/.bin/prebuild -r napi --backend cmake-js --arch arm64 --upload -u ${{ secrets.GITHUB_TOKEN }} -- --CDCMAKE_TOOLCHAIN_FILE:FILEPATH=./cmake/toolchain/arm64.cmake
|
|
98
|
+
- name: Test
|
|
99
|
+
run: sudo podman run --rm -v $(pwd):/usr/app/ -e CI=true --platform linux/${{ matrix.arch }} -t ndc-buildroot:${{ matrix.platform }}-${{ matrix.arch }} npm run test
|
|
100
|
+
- name: Upload
|
|
101
|
+
run: sudo --preserve-env=CI,LIBC node_modules/.bin/prebuild --arch ${{ matrix.node_arch }} -r napi --upload -u ${{ secrets.GITHUB_TOKEN }}
|
|
91
102
|
env:
|
|
103
|
+
LIBC: ${{ matrix.libc }}
|
|
92
104
|
CI: true
|
|
93
|
-
|
|
94
|
-
# npm-publish:
|
|
95
|
-
# needs: [build-linux, build-linux-armv7, build-linux-arm64]
|
|
96
|
-
# name: npm-publish
|
|
97
|
-
# runs-on: ubuntu-latest
|
|
98
|
-
# steps:
|
|
99
|
-
# - name: Checkout repository
|
|
100
|
-
# uses: actions/checkout@v2
|
|
101
|
-
# - name: Set up Node.js
|
|
102
|
-
# uses: actions/setup-node@v1
|
|
103
|
-
# with:
|
|
104
|
-
# node-version: 16.x
|
|
105
|
-
# registry-url: "https://registry.npmjs.org"
|
|
106
|
-
# - name: Publish
|
|
107
|
-
# run: |
|
|
108
|
-
# npm install
|
|
109
|
-
# npm publish
|
|
110
|
-
# env:
|
|
111
|
-
# NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
|
package/API.md
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
# API
|
|
2
2
|
|
|
3
|
-
##
|
|
3
|
+
## PeerConnection Class
|
|
4
4
|
|
|
5
5
|
**Constructor**
|
|
6
6
|
|
|
7
7
|
let pc = new PeerConnection(peerName[,options])
|
|
8
|
-
|
|
9
|
-
-
|
|
8
|
+
|
|
9
|
+
- peerName `<string>` Peer name to use for logs etc..
|
|
10
|
+
- options `<Object>` WebRTC Config Options
|
|
11
|
+
|
|
10
12
|
```
|
|
11
13
|
export interface RtcConfig {
|
|
12
14
|
iceServers: (string | IceServer)[];
|
|
@@ -57,6 +59,7 @@ Close Peer Connection & Clear all callbacks
|
|
|
57
59
|
**setRemoteDescription: (sdp: string, type: DescriptionType) => void**
|
|
58
60
|
|
|
59
61
|
Set Remote Description
|
|
62
|
+
|
|
60
63
|
```
|
|
61
64
|
export const enum DescriptionType {
|
|
62
65
|
Unspec = 'Unspec',
|
|
@@ -72,29 +75,21 @@ Add remote candidate info
|
|
|
72
75
|
**createDataChannel: (label: string, config?: DataChannelInitConfig) => DataChannel**
|
|
73
76
|
|
|
74
77
|
Create new data-channel
|
|
75
|
-
|
|
76
|
-
|
|
78
|
+
|
|
79
|
+
- label `<string>` Data channel name
|
|
80
|
+
- config `<Object>` Data channel options
|
|
81
|
+
|
|
77
82
|
```
|
|
78
83
|
export interface DataChannelInitConfig {
|
|
79
84
|
protocol?: string;
|
|
80
85
|
negotiated?: boolean;
|
|
81
86
|
id?: number;
|
|
82
|
-
|
|
83
|
-
maxPacketLifeTime?: number;
|
|
84
|
-
maxRetransmits?: number;
|
|
85
|
-
|
|
86
|
-
// Deprecated, use ordered, maxPacketLifeTime, and maxRetransmits
|
|
87
|
-
reliability?: {
|
|
88
|
-
type?: ReliabilityType;
|
|
89
|
-
unordered?: boolean;
|
|
90
|
-
rexmit?: number;
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
export const enum ReliabilityType {
|
|
95
|
-
Reliable = 0, Rexmit = 1, Timed = 2
|
|
87
|
+
unordered?: boolean; // Reliability
|
|
88
|
+
maxPacketLifeTime?: number; // Reliability
|
|
89
|
+
maxRetransmits?: number; // Reliability
|
|
96
90
|
}
|
|
97
91
|
```
|
|
92
|
+
|
|
98
93
|
**state: () => string**
|
|
99
94
|
|
|
100
95
|
Get current state
|
|
@@ -110,6 +105,7 @@ Get current gathering state
|
|
|
110
105
|
**onLocalDescription: (cb: (sdp: string, type: DescriptionType) => void) => void**
|
|
111
106
|
|
|
112
107
|
Local Description Callback
|
|
108
|
+
|
|
113
109
|
```
|
|
114
110
|
export const enum DescriptionType {
|
|
115
111
|
Unspec = 'Unspec',
|
|
@@ -153,6 +149,7 @@ Get rtt stat
|
|
|
153
149
|
**getSelectedCandidatePair: () => { local: SelectedCandidateInfo, remote: SelectedCandidateInfo }**
|
|
154
150
|
|
|
155
151
|
Get info about selected candidate pair
|
|
152
|
+
|
|
156
153
|
```
|
|
157
154
|
export interface SelectedCandidateInfo {
|
|
158
155
|
address: string;
|
|
@@ -162,7 +159,7 @@ export interface SelectedCandidateInfo {
|
|
|
162
159
|
}
|
|
163
160
|
```
|
|
164
161
|
|
|
165
|
-
##
|
|
162
|
+
## DataChannel Class
|
|
166
163
|
|
|
167
164
|
> You can create a new Datachannel instance by calling `PeerConnection.createDataChannel` function.
|
|
168
165
|
|
package/CMakeLists.txt
CHANGED
package/README.md
CHANGED
|
@@ -22,15 +22,11 @@ npm install node-datachannel
|
|
|
22
22
|
|
|
23
23
|
`node-datachannel` targets N-API version 8 and supports NodeJS v16 and above. It is tested on Linux, Windows and MacOS. For N-API compatibility please check [here](https://nodejs.org/api/n-api.html#n_api_n_api_version_matrix).
|
|
24
24
|
|
|
25
|
-
|
|
|
26
|
-
|
|
|
27
|
-
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
| Node V19 | + | + | + | + | + | + |
|
|
31
|
-
| Node V20 | + | + | + | + | + | + |
|
|
32
|
-
|
|
33
|
-
1. Please note that; For Linux-arm64 platform we need OpenSSL to be installed locally.
|
|
25
|
+
| | Linux [x64,armv7,arm64] (1) | Windows [x86,x64] | Mac [M1,x64] |
|
|
26
|
+
| ----------------------- | :-------------------------: | :---------------: | :----------: |
|
|
27
|
+
| NAPI V8 (>= NodeJS V16) | + | + | + |
|
|
28
|
+
|
|
29
|
+
**(1)** For Linux musl + libc
|
|
34
30
|
|
|
35
31
|
## Electron
|
|
36
32
|
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
set(CMAKE_SYSTEM_NAME Linux)
|
|
2
|
+
set(triple $ENV{TRIPLE})
|
|
3
|
+
|
|
4
|
+
# use clang and lld
|
|
5
|
+
set(CMAKE_C_COMPILER $ENV{GCC})
|
|
6
|
+
set(CMAKE_CXX_COMPILER $ENV{GCC})
|
|
7
|
+
if (CMAKE_C_COMPILER MATCHES clang)
|
|
8
|
+
add_link_options("-fuse-ld=lld")
|
|
9
|
+
endif()
|
|
10
|
+
|
|
11
|
+
set(CMAKE_SYSROOT "$ENV{SYSROOT}")
|
|
12
|
+
message(STATUS "Using sysroot: ${CMAKE_SYSROOT}")
|
|
13
|
+
|
|
14
|
+
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
|
|
15
|
+
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
|
16
|
+
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
|
17
|
+
|
|
18
|
+
set(CMAKE_C_COMPILER_TARGET ${triple})
|
|
19
|
+
set(CMAKE_CXX_COMPILER_TARGET ${triple})
|
|
20
|
+
message(STATUS "Compiling for: ${triple}")
|
|
21
|
+
|
|
22
|
+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} $ENV{COMPILER_FLAGS}")
|
|
23
|
+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} $ENV{COMPILER_FLAGS}")
|
|
@@ -139,9 +139,9 @@
|
|
|
139
139
|
}
|
|
140
140
|
},
|
|
141
141
|
"node_modules/ws": {
|
|
142
|
-
"version": "7.5.
|
|
143
|
-
"resolved": "https://registry.npmjs.org/ws/-/ws-7.5.
|
|
144
|
-
"integrity": "sha512
|
|
142
|
+
"version": "7.5.10",
|
|
143
|
+
"resolved": "https://registry.npmjs.org/ws/-/ws-7.5.10.tgz",
|
|
144
|
+
"integrity": "sha512-+dbF1tHwZpXcbOJdVOkzLDxZP1ailvSxM6ZweXTegylPny803bFhA+vqBYw4s31NSAk4S2Qz+AKXK9a4wkdjcQ==",
|
|
145
145
|
"engines": {
|
|
146
146
|
"node": ">=8.3.0"
|
|
147
147
|
},
|
|
@@ -283,9 +283,9 @@
|
|
|
283
283
|
}
|
|
284
284
|
},
|
|
285
285
|
"ws": {
|
|
286
|
-
"version": "7.5.
|
|
287
|
-
"resolved": "https://registry.npmjs.org/ws/-/ws-7.5.
|
|
288
|
-
"integrity": "sha512
|
|
286
|
+
"version": "7.5.10",
|
|
287
|
+
"resolved": "https://registry.npmjs.org/ws/-/ws-7.5.10.tgz",
|
|
288
|
+
"integrity": "sha512-+dbF1tHwZpXcbOJdVOkzLDxZP1ailvSxM6ZweXTegylPny803bFhA+vqBYw4s31NSAk4S2Qz+AKXK9a4wkdjcQ==",
|
|
289
289
|
"requires": {}
|
|
290
290
|
},
|
|
291
291
|
"y18n": {
|
package/lib/index.d.cts
CHANGED
|
@@ -71,26 +71,13 @@ export enum DescriptionType {
|
|
|
71
71
|
Rollback = 'rollback',
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
-
export const enum ReliabilityType {
|
|
75
|
-
Reliable = 0,
|
|
76
|
-
Rexmit = 1,
|
|
77
|
-
Timed = 2,
|
|
78
|
-
}
|
|
79
|
-
|
|
80
74
|
export interface DataChannelInitConfig {
|
|
81
75
|
protocol?: string;
|
|
82
76
|
negotiated?: boolean;
|
|
83
77
|
id?: number;
|
|
84
|
-
|
|
85
|
-
maxPacketLifeTime?: number;
|
|
86
|
-
maxRetransmits?: number;
|
|
87
|
-
|
|
88
|
-
// Deprecated, use ordered, maxPacketLifeTime, and maxRetransmits
|
|
89
|
-
reliability?: {
|
|
90
|
-
type?: ReliabilityType;
|
|
91
|
-
unordered?: boolean;
|
|
92
|
-
rexmit?: number;
|
|
93
|
-
};
|
|
78
|
+
unordered?: boolean; // Reliability
|
|
79
|
+
maxPacketLifeTime?: number; // Reliability
|
|
80
|
+
maxRetransmits?: number; // Reliability
|
|
94
81
|
}
|
|
95
82
|
|
|
96
83
|
export interface SelectedCandidateInfo {
|
|
@@ -113,8 +100,7 @@ export const enum Direction {
|
|
|
113
100
|
}
|
|
114
101
|
|
|
115
102
|
export class RtcpReceivingSession {
|
|
116
|
-
|
|
117
|
-
requestKeyframe(): boolean;
|
|
103
|
+
//
|
|
118
104
|
}
|
|
119
105
|
|
|
120
106
|
export class Audio {
|
package/lib/index.d.ts
CHANGED
|
@@ -71,26 +71,13 @@ export enum DescriptionType {
|
|
|
71
71
|
Rollback = 'rollback',
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
-
export const enum ReliabilityType {
|
|
75
|
-
Reliable = 0,
|
|
76
|
-
Rexmit = 1,
|
|
77
|
-
Timed = 2,
|
|
78
|
-
}
|
|
79
|
-
|
|
80
74
|
export interface DataChannelInitConfig {
|
|
81
75
|
protocol?: string;
|
|
82
76
|
negotiated?: boolean;
|
|
83
77
|
id?: number;
|
|
84
|
-
|
|
85
|
-
maxPacketLifeTime?: number;
|
|
86
|
-
maxRetransmits?: number;
|
|
87
|
-
|
|
88
|
-
// Deprecated, use ordered, maxPacketLifeTime, and maxRetransmits
|
|
89
|
-
reliability?: {
|
|
90
|
-
type?: ReliabilityType;
|
|
91
|
-
unordered?: boolean;
|
|
92
|
-
rexmit?: number;
|
|
93
|
-
};
|
|
78
|
+
unordered?: boolean; // Reliability
|
|
79
|
+
maxPacketLifeTime?: number; // Reliability
|
|
80
|
+
maxRetransmits?: number; // Reliability
|
|
94
81
|
}
|
|
95
82
|
|
|
96
83
|
export interface SelectedCandidateInfo {
|
|
@@ -113,8 +100,7 @@ export const enum Direction {
|
|
|
113
100
|
}
|
|
114
101
|
|
|
115
102
|
export class RtcpReceivingSession {
|
|
116
|
-
|
|
117
|
-
requestKeyframe(): boolean;
|
|
103
|
+
//
|
|
118
104
|
}
|
|
119
105
|
|
|
120
106
|
export class Audio {
|
package/package.json
CHANGED
|
@@ -11,8 +11,7 @@ Napi::Object RtcpReceivingSessionWrapper::Init(Napi::Env env, Napi::Object expor
|
|
|
11
11
|
env,
|
|
12
12
|
"RtcpReceivingSession",
|
|
13
13
|
{
|
|
14
|
-
|
|
15
|
-
Napi::ObjectWrap<RtcpReceivingSessionWrapper>::InstanceMethod("requestKeyframe", &RtcpReceivingSessionWrapper::requestKeyframe),
|
|
14
|
+
// Instance Methods
|
|
16
15
|
});
|
|
17
16
|
|
|
18
17
|
constructor = Napi::Persistent(func);
|
|
@@ -39,24 +38,3 @@ std::shared_ptr<rtc::RtcpReceivingSession> RtcpReceivingSessionWrapper::getSessi
|
|
|
39
38
|
{
|
|
40
39
|
return mSessionPtr;
|
|
41
40
|
}
|
|
42
|
-
|
|
43
|
-
void RtcpReceivingSessionWrapper::requestBitrate(const Napi::CallbackInfo &info)
|
|
44
|
-
{
|
|
45
|
-
Napi::Env env = info.Env();
|
|
46
|
-
int length = info.Length();
|
|
47
|
-
|
|
48
|
-
if (length < 1 || !info[0].IsNumber())
|
|
49
|
-
{
|
|
50
|
-
Napi::TypeError::New(env, "We expect (Number) as param").ThrowAsJavaScriptException();
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
unsigned int bitrate = static_cast<uint32_t>(info[0].As<Napi::Number>().ToNumber());
|
|
55
|
-
mSessionPtr->requestBitrate(bitrate);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
Napi::Value RtcpReceivingSessionWrapper::requestKeyframe(const Napi::CallbackInfo &info)
|
|
59
|
-
{
|
|
60
|
-
Napi::Env env = info.Env();
|
|
61
|
-
return Napi::Boolean::New(env, mSessionPtr->requestKeyframe());
|
|
62
|
-
}
|
|
@@ -22,15 +22,12 @@ public:
|
|
|
22
22
|
std::shared_ptr<rtc::RtcpReceivingSession> getSessionInstance();
|
|
23
23
|
|
|
24
24
|
// Functions
|
|
25
|
-
void requestBitrate(const Napi::CallbackInfo &info);
|
|
26
|
-
Napi::Value requestKeyframe(const Napi::CallbackInfo &info);
|
|
27
25
|
|
|
28
26
|
// Callbacks
|
|
29
|
-
|
|
30
27
|
|
|
31
28
|
private:
|
|
32
|
-
static std::unordered_set<RtcpReceivingSessionWrapper*> instances;
|
|
29
|
+
static std::unordered_set<RtcpReceivingSessionWrapper *> instances;
|
|
33
30
|
std::shared_ptr<rtc::RtcpReceivingSession> mSessionPtr = nullptr;
|
|
34
31
|
};
|
|
35
32
|
|
|
36
|
-
#endif // MEDIA_RTCPRECEIVINGSESSION_WRAPPER_H
|
|
33
|
+
#endif // MEDIA_RTCPRECEIVINGSESSION_WRAPPER_H
|
|
@@ -249,7 +249,7 @@ PeerConnectionWrapper::PeerConnectionWrapper(const Napi::CallbackInfo &info) : N
|
|
|
249
249
|
PLOG_DEBUG << "Peer Connection created";
|
|
250
250
|
|
|
251
251
|
// State change callback must be set to trigger cleanup on close
|
|
252
|
-
mOnStateChangeCallback = std::make_unique<ThreadSafeCallback>(Napi::Function::New(info.Env(), [](const Napi::CallbackInfo&){}));
|
|
252
|
+
mOnStateChangeCallback = std::make_unique<ThreadSafeCallback>(Napi::Function::New(info.Env(), [](const Napi::CallbackInfo &) {}));
|
|
253
253
|
|
|
254
254
|
instances.insert(this);
|
|
255
255
|
}
|
|
@@ -503,81 +503,17 @@ Napi::Value PeerConnectionWrapper::createDataChannel(const Napi::CallbackInfo &i
|
|
|
503
503
|
init.id = uint16_t(initConfig.Get("id").As<Napi::Number>().Uint32Value());
|
|
504
504
|
}
|
|
505
505
|
|
|
506
|
-
//
|
|
507
|
-
if (!initConfig.Get("
|
|
506
|
+
// Reliability.unordered parameter
|
|
507
|
+
if (!initConfig.Get("unordered").IsUndefined())
|
|
508
508
|
{
|
|
509
|
-
if (!initConfig.Get("
|
|
509
|
+
if (!initConfig.Get("unordered").IsBoolean())
|
|
510
510
|
{
|
|
511
|
-
Napi::TypeError::New(env, "Wrong DataChannel Init Config (
|
|
511
|
+
Napi::TypeError::New(env, "Wrong DataChannel Init Config (unordered)").ThrowAsJavaScriptException();
|
|
512
512
|
return info.Env().Null();
|
|
513
513
|
}
|
|
514
|
-
|
|
515
|
-
Napi::Object reliability = initConfig.Get("reliability").As<Napi::Object>();
|
|
516
|
-
if (!reliability.Get("type").IsUndefined())
|
|
517
|
-
{
|
|
518
|
-
if (!reliability.Get("type").IsNumber())
|
|
519
|
-
{
|
|
520
|
-
Napi::TypeError::New(env, "Wrong Reliability Config (type)").ThrowAsJavaScriptException();
|
|
521
|
-
return info.Env().Null();
|
|
522
|
-
}
|
|
523
|
-
switch (reliability.Get("type").As<Napi::Number>().Uint32Value())
|
|
524
|
-
{
|
|
525
|
-
case 0:
|
|
526
|
-
init.reliability.type = rtc::Reliability::Type::Reliable;
|
|
527
|
-
break;
|
|
528
|
-
case 1:
|
|
529
|
-
init.reliability.type = rtc::Reliability::Type::Rexmit;
|
|
530
|
-
break;
|
|
531
|
-
case 2:
|
|
532
|
-
init.reliability.type = rtc::Reliability::Type::Timed;
|
|
533
|
-
break;
|
|
534
|
-
default:
|
|
535
|
-
Napi::TypeError::New(env, "Unknown DataChannel Reliability Type").ThrowAsJavaScriptException();
|
|
536
|
-
return info.Env().Null();
|
|
537
|
-
}
|
|
538
|
-
}
|
|
539
|
-
|
|
540
|
-
if (!reliability.Get("unordered").IsUndefined())
|
|
541
|
-
{
|
|
542
|
-
if (!reliability.Get("unordered").IsBoolean())
|
|
543
|
-
{
|
|
544
|
-
Napi::TypeError::New(env, "Wrong reliability Config (unordered)").ThrowAsJavaScriptException();
|
|
545
|
-
return info.Env().Null();
|
|
546
|
-
}
|
|
547
|
-
init.reliability.unordered = reliability.Get("unordered").As<Napi::Boolean>();
|
|
548
|
-
}
|
|
549
|
-
|
|
550
|
-
if (!reliability.Get("rexmit").IsUndefined())
|
|
551
|
-
{
|
|
552
|
-
if (!reliability.Get("rexmit").IsNumber())
|
|
553
|
-
{
|
|
554
|
-
Napi::TypeError::New(env, "Wrong Reliability Config (rexmit)").ThrowAsJavaScriptException();
|
|
555
|
-
return info.Env().Null();
|
|
556
|
-
}
|
|
557
|
-
switch (reliability.Get("type").As<Napi::Number>().Uint32Value())
|
|
558
|
-
{
|
|
559
|
-
case 1:
|
|
560
|
-
init.reliability.rexmit = int(reliability.Get("rexmit").As<Napi::Number>().ToNumber().Uint32Value());
|
|
561
|
-
break;
|
|
562
|
-
case 2:
|
|
563
|
-
init.reliability.rexmit = std::chrono::milliseconds(reliability.Get("rexmit").As<Napi::Number>().Int32Value());
|
|
564
|
-
break;
|
|
565
|
-
}
|
|
566
|
-
}
|
|
514
|
+
init.reliability.unordered = !initConfig.Get("unordered").As<Napi::Boolean>();
|
|
567
515
|
}
|
|
568
516
|
|
|
569
|
-
// Reliability parameters
|
|
570
|
-
if (!initConfig.Get("ordered").IsUndefined())
|
|
571
|
-
{
|
|
572
|
-
if (!initConfig.Get("ordered").IsBoolean())
|
|
573
|
-
{
|
|
574
|
-
Napi::TypeError::New(env, "Wrong DataChannel Init Config (ordered)").ThrowAsJavaScriptException();
|
|
575
|
-
return info.Env().Null();
|
|
576
|
-
}
|
|
577
|
-
init.reliability.unordered = !initConfig.Get("ordered").As<Napi::Boolean>();
|
|
578
|
-
}
|
|
579
|
-
|
|
580
|
-
|
|
581
517
|
if (!initConfig.Get("maxPacketLifeTime").IsUndefined() && !initConfig.Get("maxPacketLifeTime").IsNull() &&
|
|
582
518
|
!initConfig.Get("maxRetransmits").IsUndefined() && !initConfig.Get("maxRetransmits").IsNull())
|
|
583
519
|
{
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
set(CMAKE_SYSTEM_NAME Linux)
|
|
2
|
-
set(TOOLCHAIN_PREFIX aarch64-linux-gnu)
|
|
3
|
-
|
|
4
|
-
# cross compilers to use for C and C++
|
|
5
|
-
set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}-gcc)
|
|
6
|
-
set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}-g++)
|
|
7
|
-
|
|
8
|
-
# Needed sysroot
|
|
9
|
-
# https://github.com/webrtc-uwp/chromium-build/blob/master/linux/sysroot_scripts/sysroots.json
|
|
10
|
-
set(CMAKE_SYSROOT "$ENV{ARM64_SYSROOT}")
|
|
11
|
-
|
|
12
|
-
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
|
|
13
|
-
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
|
14
|
-
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
|
15
|
-
|
|
16
|
-
set(CMAKE_C_FLAGS "-march=armv8-a -fPIC -Wno-error=format-truncation" CACHE STRING "Compiler Flags")
|
|
17
|
-
set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS}" CACHE STRING "Compiler Flags")
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
set(CMAKE_SYSTEM_NAME Linux)
|
|
2
|
-
set(TOOLCHAIN_PREFIX arm-linux-gnueabihf)
|
|
3
|
-
|
|
4
|
-
# cross compilers to use for C and C++
|
|
5
|
-
set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}-gcc)
|
|
6
|
-
set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}-g++)
|
|
7
|
-
|
|
8
|
-
# Needed sysroot
|
|
9
|
-
# https://github.com/webrtc-uwp/chromium-build/blob/master/linux/sysroot_scripts/sysroots.json
|
|
10
|
-
set(CMAKE_SYSROOT "$ENV{ARM_SYSROOT}")
|
|
11
|
-
|
|
12
|
-
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
|
|
13
|
-
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
|
14
|
-
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
|
15
|
-
|
|
16
|
-
set(CMAKE_C_FLAGS "-march=armv7-a -mfpu=neon-vfpv4 -mfloat-abi=hard -fPIC -Wno-error=format-truncation" CACHE STRING "Compiler Flags")
|
|
17
|
-
set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS}" CACHE STRING "Compiler Flags")
|