mediasoup 3.9.7 → 3.9.10

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 (80) hide show
  1. package/node/lib/Worker.js +1 -1
  2. package/node/lib/index.d.ts +1 -1
  3. package/node/lib/index.js +1 -1
  4. package/node/lib/types.js +5 -1
  5. package/node/lib/utils.d.ts +1 -2
  6. package/node/lib/utils.d.ts.map +1 -1
  7. package/node/lib/utils.js +8 -7
  8. package/package.json +9 -12
  9. package/worker/Makefile +10 -0
  10. package/worker/include/Channel/ChannelRequest.hpp +2 -2
  11. package/worker/include/DepUsrSCTP.hpp +2 -2
  12. package/worker/include/PayloadChannel/Notification.hpp +2 -2
  13. package/worker/include/PayloadChannel/PayloadChannelRequest.hpp +2 -2
  14. package/worker/include/RTC/ActiveSpeakerObserver.hpp +2 -2
  15. package/worker/include/RTC/AudioLevelObserver.hpp +2 -2
  16. package/worker/include/RTC/Consumer.hpp +2 -2
  17. package/worker/include/RTC/DtlsTransport.hpp +4 -4
  18. package/worker/include/RTC/KeyFrameRequestManager.hpp +3 -3
  19. package/worker/include/RTC/NackGenerator.hpp +5 -3
  20. package/worker/include/RTC/Parameters.hpp +2 -2
  21. package/worker/include/RTC/PipeConsumer.hpp +4 -4
  22. package/worker/include/RTC/PlainTransport.hpp +3 -3
  23. package/worker/include/RTC/PortManager.hpp +3 -3
  24. package/worker/include/RTC/Producer.hpp +6 -7
  25. package/worker/include/RTC/RTCP/Feedback.hpp +2 -1
  26. package/worker/include/RTC/RTCP/FeedbackRtpTransport.hpp +1 -1
  27. package/worker/include/RTC/RTCP/Packet.hpp +2 -2
  28. package/worker/include/RTC/RTCP/Sdes.hpp +1 -2
  29. package/worker/include/RTC/RateCalculator.hpp +5 -4
  30. package/worker/include/RTC/Router.hpp +11 -10
  31. package/worker/include/RTC/RtpDictionaries.hpp +10 -11
  32. package/worker/include/RTC/RtpPacket.hpp +17 -10
  33. package/worker/include/RTC/SenderBandwidthEstimator.hpp +2 -1
  34. package/worker/include/RTC/SimulcastConsumer.hpp +1 -1
  35. package/worker/include/RTC/Transport.hpp +7 -7
  36. package/worker/include/RTC/TransportCongestionControlClient.hpp +1 -0
  37. package/worker/include/RTC/WebRtcTransport.hpp +2 -2
  38. package/worker/include/Settings.hpp +3 -3
  39. package/worker/include/Utils.hpp +3 -2
  40. package/worker/include/Worker.hpp +2 -2
  41. package/worker/include/handles/TcpConnectionHandler.hpp +0 -1
  42. package/worker/include/handles/TcpServerHandler.hpp +2 -2
  43. package/worker/include/handles/UnixStreamSocket.hpp +0 -4
  44. package/worker/meson.build +3 -1
  45. package/worker/scripts/package-lock.json +6 -6
  46. package/worker/src/Channel/ChannelRequest.cpp +1 -1
  47. package/worker/src/DepUsrSCTP.cpp +1 -1
  48. package/worker/src/PayloadChannel/Notification.cpp +1 -1
  49. package/worker/src/PayloadChannel/PayloadChannelRequest.cpp +1 -1
  50. package/worker/src/RTC/AudioLevelObserver.cpp +1 -1
  51. package/worker/src/RTC/Codecs/VP9.cpp +10 -2
  52. package/worker/src/RTC/Consumer.cpp +6 -0
  53. package/worker/src/RTC/DtlsTransport.cpp +6 -48
  54. package/worker/src/RTC/NackGenerator.cpp +3 -3
  55. package/worker/src/RTC/PlainTransport.cpp +2 -2
  56. package/worker/src/RTC/PortManager.cpp +2 -2
  57. package/worker/src/RTC/Producer.cpp +1 -0
  58. package/worker/src/RTC/RTCP/Feedback.cpp +2 -2
  59. package/worker/src/RTC/RTCP/FeedbackRtpTransport.cpp +1 -1
  60. package/worker/src/RTC/RTCP/Packet.cpp +1 -1
  61. package/worker/src/RTC/RTCP/Sdes.cpp +1 -1
  62. package/worker/src/RTC/RateCalculator.cpp +5 -5
  63. package/worker/src/RTC/RtpDictionaries/Media.cpp +2 -2
  64. package/worker/src/RTC/RtpDictionaries/RtpCodecMimeType.cpp +4 -4
  65. package/worker/src/RTC/RtpDictionaries/RtpHeaderExtensionUri.cpp +1 -1
  66. package/worker/src/RTC/RtpDictionaries/RtpParameters.cpp +4 -4
  67. package/worker/src/RTC/RtpPacket.cpp +14 -19
  68. package/worker/src/RTC/SimulcastConsumer.cpp +4 -2
  69. package/worker/src/RTC/SvcConsumer.cpp +10 -1
  70. package/worker/src/RTC/TransportCongestionControlClient.cpp +13 -0
  71. package/worker/src/Settings.cpp +3 -4
  72. package/worker/src/Utils/Crypto.cpp +18 -10
  73. package/worker/src/handles/TcpConnectionHandler.cpp +0 -95
  74. package/worker/src/lib.cpp +2 -2
  75. package/worker/subprojects/abseil-cpp.wrap +7 -7
  76. package/worker/subprojects/nlohmann_json.wrap +4 -7
  77. package/worker/subprojects/openssl.wrap +7 -7
  78. package/worker/subprojects/usrsctp.wrap +4 -4
  79. package/worker/subprojects/wingetopt.wrap +4 -5
  80. package/worker/subprojects/packagefiles/wingetopt/meson.build +0 -43
