mediasoup 3.9.8 → 3.9.9

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 (61) 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/package.json +1 -1
  5. package/worker/include/Channel/ChannelRequest.hpp +2 -2
  6. package/worker/include/DepUsrSCTP.hpp +2 -2
  7. package/worker/include/PayloadChannel/Notification.hpp +2 -2
  8. package/worker/include/PayloadChannel/PayloadChannelRequest.hpp +2 -2
  9. package/worker/include/RTC/ActiveSpeakerObserver.hpp +2 -2
  10. package/worker/include/RTC/AudioLevelObserver.hpp +2 -2
  11. package/worker/include/RTC/Consumer.hpp +2 -2
  12. package/worker/include/RTC/DtlsTransport.hpp +4 -4
  13. package/worker/include/RTC/KeyFrameRequestManager.hpp +3 -3
  14. package/worker/include/RTC/NackGenerator.hpp +5 -3
  15. package/worker/include/RTC/Parameters.hpp +2 -2
  16. package/worker/include/RTC/PipeConsumer.hpp +4 -4
  17. package/worker/include/RTC/PlainTransport.hpp +3 -3
  18. package/worker/include/RTC/PortManager.hpp +3 -3
  19. package/worker/include/RTC/Producer.hpp +6 -7
  20. package/worker/include/RTC/RTCP/Feedback.hpp +2 -1
  21. package/worker/include/RTC/RTCP/FeedbackRtpTransport.hpp +1 -1
  22. package/worker/include/RTC/RTCP/Packet.hpp +2 -2
  23. package/worker/include/RTC/RTCP/Sdes.hpp +1 -2
  24. package/worker/include/RTC/RateCalculator.hpp +5 -4
  25. package/worker/include/RTC/Router.hpp +11 -10
  26. package/worker/include/RTC/RtpDictionaries.hpp +10 -11
  27. package/worker/include/RTC/RtpPacket.hpp +16 -9
  28. package/worker/include/RTC/SenderBandwidthEstimator.hpp +2 -1
  29. package/worker/include/RTC/SimulcastConsumer.hpp +1 -1
  30. package/worker/include/RTC/Transport.hpp +7 -7
  31. package/worker/include/RTC/WebRtcTransport.hpp +2 -2
  32. package/worker/include/Settings.hpp +3 -3
  33. package/worker/include/Worker.hpp +2 -2
  34. package/worker/include/handles/TcpConnectionHandler.hpp +0 -1
  35. package/worker/include/handles/TcpServerHandler.hpp +2 -2
  36. package/worker/include/handles/UnixStreamSocket.hpp +0 -4
  37. package/worker/meson.build +2 -0
  38. package/worker/src/Channel/ChannelRequest.cpp +1 -1
  39. package/worker/src/DepUsrSCTP.cpp +1 -1
  40. package/worker/src/PayloadChannel/Notification.cpp +1 -1
  41. package/worker/src/PayloadChannel/PayloadChannelRequest.cpp +1 -1
  42. package/worker/src/RTC/AudioLevelObserver.cpp +1 -1
  43. package/worker/src/RTC/Consumer.cpp +6 -0
  44. package/worker/src/RTC/DtlsTransport.cpp +3 -3
  45. package/worker/src/RTC/NackGenerator.cpp +3 -3
  46. package/worker/src/RTC/PlainTransport.cpp +2 -2
  47. package/worker/src/RTC/PortManager.cpp +2 -2
  48. package/worker/src/RTC/Producer.cpp +1 -0
  49. package/worker/src/RTC/RTCP/Feedback.cpp +2 -2
  50. package/worker/src/RTC/RTCP/FeedbackRtpTransport.cpp +1 -1
  51. package/worker/src/RTC/RTCP/Packet.cpp +1 -1
  52. package/worker/src/RTC/RTCP/Sdes.cpp +1 -1
  53. package/worker/src/RTC/RateCalculator.cpp +5 -5
  54. package/worker/src/RTC/RtpDictionaries/Media.cpp +2 -2
  55. package/worker/src/RTC/RtpDictionaries/RtpCodecMimeType.cpp +4 -4
  56. package/worker/src/RTC/RtpDictionaries/RtpHeaderExtensionUri.cpp +1 -1
  57. package/worker/src/RTC/RtpDictionaries/RtpParameters.cpp +4 -4
  58. package/worker/src/RTC/RtpPacket.cpp +13 -13
  59. package/worker/src/Settings.cpp +3 -4
  60. package/worker/src/handles/TcpConnectionHandler.cpp +0 -95
  61. package/worker/src/lib.cpp +2 -2
