mediasoup 3.9.2 → 3.9.6

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.
Files changed (46) hide show
  1. package/node/lib/Channel.js +1 -1
  2. package/node/lib/PayloadChannel.js +1 -1
  3. package/node/lib/Worker.js +1 -1
  4. package/node/lib/index.d.ts +1 -1
  5. package/node/lib/index.js +1 -1
  6. package/node/lib/ortc.js +4 -6
  7. package/node/lib/supportedRtpCapabilities.d.ts.map +1 -1
  8. package/node/lib/supportedRtpCapabilities.js +14 -34
  9. package/npm-scripts.js +6 -2
  10. package/package.json +12 -12
  11. package/worker/Makefile +49 -19
  12. package/worker/include/Channel/ChannelNotifier.hpp +1 -0
  13. package/worker/include/Channel/ChannelSocket.hpp +16 -5
  14. package/worker/include/Logger.hpp +1 -1
  15. package/worker/include/PayloadChannel/PayloadChannelSocket.hpp +17 -4
  16. package/worker/include/RTC/IceServer.hpp +7 -5
  17. package/worker/include/RTC/RTCP/CompoundPacket.hpp +4 -3
  18. package/worker/include/RTC/RTCP/FeedbackPsTst.hpp +11 -1
  19. package/worker/include/RTC/RTCP/ReceiverReport.hpp +3 -2
  20. package/worker/include/RTC/RtpDictionaries.hpp +2 -1
  21. package/worker/include/RTC/RtpHeaderExtensionIds.hpp +1 -0
  22. package/worker/include/RTC/StunPacket.hpp +24 -5
  23. package/worker/include/RTC/TransportCongestionControlClient.hpp +3 -0
  24. package/worker/include/common.hpp +39 -0
  25. package/worker/include/lib.hpp +12 -2
  26. package/worker/meson.build +8 -0
  27. package/worker/scripts/package-lock.json +9913 -0
  28. package/worker/src/Channel/ChannelNotifier.cpp +14 -0
  29. package/worker/src/Channel/ChannelSocket.cpp +141 -14
  30. package/worker/src/DepOpenSSL.cpp +8 -5
  31. package/worker/src/Logger.cpp +1 -1
  32. package/worker/src/PayloadChannel/PayloadChannelSocket.cpp +226 -17
  33. package/worker/src/RTC/ActiveSpeakerObserver.cpp +1 -1
  34. package/worker/src/RTC/DataConsumer.cpp +9 -6
  35. package/worker/src/RTC/IceServer.cpp +93 -33
  36. package/worker/src/RTC/Producer.cpp +20 -0
  37. package/worker/src/RTC/RtpDictionaries/RtpHeaderExtensionUri.cpp +2 -1
  38. package/worker/src/RTC/StunPacket.cpp +17 -0
  39. package/worker/src/RTC/Transport.cpp +48 -36
  40. package/worker/src/RTC/TransportCongestionControlClient.cpp +89 -22
  41. package/worker/src/RTC/WebRtcTransport.cpp +1 -2
  42. package/worker/src/Worker.cpp +9 -9
  43. package/worker/src/lib.cpp +29 -5
  44. package/worker/src/lib.rs +88 -2
  45. package/worker/src/main.cpp +10 -2
  46. package/worker/subprojects/libuv.wrap +7 -7
@@ -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
  };