@@ -81,7 +81,7 @@ class Worker extends EnhancedEventEmitter_1.EnhancedEventEmitter {
81
81
  // options
82
82
  {
83
83
  env: {
84
- MEDIASOUP_VERSION: '3.9.7',
84
+ MEDIASOUP_VERSION: '3.9.10',
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.7";
12
+ export declare const version = "3.9.10";
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.7';
14
+ exports.version = '3.9.10';
15
15
  /**
16
16
  * Expose parseScalabilityMode() function.
17
17
  */
package/node/lib/types.js CHANGED
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -1,4 +1,3 @@
1
- declare const randomNumberGenerator: (min?: number | null | undefined, max?: number | null | undefined, integer?: boolean | null | undefined) => number;
2
1
  /**
3
2
  * Clones the given object/array.
4
3
  */
@@ -6,5 +5,5 @@ export declare function clone(data: any): any;
6
5
  /**
7
6
  * Generates a random positive integer.
8
7
  */
9
- export { randomNumberGenerator as generateRandomNumber };
8
+ export declare function generateRandomNumber(): number;
10
9
  //# sourceMappingURL=utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAEA,QAAA,MAAM,qBAAqB,oHAKxB,CAAC;AAEJ;;GAEG;AACH,wBAAgB,KAAK,CAAC,IAAI,EAAE,GAAG,GAAG,GAAG,CAMpC;AAED;;GAEG;AACH,OAAO,EAAE,qBAAqB,IAAI,oBAAoB,EAAE,CAAC"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,wBAAgB,KAAK,CAAC,IAAI,EAAE,GAAG,GAAG,GAAG,CAMpC;AAED;;GAEG;AACH,wBAAgB,oBAAoB,WAGnC"}
package/node/lib/utils.js CHANGED
@@ -1,13 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.generateRandomNumber = exports.clone = void 0;
4
- const randomNumber = require("random-number");
5
- const randomNumberGenerator = randomNumber.generator({
6
- min: 100000000,
7
- max: 999999999,
8
- integer: true
9
- });
10
- exports.generateRandomNumber = randomNumberGenerator;
4
+ const crypto_1 = require("crypto");
11
5
  /**
12
6
  * Clones the given object/array.
13
7
  */
@@ -17,3 +11,10 @@ function clone(data) {
17
11
  return JSON.parse(JSON.stringify(data));
18
12
  }
19
13
  exports.clone = clone;
14
+ /**
15
+ * Generates a random positive integer.
16
+ */
17
+ function generateRandomNumber() {
18
+ return (0, crypto_1.randomInt)(100_000_000, 999_999_999);
19
+ }
20
+ exports.generateRandomNumber = generateRandomNumber;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mediasoup",
3
- "version": "3.9.7",
3
+ "version": "3.9.10",
4
4
  "description": "Cutting Edge WebRTC Video Conferencing",
5
5
  "contributors": [
6
6
  "Iñaki Baz Castillo <ibc@aliax.net> (https://inakibaz.me)",
@@ -30,7 +30,6 @@
30
30
  "worker/scripts/*.js",
31
31
  "worker/scripts/*.json",
32
32
  "worker/src",
33
- "worker/subprojects/packagefiles",
34
33
  "worker/subprojects/*.wrap",
35
34
  "worker/test/include",
36
35
  "worker/test/src",
@@ -70,26 +69,24 @@
70
69
  },
71
70
  "dependencies": {
72
71
  "@types/node": "^16.11.10",
73
- "debug": "^4.3.3",
72
+ "debug": "^4.3.4",
74
73
  "h264-profile-level-id": "^1.0.1",
75
- "random-number": "^0.0.9",
76
- "supports-color": "^9.2.1",
74
+ "supports-color": "^9.2.2",
77
75
  "uuid": "^8.3.2"
78
76
  },
79
77
  "devDependencies": {
80
78
  "@types/debug": "^4.1.7",
81
- "@types/random-number": "^0.0.1",
82
79
  "@types/uuid": "^8.3.4",
83
- "@typescript-eslint/eslint-plugin": "^5.12.1",
84
- "@typescript-eslint/parser": "^5.12.1",
85
- "eslint": "^8.9.0",
86
- "eslint-plugin-jest": "^26.1.1",
80
+ "@typescript-eslint/eslint-plugin": "^5.20.0",
81
+ "@typescript-eslint/parser": "^5.20.0",
82
+ "eslint": "^8.13.0",
83
+ "eslint-plugin-jest": "^26.1.4",
87
84
  "jest": "^27.5.1",
88
85
  "jest-tobetype": "^1.2.3",
89
86
  "open-cli": "^7.0.1",
90
87
  "pick-port": "^1.0.0",
91
88
  "sctp": "^1.0.0",
92
- "tsc-watch": "^4.6.0",
93
- "typescript": "^4.5.5"
89
+ "tsc-watch": "^5.0.3",
90
+ "typescript": "^4.6.3"
94
91
  }
95
92
  }
package/worker/Makefile CHANGED
@@ -7,6 +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
15
  MEDIASOUP_BUILDTYPE ?= Release
11
16
  GULP = ./scripts/node_modules/.bin/gulp
12
17
  LCOV = ./deps/lcov/bin/lcov
@@ -15,6 +20,11 @@ PIP_DIR = $(MEDIASOUP_OUT_DIR)/pip
15
20
  INSTALL_DIR ?= $(MEDIASOUP_OUT_DIR)/$(MEDIASOUP_BUILDTYPE)
16
21
  BUILD_DIR ?= $(MEDIASOUP_OUT_DIR)/$(MEDIASOUP_BUILDTYPE)/build
17
22
  MESON ?= $(PIP_DIR)/bin/meson
23
+ # `MESON_ARGS` can be used to provide extra configuration parameters to Meson, such as adding defines or changing
24
+ # optimization options. For instance, use `MESON_ARGS="-DMS_LOG_TRACE -DMS_LOG_FILE_LINE" npm i` to compile worker with
25
+ # tracing and enabled.
26
+ #
27
+ # NOTE: On Windows make sure to add `--vsenv` or have MSVS environment already active if you override this parameter.
18
28
  MESON_ARGS ?= ""
19
29
  # Workaround for NixOS and Guix that don't work with pre-built binaries, see:
20
30
  # https://github.com/NixOS/nixpkgs/issues/142383.
@@ -2,9 +2,9 @@
2
2
  #define MS_CHANNEL_REQUEST_HPP
3
3
 
4
4
  #include "common.hpp"
5
+ #include <absl/container/flat_hash_map.h>
5
6
  #include <nlohmann/json.hpp>
6
7
  #include <string>
7
- #include <unordered_map>
8
8
 
9
9
  using json = nlohmann::json;
10
10
 
@@ -75,7 +75,7 @@ namespace Channel
75
75
  };
76
76
 
77
77
  private:
78
- static std::unordered_map<std::string, MethodId> string2MethodId;
78
+ static absl::flat_hash_map<std::string, MethodId> string2MethodId;
79
79
 
80
80
  public:
81
81
  ChannelRequest(Channel::ChannelSocket* channel, json& jsonRequest);
@@ -4,7 +4,7 @@
4
4
  #include "common.hpp"
5
5
  #include "RTC/SctpAssociation.hpp"
6
6
  #include "handles/Timer.hpp"
7
- #include <unordered_map>
7
+ #include <absl/container/flat_hash_map.h>
8
8
 
9
9
  class DepUsrSCTP
10
10
  {
@@ -42,7 +42,7 @@ private:
42
42
  thread_local static Checker* checker;
43
43
  static uint64_t numSctpAssociations;
44
44
  static uintptr_t nextSctpAssociationId;
45
- static std::unordered_map<uintptr_t, RTC::SctpAssociation*> mapIdSctpAssociation;
45
+ static absl::flat_hash_map<uintptr_t, RTC::SctpAssociation*> mapIdSctpAssociation;
46
46
  };
47
47
 
48
48
  #endif
@@ -2,9 +2,9 @@
2
2
  #define MS_PAYLOAD_CHANNEL_NOTIFICATION_HPP
3
3
 
4
4
  #include "common.hpp"
5
+ #include <absl/container/flat_hash_map.h>
5
6
  #include <nlohmann/json.hpp>
6
7
  #include <string>
7
- #include <unordered_map>
8
8
 
9
9
  using json = nlohmann::json;
10
10
 
@@ -24,7 +24,7 @@ namespace PayloadChannel
24
24
  static bool IsNotification(json& jsonNotification);
25
25
 
26
26
  private:
27
- static std::unordered_map<std::string, EventId> string2EventId;
27
+ static absl::flat_hash_map<std::string, EventId> string2EventId;
28
28
 
29
29
  public:
30
30
  explicit Notification(json& jsonNotification);
@@ -2,9 +2,9 @@
2
2
  #define MS_PAYLOAD_CHANNEL_REQUEST_HPP
3
3
 
4
4
  #include "common.hpp"
5
+ #include <absl/container/flat_hash_map.h>
5
6
  #include <nlohmann/json.hpp>
6
7
  #include <string>
7
- #include <unordered_map>
8
8
 
9
9
  using json = nlohmann::json;
10
10
 
@@ -26,7 +26,7 @@ namespace PayloadChannel
26
26
  static bool IsRequest(json& jsonRequest);
27
27
 
28
28
  private:
29
- static std::unordered_map<std::string, MethodId> string2MethodId;
29
+ static absl::flat_hash_map<std::string, MethodId> string2MethodId;
30
30
 
31
31
  public:
32
32
  PayloadChannelRequest(PayloadChannel::PayloadChannelSocket* channel, json& jsonRequest);
@@ -3,8 +3,8 @@
3
3
 
4
4
  #include "RTC/RtpObserver.hpp"
5
5
  #include "handles/Timer.hpp"
6
+ #include <absl/container/flat_hash_map.h>
6
7
  #include <nlohmann/json.hpp>
7
- #include <unordered_map>
8
8
  #include <utility>
9
9
  #include <vector>
10
10
 
@@ -89,7 +89,7 @@ namespace RTC
89
89
  std::string dominantId{ "" };
90
90
  Timer* periodicTimer{ nullptr };
91
91
  uint16_t interval{ 300u };
92
- std::unordered_map<std::string, struct ProducerSpeaker> mapProducerSpeaker;
92
+ absl::flat_hash_map<std::string, struct ProducerSpeaker> mapProducerSpeaker;
93
93
  uint64_t lastLevelIdleTime{ 0 };
94
94
  };
