mediasoup 3.10.11 → 3.11.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/README.md CHANGED
@@ -7,7 +7,6 @@
7
7
  [![][github-actions-shield-mediasoup-node]][github-actions-mediasoup-node]
8
8
  [![][github-actions-shield-mediasoup-worker]][github-actions-mediasoup-worker]
9
9
  [![][github-actions-shield-mediasoup-rust]][github-actions-mediasoup-rust]
10
- [![][codacy-grade-shield-mediasoup]][codacy-grade-mediasoup]
11
10
  [![][opencollective-shield-mediasoup]][opencollective-mediasoup]
12
11
 
13
12
 
@@ -101,8 +100,6 @@ You can support mediasoup by [sponsoring][sponsor] it. Thanks!
101
100
  [github-actions-mediasoup-worker]: https://github.com/versatica/mediasoup/actions/workflows/mediasoup-worker.yaml
102
101
  [github-actions-shield-mediasoup-rust]: https://github.com/versatica/mediasoup/actions/workflows/mediasoup-rust.yaml/badge.svg
103
102
  [github-actions-mediasoup-rust]: https://github.com/versatica/mediasoup/actions/workflows/mediasoup-rust.yaml
104
- [codacy-grade-shield-mediasoup]: https://img.shields.io/codacy/grade/3c8b9efc83674b6189707ab4188cfb2b.svg
105
- [codacy-grade-mediasoup]: https://www.codacy.com/app/versatica/mediasoup
106
103
  [opencollective-shield-mediasoup]: https://img.shields.io/opencollective/all/mediasoup.svg
107
104
  [opencollective-mediasoup]: https://opencollective.com/mediasoup/
108
105
  [sponsor]: https://mediasoup.org/sponsor/
@@ -15,14 +15,10 @@ export interface ActiveSpeakerObserverActivity {
15
15
  producer: Producer;
16
16
  }
17
17
  export declare type ActiveSpeakerObserverEvents = RtpObserverEvents & {
18
- dominantspeaker: [{
19
- producer: Producer;
20
- }];
18
+ dominantspeaker: [Producer];
21
19
  };
22
20
  export declare type ActiveSpeakerObserverObserverEvents = RtpObserverObserverEvents & {
23
- dominantspeaker: [{
24
- producer: Producer;
25
- }];
21
+ dominantspeaker: [Producer];
26
22
  };
27
23
  declare type RtpObserverObserverConstructorOptions = RtpObserverConstructorOptions;