@@ -81,7 +81,7 @@ class Worker extends EnhancedEventEmitter_1.EnhancedEventEmitter {
81
81
  // options
82
82
  {
83
83
  env: {
84
- MEDIASOUP_VERSION: '3.9.2',
84
+ MEDIASOUP_VERSION: '3.9.6',
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.
@@ -9,7 +9,7 @@ export { types };
9
9
  /**
10
10
  * Expose mediasoup version.
11
11
  */
12
- export declare const version = "3.9.2";
12
+ export declare const version = "3.9.6";
13
13
  /**
14
14
  * Expose parseScalabilityMode() function.
15
15
  */
package/node/lib/index.js CHANGED
@@ -11,7 +11,7 @@ exports.types = types;
11
11
  /**
12
12
  * Expose mediasoup version.
13
13
  */
14
- exports.version = '3.9.2';
14
+ exports.version = '3.9.6';
15
15
  /**
16
16
  * Expose parseScalabilityMode() function.
17
17
  */
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,eAwY/B,CAAC;AAEF,OAAO,EAAE,wBAAwB,EAAE,CAAC"}
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,eAgX/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: [
@@ -360,6 +326,20 @@ const supportedRtpCapabilities = {
360
326
  preferredId: 12,
361
327
  preferredEncrypt: false,
362
328
  direction: 'sendrecv'
329
+ },
330
+ {
331
+ kind: 'video',
332
+ uri: 'http://www.webrtc.org/experiments/rtp-hdrext/abs-capture-time',
333
+ preferredId: 13,
334
+ preferredEncrypt: false,
335
+ direction: 'sendrecv'
336
+ },
337
+ {
338
+ kind: 'audio',
339
+ uri: 'http://www.webrtc.org/experiments/rtp-hdrext/abs-capture-time',
340
+ preferredId: 13,
341
+ preferredEncrypt: false,
342
+ direction: 'sendrecv'
363
343
  }
364
344
  ]
365
345
  };
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
- execute(`${MAKE} clean-pip -C worker`);
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 install --prefix worker/scripts');
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.2",
3
+ "version": "3.9.6",
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.7",
73
- "debug": "^4.3.2",
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.0.2",
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.1",
83
- "@typescript-eslint/eslint-plugin": "^5.3.1",
84
- "@typescript-eslint/parser": "^5.3.1",
85
- "eslint": "^8.2.0",
86
- "eslint-plugin-jest": "^25.2.4",
87
- "jest": "^27.3.1",
82
+ "@types/uuid": "^8.3.4",
83
+ "@typescript-eslint/eslint-plugin": "^5.10.1",
84
+ "@typescript-eslint/parser": "^5.10.1",
85
+ "eslint": "^8.7.0",
86
+ "eslint-plugin-jest": "^26.0.0",
87
+ "jest": "^27.4.7",
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.5.0",
93
- "typescript": "^4.4.4"
92
+ "tsc-watch": "^4.6.0",
93
+ "typescript": "^4.5.5"
94
94
  }
95
95
  }
package/worker/Makefile CHANGED
@@ -12,6 +12,8 @@ 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
+ INSTALL_DIR ?= $(MEDIASOUP_OUT_DIR)/$(MEDIASOUP_BUILDTYPE)
16
+ BUILD_DIR ?= $(MEDIASOUP_OUT_DIR)/$(MEDIASOUP_BUILDTYPE)/build
15
17
  MESON ?= $(PIP_DIR)/bin/meson
16
18
  MESON_ARGS ?= ""
17
19
  # Workaround for NixOS and Guix that don't work with pre-built binaries, see:
@@ -37,6 +39,13 @@ else
37
39
  export PYTHONPATH := $(PIP_DIR):${PYTHONPATH}
38
40
  endif
39
41
 