95
95
  } // namespace RTC
@@ -3,8 +3,8 @@
3
3
 
4
4
  #include "RTC/RtpObserver.hpp"
5
5
  #include "handles/Timer.hpp"
6
+ #include <absl/container/flat_hash_map.h>
6
7
  #include <nlohmann/json.hpp>
7
- #include <unordered_map>
8
8
 
9
9
  using json = nlohmann::json;
10
10
 
@@ -48,7 +48,7 @@ namespace RTC
48
48
  // Allocated by this.
49
49
  Timer* periodicTimer{ nullptr };
50
50
  // Others.
51
- std::unordered_map<RTC::Producer*, DBovs> mapProducerDBovs;
51
+ absl::flat_hash_map<RTC::Producer*, DBovs> mapProducerDBovs;
52
52
  bool silence{ true };
53
53
  };
54
54
  } // namespace RTC
@@ -14,9 +14,9 @@
14
14
  #include "RTC/RtpPacket.hpp"
15
15
  #include "RTC/RtpStream.hpp"
16
16
  #include "RTC/RtpStreamSend.hpp"
17
+ #include <absl/container/flat_hash_set.h>
17
18
  #include <nlohmann/json.hpp>
18
19
  #include <string>
19
- #include <unordered_set>
20
20
  #include <vector>
