mediasoup 3.9.2 → 3.9.3
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/node/lib/Channel.js +1 -1
- package/node/lib/PayloadChannel.js +1 -1
- package/node/lib/Worker.js +1 -1
- package/node/lib/index.d.ts +1 -1
- package/node/lib/index.js +1 -1
- package/node/lib/ortc.js +4 -6
- package/node/lib/supportedRtpCapabilities.d.ts.map +1 -1
- package/node/lib/supportedRtpCapabilities.js +0 -34
- package/npm-scripts.js +6 -2
- package/package.json +12 -12
- package/worker/Makefile +30 -14
- package/worker/include/Channel/ChannelNotifier.hpp +1 -0
- package/worker/include/Channel/ChannelSocket.hpp +16 -5
- package/worker/include/Logger.hpp +1 -1
- package/worker/include/PayloadChannel/PayloadChannelSocket.hpp +17 -4
- package/worker/include/RTC/RTCP/CompoundPacket.hpp +4 -3
- package/worker/include/RTC/RTCP/FeedbackPsTst.hpp +11 -1
- package/worker/include/RTC/RTCP/ReceiverReport.hpp +3 -2
- package/worker/include/common.hpp +39 -0
- package/worker/include/lib.hpp +12 -2
- package/worker/scripts/package-lock.json +9913 -0
- package/worker/src/Channel/ChannelNotifier.cpp +14 -0
- package/worker/src/Channel/ChannelSocket.cpp +141 -14
- package/worker/src/DepOpenSSL.cpp +8 -5
- package/worker/src/Logger.cpp +1 -1
- package/worker/src/PayloadChannel/PayloadChannelSocket.cpp +226 -17
- package/worker/src/RTC/ActiveSpeakerObserver.cpp +1 -1
- package/worker/src/RTC/DataConsumer.cpp +9 -6
- package/worker/src/RTC/Transport.cpp +48 -36
- package/worker/src/Worker.cpp +1 -1
- package/worker/src/lib.cpp +29 -5
- package/worker/src/lib.rs +80 -2
- package/worker/src/main.cpp +10 -2
package/node/lib/Channel.js
CHANGED
|
@@ -207,7 +207,7 @@ class Channel extends EnhancedEventEmitter_1.EnhancedEventEmitter {
|
|
|
207
207
|
// the response, destroying the ordered delivery. So we must wait a bit
|
|
208
208
|
// here.
|
|
209
209
|
// See https://github.com/versatica/mediasoup/issues/510
|
|
210
|
-
setImmediate(() => this.emit(msg.targetId, msg.event, msg.data));
|
|
210
|
+
setImmediate(() => this.emit(String(msg.targetId), msg.event, msg.data));
|
|
211
211
|
}
|
|
212
212
|
// Otherwise unexpected message.
|
|
213
213
|
else {
|
|
@@ -213,7 +213,7 @@ class PayloadChannel extends EnhancedEventEmitter_1.EnhancedEventEmitter {
|
|
|
213
213
|
else if (msg.targetId && msg.event) {
|
|
214
214
|
this.#ongoingNotification =
|
|
215
215
|
{
|
|
216
|
-
targetId: msg.targetId,
|
|
216
|
+
targetId: String(msg.targetId),
|
|
217
217
|
event: msg.event,
|
|
218
218
|
data: msg.data
|
|
219
219
|
};
|
package/node/lib/Worker.js
CHANGED
|
@@ -81,7 +81,7 @@ class Worker extends EnhancedEventEmitter_1.EnhancedEventEmitter {
|
|
|
81
81
|
// options
|
|
82
82
|
{
|
|
83
83
|
env: {
|
|
84
|
-
MEDIASOUP_VERSION: '3.9.
|
|
84
|
+
MEDIASOUP_VERSION: '3.9.3',
|
|
85
85
|
// Let the worker process inherit all environment variables, useful
|
|
86
86
|
// if a custom and not in the path GCC is used so the user can set
|
|
87
87
|
// LD_LIBRARY_PATH environment variable for runtime.
|
package/node/lib/index.d.ts
CHANGED
package/node/lib/index.js
CHANGED
package/node/lib/ortc.js
CHANGED
|
@@ -829,12 +829,11 @@ function matchCodecs(aCodec, bCodec, { strict = false, modify = false } = {}) {
|
|
|
829
829
|
}
|
|
830
830
|
case 'video/h264':
|
|
831
831
|
{
|
|
832
|
-
const aPacketizationMode = aCodec.parameters['packetization-mode'] || 0;
|
|
833
|
-
const bPacketizationMode = bCodec.parameters['packetization-mode'] || 0;
|
|
834
|
-
if (aPacketizationMode !== bPacketizationMode)
|
|
835
|
-
return false;
|
|
836
|
-
// If strict matching check profile-level-id.
|
|
837
832
|
if (strict) {
|
|
833
|
+
const aPacketizationMode = aCodec.parameters['packetization-mode'] || 0;
|
|
834
|
+
const bPacketizationMode = bCodec.parameters['packetization-mode'] || 0;
|
|
835
|
+
if (aPacketizationMode !== bPacketizationMode)
|
|
836
|
+
return false;
|
|
838
837
|
if (!h264.isSameProfile(aCodec.parameters, bCodec.parameters))
|
|
839
838
|
return false;
|
|
840
839
|
let selectedProfileLevelId;
|
|
@@ -856,7 +855,6 @@ function matchCodecs(aCodec, bCodec, { strict = false, modify = false } = {}) {
|
|
|
856
855
|
}
|
|
857
856
|
case 'video/vp9':
|
|
858
857
|
{
|
|
859
|
-
// If strict matching check profile-id.
|
|
860
858
|
if (strict) {
|
|
861
859
|
const aProfileId = aCodec.parameters['profile-id'] || 0;
|
|
862
860
|
const bProfileId = bCodec.parameters['profile-id'] || 0;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"supportedRtpCapabilities.d.ts","sourceRoot":"","sources":["../src/supportedRtpCapabilities.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAElD,QAAA,MAAM,wBAAwB,EAAE,
|
|
1
|
+
{"version":3,"file":"supportedRtpCapabilities.d.ts","sourceRoot":"","sources":["../src/supportedRtpCapabilities.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAElD,QAAA,MAAM,wBAAwB,EAAE,eAkW/B,CAAC;AAEF,OAAO,EAAE,wBAAwB,EAAE,CAAC"}
|
|
@@ -207,39 +207,6 @@ const supportedRtpCapabilities = {
|
|
|
207
207
|
mimeType: 'video/H264',
|
|
208
208
|
clockRate: 90000,
|
|
209
209
|
parameters: {
|
|
210
|
-
'packetization-mode': 1,
|
|
211
|
-
'level-asymmetry-allowed': 1
|
|
212
|
-
},
|
|
213
|
-
rtcpFeedback: [
|
|
214
|
-
{ type: 'nack' },
|
|
215
|
-
{ type: 'nack', parameter: 'pli' },
|
|
216
|
-
{ type: 'ccm', parameter: 'fir' },
|
|
217
|
-
{ type: 'goog-remb' },
|
|
218
|
-
{ type: 'transport-cc' }
|
|
219
|
-
]
|
|
220
|
-
},
|
|
221
|
-
{
|
|
222
|
-
kind: 'video',
|
|
223
|
-
mimeType: 'video/H264',
|
|
224
|
-
clockRate: 90000,
|
|
225
|
-
parameters: {
|
|
226
|
-
'packetization-mode': 0,
|
|
227
|
-
'level-asymmetry-allowed': 1
|
|
228
|
-
},
|
|
229
|
-
rtcpFeedback: [
|
|
230
|
-
{ type: 'nack' },
|
|
231
|
-
{ type: 'nack', parameter: 'pli' },
|
|
232
|
-
{ type: 'ccm', parameter: 'fir' },
|
|
233
|
-
{ type: 'goog-remb' },
|
|
234
|
-
{ type: 'transport-cc' }
|
|
235
|
-
]
|
|
236
|
-
},
|
|
237
|
-
{
|
|
238
|
-
kind: 'video',
|
|
239
|
-
mimeType: 'video/H265',
|
|
240
|
-
clockRate: 90000,
|
|
241
|
-
parameters: {
|
|
242
|
-
'packetization-mode': 1,
|
|
243
210
|
'level-asymmetry-allowed': 1
|
|
244
211
|
},
|
|
245
212
|
rtcpFeedback: [
|
|
@@ -255,7 +222,6 @@ const supportedRtpCapabilities = {
|
|
|
255
222
|
mimeType: 'video/H265',
|
|
256
223
|
clockRate: 90000,
|
|
257
224
|
parameters: {
|
|
258
|
-
'packetization-mode': 0,
|
|
259
225
|
'level-asymmetry-allowed': 1
|
|
260
226
|
},
|
|
261
227
|
rtcpFeedback: [
|
package/npm-scripts.js
CHANGED
|
@@ -121,8 +121,12 @@ switch (task)
|
|
|
121
121
|
if (!process.env.MEDIASOUP_WORKER_BIN)
|
|
122
122
|
{
|
|
123
123
|
execute('node npm-scripts.js worker:build');
|
|
124
|
-
|
|
124
|
+
// Clean build artifacts except `mediasoup-worker`.
|
|
125
|
+
execute(`${MAKE} clean-build -C worker`);
|
|
126
|
+
// Clean downloaded dependencies.
|
|
125
127
|
execute(`${MAKE} clean-subprojects -C worker`);
|
|
128
|
+
// Clean PIP/Meson/Ninja.
|
|
129
|
+
execute(`${MAKE} clean-pip -C worker`);
|
|
126
130
|
}
|
|
127
131
|
|
|
128
132
|
break;
|
|
@@ -143,7 +147,7 @@ switch (task)
|
|
|
143
147
|
|
|
144
148
|
case 'install-clang-tools':
|
|
145
149
|
{
|
|
146
|
-
execute('npm
|
|
150
|
+
execute('npm ci --prefix worker/scripts');
|
|
147
151
|
|
|
148
152
|
break;
|
|
149
153
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mediasoup",
|
|
3
|
-
"version": "3.9.
|
|
3
|
+
"version": "3.9.3",
|
|
4
4
|
"description": "Cutting Edge WebRTC Video Conferencing",
|
|
5
5
|
"contributors": [
|
|
6
6
|
"Iñaki Baz Castillo <ibc@aliax.net> (https://inakibaz.me)",
|
|
@@ -69,27 +69,27 @@
|
|
|
69
69
|
"testRegex": "node/tests/test.*\\.js"
|
|
70
70
|
},
|
|
71
71
|
"dependencies": {
|
|
72
|
-
"@types/node": "^16.11.
|
|
73
|
-
"debug": "^4.3.
|
|
72
|
+
"@types/node": "^16.11.10",
|
|
73
|
+
"debug": "^4.3.3",
|
|
74
74
|
"h264-profile-level-id": "^1.0.1",
|
|
75
75
|
"random-number": "^0.0.9",
|
|
76
|
-
"supports-color": "^9.
|
|
76
|
+
"supports-color": "^9.2.1",
|
|
77
77
|
"uuid": "^8.3.2"
|
|
78
78
|
},
|
|
79
79
|
"devDependencies": {
|
|
80
80
|
"@types/debug": "^4.1.7",
|
|
81
81
|
"@types/random-number": "^0.0.1",
|
|
82
|
-
"@types/uuid": "^8.3.
|
|
83
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
84
|
-
"@typescript-eslint/parser": "^5.
|
|
85
|
-
"eslint": "^8.
|
|
86
|
-
"eslint-plugin-jest": "^25.
|
|
87
|
-
"jest": "^27.
|
|
82
|
+
"@types/uuid": "^8.3.3",
|
|
83
|
+
"@typescript-eslint/eslint-plugin": "^5.8.0",
|
|
84
|
+
"@typescript-eslint/parser": "^5.8.0",
|
|
85
|
+
"eslint": "^8.5.0",
|
|
86
|
+
"eslint-plugin-jest": "^25.3.0",
|
|
87
|
+
"jest": "^27.4.5",
|
|
88
88
|
"jest-tobetype": "^1.2.3",
|
|
89
89
|
"open-cli": "^7.0.1",
|
|
90
90
|
"pick-port": "^1.0.0",
|
|
91
91
|
"sctp": "^1.0.0",
|
|
92
|
-
"tsc-watch": "^4.
|
|
93
|
-
"typescript": "^4.
|
|
92
|
+
"tsc-watch": "^4.6.0",
|
|
93
|
+
"typescript": "^4.5.4"
|
|
94
94
|
}
|
|
95
95
|
}
|
package/worker/Makefile
CHANGED
|
@@ -12,6 +12,7 @@ GULP = ./scripts/node_modules/.bin/gulp
|
|
|
12
12
|
LCOV = ./deps/lcov/bin/lcov
|
|
13
13
|
DOCKER ?= docker
|
|
14
14
|
PIP_DIR = $(MEDIASOUP_OUT_DIR)/pip
|
|
15
|
+
BUILD_DIR ?= $(MEDIASOUP_OUT_DIR)/$(MEDIASOUP_BUILDTYPE)/build
|
|
15
16
|
MESON ?= $(PIP_DIR)/bin/meson
|
|
16
17
|
MESON_ARGS ?= ""
|
|
17
18
|
# Workaround for NixOS and Guix that don't work with pre-built binaries, see:
|
|
@@ -37,6 +38,13 @@ else
|
|
|
37
38
|
export PYTHONPATH := $(PIP_DIR):${PYTHONPATH}
|
|
38
39
|
endif
|
|
39
40
|
|
|
41
|
+
# Activate VS environment on Windows by default.
|
|
42
|
+
ifeq ($(OS),Windows_NT)
|
|
43
|
+
ifeq ($(MESON_ARGS),"")
|
|
44
|
+
MESON_ARGS = $(subst $\",,"--vsenv")
|
|
45
|
+
endif
|
|
46
|
+
endif
|
|
47
|
+
|
|
40
48
|
.PHONY: \
|
|
41
49
|
default meson-ninja setup clean clean-pip clean-subprojects clean-all mediasoup-worker xcode lint format test tidy \
|
|
42
50
|
fuzzer fuzzer-run-all docker-build docker-run libmediasoup-worker
|
|
@@ -69,14 +77,14 @@ ifeq ($(MEDIASOUP_BUILDTYPE),Release)
|
|
|
69
77
|
-Db_staticpic=true \
|
|
70
78
|
--reconfigure \
|
|
71
79
|
$(MESON_ARGS) \
|
|
72
|
-
$(
|
|
80
|
+
$(BUILD_DIR) || \
|
|
73
81
|
$(MESON) setup \
|
|
74
82
|
--buildtype release \
|
|
75
83
|
-Db_ndebug=true \
|
|
76
84
|
-Db_pie=true \
|
|
77
85
|
-Db_staticpic=true \
|
|
78
86
|
$(MESON_ARGS) \
|
|
79
|
-
$(
|
|
87
|
+
$(BUILD_DIR)
|
|
80
88
|
else
|
|
81
89
|
ifeq ($(MEDIASOUP_BUILDTYPE),Debug)
|
|
82
90
|
$(MESON) setup \
|
|
@@ -85,13 +93,13 @@ ifeq ($(MEDIASOUP_BUILDTYPE),Debug)
|
|
|
85
93
|
-Db_staticpic=true \
|
|
86
94
|
--reconfigure \
|
|
87
95
|
$(MESON_ARGS) \
|
|
88
|
-
$(
|
|
96
|
+
$(BUILD_DIR) || \
|
|
89
97
|
$(MESON) setup \
|
|
90
98
|
--buildtype debug \
|
|
91
99
|
-Db_pie=true \
|
|
92
100
|
-Db_staticpic=true \
|
|
93
101
|
$(MESON_ARGS) \
|
|
94
|
-
$(
|
|
102
|
+
$(BUILD_DIR)
|
|
95
103
|
else
|
|
96
104
|
$(MESON) setup \
|
|
97
105
|
--buildtype $(MEDIASOUP_BUILDTYPE) \
|
|
@@ -100,20 +108,23 @@ else
|
|
|
100
108
|
-Db_staticpic=true \
|
|
101
109
|
--reconfigure \
|
|
102
110
|
$(MESON_ARGS) \
|
|
103
|
-
$(
|
|
111
|
+
$(BUILD_DIR) || \
|
|
104
112
|
$(MESON) setup \
|
|
105
113
|
--buildtype $(MEDIASOUP_BUILDTYPE) \
|
|
106
114
|
-Db_ndebug=if-release \
|
|
107
115
|
-Db_pie=true \
|
|
108
116
|
-Db_staticpic=true \
|
|
109
117
|
$(MESON_ARGS) \
|
|
110
|
-
$(
|
|
118
|
+
$(BUILD_DIR)
|
|
111
119
|
endif
|
|
112
120
|
endif
|
|
113
121
|
|
|
114
122
|
clean:
|
|
115
123
|
$(RM) -rf $(MEDIASOUP_OUT_DIR)/$(MEDIASOUP_BUILDTYPE)
|
|
116
124
|
|
|
125
|
+
clean-build:
|
|
126
|
+
$(RM) -rf $(BUILD_DIR)
|
|
127
|
+
|
|
117
128
|
clean-pip:
|
|
118
129
|
$(RM) -rf $(PIP_DIR)
|
|
119
130
|
|
|
@@ -125,7 +136,12 @@ clean-all: clean-subprojects
|
|
|
125
136
|
|
|
126
137
|
mediasoup-worker: setup
|
|
127
138
|
ifeq ($(MEDIASOUP_WORKER_BIN),)
|
|
128
|
-
$(MESON) compile -j $(CORES) -C $(
|
|
139
|
+
$(MESON) compile -j $(CORES) -C $(BUILD_DIR) mediasoup-worker
|
|
140
|
+
endif
|
|
141
|
+
ifeq ($(OS),Windows_NT)
|
|
142
|
+
cp $(BUILD_DIR)/mediasoup-worker.exe $(MEDIASOUP_OUT_DIR)/$(MEDIASOUP_BUILDTYPE)/mediasoup-worker.exe
|
|
143
|
+
else
|
|
144
|
+
cp $(BUILD_DIR)/mediasoup-worker $(MEDIASOUP_OUT_DIR)/$(MEDIASOUP_BUILDTYPE)/mediasoup-worker
|
|
129
145
|
endif
|
|
130
146
|
|
|
131
147
|
xcode: setup
|
|
@@ -139,14 +155,14 @@ format:
|
|
|
139
155
|
|
|
140
156
|
test: setup
|
|
141
157
|
ifeq ($(MEDIASOUP_WORKER_BIN),)
|
|
142
|
-
$(MESON) compile -j $(CORES) -C $(
|
|
158
|
+
$(MESON) compile -j $(CORES) -C $(BUILD_DIR) mediasoup-worker-test
|
|
143
159
|
# On Windows lcov doesn't work (at least not yet) and we need to add `.exe` to
|
|
144
160
|
# the binary path.
|
|
145
161
|
ifeq ($(OS),Windows_NT)
|
|
146
|
-
$(
|
|
162
|
+
$(BUILD_DIR)/mediasoup-worker-test.exe --invisibles --use-colour=yes $(MEDIASOUP_TEST_TAGS)
|
|
147
163
|
else
|
|
148
164
|
$(LCOV) --directory ./ --zerocounters
|
|
149
|
-
$(
|
|
165
|
+
$(BUILD_DIR)/mediasoup-worker-test --invisibles --use-colour=yes $(MEDIASOUP_TEST_TAGS)
|
|
150
166
|
endif
|
|
151
167
|
endif
|
|
152
168
|
|
|
@@ -155,18 +171,18 @@ tidy:
|
|
|
155
171
|
-clang-tidy-binary=./scripts/node_modules/.bin/clang-tidy \
|
|
156
172
|
-clang-apply-replacements-binary=./scripts/node_modules/.bin/clang-apply-replacements \
|
|
157
173
|
-header-filter='(Channel/**/*.hpp|DepLibSRTP.hpp|DepLibUV.hpp|DepLibWebRTC.hpp|DepOpenSSL.hpp|DepUsrSCTP.hpp|LogLevel.hpp|Logger.hpp|MediaSoupError.hpp|RTC/**/*.hpp|Settings.hpp|Utils.hpp|Worker.hpp|common.hpp|handles/**/*.hpp)' \
|
|
158
|
-
-p=$(
|
|
174
|
+
-p=$(BUILD_DIR) \
|
|
159
175
|
-j=$(CORES) \
|
|
160
176
|
-checks=$(MEDIASOUP_TIDY_CHECKS) \
|
|
161
177
|
-quiet
|
|
162
178
|
|
|
163
179
|
fuzzer: setup
|
|
164
180
|
ifeq ($(MEDIASOUP_WORKER_BIN),)
|
|
165
|
-
$(MESON) compile -j $(CORES) -C $(
|
|
181
|
+
$(MESON) compile -j $(CORES) -C $(BUILD_DIR) mediasoup-worker-fuzzer
|
|
166
182
|
endif
|
|
167
183
|
|
|
168
184
|
fuzzer-run-all:
|
|
169
|
-
LSAN_OPTIONS=verbosity=1:log_threads=1 ./$(
|
|
185
|
+
LSAN_OPTIONS=verbosity=1:log_threads=1 ./$(BUILD_DIR)/mediasoup-worker-fuzzer -artifact_prefix=fuzzer/reports/ -max_len=1400 fuzzer/new-corpus deps/webrtc-fuzzer-corpora/corpora/stun-corpus deps/webrtc-fuzzer-corpora/corpora/rtp-corpus deps/webrtc-fuzzer-corpora/corpora/rtcp-corpus
|
|
170
186
|
|
|
171
187
|
docker-build:
|
|
172
188
|
ifeq ($(DOCKER_NO_CACHE),true)
|
|
@@ -184,4 +200,4 @@ docker-run:
|
|
|
184
200
|
mediasoup/docker:latest
|
|
185
201
|
|
|
186
202
|
libmediasoup-worker: setup
|
|
187
|
-
$(MESON) compile -j $(CORES) -C $(
|
|
203
|
+
$(MESON) compile -j $(CORES) -C $(BUILD_DIR) libmediasoup-worker
|
|
@@ -12,6 +12,7 @@ namespace Channel
|
|
|
12
12
|
{
|
|
13
13
|
public:
|
|
14
14
|
static void ClassInit(Channel::ChannelSocket* channel);
|
|
15
|
+
static void Emit(uint64_t targetId, const char* event);
|
|
15
16
|
static void Emit(const std::string& targetId, const char* event);
|
|
16
17
|
static void Emit(const std::string& targetId, const char* event, json& data);
|
|
17
18
|
|
|
@@ -64,16 +64,22 @@ namespace Channel
|
|
|
64
64
|
|
|
65
65
|
public:
|
|
66
66
|
explicit ChannelSocket(int consumerFd, int producerFd);
|
|
67
|
+
explicit ChannelSocket(
|
|
68
|
+
ChannelReadFn channelReadFn,
|
|
69
|
+
ChannelReadCtx channelReadCtx,
|
|
70
|
+
ChannelWriteFn channelWriteFn,
|
|
71
|
+
ChannelWriteCtx channelWriteCtx);
|
|
67
72
|
virtual ~ChannelSocket();
|
|
68
73
|
|
|
69
74
|
public:
|
|
70
75
|
void Close();
|
|
71
76
|
void SetListener(Listener* listener);
|
|
77
|
+
bool CallbackRead();
|
|
72
78
|
void Send(json& jsonMessage);
|
|
73
|
-
void SendLog(char* message, uint32_t messageLen);
|
|
79
|
+
void SendLog(const char* message, uint32_t messageLen);
|
|
74
80
|
|
|
75
81
|
private:
|
|
76
|
-
void SendImpl(const
|
|
82
|
+
void SendImpl(const uint8_t* payload, uint32_t payloadLen);
|
|
77
83
|
|
|
78
84
|
/* Pure virtual methods inherited from ConsumerSocket::Listener. */
|
|
79
85
|
public:
|
|
@@ -85,9 +91,14 @@ namespace Channel
|
|
|
85
91
|
Listener* listener{ nullptr };
|
|
86
92
|
// Others.
|
|
87
93
|
bool closed{ false };
|
|
88
|
-
ConsumerSocket consumerSocket;
|
|
89
|
-
ProducerSocket producerSocket;
|
|
90
|
-
|
|
94
|
+
ConsumerSocket* consumerSocket{ nullptr };
|
|
95
|
+
ProducerSocket* producerSocket{ nullptr };
|
|
96
|
+
ChannelReadFn channelReadFn{ nullptr };
|
|
97
|
+
ChannelReadCtx channelReadCtx{ nullptr };
|
|
98
|
+
ChannelWriteFn channelWriteFn{ nullptr };
|
|
99
|
+
ChannelWriteCtx channelWriteCtx{ nullptr };
|
|
100
|
+
uv_async_t* uvReadHandle{ nullptr };
|
|
101
|
+
uint8_t* writeBuffer{ nullptr };
|
|
91
102
|
};
|
|
92
103
|
} // namespace Channel
|
|
93
104
|
|
|
@@ -132,7 +132,7 @@ public:
|
|
|
132
132
|
static void ClassInit(Channel::ChannelSocket* channel);
|
|
133
133
|
|
|
134
134
|
public:
|
|
135
|
-
static const
|
|
135
|
+
static const uint64_t pid;
|
|
136
136
|
thread_local static Channel::ChannelSocket* channel;
|
|
137
137
|
static const size_t bufferSize {50000};
|
|
138
138
|
thread_local static char buffer[];
|
|
@@ -71,16 +71,24 @@ namespace PayloadChannel
|
|
|
71
71
|
|
|
72
72
|
public:
|
|
73
73
|
explicit PayloadChannelSocket(int consumerFd, int producerFd);
|
|
74
|
+
explicit PayloadChannelSocket(
|
|
75
|
+
PayloadChannelReadFn payloadChannelReadFn,
|
|
76
|
+
PayloadChannelReadCtx payloadChannelReadCtx,
|
|
77
|
+
PayloadChannelWriteFn payloadChannelWriteFn,
|
|
78
|
+
PayloadChannelWriteCtx payloadChannelWriteCtx);
|
|
74
79
|
virtual ~PayloadChannelSocket();
|
|
75
80
|
|
|
76
81
|
public:
|
|
77
82
|
void Close();
|
|
78
83
|
void SetListener(Listener* listener);
|
|
84
|
+
bool CallbackRead();
|
|
79
85
|
void Send(json& jsonMessage, const uint8_t* payload, size_t payloadLen);
|
|
80
86
|
void Send(json& jsonMessage);
|
|
81
87
|
|
|
82
88
|
private:
|
|
83
|
-
void SendImpl(const
|
|
89
|
+
void SendImpl(const uint8_t* message, uint32_t messageLen);
|
|
90
|
+
void SendImpl(
|
|
91
|
+
const uint8_t* message, uint32_t messageLen, const uint8_t* payload, uint32_t payloadLen);
|
|
84
92
|
|
|
85
93
|
/* Pure virtual methods inherited from ConsumerSocket::Listener. */
|
|
86
94
|
public:
|
|
@@ -92,11 +100,16 @@ namespace PayloadChannel
|
|
|
92
100
|
Listener* listener{ nullptr };
|
|
93
101
|
// Others.
|
|
94
102
|
bool closed{ false };
|
|
95
|
-
ConsumerSocket consumerSocket;
|
|
96
|
-
ProducerSocket producerSocket;
|
|
103
|
+
ConsumerSocket* consumerSocket{ nullptr };
|
|
104
|
+
ProducerSocket* producerSocket{ nullptr };
|
|
105
|
+
PayloadChannelReadFn payloadChannelReadFn{ nullptr };
|
|
106
|
+
PayloadChannelReadCtx payloadChannelReadCtx{ nullptr };
|
|
107
|
+
PayloadChannelWriteFn payloadChannelWriteFn{ nullptr };
|
|
108
|
+
PayloadChannelWriteCtx payloadChannelWriteCtx{ nullptr };
|
|
97
109
|
PayloadChannel::Notification* ongoingNotification{ nullptr };
|
|
98
110
|
PayloadChannel::PayloadChannelRequest* ongoingRequest{ nullptr };
|
|
99
|
-
|
|
111
|
+
uv_async_t* uvReadHandle{ nullptr };
|
|
112
|
+
uint8_t* writeBuffer{ nullptr };
|
|
100
113
|
};
|
|
101
114
|
} // namespace PayloadChannel
|
|
102
115
|
|
|
@@ -46,9 +46,10 @@ namespace RTC
|
|
|
46
46
|
bool HasReceiverReferenceTime()
|
|
47
47
|
{
|
|
48
48
|
return std::any_of(
|
|
49
|
-
this->xrPacket.Begin(),
|
|
50
|
-
|
|
51
|
-
|
|
49
|
+
this->xrPacket.Begin(),
|
|
50
|
+
this->xrPacket.End(),
|
|
51
|
+
[](const ExtendedReportBlock* report)
|
|
52
|
+
{ return report->GetType() == ExtendedReportBlock::Type::RRT; });
|
|
52
53
|
}
|
|
53
54
|
void Serialize(uint8_t* data);
|
|
54
55
|
|
|
@@ -24,6 +24,12 @@ namespace RTC
|
|
|
24
24
|
class FeedbackPsTstItem : public FeedbackItem
|
|
25
25
|
{
|
|
26
26
|
public:
|
|
27
|
+
#ifdef _WIN32
|
|
28
|
+
#pragma pack(push, 1)
|
|
29
|
+
#define MEDIASOUP_PACKED
|
|
30
|
+
#else
|
|
31
|
+
#define MEDIASOUP_PACKED __attribute__((packed))
|
|
32
|
+
#endif
|
|
27
33
|
struct Header
|
|
28
34
|
{
|
|
29
35
|
uint32_t ssrc;
|
|
@@ -36,7 +42,11 @@ namespace RTC
|
|
|
36
42
|
uint8_t reserved2 : 3;
|
|
37
43
|
uint8_t index : 5;
|
|
38
44
|
#endif
|
|
39
|
-
};
|
|
45
|
+
} MEDIASOUP_PACKED;
|
|
46
|
+
#ifdef _WIN32
|
|
47
|
+
#pragma pack(pop)
|
|
48
|
+
#endif
|
|
49
|
+
#undef MEDIASOUP_PACKED
|
|
40
50
|
|
|
41
51
|
public:
|
|
42
52
|
static const size_t HeaderSize{ 8 };
|
|
@@ -82,8 +82,9 @@ namespace RTC
|
|
|
82
82
|
void SetTotalLost(int32_t totalLost)
|
|
83
83
|
{
|
|
84
84
|
// Get the limit value for possitive and negative totalLost.
|
|
85
|
-
int32_t clamp = (totalLost >= 0)
|
|
86
|
-
|
|
85
|
+
int32_t clamp = (totalLost >= 0) ? totalLost > 0x07FFFFF ? 0x07FFFFF : totalLost
|
|
86
|
+
: -totalLost > 0x0800000 ? 0x0800000
|
|
87
|
+
: -totalLost;
|
|
87
88
|
|
|
88
89
|
uint32_t value = (totalLost >= 0) ? (clamp & 0x07FFFFF) : (clamp | 0x0800000);
|
|
89
90
|
|
|
@@ -23,4 +23,43 @@ typedef SSIZE_T ssize_t;
|
|
|
23
23
|
#include <sys/socket.h> // struct sockaddr, struct sockaddr_storage, AF_INET, AF_INET6
|
|
24
24
|
#endif
|
|
25
25
|
|
|
26
|
+
using ChannelReadCtx = void*;
|
|
27
|
+
using ChannelReadFreeFn = void (*)(uint8_t*, uint32_t, size_t);
|
|
28
|
+
// Returns `ChannelReadFree` on successful read that must be used to free `message`.
|
|
29
|
+
using ChannelReadFn = ChannelReadFreeFn (*)(
|
|
30
|
+
uint8_t** /* message */,
|
|
31
|
+
uint32_t* /* messageLen */,
|
|
32
|
+
size_t* /* messageCtx */,
|
|
33
|
+
// This is `uv_async_t` handle that can be called later with `uv_async_send()` when there is more
|
|
34
|
+
// data to read.
|
|
35
|
+
const void* /* handle */,
|
|
36
|
+
ChannelReadCtx /* ctx */);
|
|
37
|
+
|
|
38
|
+
using ChannelWriteCtx = void*;
|
|
39
|
+
using ChannelWriteFn =
|
|
40
|
+
void (*)(const uint8_t* /* message */, uint32_t /* messageLen */, ChannelWriteCtx /* ctx */);
|
|
41
|
+
|
|
42
|
+
using PayloadChannelReadCtx = void*;
|
|
43
|
+
using PayloadChannelReadFreeFn = void (*)(uint8_t*, uint32_t, size_t);
|
|
44
|
+
// Returns `PayloadChannelReadFree` on successful read that must be used to free `message` and `payload`.
|
|
45
|
+
using PayloadChannelReadFn = PayloadChannelReadFreeFn (*)(
|
|
46
|
+
uint8_t** /* message */,
|
|
47
|
+
uint32_t* /* messageLen */,
|
|
48
|
+
size_t* /* messageCtx */,
|
|
49
|
+
uint8_t** /* payload */,
|
|
50
|
+
uint32_t* /* payloadLen */,
|
|
51
|
+
size_t* /* payloadCapacity */,
|
|
52
|
+
// This is `uv_async_t` handle that can be called later with `uv_async_send()` when there is more
|
|
53
|
+
// data to read.
|
|
54
|
+
const void* /* handle */,
|
|
55
|
+
PayloadChannelReadCtx /* ctx */);
|
|
56
|
+
|
|
57
|
+
using PayloadChannelWriteCtx = void*;
|
|
58
|
+
using PayloadChannelWriteFn = void (*)(
|
|
59
|
+
const uint8_t* /* message */,
|
|
60
|
+
uint32_t /* messageLen */,
|
|
61
|
+
const uint8_t* /* payload */,
|
|
62
|
+
uint32_t /* payloadLen */,
|
|
63
|
+
ChannelWriteCtx /* ctx */);
|
|
64
|
+
|
|
26
65
|
#endif
|
package/worker/include/lib.hpp
CHANGED
|
@@ -1,8 +1,18 @@
|
|
|
1
|
-
|
|
1
|
+
#include "common.hpp"
|
|
2
|
+
|
|
3
|
+
extern "C" int mediasoup_worker_run(
|
|
2
4
|
int argc,
|
|
3
5
|
char* argv[],
|
|
4
6
|
const char* version,
|
|
5
7
|
int consumerChannelFd,
|
|
6
8
|
int producerChannelFd,
|
|
7
9
|
int payloadConsumeChannelFd,
|
|
8
|
-
int payloadProduceChannelFd
|
|
10
|
+
int payloadProduceChannelFd,
|
|
11
|
+
ChannelReadFn channelReadFn,
|
|
12
|
+
ChannelReadCtx channelReadCtx,
|
|
13
|
+
ChannelWriteFn channelWriteFn,
|
|
14
|
+
ChannelWriteCtx channelWriteCtx,
|
|
15
|
+
PayloadChannelReadFn payloadChannelReadFn,
|
|
16
|
+
PayloadChannelReadCtx payloadChannelReadCtx,
|
|
17
|
+
PayloadChannelWriteFn payloadChannelWriteFn,
|
|
18
|
+
PayloadChannelWriteCtx payloadChannelWriteCtx);
|