42
+ # Activate VS environment on Windows by default.
43
+ ifeq ($(OS),Windows_NT)
44
+ ifeq ($(MESON_ARGS),"")
45
+ MESON_ARGS = $(subst $\",,"--vsenv")
46
+ endif
47
+ endif
48
+
40
49
  .PHONY: \
41
50
  default meson-ninja setup clean clean-pip clean-subprojects clean-all mediasoup-worker xcode lint format test tidy \
42
51
  fuzzer fuzzer-run-all docker-build docker-run libmediasoup-worker
@@ -63,56 +72,77 @@ setup: meson-ninja
63
72
  # https://github.com/ninja-build/ninja/issues/1997
64
73
  ifeq ($(MEDIASOUP_BUILDTYPE),Release)
65
74
  $(MESON) setup \
75
+ --prefix $(INSTALL_DIR) \
76
+ --bindir '' \
77
+ --libdir '' \
66
78
  --buildtype release \
67
79
  -Db_ndebug=true \
68
80
  -Db_pie=true \
69
81
  -Db_staticpic=true \
70
82
  --reconfigure \
71
83
  $(MESON_ARGS) \
72
- $(MEDIASOUP_OUT_DIR)/$(MEDIASOUP_BUILDTYPE) || \
84
+ $(BUILD_DIR) || \
73
85
  $(MESON) setup \
86
+ --prefix $(INSTALL_DIR) \
87
+ --bindir '' \
88
+ --libdir '' \
74
89
  --buildtype release \
75
90
  -Db_ndebug=true \
76
91
  -Db_pie=true \
77
92
  -Db_staticpic=true \
78
93
  $(MESON_ARGS) \
79
- $(MEDIASOUP_OUT_DIR)/$(MEDIASOUP_BUILDTYPE)
94
+ $(BUILD_DIR)
80
95
  else
81
96
  ifeq ($(MEDIASOUP_BUILDTYPE),Debug)
82
97
  $(MESON) setup \
98
+ --prefix $(INSTALL_DIR) \
99
+ --bindir '' \
100
+ --libdir '' \
83
101
  --buildtype debug \
84
102
  -Db_pie=true \
85
103
  -Db_staticpic=true \
86
104
  --reconfigure \
87
105
  $(MESON_ARGS) \
88
- $(MEDIASOUP_OUT_DIR)/$(MEDIASOUP_BUILDTYPE) || \
106
+ $(BUILD_DIR) || \
89
107
  $(MESON) setup \
108
+ --prefix $(INSTALL_DIR) \
109
+ --bindir '' \
110
+ --libdir '' \
90
111
  --buildtype debug \
91
112
  -Db_pie=true \
92
113
  -Db_staticpic=true \
93
114
  $(MESON_ARGS) \
94
- $(MEDIASOUP_OUT_DIR)/$(MEDIASOUP_BUILDTYPE)
115
+ $(BUILD_DIR)
95
116
  else
96
117
  $(MESON) setup \
118
+ --prefix $(INSTALL_DIR) \
119
+ --bindir '' \
120
+ --libdir '' \
97
121
  --buildtype $(MEDIASOUP_BUILDTYPE) \
98
122
  -Db_ndebug=if-release \
99
123
  -Db_pie=true \
100
124
  -Db_staticpic=true \
101
125
  --reconfigure \
102
126
  $(MESON_ARGS) \
103
- $(MEDIASOUP_OUT_DIR)/$(MEDIASOUP_BUILDTYPE) || \
127
+ $(BUILD_DIR) || \
104
128
  $(MESON) setup \
129
+ --prefix $(INSTALL_DIR) \
130
+ --bindir '' \
131
+ --libdir '' \
105
132
  --buildtype $(MEDIASOUP_BUILDTYPE) \
106
133
  -Db_ndebug=if-release \
107
134
  -Db_pie=true \
108
135
  -Db_staticpic=true \
109
136
  $(MESON_ARGS) \
110
- $(MEDIASOUP_OUT_DIR)/$(MEDIASOUP_BUILDTYPE)
137
+ $(BUILD_DIR)
111
138
  endif
112
139
  endif
113
140
 
114
141
  clean:
115
- $(RM) -rf $(MEDIASOUP_OUT_DIR)/$(MEDIASOUP_BUILDTYPE)
142
+ $(RM) -rf $(INSTALL_DIR)
143
+
144
+ clean-build:
145
+ $(RM) -rf $(BUILD_DIR)
116
146
 
117
147
  clean-pip:
118
148
  $(RM) -rf $(PIP_DIR)
@@ -125,7 +155,8 @@ clean-all: clean-subprojects
125
155
 
126
156
  mediasoup-worker: setup
127
157
  ifeq ($(MEDIASOUP_WORKER_BIN),)
128
- $(MESON) compile -j $(CORES) -C $(MEDIASOUP_OUT_DIR)/$(MEDIASOUP_BUILDTYPE) mediasoup-worker
158
+ $(MESON) compile -C $(BUILD_DIR) -j $(CORES) mediasoup-worker
159
+ $(MESON) install -C $(BUILD_DIR) --no-rebuild --tags mediasoup-worker
129
160
  endif
130
161
 
131
162
  xcode: setup
@@ -138,16 +169,15 @@ format:
138
169
  $(GULP) --gulpfile ./scripts/gulpfile.js format:worker
139
170
 
140
171
  test: setup
141
- ifeq ($(MEDIASOUP_WORKER_BIN),)
142
- $(MESON) compile -j $(CORES) -C $(MEDIASOUP_OUT_DIR)/$(MEDIASOUP_BUILDTYPE) mediasoup-worker-test
172
+ $(MESON) compile -C $(BUILD_DIR) -j $(CORES) mediasoup-worker-test
173
+ $(MESON) install -C $(BUILD_DIR) --no-rebuild --tags mediasoup-worker-test
143
174
  # On Windows lcov doesn't work (at least not yet) and we need to add `.exe` to
144
175
  # the binary path.
145
176
  ifeq ($(OS),Windows_NT)
146
- $(MEDIASOUP_OUT_DIR)/$(MEDIASOUP_BUILDTYPE)/mediasoup-worker-test.exe --invisibles --use-colour=yes $(MEDIASOUP_TEST_TAGS)
177
+ $(BUILD_DIR)/mediasoup-worker-test.exe --invisibles --use-colour=yes $(MEDIASOUP_TEST_TAGS)
147
178
  else
148
179
  $(LCOV) --directory ./ --zerocounters
149
- $(MEDIASOUP_OUT_DIR)/$(MEDIASOUP_BUILDTYPE)/mediasoup-worker-test --invisibles --use-colour=yes $(MEDIASOUP_TEST_TAGS)
150
- endif
180
+ $(BUILD_DIR)/mediasoup-worker-test --invisibles --use-colour=yes $(MEDIASOUP_TEST_TAGS)
151
181
  endif
152
182
 
153
183
  tidy:
@@ -155,18 +185,17 @@ tidy:
155
185
  -clang-tidy-binary=./scripts/node_modules/.bin/clang-tidy \
156
186
  -clang-apply-replacements-binary=./scripts/node_modules/.bin/clang-apply-replacements \
157
187
  -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=$(MEDIASOUP_OUT_DIR)/$(MEDIASOUP_BUILDTYPE) \
188
+ -p=$(BUILD_DIR) \
159
189
  -j=$(CORES) \
160
190
  -checks=$(MEDIASOUP_TIDY_CHECKS) \
161
191
  -quiet
162
192
 
163
193
  fuzzer: setup
164
- ifeq ($(MEDIASOUP_WORKER_BIN),)
165
- $(MESON) compile -j $(CORES) -C $(MEDIASOUP_OUT_DIR)/$(MEDIASOUP_BUILDTYPE) mediasoup-worker-fuzzer
166
- endif
194
+ $(MESON) compile -C $(BUILD_DIR) -j $(CORES) mediasoup-worker-fuzzer
195
+ $(MESON) install -C $(BUILD_DIR) --no-rebuild --tags mediasoup-worker-fuzzer
167
196
 
168
197
  fuzzer-run-all:
169
- LSAN_OPTIONS=verbosity=1:log_threads=1 ./$(MEDIASOUP_OUT_DIR)/$(MEDIASOUP_BUILDTYPE)/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
198
+ 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
199
 
171
200
  docker-build:
172
201
  ifeq ($(DOCKER_NO_CACHE),true)
@@ -184,4 +213,5 @@ docker-run:
184
213
  mediasoup/docker:latest
185
214
 
186
215
  libmediasoup-worker: setup
187
- $(MESON) compile -j $(CORES) -C $(MEDIASOUP_OUT_DIR)/$(MEDIASOUP_BUILDTYPE) libmediasoup-worker
216
+ $(MESON) compile -C $(BUILD_DIR) -j $(CORES) libmediasoup-worker
217
+ $(MESON) install -C $(BUILD_DIR) --no-rebuild --tags 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 void* payload, uint32_t payloadLen);
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
- uint8_t* writeBuffer;
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 int64_t pid;
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 void* payload, uint32_t payloadLen);
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
- uint8_t* writeBuffer;
111
+ uv_async_t* uvReadHandle{ nullptr };
112
+ uint8_t* writeBuffer{ nullptr };
100
113
  };