21
21
 
22
22
  using json = nlohmann::json;
@@ -182,7 +182,7 @@ namespace RTC
182
182
  struct RTC::RtpHeaderExtensionIds rtpHeaderExtensionIds;
183
183
  const std::vector<uint8_t>* producerRtpStreamScores{ nullptr };
184
184
  // Others.
185
- std::unordered_set<uint8_t> supportedCodecPayloadTypes;
185
+ absl::flat_hash_set<uint8_t> supportedCodecPayloadTypes;
186
186
  uint64_t lastRtcpSentTime{ 0u };
187
187
  uint16_t maxRtcpInterval{ 0u };
188
188
  bool externallyManagedBitrate{ false };
@@ -7,7 +7,7 @@
7
7
  #include <openssl/bio.h>
8
8
  #include <openssl/ssl.h>
9
9
  #include <openssl/x509.h>
10
- #include <map>
10
+ #include <absl/container/flat_hash_map.h>
11
11
  #include <string>
12
12
  #include <vector>
13
13
 
@@ -144,9 +144,9 @@ namespace RTC
144
144
  thread_local static EVP_PKEY* privateKey;
145
145
  thread_local static SSL_CTX* sslCtx;
146
146
  thread_local static uint8_t sslReadBuffer[];
147
- static std::map<std::string, Role> string2Role;
148
- static std::map<std::string, FingerprintAlgorithm> string2FingerprintAlgorithm;
149
- static std::map<FingerprintAlgorithm, std::string> fingerprintAlgorithm2String;
147
+ static absl::flat_hash_map<std::string, Role> string2Role;
148
+ static absl::flat_hash_map<std::string, FingerprintAlgorithm> string2FingerprintAlgorithm;
149
+ static absl::flat_hash_map<FingerprintAlgorithm, std::string> fingerprintAlgorithm2String;
150
150
  thread_local static std::vector<Fingerprint> localFingerprints;