28
24
  export declare class ActiveSpeakerObserver extends RtpObserver<ActiveSpeakerObserverEvents> {
@@ -1 +1 @@
1
- {"version":3,"file":"ActiveSpeakerObserver.d.ts","sourceRoot":"","sources":["../src/ActiveSpeakerObserver.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EACN,WAAW,EACX,iBAAiB,EACjB,yBAAyB,EACzB,6BAA6B,EAC7B,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,MAAM,WAAW,4BAA4B;IAE5C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAClC;AAED,MAAM,WAAW,6BAA6B;IAE7C;;OAEG;IACH,QAAQ,EAAE,QAAQ,CAAC;CACnB;AAED,oBAAY,2BAA2B,GAAG,iBAAiB,GAC3D;IACC,eAAe,EAAE,CAAC;QAAE,QAAQ,EAAE,QAAQ,CAAA;KAAE,CAAC,CAAC;CAC1C,CAAC;AAEF,oBAAY,mCAAmC,GAAG,yBAAyB,GAC3E;IACC,eAAe,EAAE,CAAC;QAAE,QAAQ,EAAE,QAAQ,CAAA;KAAE,CAAC,CAAC;CAC1C,CAAC;AAEF,aAAK,qCAAqC,GAAG,6BAA6B,CAAC;AAI3E,qBAAa,qBAAsB,SAAQ,WAAW,CAAC,2BAA2B,CAAC;IAElF;;OAEG;gBACS,OAAO,EAAE,qCAAqC;IAO1D;;OAEG;IACH,IAAI,QAAQ,IAAI,oBAAoB,CAAC,mCAAmC,CAAC,CAGxE;IAED,OAAO,CAAC,yBAAyB;CA4BjC"}
1
+ {"version":3,"file":"ActiveSpeakerObserver.d.ts","sourceRoot":"","sources":["../src/ActiveSpeakerObserver.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EACN,WAAW,EACX,iBAAiB,EACjB,yBAAyB,EACzB,6BAA6B,EAC7B,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,MAAM,WAAW,4BAA4B;IAE5C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAClC;AAED,MAAM,WAAW,6BAA6B;IAE7C;;OAEG;IACH,QAAQ,EAAE,QAAQ,CAAC;CACnB;AAED,oBAAY,2BAA2B,GAAG,iBAAiB,GAC3D;IACC,eAAe,EAAE,CAAC,QAAQ,CAAC,CAAC;CAC5B,CAAC;AAEF,oBAAY,mCAAmC,GAAG,yBAAyB,GAC3E;IACC,eAAe,EAAE,CAAC,QAAQ,CAAC,CAAC;CAC5B,CAAC;AAEF,aAAK,qCAAqC,GAAG,6BAA6B,CAAC;AAI3E,qBAAa,qBAAsB,SAAQ,WAAW,CAAC,2BAA2B,CAAC;IAElF;;OAEG;gBACS,OAAO,EAAE,qCAAqC;IAO1D;;OAEG;IACH,IAAI,QAAQ,IAAI,oBAAoB,CAAC,mCAAmC,CAAC,CAGxE;IAED,OAAO,CAAC,yBAAyB;CA0BjC"}
@@ -26,9 +26,8 @@ class ActiveSpeakerObserver extends RtpObserver_1.RtpObserver {
26
26
  const producer = this.getProducerById(data.producerId);
27
27
  if (!producer)
28
28
  break;
29
- const dominantSpeaker = { producer };
30
- this.safeEmit('dominantspeaker', dominantSpeaker);
31
- this.observer.safeEmit('dominantspeaker', dominantSpeaker);
29
+ this.safeEmit('dominantspeaker', producer);
30
+ this.observer.safeEmit('dominantspeaker', producer);
32
31
  break;
33
32
  }
34
33
  default:
@@ -81,7 +81,7 @@ class Worker extends EnhancedEventEmitter_1.EnhancedEventEmitter {
81
81
  // options
82
82
  {
83
83
  env: {
84
- MEDIASOUP_VERSION: '3.10.11',
84
+ MEDIASOUP_VERSION: '3.11.0',
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.10.11";
12
+ export declare const version = "3.11.0";
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.10.11';
14
+ exports.version = '3.11.0';
15
15
  /**
16
16
  * Expose parseScalabilityMode() function.
17
17
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mediasoup",
3
- "version": "3.10.11",
3
+ "version": "3.11.0",
4
4
  "description": "Cutting Edge WebRTC Video Conferencing",
5
5
  "contributors": [
6
6
  "Iñaki Baz Castillo <ibc@aliax.net> (https://inakibaz.me)",
@@ -69,20 +69,20 @@
69
69
  "testRegex": "node/tests/test.*\\.js"
70
70
  },
71
71
  "dependencies": {
72
- "@types/node": "^16.11.10",
72
+ "@types/node": "^18.11.9",
73
73
  "debug": "^4.3.4",
74
74
  "h264-profile-level-id": "^1.0.1",
75
75
  "supports-color": "^9.2.3",
76
- "uuid": "^8.3.2"
76
+ "uuid": "^9.0.0"
77
77
  },
78
78
  "devDependencies": {
79
79
  "@types/debug": "^4.1.7",
80
80
  "@types/uuid": "^8.3.4",
81
- "@typescript-eslint/eslint-plugin": "^5.40.1",
82
- "@typescript-eslint/parser": "^5.40.1",
83
- "eslint": "^8.25.0",
81
+ "@typescript-eslint/eslint-plugin": "^5.42.0",
82
+ "@typescript-eslint/parser": "^5.42.0",
83
+ "eslint": "^8.26.0",
84
84
  "eslint-plugin-jest": "^27.1.3",
85
- "jest": "^29.2.1",
85
+ "jest": "^29.2.2",
86
86
  "jest-tobetype": "^1.2.3",
87
87
  "open-cli": "^7.1.0",
88
88
  "pick-port": "^1.0.1",
package/worker/Makefile CHANGED
@@ -7,11 +7,11 @@ PYTHON ?= $(shell command -v python3 2> /dev/null || echo python)
7
7
  ROOT_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
8
8
  CORES ?= $(shell ${ROOT_DIR}/scripts/cpu_cores.sh || echo 4)
9
9
  MEDIASOUP_OUT_DIR ?= $(shell pwd)/out
10
- # Controls build types, `Release` and `Debug` are presets optimized for those use cases.
11
- # Other build types are possible too, but they are not presets and will require `MESON_ARGS` use to customize build
12
- # configuration.
13
- # Check the meaning of useful macros in the `worker/include/Logger.hpp` header file if you want to enable tracing or
14
- # other debug information.
10
+ # Controls build types, `Release` and `Debug` are presets optimized for those
11
+ # use cases. Other build types are possible too, but they are not presets and
12
+ # will require `MESON_ARGS` use to customize build configuration.
13
+ # Check the meaning of useful macros in the `worker/include/Logger.hpp` header
14
+ # file if you want to enable tracing or other debug information.
15
15
  MEDIASOUP_BUILDTYPE ?= Release
16
16
  GULP = ./scripts/node_modules/.bin/gulp
17
17
  LCOV = ./deps/lcov/bin/lcov
@@ -21,11 +21,13 @@ INSTALL_DIR ?= $(MEDIASOUP_OUT_DIR)/$(MEDIASOUP_BUILDTYPE)
21
21
  BUILD_DIR ?= $(MEDIASOUP_OUT_DIR)/$(MEDIASOUP_BUILDTYPE)/build
22
22
  MESON ?= $(PIP_DIR)/bin/meson
23
23
  MESON_VERSION ?= 0.61.5
24
- # `MESON_ARGS` can be used to provide extra configuration parameters to Meson, such as adding defines or changing
25
- # optimization options. For instance, use `MESON_ARGS="-Dms_log_trace=true -Dms_log_file_line=true" npm i` to compile worker with
26
- # tracing and enabled.
24
+ # `MESON_ARGS` can be used to provide extra configuration parameters to Meson,
25
+ # such as adding defines or changing optimization options. For instance, use
26
+ # `MESON_ARGS="-Dms_log_trace=true -Dms_log_file_line=true" npm i` to compile
27
+ # worker with tracing and enabled.
27
28
  #
28
- # NOTE: On Windows make sure to add `--vsenv` or have MSVS environment already active if you override this parameter.
29
+ # NOTE: On Windows make sure to add `--vsenv` or have MSVS environment already
30
+ # active if you override this parameter.
29
31
  MESON_ARGS ?= ""
30
32
  # Workaround for NixOS and Guix that don't work with pre-built binaries, see:
31
33
  # https://github.com/NixOS/nixpkgs/issues/142383.
@@ -43,7 +45,8 @@ endif
43
45
 
44
46
  # Instruct Python where to look for modules it needs, such that `meson` actually
45
47
  # runs from installed location.
46
- # For some reason on Windows adding `:${PYTHONPATH}` breaks things.
48
+ #
49
+ # NOTE: For some reason on Windows adding `:${PYTHONPATH}` breaks things.
47
50
  ifeq ($(OS),Windows_NT)
48
51
  export PYTHONPATH := $(PIP_DIR)
49
52
  else
@@ -58,18 +61,35 @@ endif
58
61
  endif
59
62
 
60
63
  .PHONY: \
61
- default meson-ninja setup clean clean-pip clean-subprojects clean-all mediasoup-worker xcode lint format test tidy \
62
- fuzzer fuzzer-run-all docker-build docker-run libmediasoup-worker
64
+ default \
65
+ meson-ninja \
66
+ setup \
67
+ clean \
68
+ clean-build \
69
+ clean-pip \
70
+ clean-subprojects \
71
+ clean-all \
72
+ update-wrap-file \
73
+ mediasoup-worker \
74
+ libmediasoup-worker \
75
+ xcode \
76
+ lint \
77
+ format \
78
+ test \
79
+ tidy \
80
+ fuzzer \
81
+ fuzzer-run-all \
82
+ docker-build \
83
+ docker-run
63
84
 
64
85
  default: mediasoup-worker
65
86
 
66
87
  meson-ninja:
67
88
  ifeq ($(wildcard $(PIP_DIR)),)
68
- # Updated pip and setuptools are needed for meson
89
+ # Updated pip and setuptools are needed for meson.
69
90
  # `--system` is not present everywhere and is only needed as workaround for
70
- # Debian-specific issue (copied from
71
- # https://github.com/gluster/gstatus/pull/33), fallback to command without
72
- # `--system` if the first one fails.
91
+ # Debian-specific issue (copied from https://github.com/gluster/gstatus/pull/33),
92
+ # fallback to command without `--system` if the first one fails.
73
93
  $(PYTHON) -m pip install --system --target=$(PIP_DIR) pip setuptools || \
74
94
  $(PYTHON) -m pip install --target=$(PIP_DIR) pip setuptools || \
75
95
  echo "Installation failed, likely because PIP is unavailable, if you are on Debian/Ubuntu or derivative please install the python3-pip package"
@@ -164,12 +184,21 @@ clean-subprojects: meson-ninja
164
184
  clean-all: clean-subprojects
165
185
  $(RM) -rf $(MEDIASOUP_OUT_DIR)
166
186
 
187
+ # Update the wrap file of a subproject. Usage example:
188
+ # make update-wrap-file SUBPROJECT=openssl
189
+ update-wrap-file: meson-ninja
190
+ $(MESON) subprojects update --reset $(SUBPROJECT)
191
+
167
192
  mediasoup-worker: setup
168
193
  ifeq ($(MEDIASOUP_WORKER_BIN),)
169
194
  $(MESON) compile -C $(BUILD_DIR) -j $(CORES) mediasoup-worker
170
195
  $(MESON) install -C $(BUILD_DIR) --no-rebuild --tags mediasoup-worker
171
196
  endif
172
197
 
198
+ libmediasoup-worker: setup
199
+ $(MESON) compile -C $(BUILD_DIR) -j $(CORES) libmediasoup-worker
200
+ $(MESON) install -C $(BUILD_DIR) --no-rebuild --tags libmediasoup-worker
201
+
173
202
  xcode: setup
174
203
  $(MESON) setup --buildtype debug --backend xcode $(MEDIASOUP_OUT_DIR)/xcode
175
204
 
@@ -222,7 +251,3 @@ docker-run:
222
251
  --cap-add SYS_PTRACE \
223
252
  -v $(shell pwd)/../:/mediasoup \
224
253
  mediasoup/docker:latest
225
-
226
- libmediasoup-worker: setup
227
- $(MESON) compile -C $(BUILD_DIR) -j $(CORES) libmediasoup-worker
228
- $(MESON) install -C $(BUILD_DIR) --no-rebuild --tags libmediasoup-worker
@@ -382,26 +382,29 @@ void SendSideBandwidthEstimation::UpdatePacketsLost(int packets_lost,
382
382
 
383
383
  // Check sequence number diff and weight loss report
384
384
  if (number_of_packets > 0) {
385
- // Accumulate reports.
386
- lost_packets_since_last_loss_update_ += packets_lost;
387
- expected_packets_since_last_loss_update_ += number_of_packets;
385
+ int64_t expected =
386
+ expected_packets_since_last_loss_update_ + number_of_packets;
388
387
 
389
388
  // Don't generate a loss rate until it can be based on enough packets.
390
- if (expected_packets_since_last_loss_update_ < kLimitNumPackets)
389
+ if (expected < kLimitNumPackets) {
390
+ // Accumulate reports.
391
+ expected_packets_since_last_loss_update_ = expected;
392
+ lost_packets_since_last_loss_update_ += packets_lost;
391
393
  return;
394
+ }
392
395
 
393
396
  has_decreased_since_last_fraction_loss_ = false;
394
- int64_t lost_q8 = lost_packets_since_last_loss_update_ << 8;
395
- int64_t expected = expected_packets_since_last_loss_update_;
397
+ int64_t lost_q8 =
398
+ std::max<int64_t>(lost_packets_since_last_loss_update_ + packets_lost, 0) << 8;
396
399
  last_fraction_loss_ = std::min<int>(lost_q8 / expected, 255);
397
400
 
398
401
  // Reset accumulators.
399
-
400
402
  lost_packets_since_last_loss_update_ = 0;
401
403
  expected_packets_since_last_loss_update_ = 0;
402
404
  last_loss_packet_report_ = at_time;
403
405
  UpdateEstimate(at_time);
404
406
  }
407
+
405
408
  UpdateUmaStatsPacketsLost(at_time, packets_lost);
406
409
  }
407
410
 
@@ -431,7 +431,7 @@ NetworkControlUpdate GoogCcNetworkController::OnTransportPacketsFeedback(
431
431
  for (const auto& feedback : feedbacks) {
432
432
  TimeDelta feedback_rtt =
433
433
  report.feedback_time - feedback.sent_packet.send_time;
434
- TimeDelta min_pending_time = feedback.receive_time - max_recv_time;
434
+ TimeDelta min_pending_time = max_recv_time - feedback.receive_time;
435
435
  TimeDelta propagation_rtt = feedback_rtt - min_pending_time;
436
436
  max_feedback_rtt = std::max(max_feedback_rtt, feedback_rtt);
437
437
  min_propagation_rtt = std::min(min_propagation_rtt, propagation_rtt);
@@ -9,10 +9,9 @@
9
9
  #include <vector>
10
10
 
11
11
  // Implementation of Dominant Speaker Identification for Multipoint
12
- // Videoconferencing by Ilana Volfin and Israel Cohen. This
13
- // implementation uses the RTP Audio Level extension from RFC-6464
14
- // for the input signal.
15
- // This has been ported from DominantSpeakerIdentification.java in Jitsi.
12
+ // Videoconferencing by Ilana Volfin and Israel Cohen. This implementation uses
13
+ // the RTP Audio Level extension from RFC-6464 for the input signal. This has
14
+ // been ported from DominantSpeakerIdentification.java in Jitsi:
16
15
  // https://github.com/jitsi/jitsi-utils/blob/master/src/main/java/org/jitsi/utils/dsi/DominantSpeakerIdentification.java
17
16
  namespace RTC
18
17
  {
@@ -24,7 +23,7 @@ namespace RTC
24
23
  public:
25
24
  Speaker();
26
25
  void EvalActivityScores();
27
- double GetActivityScore(int32_t interval);
26
+ double GetActivityScore(uint8_t interval);
28
27
  void LevelChanged(uint32_t level, uint64_t now);
29
28
  void LevelTimedOut(uint64_t now);
30
29
 
@@ -39,28 +38,36 @@ namespace RTC
39
38
 
40
39
  public:
41
40
  bool paused{ false };
42
- double immediateActivityScore;
43
- double mediumActivityScore;
44
- double longActivityScore;
41
+ double immediateActivityScore{ 0 };
42
+ double mediumActivityScore{ 0 };
43
+ double longActivityScore{ 0 };
45
44
  uint64_t lastLevelChangeTime{ 0 };
46
45
 
47
46
  private:
48
- uint8_t minLevel;
49
- uint8_t nextMinLevel;
50
- uint32_t nextMinLevelWindowLen{ 0 };
47
+ uint8_t minLevel{ 0u };
48
+ uint8_t nextMinLevel{ 0u };
49
+ uint32_t nextMinLevelWindowLen{ 0u };
51
50
  std::vector<uint8_t> immediates;
52
51
  std::vector<uint8_t> mediums;
53
52
  std::vector<uint8_t> longs;
54
53
  std::vector<uint8_t> levels;
55
- size_t nextLevelIndex;
54
+ size_t nextLevelIndex{ 0u };
56
55
  };
57
56
 
58
- struct ProducerSpeaker
57
+ class ProducerSpeaker
59
58
  {
59
+ public:
60
+ explicit ProducerSpeaker(RTC::Producer* producer);
61
+ ~ProducerSpeaker();
62
+
63
+ public:
60
64
  RTC::Producer* producer;
61
65
  Speaker* speaker;
62
66
  };
63
67
 
68
+ private:
69
+ static const size_t RelativeSpeachActivitiesLen{ 3u };
70
+
64
71
  public:
65
72
  ActiveSpeakerObserver(const std::string& id, RTC::RtpObserver::Listener* listener, json& data);
66
73
  ~ActiveSpeakerObserver() override;
@@ -84,13 +91,13 @@ namespace RTC
84
91
  void OnTimer(Timer* timer) override;
85
92
 
86
93
  private:
87
- static constexpr int relativeSpeachActivitiesLen{ 3 };
88
- double relativeSpeachActivities[relativeSpeachActivitiesLen];
89
- std::string dominantId{ "" };
94
+ double relativeSpeachActivities[RelativeSpeachActivitiesLen];
95
+ std::string dominantId;
90
96
  Timer* periodicTimer{ nullptr };
91
97
  uint16_t interval{ 300u };
92
- absl::flat_hash_map<std::string, struct ProducerSpeaker> mapProducerSpeaker;
93
- uint64_t lastLevelIdleTime{ 0 };
98
+ // Map of ProducerSpeakers indexed by Producer id.
99
+ absl::flat_hash_map<std::string, ProducerSpeaker*> mapProducerSpeakers;
100
+ uint64_t lastLevelIdleTime{ 0u };
94
101
  };
95
102
  } // namespace RTC
96
103
 
@@ -17,11 +17,14 @@ namespace RTC
17
17
  class CompoundPacket
18
18
  {
19
19
  public:
20
- // Maximum size for a CompundPacket, leaving free space for encryption.
21
- // SRTP_MAX_TRAILER_LEN+4 is the maximum number of octects that will be
22
- // added to an RTCP packet by srtp_protect_rtcp().
23
- // srtp.h: SRTP_MAX_TRAILER_LEN (SRTP_MAX_TAG_LEN + SRTP_MAX_MKI_LEN)
24
- constexpr static size_t MaxSize{ RTC::MtuSize - 148u };
20
+ // Maximum size for a CompundPacket.
21
+ // * IPv4|Ipv6 header size: 20|40 bytes. IPv6 considered.
22
+ // * UDP|TCP header size: 8|20 bytes. TCP considered.
23
+ // * SRTP Encryption: 148 bytes.
24
+ // SRTP_MAX_TRAILER_LEN+4 is the maximum number of octects that will be
25
+ // added to an RTCP packet by srtp_protect_rtcp().
26
+ // srtp.h: SRTP_MAX_TRAILER_LEN (SRTP_MAX_TAG_LEN + SRTP_MAX_MKI_LEN)
27
+ constexpr static size_t MaxSize{ RTC::MtuSize - 40u - 20u - 148u };
25
28
 
26
29
  public:
27
30
  CompoundPacket() = default;