101
114
  } // namespace PayloadChannel
102
115
 
@@ -61,15 +61,15 @@ namespace RTC
61
61
  {
62
62
  return this->selectedTuple;
63
63
  }
64
- void SetUsernameFragment(const std::string& usernameFragment)
64
+ void RestartIce(const std::string& usernameFragment, const std::string& password)
65
65
  {
66
66
  this->oldUsernameFragment = this->usernameFragment;
67
67
  this->usernameFragment = usernameFragment;
68
- }
69
- void SetPassword(const std::string& password)
70
- {
68
+
71
69
  this->oldPassword = this->password;
72
70
  this->password = password;
71
+
72
+ this->remoteNomination = 0u;
73
73
  }
74
74
  bool IsValidTuple(const RTC::TransportTuple* tuple) const;
75
75
  void RemoveTuple(RTC::TransportTuple* tuple);
@@ -78,7 +78,8 @@ namespace RTC
78
78
  void ForceSelectedTuple(const RTC::TransportTuple* tuple);
79
79
 
80
80
  private:
81
- void HandleTuple(RTC::TransportTuple* tuple, bool hasUseCandidate);
81
+ void HandleTuple(
82
+ RTC::TransportTuple* tuple, bool hasUseCandidate, bool hasNomination, uint32_t nomination);
82
83
  /**
83
84
  * Store the given tuple and return its stored address.
84
85
  */