151
151
  static std::vector<SrtpCryptoSuiteMapEntry> srtpCryptoSuites;
152
152
 
@@ -2,7 +2,7 @@
2
2
  #define MS_KEY_FRAME_REQUEST_MANAGER_HPP
3
3
 
4
4
  #include "handles/Timer.hpp"
5
- #include <map>
5
+ #include <absl/container/flat_hash_map.h>
6
6
 
7
7
  namespace RTC
8
8
  {
@@ -122,8 +122,8 @@ namespace RTC
122
122
  private:
123
123
  Listener* listener{ nullptr };
124
124
  uint32_t keyFrameRequestDelay{ 0u }; // 0 means disabled.
125
- std::map<uint32_t, PendingKeyFrameInfo*> mapSsrcPendingKeyFrameInfo;
126
- std::map<uint32_t, KeyFrameRequestDelayer*> mapSsrcKeyFrameRequestDelayer;
125
+ absl::flat_hash_map<uint32_t, PendingKeyFrameInfo*> mapSsrcPendingKeyFrameInfo;
126
+ absl::flat_hash_map<uint32_t, KeyFrameRequestDelayer*> mapSsrcKeyFrameRequestDelayer;
127
127
  };
128
128
  } // namespace RTC
129
129
 
@@ -5,6 +5,8 @@
5
5
  #include "RTC/RtpPacket.hpp"
6
6
  #include "RTC/SeqManager.hpp"
7
7
  #include "handles/Timer.hpp"
8
+ #include <absl/container/btree_map.h>
9
+ #include <absl/container/btree_set.h>
8
10
  #include <map>
9
11
  #include <set>
10
12
  #include <vector>
@@ -75,9 +77,9 @@ namespace RTC
75
77
  // Allocated by this.
76
78
  Timer* timer{ nullptr };
77
79
  // Others.
78
- std::map<uint16_t, NackInfo, RTC::SeqManager<uint16_t>::SeqLowerThan> nackList;
79
- std::set<uint16_t, RTC::SeqManager<uint16_t>::SeqLowerThan> keyFrameList;
80
- std::set<uint16_t, RTC::SeqManager<uint16_t>::SeqLowerThan> recoveredList;
80
+ absl::btree_map<uint16_t, NackInfo, RTC::SeqManager<uint16_t>::SeqLowerThan> nackList;
81
+ absl::btree_set<uint16_t, RTC::SeqManager<uint16_t>::SeqLowerThan> keyFrameList;
82
+ absl::btree_set<uint16_t, RTC::SeqManager<uint16_t>::SeqLowerThan> recoveredList;
81
83
  bool started{ false };
82
84
  uint16_t lastSeq{ 0u }; // Seq number of last valid packet.
83
85
  uint32_t rtt{ 0u }; // Round trip time (ms).
@@ -2,9 +2,9 @@
2
2
  #define MS_RTC_PARAMETERS_HPP
3
3
 
4
4
  #include "common.hpp"
5
+ #include <absl/container/flat_hash_map.h>
5
6
  #include <nlohmann/json.hpp>