@@ -81,7 +81,7 @@ class Worker extends EnhancedEventEmitter_1.EnhancedEventEmitter {
81
81
  // options
82
82
  {
83
83
  env: {
84
- MEDIASOUP_VERSION: '3.9.8',
84
+ MEDIASOUP_VERSION: '3.9.9',
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.8";
12
+ export declare const version = "3.9.9";
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.8';
14
+ exports.version = '3.9.9';
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.9.8",
3
+ "version": "3.9.9",
4
4
  "description": "Cutting Edge WebRTC Video Conferencing",
5
5
  "contributors": [
6
6
  "Iñaki Baz Castillo <ibc@aliax.net> (https://inakibaz.me)",
@@ -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
 
@@ -3,10 +3,9 @@
3
3
 
4
4
  #include "common.hpp"
5
5
  #include "RTC/Parameters.hpp"
6
- #include <map>
6
+ #include <absl/container/flat_hash_map.h>
7
7
  #include <nlohmann/json.hpp>
8
8
  #include <string>
9
- #include <unordered_map>
10
9
  #include <vector>
11
10
 
12
11
  using json = nlohmann::json;
@@ -29,8 +28,8 @@ namespace RTC
29
28
  static const std::string& GetString(Kind kind);
30
29
 
31
30
  private:
32
- static std::unordered_map<std::string, Kind> string2Kind;
33
- static std::map<Kind, std::string> kind2String;
31
+ static absl::flat_hash_map<std::string, Kind> string2Kind;
32
+ static absl::flat_hash_map<Kind, std::string> kind2String;
34
33
  };
35
34
 
36
35
  class RtpCodecMimeType
@@ -75,10 +74,10 @@ namespace RTC
75
74
  };
76
75
 
77
76
  public:
78
- static std::unordered_map<std::string, Type> string2Type;
79
- static std::map<Type, std::string> type2String;
80
- static std::unordered_map<std::string, Subtype> string2Subtype;
81
- static std::map<Subtype, std::string> subtype2String;
77
+ static absl::flat_hash_map<std::string, Type> string2Type;
78
+ static absl::flat_hash_map<Type, std::string> type2String;
79
+ static absl::flat_hash_map<std::string, Subtype> string2Subtype;
80
+ static absl::flat_hash_map<Subtype, std::string> subtype2String;
82
81
 
83
82
  public:
84
83
  RtpCodecMimeType() = default;
@@ -145,7 +144,7 @@ namespace RTC
145
144
  };
146
145
 
147
146
  private:
148
- static std::unordered_map<std::string, Type> string2Type;
147
+ static absl::flat_hash_map<std::string, Type> string2Type;
149
148
 
150
149
  public:
151
150
  static Type GetType(std::string& uri);
@@ -269,8 +268,8 @@ namespace RTC
269
268
  static std::string& GetTypeString(Type type);
270
269
 
271
270
  private:
272
- static std::unordered_map<std::string, Type> string2Type;
273
- static std::map<Type, std::string> type2String;
271
+ static absl::flat_hash_map<std::string, Type> string2Type;
272
+ static absl::flat_hash_map<Type, std::string> type2String;
274
273
 
275
274
  public:
276
275
  RtpParameters() = default;
@@ -4,7 +4,8 @@
4
4
  #include "common.hpp"
5
5
  #include "Utils.hpp"
6
6
  #include "RTC/Codecs/PayloadDescriptorHandler.hpp"
7
- #include <map>
7
+ #include <absl/container/flat_hash_map.h>
8
+ #include <array>
8
9
  #include <nlohmann/json.hpp>
9
10
  #include <string>
10
11
  #include <vector>
@@ -473,9 +474,11 @@ namespace RTC
473
474
  }