@@ -101,6 +102,7 @@ namespace RTC
101
102
  std::string password;
102
103
  std::string oldUsernameFragment;
103
104
  std::string oldPassword;
105
+ uint32_t remoteNomination{ 0u };
104
106
  IceState state{ IceState::NEW };
105
107
  std::list<RTC::TransportTuple> tuples;
106
108
  RTC::TransportTuple* selectedTuple{ nullptr };
@@ -46,9 +46,10 @@ namespace RTC
46
46
  bool HasReceiverReferenceTime()
47
47
  {
48
48
  return std::any_of(
49
- this->xrPacket.Begin(), this->xrPacket.End(), [](const ExtendedReportBlock* report) {
50
- return report->GetType() == ExtendedReportBlock::Type::RRT;
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) ? totalLost > 0x07FFFFF ? 0x07FFFFF : totalLost
86
- : -totalLost > 0x0800000 ? 0x0800000 : -totalLost;
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
 
@@ -140,7 +140,8 @@ namespace RTC
140
140
  FRAME_MARKING = 7,
141
141
  SSRC_AUDIO_LEVEL = 10,
142
142
  VIDEO_ORIENTATION = 11,
143
- TOFFSET = 12
143
+ TOFFSET = 12,
144
+ ABS_CAPTURE_TIME = 13,
144
145
  };
145
146
 
146
147
  private:
@@ -18,6 +18,7 @@ namespace RTC
18
18
  uint8_t ssrcAudioLevel{ 0u };
19
19
  uint8_t videoOrientation{ 0u };
20
20
  uint8_t toffset{ 0u };
21
+ uint8_t absCaptureTime{ 0u };
21
22
  };
22
23
  } // namespace RTC
23
24
 
@@ -41,7 +41,8 @@ namespace RTC
41
41
  ALTERNATE_SERVER = 0x8023,
42
42
  FINGERPRINT = 0x8028,
43
43
  ICE_CONTROLLED = 0x8029,
44
- ICE_CONTROLLING = 0x802A
44
+ ICE_CONTROLLING = 0x802A,
45
+ NOMINATION = 0xC001
45
46
  };
46
47
 
47
48
  // Authentication result.
@@ -114,6 +115,10 @@ namespace RTC
114
115
  {
115
116
  this->hasUseCandidate = true;
116
117
  }
118
+ void SetNomination(uint32_t nomination)
119
+ {
120
+ this->nomination = nomination;
121
+ }
117
122
  void SetXorMappedAddress(const struct sockaddr* xorMappedAddress)
118
123
  {
119
124
  this->xorMappedAddress = xorMappedAddress;
@@ -150,6 +155,18 @@ namespace RTC
150
155
  {
151
156
  return this->hasUseCandidate;
152
157
  }
158
+ void SetHasNomination()
159
+ {
160
+ this->hasNomination = true;
161
+ }
162
+ bool HasNomination() const
163
+ {
164
+ return this->hasNomination;
165
+ }
166
+ uint32_t GetNomination() const
167
+ {
168
+ return this->nomination;
169
+ }
153
170
  uint16_t GetErrorCode() const
154
171
  {
155
172
  return this->errorCode;
@@ -177,10 +194,12 @@ namespace RTC
177
194
  uint8_t* data{ nullptr }; // Pointer to binary data.
178
195
  size_t size{ 0u }; // The full message size (including header).
179
196
  // STUN attributes.
180
- std::string username; // Less than 513 bytes.
181
- uint32_t priority{ 0u }; // 4 bytes unsigned integer.
182
- uint64_t iceControlling{ 0u }; // 8 bytes unsigned integer.
183
- uint64_t iceControlled{ 0u }; // 8 bytes unsigned integer.
197
+ std::string username; // Less than 513 bytes.
198
+ uint32_t priority{ 0u }; // 4 bytes unsigned integer.
199
+ uint64_t iceControlling{ 0u }; // 8 bytes unsigned integer.
200
+ uint64_t iceControlled{ 0u }; // 8 bytes unsigned integer.
201
+ bool hasNomination{ false };
202
+ uint32_t nomination{ 0u }; // 4 bytes unsigned integer.
184
203
  bool hasUseCandidate{ false }; // 0 bytes.
185
204
  const uint8_t* messageIntegrity{ nullptr }; // 20 bytes.
186
205
  bool hasFingerprint{ false }; // 4 bytes.