6
7
  #include <string>
7
- #include <unordered_map>
8
8
  #include <vector>
9
9
 
10
10
  using json = nlohmann::json;
@@ -78,7 +78,7 @@ namespace RTC
78
78
  const std::vector<int32_t>& GetArrayOfIntegers(const std::string& key) const;
79
79
 
80
80
  private:
81
- std::unordered_map<std::string, Value> mapKeyValues;
81
+ absl::flat_hash_map<std::string, Value> mapKeyValues;
82
82
  };
83
83
  } // namespace RTC
84
84
 
@@ -60,11 +60,11 @@ namespace RTC
60
60
  // Allocated by this.
61
61
  std::vector<RTC::RtpStreamSend*> rtpStreams;
62
62
  // Others.
63
- std::unordered_map<uint32_t, uint32_t> mapMappedSsrcSsrc;
64
- std::unordered_map<uint32_t, RTC::RtpStreamSend*> mapSsrcRtpStream;
63
+ absl::flat_hash_map<uint32_t, uint32_t> mapMappedSsrcSsrc;
64
+ absl::flat_hash_map<uint32_t, RTC::RtpStreamSend*> mapSsrcRtpStream;
65
65
  bool keyFrameSupported{ false };
66
- std::unordered_map<RTC::RtpStreamSend*, bool> mapRtpStreamSyncRequired;
67
- std::unordered_map<RTC::RtpStreamSend*, RTC::SeqManager<uint16_t>> mapRtpStreamRtpSeqManager;
66
+ absl::flat_hash_map<RTC::RtpStreamSend*, bool> mapRtpStreamSyncRequired;
67
+ absl::flat_hash_map<RTC::RtpStreamSend*, RTC::SeqManager<uint16_t>> mapRtpStreamRtpSeqManager;
68
68
  };
69
69
  } // namespace RTC
70
70
 
@@ -5,7 +5,7 @@
5
5
  #include "RTC/Transport.hpp"
6
6
  #include "RTC/TransportTuple.hpp"
7
7
  #include "RTC/UdpSocket.hpp"
8
- #include <map>
8
+ #include <absl/container/flat_hash_map.h>
9
9
 
10
10
  namespace RTC
11
11
  {
@@ -19,8 +19,8 @@ namespace RTC
19
19
  };
20
20
 
21
21
  private:
22
- static std::map<std::string, RTC::SrtpSession::CryptoSuite> string2SrtpCryptoSuite;
23
- static std::map<RTC::SrtpSession::CryptoSuite, std::string> srtpCryptoSuite2String;
22
+ static absl::flat_hash_map<std::string, RTC::SrtpSession::CryptoSuite> string2SrtpCryptoSuite;
23
+ static absl::flat_hash_map<RTC::SrtpSession::CryptoSuite, std::string> srtpCryptoSuite2String;
24
24
  static size_t srtpMasterLength;
25
25
 
26
26
  public:
@@ -4,9 +4,9 @@
4
4
  #include "common.hpp"
5
5
  #include "Settings.hpp"
6
6
  #include <uv.h>
7
+ #include <absl/container/flat_hash_map.h>
7
8
  #include <nlohmann/json.hpp>
8
9
  #include <string>
9
- #include <unordered_map>
10
10
  #include <vector>
11
11
 
12
12
  namespace RTC
@@ -54,8 +54,8 @@ namespace RTC
54
54
  static std::vector<bool>& GetPorts(Transport transport, const std::string& ip);
55
55
 
56
56
  private:
57
- thread_local static std::unordered_map<std::string, std::vector<bool>> mapUdpIpPorts;
58
- thread_local static std::unordered_map<std::string, std::vector<bool>> mapTcpIpPorts;
57
+ thread_local static absl::flat_hash_map<std::string, std::vector<bool>> mapUdpIpPorts;
58
+ thread_local static absl::flat_hash_map<std::string, std::vector<bool>> mapTcpIpPorts;
59
59
  };
60
60
  } // namespace RTC
61
61
 
@@ -12,7 +12,6 @@
12
12
  #include "RTC/RtpHeaderExtensionIds.hpp"
13
13
  #include "RTC/RtpPacket.hpp"
14
14
  #include "RTC/RtpStreamRecv.hpp"
15
- #include <map>
16
15
  #include <nlohmann/json.hpp>
17
16
  #include <string>
18
17
  #include <vector>
@@ -55,7 +54,7 @@ namespace RTC
55
54
  private:
56
55
  struct RtpMapping
57
56
  {
58
- std::map<uint8_t, uint8_t> codecs;
57
+ absl::flat_hash_map<uint8_t, uint8_t> codecs;
59
58
  std::vector<RtpEncodingMapping> encodings;
60
59
  };