474
475
  else if (HasOneByteExtensions())
475
476
  {
476
- auto it = this->mapOneByteExtensions.find(id);
477
+ if (id > 14)
478
+ return false;
477
479
 
478
- return it != this->mapOneByteExtensions.end();
480
+ // `-1` because we have 14 elements total 0..13 and `id` is in the range 1..14.
481
+ return this->oneByteExtensions[id - 1] != nullptr;
479
482
  }
480
483
  else if (HasTwoBytesExtensions())
481
484
  {
@@ -508,12 +511,14 @@ namespace RTC
508
511
  }
509
512
  else if (HasOneByteExtensions())
510
513
  {
511
- auto it = this->mapOneByteExtensions.find(id);
512
-
513
- if (it == this->mapOneByteExtensions.end())
514
+ if (id > 14)
514
515
  return nullptr;
515
516
 
516
- auto* extension = it->second;
517
+ // `-1` because we have 14 elements total 0..13 and `id` is in the range 1..14.
518
+ auto* extension = this->oneByteExtensions[id - 1];
519
+
520
+ if (!extension)
521
+ return nullptr;
517
522
 
518
523
  // In One-Byte extensions value length 0 means 1.
519
524
  len = extension->len + 1;
@@ -611,8 +616,10 @@ namespace RTC
611
616
  Header* header{ nullptr };
612
617
  uint8_t* csrcList{ nullptr };
613
618
  HeaderExtension* headerExtension{ nullptr };
614
- std::map<uint8_t, OneByteExtension*> mapOneByteExtensions;
615
- std::map<uint8_t, TwoBytesExtension*> mapTwoBytesExtensions;
619
+ // There might be up to 14 one-byte header extensions
620
+ // (https://datatracker.ietf.org/doc/html/rfc5285#section-4.2), use std::array.
621
+ std::array<OneByteExtension*, 14> oneByteExtensions;
622
+ absl::flat_hash_map<uint8_t, TwoBytesExtension*> mapTwoBytesExtensions;
616
623
  uint8_t midExtensionId{ 0u };
617
624
  uint8_t ridExtensionId{ 0u };
618
625
  uint8_t rridExtensionId{ 0u };
@@ -6,6 +6,7 @@
6
6
  #include "RTC/RateCalculator.hpp"
7
7
  #include "RTC/SeqManager.hpp"
8
8
  #include "RTC/TrendCalculator.hpp"
9
+ #include <absl/container/btree_map.h>
9
10
  #include <map>
10
11
 
11
12
  namespace RTC
@@ -102,7 +103,7 @@ namespace RTC
102
103
  uint32_t initialAvailableBitrate{ 0u };
103
104
  uint32_t availableBitrate{ 0u };
104
105
  uint64_t lastAvailableBitrateEventAtMs{ 0u };
105
- std::map<uint16_t, SentInfo, RTC::SeqManager<uint16_t>::SeqLowerThan> sentInfos;
106
+ absl::btree_map<uint16_t, SentInfo, RTC::SeqManager<uint16_t>::SeqLowerThan> sentInfos;
106
107
  float rtt{ 0 }; // Round trip time in ms.
107
108
  CummulativeResult cummulativeResult;
108
109
  CummulativeResult probationCummulativeResult;
@@ -97,7 +97,7 @@ namespace RTC
97
97
  // Allocated by this.
98
98
  RTC::RtpStreamSend* rtpStream{ nullptr };
99
99
  // Others.
100
- std::unordered_map<uint32_t, int16_t> mapMappedSsrcSpatialLayer;
100
+ absl::flat_hash_map<uint32_t, int16_t> mapMappedSsrcSpatialLayer;
101
101
  std::vector<RTC::RtpStreamSend*> rtpStreams;
102
102
  std::vector<RTC::RtpStream*> producerRtpStreams; // Indexed by spatial layer.
103
103
  bool syncRequired{ false };