61
60
 
@@ -113,7 +112,7 @@ namespace RTC
113
112
  {
114
113
  return this->paused;
115
114
  }
116
- const std::map<RTC::RtpStreamRecv*, uint32_t>& GetRtpStreams()
115
+ const absl::flat_hash_map<RTC::RtpStreamRecv*, uint32_t>& GetRtpStreams()
117
116
  {
118
117
  return this->mapRtpStreamMappedSsrc;
119
118
  }
@@ -161,7 +160,7 @@ namespace RTC
161
160
  // Passed by argument.
162
161
  RTC::Producer::Listener* listener{ nullptr };
163
162
  // Allocated by this.
164
- std::map<uint32_t, RTC::RtpStreamRecv*> mapSsrcRtpStream;
163
+ absl::flat_hash_map<uint32_t, RTC::RtpStreamRecv*> mapSsrcRtpStream;
165
164
  RTC::KeyFrameRequestManager* keyFrameRequestManager{ nullptr };
166
165
  // Others.
167
166
  RTC::Media::Kind kind;
@@ -170,9 +169,9 @@ namespace RTC
170
169
  struct RtpMapping rtpMapping;
171
170
  std::vector<RTC::RtpStreamRecv*> rtpStreamByEncodingIdx;
172
171
  std::vector<uint8_t> rtpStreamScores;
173
- std::map<uint32_t, RTC::RtpStreamRecv*> mapRtxSsrcRtpStream;
174
- std::map<RTC::RtpStreamRecv*, uint32_t> mapRtpStreamMappedSsrc;
175
- std::map<uint32_t, uint32_t> mapMappedSsrcSsrc;
172
+ absl::flat_hash_map<uint32_t, RTC::RtpStreamRecv*> mapRtxSsrcRtpStream;
173
+ absl::flat_hash_map<RTC::RtpStreamRecv*, uint32_t> mapRtpStreamMappedSsrc;
174
+ absl::flat_hash_map<uint32_t, uint32_t> mapMappedSsrcSsrc;
176
175
  struct RTC::RtpHeaderExtensionIds rtpHeaderExtensionIds;
177
176
  bool paused{ false };
178
177
  RTC::RtpPacket* currentRtpPacket{ nullptr };
@@ -4,6 +4,7 @@
4
4
  #include "common.hpp"
5
5
  #include "RTC/RTCP/FeedbackItem.hpp"
6
6
  #include "RTC/RTCP/Packet.hpp"
7
+ #include <absl/container/flat_hash_map.h>
7
8
 
8
9
  namespace RTC
9
10
  {
@@ -27,7 +28,7 @@ namespace RTC
27
28
  static const std::string& MessageType2String(typename T::MessageType type);
28
29
 
29
30
  private:
30
- static std::map<typename T::MessageType, std::string> type2String;
31
+ static absl::flat_hash_map<typename T::MessageType, std::string> type2String;
31
32
 
32
33
  public:
33
34
  typename T::MessageType GetMessageType() const
@@ -197,7 +197,7 @@ namespace RTC
197
197
  static FeedbackRtpTransportPacket* Parse(const uint8_t* data, size_t len);
198
198
 
199
199
  private:
200
- static std::map<Status, std::string> status2String;
200
+ static absl::flat_hash_map<Status, std::string> status2String;
201
201
 
202
202
  public:
203
203
  FeedbackRtpTransportPacket(uint32_t senderSsrc, uint32_t mediaSsrc)
@@ -2,7 +2,7 @@
2
2
  #define MS_RTC_RTCP_PACKET_HPP
3
3
 
4
4
  #include "common.hpp"
5
- #include <map>
5
+ #include <absl/container/flat_hash_map.h>
6
6
  #include <string>
7
7
 
8
8
  namespace RTC
@@ -72,7 +72,7 @@ namespace RTC
72
72
  static const std::string& Type2String(Type type);
73
73
 
74
74
  private:
75
- static std::map<Type, std::string> type2String;
75
+ static absl::flat_hash_map<Type, std::string> type2String;
76
76
 
77
77
  public:
78
78
  explicit Packet(Type type) : type(type)
@@ -3,7 +3,6 @@
3
3
 
4
4
  #include "common.hpp"
5
5
  #include "RTC/RTCP/Packet.hpp"
6
- #include <map>
7
6
  #include <string>
8
7
  #include <vector>
9
8
 
@@ -77,7 +76,7 @@ namespace RTC
77
76
  std::unique_ptr<uint8_t[]> raw;
78
77
 
79
78
  private:
80
- static std::map<SdesItem::Type, std::string> type2String;
79
+ static absl::flat_hash_map<SdesItem::Type, std::string> type2String;
81
80
  };
82
81
 
83
82
  class SdesChunk
@@ -24,8 +24,7 @@ namespace RTC
24
24
  : windowSizeMs(windowSizeMs), scale(scale), windowItems(windowItems)
25
25
  {
26
26
  this->itemSizeMs = std::max(windowSizeMs / windowItems, static_cast<size_t>(1));
27
-
28
- Reset();
27
+ this->buffer.resize(windowItems);
29
28
  }
30
29
  void Update(size_t size, uint64_t nowMs);
31
30
  uint32_t GetRate(uint64_t nowMs);
@@ -38,7 +37,9 @@ namespace RTC
38
37
  void RemoveOldData(uint64_t nowMs);
39
38
  void Reset()
40
39
  {
41
- this->buffer.reset(new BufferItem[this->windowItems]);
40
+ std::memset(
41
+ static_cast<void*>(&this->buffer.front()), 0, sizeof(BufferItem) * this->buffer.size());
42
+
42
43
  this->newestItemStartTime = 0u;
43
44
  this->newestItemIndex = -1;
44
45
  this->oldestItemStartTime = 0u;
@@ -65,7 +66,7 @@ namespace RTC
65
66
  // Item Size (in milliseconds), calculated as: windowSizeMs / windowItems.
66
67
  size_t itemSizeMs{ 0u };
67
68
  // Buffer to keep data.
68
- std::unique_ptr<BufferItem[]> buffer;
69
+ std::vector<BufferItem> buffer;
69
70
  // Time (in milliseconds) for last item in the time window.
70
71
  uint64_t newestItemStartTime{ 0u };
71
72
  // Index for the last item in the time window.
@@ -13,9 +13,9 @@
13
13
  #include "RTC/RtpPacket.hpp"
14
14
  #include "RTC/RtpStream.hpp"
15
15
  #include "RTC/Transport.hpp"
16
+ #include <absl/container/flat_hash_map.h>
16
17
  #include <nlohmann/json.hpp>
17
18
  #include <string>
18
- #include <unordered_map>
19
19
  #include <unordered_set>
20
20
 
21
21
  using json = nlohmann::json;
@@ -93,16 +93,17 @@ namespace RTC
93
93
 
94
94
  private:
95
95
  // Allocated by this.
96
- std::unordered_map<std::string, RTC::Transport*> mapTransports;
97
- std::unordered_map<std::string, RTC::RtpObserver*> mapRtpObservers;
96
+ absl::flat_hash_map<std::string, RTC::Transport*> mapTransports;
97
+ absl::flat_hash_map<std::string, RTC::RtpObserver*> mapRtpObservers;
98
98
  // Others.
99
- std::unordered_map<RTC::Producer*, std::unordered_set<RTC::Consumer*>> mapProducerConsumers;
100
- std::unordered_map<RTC::Consumer*, RTC::Producer*> mapConsumerProducer;
101
- std::unordered_map<RTC::Producer*, std::unordered_set<RTC::RtpObserver*>> mapProducerRtpObservers;
102
- std::unordered_map<std::string, RTC::Producer*> mapProducers;
103
- std::unordered_map<RTC::DataProducer*, std::unordered_set<RTC::DataConsumer*>> mapDataProducerDataConsumers;
104
- std::unordered_map<RTC::DataConsumer*, RTC::DataProducer*> mapDataConsumerDataProducer;
105
- std::unordered_map<std::string, RTC::DataProducer*> mapDataProducers;
99
+ absl::flat_hash_map<RTC::Producer*, absl::flat_hash_set<RTC::Consumer*>> mapProducerConsumers;
100
+ absl::flat_hash_map<RTC::Consumer*, RTC::Producer*> mapConsumerProducer;
101
+ absl::flat_hash_map<RTC::Producer*, absl::flat_hash_set<RTC::RtpObserver*>> mapProducerRtpObservers;
102
+ absl::flat_hash_map<std::string, RTC::Producer*> mapProducers;
103
+ absl::flat_hash_map<RTC::DataProducer*, absl::flat_hash_set<RTC::DataConsumer*>>
104
+ mapDataProducerDataConsumers;
105
+ absl::flat_hash_map<RTC::DataConsumer*, RTC::DataProducer*> mapDataConsumerDataProducer;
106
+ absl::flat_hash_map<std::string, RTC::DataProducer*> mapDataProducers;
106
107
  };
107
108
  } // namespace RTC
108
109