Unverified 提交 ff17d135 authored 作者: José Luis Millán's avatar José Luis Millán 提交者: GitHub

Use more efficient collections (#782)

* Replace `std::map` with `std::unordered_map` in all places where applicable

* Replace most of `std::map/set/unordered_map/unordered_set` with more efficient collections from abseil-cpp

Taken from 'memory optimizations' branch to make it more readable and
concise.
Co-authored-by: 's avatarNazar Mokrynskyi <nazar@mokrynskyi.com>
上级 6076cc9b
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
#define MS_CHANNEL_REQUEST_HPP #define MS_CHANNEL_REQUEST_HPP
#include "common.hpp" #include "common.hpp"
#include <absl/container/flat_hash_map.h>
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>
#include <string> #include <string>
#include <unordered_map>
using json = nlohmann::json; using json = nlohmann::json;
...@@ -75,7 +75,7 @@ namespace Channel ...@@ -75,7 +75,7 @@ namespace Channel
}; };
private: private:
static std::unordered_map<std::string, MethodId> string2MethodId; static absl::flat_hash_map<std::string, MethodId> string2MethodId;
public: public:
ChannelRequest(Channel::ChannelSocket* channel, json& jsonRequest); ChannelRequest(Channel::ChannelSocket* channel, json& jsonRequest);
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
#include "common.hpp" #include "common.hpp"
#include "RTC/SctpAssociation.hpp" #include "RTC/SctpAssociation.hpp"
#include "handles/Timer.hpp" #include "handles/Timer.hpp"
#include <unordered_map> #include <absl/container/flat_hash_map.h>
class DepUsrSCTP class DepUsrSCTP
{ {
...@@ -42,7 +42,7 @@ private: ...@@ -42,7 +42,7 @@ private:
thread_local static Checker* checker; thread_local static Checker* checker;
static uint64_t numSctpAssociations; static uint64_t numSctpAssociations;
static uintptr_t nextSctpAssociationId; static uintptr_t nextSctpAssociationId;
static std::unordered_map<uintptr_t, RTC::SctpAssociation*> mapIdSctpAssociation; static absl::flat_hash_map<uintptr_t, RTC::SctpAssociation*> mapIdSctpAssociation;
}; };
#endif #endif
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
#define MS_PAYLOAD_CHANNEL_NOTIFICATION_HPP #define MS_PAYLOAD_CHANNEL_NOTIFICATION_HPP
#include "common.hpp" #include "common.hpp"
#include <absl/container/flat_hash_map.h>
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>
#include <string> #include <string>
#include <unordered_map>
using json = nlohmann::json; using json = nlohmann::json;
...@@ -24,7 +24,7 @@ namespace PayloadChannel ...@@ -24,7 +24,7 @@ namespace PayloadChannel
static bool IsNotification(json& jsonNotification); static bool IsNotification(json& jsonNotification);
private: private:
static std::unordered_map<std::string, EventId> string2EventId; static absl::flat_hash_map<std::string, EventId> string2EventId;
public: public:
explicit Notification(json& jsonNotification); explicit Notification(json& jsonNotification);
......
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
#define MS_PAYLOAD_CHANNEL_REQUEST_HPP #define MS_PAYLOAD_CHANNEL_REQUEST_HPP
#include "common.hpp" #include "common.hpp"
#include <absl/container/flat_hash_map.h>
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>
#include <string> #include <string>
#include <unordered_map>
using json = nlohmann::json; using json = nlohmann::json;
...@@ -26,7 +26,7 @@ namespace PayloadChannel ...@@ -26,7 +26,7 @@ namespace PayloadChannel
static bool IsRequest(json& jsonRequest); static bool IsRequest(json& jsonRequest);
private: private:
static std::unordered_map<std::string, MethodId> string2MethodId; static absl::flat_hash_map<std::string, MethodId> string2MethodId;
public: public:
PayloadChannelRequest(PayloadChannel::PayloadChannelSocket* channel, json& jsonRequest); PayloadChannelRequest(PayloadChannel::PayloadChannelSocket* channel, json& jsonRequest);
......
...@@ -3,8 +3,8 @@ ...@@ -3,8 +3,8 @@
#include "RTC/RtpObserver.hpp" #include "RTC/RtpObserver.hpp"
#include "handles/Timer.hpp" #include "handles/Timer.hpp"
#include <absl/container/flat_hash_map.h>
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>
#include <unordered_map>
#include <utility> #include <utility>
#include <vector> #include <vector>
...@@ -89,7 +89,7 @@ namespace RTC ...@@ -89,7 +89,7 @@ namespace RTC
std::string dominantId{ "" }; std::string dominantId{ "" };
Timer* periodicTimer{ nullptr }; Timer* periodicTimer{ nullptr };
uint16_t interval{ 300u }; uint16_t interval{ 300u };
std::unordered_map<std::string, struct ProducerSpeaker> mapProducerSpeaker; absl::flat_hash_map<std::string, struct ProducerSpeaker> mapProducerSpeaker;
uint64_t lastLevelIdleTime{ 0 }; uint64_t lastLevelIdleTime{ 0 };
}; };
} // namespace RTC } // namespace RTC
......
...@@ -3,8 +3,8 @@ ...@@ -3,8 +3,8 @@
#include "RTC/RtpObserver.hpp" #include "RTC/RtpObserver.hpp"
#include "handles/Timer.hpp" #include "handles/Timer.hpp"
#include <absl/container/flat_hash_map.h>
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>
#include <unordered_map>
using json = nlohmann::json; using json = nlohmann::json;
...@@ -48,7 +48,7 @@ namespace RTC ...@@ -48,7 +48,7 @@ namespace RTC
// Allocated by this. // Allocated by this.
Timer* periodicTimer{ nullptr }; Timer* periodicTimer{ nullptr };
// Others. // Others.
std::unordered_map<RTC::Producer*, DBovs> mapProducerDBovs; absl::flat_hash_map<RTC::Producer*, DBovs> mapProducerDBovs;
bool silence{ true }; bool silence{ true };
}; };
} // namespace RTC } // namespace RTC
......
...@@ -14,9 +14,9 @@ ...@@ -14,9 +14,9 @@
#include "RTC/RtpPacket.hpp" #include "RTC/RtpPacket.hpp"
#include "RTC/RtpStream.hpp" #include "RTC/RtpStream.hpp"
#include "RTC/RtpStreamSend.hpp" #include "RTC/RtpStreamSend.hpp"
#include <absl/container/flat_hash_set.h>
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>
#include <string> #include <string>
#include <unordered_set>
#include <vector> #include <vector>
using json = nlohmann::json; using json = nlohmann::json;
...@@ -182,7 +182,7 @@ namespace RTC ...@@ -182,7 +182,7 @@ namespace RTC
struct RTC::RtpHeaderExtensionIds rtpHeaderExtensionIds; struct RTC::RtpHeaderExtensionIds rtpHeaderExtensionIds;
const std::vector<uint8_t>* producerRtpStreamScores{ nullptr }; const std::vector<uint8_t>* producerRtpStreamScores{ nullptr };
// Others. // Others.
std::unordered_set<uint8_t> supportedCodecPayloadTypes; absl::flat_hash_set<uint8_t> supportedCodecPayloadTypes;
uint64_t lastRtcpSentTime{ 0u }; uint64_t lastRtcpSentTime{ 0u };
uint16_t maxRtcpInterval{ 0u }; uint16_t maxRtcpInterval{ 0u };
bool externallyManagedBitrate{ false }; bool externallyManagedBitrate{ false };
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
#include <openssl/bio.h> #include <openssl/bio.h>
#include <openssl/ssl.h> #include <openssl/ssl.h>
#include <openssl/x509.h> #include <openssl/x509.h>
#include <map> #include <absl/container/flat_hash_map.h>
#include <string> #include <string>
#include <vector> #include <vector>
...@@ -144,9 +144,9 @@ namespace RTC ...@@ -144,9 +144,9 @@ namespace RTC
thread_local static EVP_PKEY* privateKey; thread_local static EVP_PKEY* privateKey;
thread_local static SSL_CTX* sslCtx; thread_local static SSL_CTX* sslCtx;
thread_local static uint8_t sslReadBuffer[]; thread_local static uint8_t sslReadBuffer[];
static std::map<std::string, Role> string2Role; static absl::flat_hash_map<std::string, Role> string2Role;
static std::map<std::string, FingerprintAlgorithm> string2FingerprintAlgorithm; static absl::flat_hash_map<std::string, FingerprintAlgorithm> string2FingerprintAlgorithm;
static std::map<FingerprintAlgorithm, std::string> fingerprintAlgorithm2String; static absl::flat_hash_map<FingerprintAlgorithm, std::string> fingerprintAlgorithm2String;
thread_local static std::vector<Fingerprint> localFingerprints; thread_local static std::vector<Fingerprint> localFingerprints;
static std::vector<SrtpCryptoSuiteMapEntry> srtpCryptoSuites; static std::vector<SrtpCryptoSuiteMapEntry> srtpCryptoSuites;
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
#define MS_KEY_FRAME_REQUEST_MANAGER_HPP #define MS_KEY_FRAME_REQUEST_MANAGER_HPP
#include "handles/Timer.hpp" #include "handles/Timer.hpp"
#include <map> #include <absl/container/flat_hash_map.h>
namespace RTC namespace RTC
{ {
...@@ -122,8 +122,8 @@ namespace RTC ...@@ -122,8 +122,8 @@ namespace RTC
private: private:
Listener* listener{ nullptr }; Listener* listener{ nullptr };
uint32_t keyFrameRequestDelay{ 0u }; // 0 means disabled. uint32_t keyFrameRequestDelay{ 0u }; // 0 means disabled.
std::map<uint32_t, PendingKeyFrameInfo*> mapSsrcPendingKeyFrameInfo; absl::flat_hash_map<uint32_t, PendingKeyFrameInfo*> mapSsrcPendingKeyFrameInfo;
std::map<uint32_t, KeyFrameRequestDelayer*> mapSsrcKeyFrameRequestDelayer; absl::flat_hash_map<uint32_t, KeyFrameRequestDelayer*> mapSsrcKeyFrameRequestDelayer;
}; };
} // namespace RTC } // namespace RTC
......
...@@ -5,6 +5,8 @@ ...@@ -5,6 +5,8 @@
#include "RTC/RtpPacket.hpp" #include "RTC/RtpPacket.hpp"
#include "RTC/SeqManager.hpp" #include "RTC/SeqManager.hpp"
#include "handles/Timer.hpp" #include "handles/Timer.hpp"
#include <absl/container/btree_map.h>
#include <absl/container/btree_set.h>
#include <map> #include <map>
#include <set> #include <set>
#include <vector> #include <vector>
...@@ -75,9 +77,9 @@ namespace RTC ...@@ -75,9 +77,9 @@ namespace RTC
// Allocated by this. // Allocated by this.
Timer* timer{ nullptr }; Timer* timer{ nullptr };
// Others. // Others.
std::map<uint16_t, NackInfo, RTC::SeqManager<uint16_t>::SeqLowerThan> nackList; absl::btree_map<uint16_t, NackInfo, RTC::SeqManager<uint16_t>::SeqLowerThan> nackList;
std::set<uint16_t, RTC::SeqManager<uint16_t>::SeqLowerThan> keyFrameList; absl::btree_set<uint16_t, RTC::SeqManager<uint16_t>::SeqLowerThan> keyFrameList;
std::set<uint16_t, RTC::SeqManager<uint16_t>::SeqLowerThan> recoveredList; absl::btree_set<uint16_t, RTC::SeqManager<uint16_t>::SeqLowerThan> recoveredList;
bool started{ false }; bool started{ false };
uint16_t lastSeq{ 0u }; // Seq number of last valid packet. uint16_t lastSeq{ 0u }; // Seq number of last valid packet.
uint32_t rtt{ 0u }; // Round trip time (ms). uint32_t rtt{ 0u }; // Round trip time (ms).
......
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
#define MS_RTC_PARAMETERS_HPP #define MS_RTC_PARAMETERS_HPP
#include "common.hpp" #include "common.hpp"
#include <absl/container/flat_hash_map.h>
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>
#include <string> #include <string>
#include <unordered_map>
#include <vector> #include <vector>
using json = nlohmann::json; using json = nlohmann::json;
...@@ -78,7 +78,7 @@ namespace RTC ...@@ -78,7 +78,7 @@ namespace RTC
const std::vector<int32_t>& GetArrayOfIntegers(const std::string& key) const; const std::vector<int32_t>& GetArrayOfIntegers(const std::string& key) const;
private: private:
std::unordered_map<std::string, Value> mapKeyValues; absl::flat_hash_map<std::string, Value> mapKeyValues;
}; };
} // namespace RTC } // namespace RTC
......
...@@ -60,11 +60,11 @@ namespace RTC ...@@ -60,11 +60,11 @@ namespace RTC
// Allocated by this. // Allocated by this.
std::vector<RTC::RtpStreamSend*> rtpStreams; std::vector<RTC::RtpStreamSend*> rtpStreams;
// Others. // Others.
std::unordered_map<uint32_t, uint32_t> mapMappedSsrcSsrc; absl::flat_hash_map<uint32_t, uint32_t> mapMappedSsrcSsrc;
std::unordered_map<uint32_t, RTC::RtpStreamSend*> mapSsrcRtpStream; absl::flat_hash_map<uint32_t, RTC::RtpStreamSend*> mapSsrcRtpStream;
bool keyFrameSupported{ false }; bool keyFrameSupported{ false };
std::unordered_map<RTC::RtpStreamSend*, bool> mapRtpStreamSyncRequired; absl::flat_hash_map<RTC::RtpStreamSend*, bool> mapRtpStreamSyncRequired;
std::unordered_map<RTC::RtpStreamSend*, RTC::SeqManager<uint16_t>> mapRtpStreamRtpSeqManager; absl::flat_hash_map<RTC::RtpStreamSend*, RTC::SeqManager<uint16_t>> mapRtpStreamRtpSeqManager;
}; };
} // namespace RTC } // namespace RTC
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
#include "RTC/Transport.hpp" #include "RTC/Transport.hpp"
#include "RTC/TransportTuple.hpp" #include "RTC/TransportTuple.hpp"
#include "RTC/UdpSocket.hpp" #include "RTC/UdpSocket.hpp"
#include <map> #include <absl/container/flat_hash_map.h>
namespace RTC namespace RTC
{ {
...@@ -19,8 +19,8 @@ namespace RTC ...@@ -19,8 +19,8 @@ namespace RTC
}; };
private: private:
static std::map<std::string, RTC::SrtpSession::CryptoSuite> string2SrtpCryptoSuite; static absl::flat_hash_map<std::string, RTC::SrtpSession::CryptoSuite> string2SrtpCryptoSuite;
static std::map<RTC::SrtpSession::CryptoSuite, std::string> srtpCryptoSuite2String; static absl::flat_hash_map<RTC::SrtpSession::CryptoSuite, std::string> srtpCryptoSuite2String;
static size_t srtpMasterLength; static size_t srtpMasterLength;
public: public:
......
...@@ -4,9 +4,9 @@ ...@@ -4,9 +4,9 @@
#include "common.hpp" #include "common.hpp"
#include "Settings.hpp" #include "Settings.hpp"
#include <uv.h> #include <uv.h>
#include <absl/container/flat_hash_map.h>
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>
#include <string> #include <string>
#include <unordered_map>
#include <vector> #include <vector>
namespace RTC namespace RTC
...@@ -54,8 +54,8 @@ namespace RTC ...@@ -54,8 +54,8 @@ namespace RTC
static std::vector<bool>& GetPorts(Transport transport, const std::string& ip); static std::vector<bool>& GetPorts(Transport transport, const std::string& ip);
private: private:
thread_local static std::unordered_map<std::string, std::vector<bool>> mapUdpIpPorts; thread_local static absl::flat_hash_map<std::string, std::vector<bool>> mapUdpIpPorts;
thread_local static std::unordered_map<std::string, std::vector<bool>> mapTcpIpPorts; thread_local static absl::flat_hash_map<std::string, std::vector<bool>> mapTcpIpPorts;
}; };
} // namespace RTC } // namespace RTC
......
...@@ -12,7 +12,6 @@ ...@@ -12,7 +12,6 @@
#include "RTC/RtpHeaderExtensionIds.hpp" #include "RTC/RtpHeaderExtensionIds.hpp"
#include "RTC/RtpPacket.hpp" #include "RTC/RtpPacket.hpp"
#include "RTC/RtpStreamRecv.hpp" #include "RTC/RtpStreamRecv.hpp"
#include <map>
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>
#include <string> #include <string>
#include <vector> #include <vector>
...@@ -55,7 +54,7 @@ namespace RTC ...@@ -55,7 +54,7 @@ namespace RTC
private: private:
struct RtpMapping struct RtpMapping
{ {
std::map<uint8_t, uint8_t> codecs; absl::flat_hash_map<uint8_t, uint8_t> codecs;
std::vector<RtpEncodingMapping> encodings; std::vector<RtpEncodingMapping> encodings;
}; };
...@@ -113,7 +112,7 @@ namespace RTC ...@@ -113,7 +112,7 @@ namespace RTC
{ {
return this->paused; return this->paused;
} }
const std::map<RTC::RtpStreamRecv*, uint32_t>& GetRtpStreams() const absl::flat_hash_map<RTC::RtpStreamRecv*, uint32_t>& GetRtpStreams()
{ {
return this->mapRtpStreamMappedSsrc; return this->mapRtpStreamMappedSsrc;
} }
...@@ -161,7 +160,7 @@ namespace RTC ...@@ -161,7 +160,7 @@ namespace RTC
// Passed by argument. // Passed by argument.
RTC::Producer::Listener* listener{ nullptr }; RTC::Producer::Listener* listener{ nullptr };
// Allocated by this. // Allocated by this.
std::map<uint32_t, RTC::RtpStreamRecv*> mapSsrcRtpStream; absl::flat_hash_map<uint32_t, RTC::RtpStreamRecv*> mapSsrcRtpStream;
RTC::KeyFrameRequestManager* keyFrameRequestManager{ nullptr }; RTC::KeyFrameRequestManager* keyFrameRequestManager{ nullptr };
// Others. // Others.
RTC::Media::Kind kind; RTC::Media::Kind kind;
...@@ -170,9 +169,9 @@ namespace RTC ...@@ -170,9 +169,9 @@ namespace RTC
struct RtpMapping rtpMapping; struct RtpMapping rtpMapping;
std::vector<RTC::RtpStreamRecv*> rtpStreamByEncodingIdx; std::vector<RTC::RtpStreamRecv*> rtpStreamByEncodingIdx;
std::vector<uint8_t> rtpStreamScores; std::vector<uint8_t> rtpStreamScores;
std::map<uint32_t, RTC::RtpStreamRecv*> mapRtxSsrcRtpStream; absl::flat_hash_map<uint32_t, RTC::RtpStreamRecv*> mapRtxSsrcRtpStream;
std::map<RTC::RtpStreamRecv*, uint32_t> mapRtpStreamMappedSsrc; absl::flat_hash_map<RTC::RtpStreamRecv*, uint32_t> mapRtpStreamMappedSsrc;
std::map<uint32_t, uint32_t> mapMappedSsrcSsrc; absl::flat_hash_map<uint32_t, uint32_t> mapMappedSsrcSsrc;
struct RTC::RtpHeaderExtensionIds rtpHeaderExtensionIds; struct RTC::RtpHeaderExtensionIds rtpHeaderExtensionIds;
bool paused{ false }; bool paused{ false };
RTC::RtpPacket* currentRtpPacket{ nullptr }; RTC::RtpPacket* currentRtpPacket{ nullptr };
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include "common.hpp" #include "common.hpp"
#include "RTC/RTCP/FeedbackItem.hpp" #include "RTC/RTCP/FeedbackItem.hpp"
#include "RTC/RTCP/Packet.hpp" #include "RTC/RTCP/Packet.hpp"
#include <absl/container/flat_hash_map.h>
namespace RTC namespace RTC
{ {
...@@ -27,7 +28,7 @@ namespace RTC ...@@ -27,7 +28,7 @@ namespace RTC
static const std::string& MessageType2String(typename T::MessageType type); static const std::string& MessageType2String(typename T::MessageType type);
private: private:
static std::map<typename T::MessageType, std::string> type2String; static absl::flat_hash_map<typename T::MessageType, std::string> type2String;
public: public:
typename T::MessageType GetMessageType() const typename T::MessageType GetMessageType() const
......
...@@ -197,7 +197,7 @@ namespace RTC ...@@ -197,7 +197,7 @@ namespace RTC
static FeedbackRtpTransportPacket* Parse(const uint8_t* data, size_t len); static FeedbackRtpTransportPacket* Parse(const uint8_t* data, size_t len);
private: private:
static std::map<Status, std::string> status2String; static absl::flat_hash_map<Status, std::string> status2String;
public: public:
FeedbackRtpTransportPacket(uint32_t senderSsrc, uint32_t mediaSsrc) FeedbackRtpTransportPacket(uint32_t senderSsrc, uint32_t mediaSsrc)
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
#define MS_RTC_RTCP_PACKET_HPP #define MS_RTC_RTCP_PACKET_HPP
#include "common.hpp" #include "common.hpp"
#include <map> #include <absl/container/flat_hash_map.h>
#include <string> #include <string>
namespace RTC namespace RTC
...@@ -72,7 +72,7 @@ namespace RTC ...@@ -72,7 +72,7 @@ namespace RTC
static const std::string& Type2String(Type type); static const std::string& Type2String(Type type);
private: private:
static std::map<Type, std::string> type2String; static absl::flat_hash_map<Type, std::string> type2String;
public: public:
explicit Packet(Type type) : type(type) explicit Packet(Type type) : type(type)
......
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
#include "common.hpp" #include "common.hpp"
#include "RTC/RTCP/Packet.hpp" #include "RTC/RTCP/Packet.hpp"
#include <map>
#include <string> #include <string>
#include <vector> #include <vector>
...@@ -77,7 +76,7 @@ namespace RTC ...@@ -77,7 +76,7 @@ namespace RTC
std::unique_ptr<uint8_t[]> raw; std::unique_ptr<uint8_t[]> raw;
private: private:
static std::map<SdesItem::Type, std::string> type2String; static absl::flat_hash_map<SdesItem::Type, std::string> type2String;
}; };
class SdesChunk class SdesChunk
......
...@@ -13,9 +13,9 @@ ...@@ -13,9 +13,9 @@
#include "RTC/RtpPacket.hpp" #include "RTC/RtpPacket.hpp"
#include "RTC/RtpStream.hpp" #include "RTC/RtpStream.hpp"
#include "RTC/Transport.hpp" #include "RTC/Transport.hpp"
#include <absl/container/flat_hash_map.h>
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>
#include <string> #include <string>
#include <unordered_map>
#include <unordered_set> #include <unordered_set>
using json = nlohmann::json; using json = nlohmann::json;
...@@ -93,16 +93,17 @@ namespace RTC ...@@ -93,16 +93,17 @@ namespace RTC
private: private:
// Allocated by this. // Allocated by this.
std::unordered_map<std::string, RTC::Transport*> mapTransports; absl::flat_hash_map<std::string, RTC::Transport*> mapTransports;
std::unordered_map<std::string, RTC::RtpObserver*> mapRtpObservers; absl::flat_hash_map<std::string, RTC::RtpObserver*> mapRtpObservers;
// Others. // Others.
std::unordered_map<RTC::Producer*, std::unordered_set<RTC::Consumer*>> mapProducerConsumers; absl::flat_hash_map<RTC::Producer*, absl::flat_hash_set<RTC::Consumer*>> mapProducerConsumers;
std::unordered_map<RTC::Consumer*, RTC::Producer*> mapConsumerProducer; absl::flat_hash_map<RTC::Consumer*, RTC::Producer*> mapConsumerProducer;
std::unordered_map<RTC::Producer*, std::unordered_set<RTC::RtpObserver*>> mapProducerRtpObservers; absl::flat_hash_map<RTC::Producer*, absl::flat_hash_set<RTC::RtpObserver*>> mapProducerRtpObservers;
std::unordered_map<std::string, RTC::Producer*> mapProducers; absl::flat_hash_map<std::string, RTC::Producer*> mapProducers;
std::unordered_map<RTC::DataProducer*, std::unordered_set<RTC::DataConsumer*>> mapDataProducerDataConsumers; absl::flat_hash_map<RTC::DataProducer*, absl::flat_hash_set<RTC::DataConsumer*>>
std::unordered_map<RTC::DataConsumer*, RTC::DataProducer*> mapDataConsumerDataProducer; mapDataProducerDataConsumers;
std::unordered_map<std::string, RTC::DataProducer*> mapDataProducers; absl::flat_hash_map<RTC::DataConsumer*, RTC::DataProducer*> mapDataConsumerDataProducer;
absl::flat_hash_map<std::string, RTC::DataProducer*> mapDataProducers;
}; };
} // namespace RTC } // namespace RTC
......
...@@ -3,10 +3,9 @@ ...@@ -3,10 +3,9 @@
#include "common.hpp" #include "common.hpp"
#include "RTC/Parameters.hpp" #include "RTC/Parameters.hpp"
#include <map> #include <absl/container/flat_hash_map.h>
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>
#include <string> #include <string>
#include <unordered_map>
#include <vector> #include <vector>
using json = nlohmann::json; using json = nlohmann::json;
...@@ -29,8 +28,8 @@ namespace RTC ...@@ -29,8 +28,8 @@ namespace RTC
static const std::string& GetString(Kind kind); static const std::string& GetString(Kind kind);
private: private:
static std::unordered_map<std::string, Kind> string2Kind; static absl::flat_hash_map<std::string, Kind> string2Kind;
static std::map<Kind, std::string> kind2String; static absl::flat_hash_map<Kind, std::string> kind2String;
}; };
class RtpCodecMimeType class RtpCodecMimeType
...@@ -75,10 +74,10 @@ namespace RTC ...@@ -75,10 +74,10 @@ namespace RTC
}; };
public: public:
static std::unordered_map<std::string, Type> string2Type; static absl::flat_hash_map<std::string, Type> string2Type;
static std::map<Type, std::string> type2String; static absl::flat_hash_map<Type, std::string> type2String;
static std::unordered_map<std::string, Subtype> string2Subtype; static absl::flat_hash_map<std::string, Subtype> string2Subtype;
static std::map<Subtype, std::string> subtype2String; static absl::flat_hash_map<Subtype, std::string> subtype2String;
public: public:
RtpCodecMimeType() = default; RtpCodecMimeType() = default;
...@@ -145,7 +144,7 @@ namespace RTC ...@@ -145,7 +144,7 @@ namespace RTC
}; };
private: private:
static std::unordered_map<std::string, Type> string2Type; static absl::flat_hash_map<std::string, Type> string2Type;
public: public:
static Type GetType(std::string& uri); static Type GetType(std::string& uri);
...@@ -269,8 +268,8 @@ namespace RTC ...@@ -269,8 +268,8 @@ namespace RTC
static std::string& GetTypeString(Type type); static std::string& GetTypeString(Type type);
private: private:
static std::unordered_map<std::string, Type> string2Type; static absl::flat_hash_map<std::string, Type> string2Type;
static std::map<Type, std::string> type2String; static absl::flat_hash_map<Type, std::string> type2String;
public: public:
RtpParameters() = default; RtpParameters() = default;
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
#include "common.hpp" #include "common.hpp"
#include "Utils.hpp" #include "Utils.hpp"
#include "RTC/Codecs/PayloadDescriptorHandler.hpp" #include "RTC/Codecs/PayloadDescriptorHandler.hpp"
#include <map> #include <absl/container/btree_map.h>
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>
#include <string> #include <string>
#include <vector> #include <vector>
...@@ -611,8 +611,8 @@ namespace RTC ...@@ -611,8 +611,8 @@ namespace RTC
Header* header{ nullptr }; Header* header{ nullptr };
uint8_t* csrcList{ nullptr }; uint8_t* csrcList{ nullptr };
HeaderExtension* headerExtension{ nullptr }; HeaderExtension* headerExtension{ nullptr };
std::map<uint8_t, OneByteExtension*> mapOneByteExtensions; absl::btree_map<uint8_t, OneByteExtension*> mapOneByteExtensions;
std::map<uint8_t, TwoBytesExtension*> mapTwoBytesExtensions; absl::btree_map<uint8_t, TwoBytesExtension*> mapTwoBytesExtensions;
uint8_t midExtensionId{ 0u }; uint8_t midExtensionId{ 0u };
uint8_t ridExtensionId{ 0u }; uint8_t ridExtensionId{ 0u };
uint8_t rridExtensionId{ 0u }; uint8_t rridExtensionId{ 0u };
......
...@@ -102,7 +102,7 @@ namespace RTC ...@@ -102,7 +102,7 @@ namespace RTC
uint32_t initialAvailableBitrate{ 0u }; uint32_t initialAvailableBitrate{ 0u };
uint32_t availableBitrate{ 0u }; uint32_t availableBitrate{ 0u };
uint64_t lastAvailableBitrateEventAtMs{ 0u }; uint64_t lastAvailableBitrateEventAtMs{ 0u };
std::map<uint16_t, SentInfo, RTC::SeqManager<uint16_t>::SeqLowerThan> sentInfos; absl::btree_map<uint16_t, SentInfo, RTC::SeqManager<uint16_t>::SeqLowerThan> sentInfos;
float rtt{ 0 }; // Round trip time in ms. float rtt{ 0 }; // Round trip time in ms.
CummulativeResult cummulativeResult; CummulativeResult cummulativeResult;
CummulativeResult probationCummulativeResult; CummulativeResult probationCummulativeResult;
......
...@@ -97,7 +97,7 @@ namespace RTC ...@@ -97,7 +97,7 @@ namespace RTC
// Allocated by this. // Allocated by this.
RTC::RtpStreamSend* rtpStream{ nullptr }; RTC::RtpStreamSend* rtpStream{ nullptr };
// Others. // Others.
std::unordered_map<uint32_t, int16_t> mapMappedSsrcSpatialLayer; absl::flat_hash_map<uint32_t, int16_t> mapMappedSsrcSpatialLayer;
std::vector<RTC::RtpStreamSend*> rtpStreams; std::vector<RTC::RtpStreamSend*> rtpStreams;
std::vector<RTC::RtpStream*> producerRtpStreams; // Indexed by spatial layer. std::vector<RTC::RtpStream*> producerRtpStreams; // Indexed by spatial layer.
bool syncRequired{ false }; bool syncRequired{ false };
......
...@@ -26,9 +26,9 @@ ...@@ -26,9 +26,9 @@
#include "RTC/TransportCongestionControlClient.hpp" #include "RTC/TransportCongestionControlClient.hpp"
#include "RTC/TransportCongestionControlServer.hpp" #include "RTC/TransportCongestionControlServer.hpp"
#include "handles/Timer.hpp" #include "handles/Timer.hpp"
#include <absl/container/flat_hash_map.h>
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>
#include <string> #include <string>
#include <unordered_map>
using json = nlohmann::json; using json = nlohmann::json;
...@@ -273,12 +273,12 @@ namespace RTC ...@@ -273,12 +273,12 @@ namespace RTC
// Passed by argument. // Passed by argument.
Listener* listener{ nullptr }; Listener* listener{ nullptr };
// Allocated by this. // Allocated by this.
std::unordered_map<std::string, RTC::Producer*> mapProducers; absl::flat_hash_map<std::string, RTC::Producer*> mapProducers;
std::unordered_map<std::string, RTC::Consumer*> mapConsumers; absl::flat_hash_map<std::string, RTC::Consumer*> mapConsumers;
std::unordered_map<std::string, RTC::DataProducer*> mapDataProducers; absl::flat_hash_map<std::string, RTC::DataProducer*> mapDataProducers;
std::unordered_map<std::string, RTC::DataConsumer*> mapDataConsumers; absl::flat_hash_map<std::string, RTC::DataConsumer*> mapDataConsumers;
std::unordered_map<uint32_t, RTC::Consumer*> mapSsrcConsumer; absl::flat_hash_map<uint32_t, RTC::Consumer*> mapSsrcConsumer;
std::unordered_map<uint32_t, RTC::Consumer*> mapRtxSsrcConsumer; absl::flat_hash_map<uint32_t, RTC::Consumer*> mapRtxSsrcConsumer;
Timer* rtcpTimer{ nullptr }; Timer* rtcpTimer{ nullptr };
RTC::TransportCongestionControlClient* tccClient{ nullptr }; RTC::TransportCongestionControlClient* tccClient{ nullptr };
RTC::TransportCongestionControlServer* tccServer{ nullptr }; RTC::TransportCongestionControlServer* tccServer{ nullptr };
......
...@@ -110,8 +110,8 @@ namespace RTC ...@@ -110,8 +110,8 @@ namespace RTC
// Allocated by this. // Allocated by this.
RTC::IceServer* iceServer{ nullptr }; RTC::IceServer* iceServer{ nullptr };
// Map of UdpSocket/TcpServer and local announced IP (if any). // Map of UdpSocket/TcpServer and local announced IP (if any).
std::unordered_map<RTC::UdpSocket*, std::string> udpSockets; absl::flat_hash_map<RTC::UdpSocket*, std::string> udpSockets;
std::unordered_map<RTC::TcpServer*, std::string> tcpServers; absl::flat_hash_map<RTC::TcpServer*, std::string> tcpServers;
RTC::DtlsTransport* dtlsTransport{ nullptr }; RTC::DtlsTransport* dtlsTransport{ nullptr };
RTC::SrtpSession* srtpRecvSession{ nullptr }; RTC::SrtpSession* srtpRecvSession{ nullptr };
RTC::SrtpSession* srtpSendSession{ nullptr }; RTC::SrtpSession* srtpSendSession{ nullptr };
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
#include "common.hpp" #include "common.hpp"
#include "LogLevel.hpp" #include "LogLevel.hpp"
#include "Channel/ChannelRequest.hpp" #include "Channel/ChannelRequest.hpp"
#include <map> #include <absl/container/flat_hash_map.h>
#include <string> #include <string>
#include <vector> #include <vector>
...@@ -54,8 +54,8 @@ public: ...@@ -54,8 +54,8 @@ public:
thread_local static struct Configuration configuration; thread_local static struct Configuration configuration;
private: private:
static std::map<std::string, LogLevel> string2LogLevel; static absl::flat_hash_map<std::string, LogLevel> string2LogLevel;
static std::map<LogLevel, std::string> logLevel2String; static absl::flat_hash_map<LogLevel, std::string> logLevel2String;
}; };
#endif #endif
...@@ -9,9 +9,9 @@ ...@@ -9,9 +9,9 @@
#include "PayloadChannel/PayloadChannelSocket.hpp" #include "PayloadChannel/PayloadChannelSocket.hpp"
#include "RTC/Router.hpp" #include "RTC/Router.hpp"
#include "handles/SignalsHandler.hpp" #include "handles/SignalsHandler.hpp"
#include <absl/container/flat_hash_map.h>
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>
#include <string> #include <string>
#include <unordered_map>
using json = nlohmann::json; using json = nlohmann::json;
...@@ -55,7 +55,7 @@ private: ...@@ -55,7 +55,7 @@ private:
PayloadChannel::PayloadChannelSocket* payloadChannel{ nullptr }; PayloadChannel::PayloadChannelSocket* payloadChannel{ nullptr };
// Allocated by this. // Allocated by this.
SignalsHandler* signalsHandler{ nullptr }; SignalsHandler* signalsHandler{ nullptr };
std::unordered_map<std::string, RTC::Router*> mapRouters; absl::flat_hash_map<std::string, RTC::Router*> mapRouters;
// Others. // Others.
bool closed{ false }; bool closed{ false };
}; };
......
...@@ -4,8 +4,8 @@ ...@@ -4,8 +4,8 @@
#include "common.hpp" #include "common.hpp"
#include "handles/TcpConnectionHandler.hpp" #include "handles/TcpConnectionHandler.hpp"
#include <uv.h> #include <uv.h>
#include <absl/container/flat_hash_set.h>
#include <string> #include <string>
#include <unordered_set>
class TcpServerHandler : public TcpConnectionHandler::Listener class TcpServerHandler : public TcpConnectionHandler::Listener
{ {
...@@ -68,7 +68,7 @@ private: ...@@ -68,7 +68,7 @@ private:
// Allocated by this (may be passed by argument). // Allocated by this (may be passed by argument).
uv_tcp_t* uvHandle{ nullptr }; uv_tcp_t* uvHandle{ nullptr };
// Others. // Others.
std::unordered_set<TcpConnectionHandler*> connections; absl::flat_hash_set<TcpConnectionHandler*> connections;
bool closed{ false }; bool closed{ false };
}; };
......
...@@ -196,6 +196,7 @@ libwebrtc_include_directories = include_directories('include') ...@@ -196,6 +196,7 @@ libwebrtc_include_directories = include_directories('include')
subdir('deps/libwebrtc') subdir('deps/libwebrtc')
dependencies = [ dependencies = [
abseil_cpp_proj.get_variable('absl_container_dep'),
openssl_proj.get_variable('openssl_dep'), openssl_proj.get_variable('openssl_dep'),
nlohmann_json_proj.get_variable('nlohmann_json_dep'), nlohmann_json_proj.get_variable('nlohmann_json_dep'),
libuv_proj.get_variable('libuv_dep'), libuv_proj.get_variable('libuv_dep'),
...@@ -205,6 +206,7 @@ dependencies = [ ...@@ -205,6 +206,7 @@ dependencies = [
] ]
link_whole = [ link_whole = [
abseil_cpp_proj.get_variable('absl_container_lib'),
openssl_proj.get_variable('libcrypto_lib'), openssl_proj.get_variable('libcrypto_lib'),
openssl_proj.get_variable('libssl_lib'), openssl_proj.get_variable('libssl_lib'),
libuv_proj.get_variable('libuv'), libuv_proj.get_variable('libuv'),
......
...@@ -11,7 +11,7 @@ namespace Channel ...@@ -11,7 +11,7 @@ namespace Channel
/* Class variables. */ /* Class variables. */
// clang-format off // clang-format off
std::unordered_map<std::string, ChannelRequest::MethodId> ChannelRequest::string2MethodId = absl::flat_hash_map<std::string, ChannelRequest::MethodId> ChannelRequest::string2MethodId =
{ {
{ "worker.close", ChannelRequest::MethodId::WORKER_CLOSE }, { "worker.close", ChannelRequest::MethodId::WORKER_CLOSE },
{ "worker.dump", ChannelRequest::MethodId::WORKER_DUMP }, { "worker.dump", ChannelRequest::MethodId::WORKER_DUMP },
......
...@@ -55,7 +55,7 @@ inline static void sctpDebug(const char* format, ...) ...@@ -55,7 +55,7 @@ inline static void sctpDebug(const char* format, ...)
thread_local DepUsrSCTP::Checker* DepUsrSCTP::checker{ nullptr }; thread_local DepUsrSCTP::Checker* DepUsrSCTP::checker{ nullptr };
uint64_t DepUsrSCTP::numSctpAssociations{ 0u }; uint64_t DepUsrSCTP::numSctpAssociations{ 0u };
uintptr_t DepUsrSCTP::nextSctpAssociationId{ 0u }; uintptr_t DepUsrSCTP::nextSctpAssociationId{ 0u };
std::unordered_map<uintptr_t, RTC::SctpAssociation*> DepUsrSCTP::mapIdSctpAssociation; absl::flat_hash_map<uintptr_t, RTC::SctpAssociation*> DepUsrSCTP::mapIdSctpAssociation;
/* Static methods. */ /* Static methods. */
......
...@@ -11,7 +11,7 @@ namespace PayloadChannel ...@@ -11,7 +11,7 @@ namespace PayloadChannel
/* Class variables. */ /* Class variables. */
// clang-format off // clang-format off
std::unordered_map<std::string, Notification::EventId> Notification::string2EventId = absl::flat_hash_map<std::string, Notification::EventId> Notification::string2EventId =
{ {
{ "transport.sendRtcp", Notification::EventId::TRANSPORT_SEND_RTCP }, { "transport.sendRtcp", Notification::EventId::TRANSPORT_SEND_RTCP },
{ "producer.send", Notification::EventId::PRODUCER_SEND }, { "producer.send", Notification::EventId::PRODUCER_SEND },
......
...@@ -12,7 +12,7 @@ namespace PayloadChannel ...@@ -12,7 +12,7 @@ namespace PayloadChannel
/* Class variables. */ /* Class variables. */
// clang-format off // clang-format off
std::unordered_map<std::string, PayloadChannelRequest::MethodId> PayloadChannelRequest::string2MethodId = absl::flat_hash_map<std::string, PayloadChannelRequest::MethodId> PayloadChannelRequest::string2MethodId =
{ {
{ "dataConsumer.send", PayloadChannelRequest::MethodId::DATA_CONSUMER_SEND }, { "dataConsumer.send", PayloadChannelRequest::MethodId::DATA_CONSUMER_SEND },
}; };
......
...@@ -146,7 +146,7 @@ namespace RTC ...@@ -146,7 +146,7 @@ namespace RTC
{ {
MS_TRACE(); MS_TRACE();
std::map<int8_t, RTC::Producer*> mapDBovsProducer; absl::btree_map<int8_t, RTC::Producer*> mapDBovsProducer;
for (auto& kv : this->mapProducerDBovs) for (auto& kv : this->mapProducerDBovs)
{ {
......
...@@ -83,7 +83,7 @@ namespace RTC ...@@ -83,7 +83,7 @@ namespace RTC
thread_local SSL_CTX* DtlsTransport::sslCtx{ nullptr }; thread_local SSL_CTX* DtlsTransport::sslCtx{ nullptr };
thread_local uint8_t DtlsTransport::sslReadBuffer[SslReadBufferSize]; thread_local uint8_t DtlsTransport::sslReadBuffer[SslReadBufferSize];
// clang-format off // clang-format off
std::map<std::string, DtlsTransport::FingerprintAlgorithm> DtlsTransport::string2FingerprintAlgorithm = absl::flat_hash_map<std::string, DtlsTransport::FingerprintAlgorithm> DtlsTransport::string2FingerprintAlgorithm =
{ {
{ "sha-1", DtlsTransport::FingerprintAlgorithm::SHA1 }, { "sha-1", DtlsTransport::FingerprintAlgorithm::SHA1 },
{ "sha-224", DtlsTransport::FingerprintAlgorithm::SHA224 }, { "sha-224", DtlsTransport::FingerprintAlgorithm::SHA224 },
...@@ -91,7 +91,7 @@ namespace RTC ...@@ -91,7 +91,7 @@ namespace RTC
{ "sha-384", DtlsTransport::FingerprintAlgorithm::SHA384 }, { "sha-384", DtlsTransport::FingerprintAlgorithm::SHA384 },
{ "sha-512", DtlsTransport::FingerprintAlgorithm::SHA512 } { "sha-512", DtlsTransport::FingerprintAlgorithm::SHA512 }
}; };
std::map<DtlsTransport::FingerprintAlgorithm, std::string> DtlsTransport::fingerprintAlgorithm2String = absl::flat_hash_map<DtlsTransport::FingerprintAlgorithm, std::string> DtlsTransport::fingerprintAlgorithm2String =
{ {
{ DtlsTransport::FingerprintAlgorithm::SHA1, "sha-1" }, { DtlsTransport::FingerprintAlgorithm::SHA1, "sha-1" },
{ DtlsTransport::FingerprintAlgorithm::SHA224, "sha-224" }, { DtlsTransport::FingerprintAlgorithm::SHA224, "sha-224" },
...@@ -99,7 +99,7 @@ namespace RTC ...@@ -99,7 +99,7 @@ namespace RTC
{ DtlsTransport::FingerprintAlgorithm::SHA384, "sha-384" }, { DtlsTransport::FingerprintAlgorithm::SHA384, "sha-384" },
{ DtlsTransport::FingerprintAlgorithm::SHA512, "sha-512" } { DtlsTransport::FingerprintAlgorithm::SHA512, "sha-512" }
}; };
std::map<std::string, DtlsTransport::Role> DtlsTransport::string2Role = absl::flat_hash_map<std::string, DtlsTransport::Role> DtlsTransport::string2Role =
{ {
{ "auto", DtlsTransport::Role::AUTO }, { "auto", DtlsTransport::Role::AUTO },
{ "client", DtlsTransport::Role::CLIENT }, { "client", DtlsTransport::Role::CLIENT },
......
...@@ -152,18 +152,18 @@ namespace RTC ...@@ -152,18 +152,18 @@ namespace RTC
// clear it and request a keyframe. // clear it and request a keyframe.
uint16_t numNewNacks = seqEnd - seqStart; uint16_t numNewNacks = seqEnd - seqStart;
if (this->nackList.size() + numNewNacks > MaxNackPackets) if (static_cast<uint16_t>(this->nackList.size()) + numNewNacks > MaxNackPackets)
{ {
// clang-format off // clang-format off
while ( while (
RemoveNackItemsUntilKeyFrame() && RemoveNackItemsUntilKeyFrame() &&
this->nackList.size() + numNewNacks > MaxNackPackets static_cast<uint16_t>(this->nackList.size()) + numNewNacks > MaxNackPackets
) )
// clang-format on // clang-format on
{ {
} }
if (this->nackList.size() + numNewNacks > MaxNackPackets) if (static_cast<uint16_t>(this->nackList.size()) + numNewNacks > MaxNackPackets)
{ {
MS_WARN_TAG( MS_WARN_TAG(
rtx, "NACK list full, clearing it and requesting a key frame [seqEnd:%" PRIu16 "]", seqEnd); rtx, "NACK list full, clearing it and requesting a key frame [seqEnd:%" PRIu16 "]", seqEnd);
......
...@@ -14,12 +14,12 @@ namespace RTC ...@@ -14,12 +14,12 @@ namespace RTC
// NOTE: PlainTransport allows AES_CM_128_HMAC_SHA1_80 and // NOTE: PlainTransport allows AES_CM_128_HMAC_SHA1_80 and
// AES_CM_128_HMAC_SHA1_32 SRTP crypto suites. // AES_CM_128_HMAC_SHA1_32 SRTP crypto suites.
// clang-format off // clang-format off
std::map<std::string, RTC::SrtpSession::CryptoSuite> PlainTransport::string2SrtpCryptoSuite = absl::flat_hash_map<std::string, RTC::SrtpSession::CryptoSuite> PlainTransport::string2SrtpCryptoSuite =
{ {
{ "AES_CM_128_HMAC_SHA1_80", RTC::SrtpSession::CryptoSuite::AES_CM_128_HMAC_SHA1_80 }, { "AES_CM_128_HMAC_SHA1_80", RTC::SrtpSession::CryptoSuite::AES_CM_128_HMAC_SHA1_80 },
{ "AES_CM_128_HMAC_SHA1_32", RTC::SrtpSession::CryptoSuite::AES_CM_128_HMAC_SHA1_32 } { "AES_CM_128_HMAC_SHA1_32", RTC::SrtpSession::CryptoSuite::AES_CM_128_HMAC_SHA1_32 }
}; };
std::map<RTC::SrtpSession::CryptoSuite, std::string> PlainTransport::srtpCryptoSuite2String = absl::flat_hash_map<RTC::SrtpSession::CryptoSuite, std::string> PlainTransport::srtpCryptoSuite2String =
{ {
{ RTC::SrtpSession::CryptoSuite::AES_CM_128_HMAC_SHA1_80, "AES_CM_128_HMAC_SHA1_80" }, { RTC::SrtpSession::CryptoSuite::AES_CM_128_HMAC_SHA1_80, "AES_CM_128_HMAC_SHA1_80" },
{ RTC::SrtpSession::CryptoSuite::AES_CM_128_HMAC_SHA1_32, "AES_CM_128_HMAC_SHA1_32" } { RTC::SrtpSession::CryptoSuite::AES_CM_128_HMAC_SHA1_32, "AES_CM_128_HMAC_SHA1_32" }
......
...@@ -26,8 +26,8 @@ namespace RTC ...@@ -26,8 +26,8 @@ namespace RTC
{ {
/* Class variables. */ /* Class variables. */
thread_local std::unordered_map<std::string, std::vector<bool>> PortManager::mapUdpIpPorts; thread_local absl::flat_hash_map<std::string, std::vector<bool>> PortManager::mapUdpIpPorts;
thread_local std::unordered_map<std::string, std::vector<bool>> PortManager::mapTcpIpPorts; thread_local absl::flat_hash_map<std::string, std::vector<bool>> PortManager::mapTcpIpPorts;
/* Class methods. */ /* Class methods. */
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "RTC/RTCP/FeedbackPs.hpp" #include "RTC/RTCP/FeedbackPs.hpp"
#include "RTC/RTCP/FeedbackRtp.hpp" #include "RTC/RTCP/FeedbackRtp.hpp"
#include "RTC/RTCP/XrReceiverReferenceTime.hpp" #include "RTC/RTCP/XrReceiverReferenceTime.hpp"
#include <absl/container/inlined_vector.h>
#include <cstring> // std::memcpy() #include <cstring> // std::memcpy()
#include <iterator> // std::ostream_iterator #include <iterator> // std::ostream_iterator
#include <sstream> // std::ostringstream #include <sstream> // std::ostringstream
......
...@@ -98,7 +98,7 @@ namespace RTC ...@@ -98,7 +98,7 @@ namespace RTC
// clang-format off // clang-format off
template<> template<>
std::map<FeedbackPs::MessageType, std::string> FeedbackPacket<FeedbackPs>::type2String = absl::flat_hash_map<FeedbackPs::MessageType, std::string> FeedbackPacket<FeedbackPs>::type2String =
{ {
{ FeedbackPs::MessageType::PLI, "PLI" }, { FeedbackPs::MessageType::PLI, "PLI" },
{ FeedbackPs::MessageType::SLI, "SLI" }, { FeedbackPs::MessageType::SLI, "SLI" },
...@@ -188,7 +188,7 @@ namespace RTC ...@@ -188,7 +188,7 @@ namespace RTC
// clang-format off // clang-format off
template<> template<>
std::map<FeedbackRtp::MessageType, std::string> FeedbackPacket<FeedbackRtp>::type2String = absl::flat_hash_map<FeedbackRtp::MessageType, std::string> FeedbackPacket<FeedbackRtp>::type2String =
{ {
{ FeedbackRtp::MessageType::NACK, "NACK" }, { FeedbackRtp::MessageType::NACK, "NACK" },
{ FeedbackRtp::MessageType::TMMBR, "TMMBR" }, { FeedbackRtp::MessageType::TMMBR, "TMMBR" },
......
...@@ -60,7 +60,7 @@ namespace RTC ...@@ -60,7 +60,7 @@ namespace RTC
int16_t FeedbackRtpTransportPacket::maxPacketDelta{ 0x7FFF }; int16_t FeedbackRtpTransportPacket::maxPacketDelta{ 0x7FFF };
// clang-format off // clang-format off
std::map<FeedbackRtpTransportPacket::Status, std::string> FeedbackRtpTransportPacket::status2String = absl::flat_hash_map<FeedbackRtpTransportPacket::Status, std::string> FeedbackRtpTransportPacket::status2String =
{ {
{ FeedbackRtpTransportPacket::Status::NotReceived, "NR" }, { FeedbackRtpTransportPacket::Status::NotReceived, "NR" },
{ FeedbackRtpTransportPacket::Status::SmallDelta, "SD" }, { FeedbackRtpTransportPacket::Status::SmallDelta, "SD" },
......
...@@ -21,7 +21,7 @@ namespace RTC ...@@ -21,7 +21,7 @@ namespace RTC
/* Class variables. */ /* Class variables. */
// clang-format off // clang-format off
std::map<Type, std::string> Packet::type2String = absl::flat_hash_map<Type, std::string> Packet::type2String =
{ {
{ Type::SR, "SR" }, { Type::SR, "SR" },
{ Type::RR, "RR" }, { Type::RR, "RR" },
......
...@@ -13,7 +13,7 @@ namespace RTC ...@@ -13,7 +13,7 @@ namespace RTC
/* Item Class variables. */ /* Item Class variables. */
// clang-format off // clang-format off
std::map<SdesItem::Type, std::string> SdesItem::type2String = absl::flat_hash_map<SdesItem::Type, std::string> SdesItem::type2String =
{ {
{ SdesItem::Type::END, "END" }, { SdesItem::Type::END, "END" },
{ SdesItem::Type::CNAME, "CNAME" }, { SdesItem::Type::CNAME, "CNAME" },
......
...@@ -11,13 +11,13 @@ namespace RTC ...@@ -11,13 +11,13 @@ namespace RTC
/* Class variables. */ /* Class variables. */
// clang-format off // clang-format off
std::unordered_map<std::string, Media::Kind> Media::string2Kind = absl::flat_hash_map<std::string, Media::Kind> Media::string2Kind =
{ {
{ "", Media::Kind::ALL }, { "", Media::Kind::ALL },
{ "audio", Media::Kind::AUDIO }, { "audio", Media::Kind::AUDIO },
{ "video", Media::Kind::VIDEO } { "video", Media::Kind::VIDEO }
}; };
std::map<Media::Kind, std::string> Media::kind2String = absl::flat_hash_map<Media::Kind, std::string> Media::kind2String =
{ {
{ Media::Kind::ALL, "" }, { Media::Kind::ALL, "" },
{ Media::Kind::AUDIO, "audio" }, { Media::Kind::AUDIO, "audio" },
......
...@@ -11,17 +11,17 @@ namespace RTC ...@@ -11,17 +11,17 @@ namespace RTC
/* Class variables. */ /* Class variables. */
// clang-format off // clang-format off
std::unordered_map<std::string, RtpCodecMimeType::Type> RtpCodecMimeType::string2Type = absl::flat_hash_map<std::string, RtpCodecMimeType::Type> RtpCodecMimeType::string2Type =
{ {
{ "audio", RtpCodecMimeType::Type::AUDIO }, { "audio", RtpCodecMimeType::Type::AUDIO },
{ "video", RtpCodecMimeType::Type::VIDEO } { "video", RtpCodecMimeType::Type::VIDEO }
}; };
std::map<RtpCodecMimeType::Type, std::string> RtpCodecMimeType::type2String = absl::flat_hash_map<RtpCodecMimeType::Type, std::string> RtpCodecMimeType::type2String =
{ {
{ RtpCodecMimeType::Type::AUDIO, "audio" }, { RtpCodecMimeType::Type::AUDIO, "audio" },
{ RtpCodecMimeType::Type::VIDEO, "video" } { RtpCodecMimeType::Type::VIDEO, "video" }
}; };
std::unordered_map<std::string, RtpCodecMimeType::Subtype> RtpCodecMimeType::string2Subtype = absl::flat_hash_map<std::string, RtpCodecMimeType::Subtype> RtpCodecMimeType::string2Subtype =
{ {
// Audio codecs: // Audio codecs:
{ "opus", RtpCodecMimeType::Subtype::OPUS }, { "opus", RtpCodecMimeType::Subtype::OPUS },
...@@ -48,7 +48,7 @@ namespace RTC ...@@ -48,7 +48,7 @@ namespace RTC
{ "x-ulpfecuc", RtpCodecMimeType::Subtype::X_ULPFECUC }, { "x-ulpfecuc", RtpCodecMimeType::Subtype::X_ULPFECUC },
{ "red", RtpCodecMimeType::Subtype::RED } { "red", RtpCodecMimeType::Subtype::RED }
}; };
std::map<RtpCodecMimeType::Subtype, std::string> RtpCodecMimeType::subtype2String = absl::flat_hash_map<RtpCodecMimeType::Subtype, std::string> RtpCodecMimeType::subtype2String =
{ {
// Audio codecs: // Audio codecs:
{ RtpCodecMimeType::Subtype::OPUS, "opus" }, { RtpCodecMimeType::Subtype::OPUS, "opus" },
......
...@@ -10,7 +10,7 @@ namespace RTC ...@@ -10,7 +10,7 @@ namespace RTC
/* Class variables. */ /* Class variables. */
// clang-format off // clang-format off
std::unordered_map<std::string, RtpHeaderExtensionUri::Type> RtpHeaderExtensionUri::string2Type = absl::flat_hash_map<std::string, RtpHeaderExtensionUri::Type> RtpHeaderExtensionUri::string2Type =
{ {
{ "urn:ietf:params:rtp-hdrext:sdes:mid", RtpHeaderExtensionUri::Type::MID }, { "urn:ietf:params:rtp-hdrext:sdes:mid", RtpHeaderExtensionUri::Type::MID },
{ "urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id", RtpHeaderExtensionUri::Type::RTP_STREAM_ID }, { "urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id", RtpHeaderExtensionUri::Type::RTP_STREAM_ID },
......
...@@ -4,14 +4,14 @@ ...@@ -4,14 +4,14 @@
#include "Logger.hpp" #include "Logger.hpp"
#include "MediaSoupErrors.hpp" #include "MediaSoupErrors.hpp"
#include "RTC/RtpDictionaries.hpp" #include "RTC/RtpDictionaries.hpp"
#include <unordered_set> #include <absl/container/flat_hash_set.h>
namespace RTC namespace RTC
{ {
/* Class variables. */ /* Class variables. */
// clang-format off // clang-format off
std::unordered_map<std::string, RtpParameters::Type> RtpParameters::string2Type = absl::flat_hash_map<std::string, RtpParameters::Type> RtpParameters::string2Type =
{ {
{ "none", RtpParameters::Type::NONE }, { "none", RtpParameters::Type::NONE },
{ "simple", RtpParameters::Type::SIMPLE }, { "simple", RtpParameters::Type::SIMPLE },
...@@ -19,7 +19,7 @@ namespace RTC ...@@ -19,7 +19,7 @@ namespace RTC
{ "svc", RtpParameters::Type::SVC }, { "svc", RtpParameters::Type::SVC },
{ "pipe", RtpParameters::Type::PIPE } { "pipe", RtpParameters::Type::PIPE }
}; };
std::map<RtpParameters::Type, std::string> RtpParameters::type2String = absl::flat_hash_map<RtpParameters::Type, std::string> RtpParameters::type2String =
{ {
{ RtpParameters::Type::NONE, "none" }, { RtpParameters::Type::NONE, "none" },
{ RtpParameters::Type::SIMPLE, "simple" }, { RtpParameters::Type::SIMPLE, "simple" },
...@@ -266,7 +266,7 @@ namespace RTC ...@@ -266,7 +266,7 @@ namespace RTC
static const std::string AptString{ "apt" }; static const std::string AptString{ "apt" };
std::unordered_set<uint8_t> payloadTypes; absl::flat_hash_set<uint8_t> payloadTypes;
for (auto& codec : this->codecs) for (auto& codec : this->codecs)
{ {
......
...@@ -5,8 +5,7 @@ ...@@ -5,8 +5,7 @@
#include "Logger.hpp" #include "Logger.hpp"
#include "MediaSoupErrors.hpp" #include "MediaSoupErrors.hpp"
#include "Utils.hpp" #include "Utils.hpp"
#include <cctype> // isprint() #include <cctype> // isprint()
#include <cerrno>
#include <iterator> // std::ostream_iterator #include <iterator> // std::ostream_iterator
#include <mutex> #include <mutex>
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>
...@@ -24,14 +23,14 @@ static std::mutex globalSyncMutex; ...@@ -24,14 +23,14 @@ static std::mutex globalSyncMutex;
thread_local struct Settings::Configuration Settings::configuration; thread_local struct Settings::Configuration Settings::configuration;
// clang-format off // clang-format off
std::map<std::string, LogLevel> Settings::string2LogLevel = absl::flat_hash_map<std::string, LogLevel> Settings::string2LogLevel =
{ {
{ "debug", LogLevel::LOG_DEBUG }, { "debug", LogLevel::LOG_DEBUG },
{ "warn", LogLevel::LOG_WARN }, { "warn", LogLevel::LOG_WARN },
{ "error", LogLevel::LOG_ERROR }, { "error", LogLevel::LOG_ERROR },
{ "none", LogLevel::LOG_NONE } { "none", LogLevel::LOG_NONE }
}; };
std::map<LogLevel, std::string> Settings::logLevel2String = absl::flat_hash_map<LogLevel, std::string> Settings::logLevel2String =
{ {
{ LogLevel::LOG_DEBUG, "debug" }, { LogLevel::LOG_DEBUG, "debug" },
{ LogLevel::LOG_WARN, "warn" }, { LogLevel::LOG_WARN, "warn" },
......
...@@ -19,11 +19,11 @@ ...@@ -19,11 +19,11 @@
#include "RTC/DtlsTransport.hpp" #include "RTC/DtlsTransport.hpp"
#include "RTC/SrtpSession.hpp" #include "RTC/SrtpSession.hpp"
#include <uv.h> #include <uv.h>
#include <absl/container/flat_hash_map.h>
#include <cerrno> #include <cerrno>
#include <csignal> // sigaction() #include <csignal> // sigaction()
#include <cstdlib> // std::_Exit(), std::genenv() #include <cstdlib> // std::_Exit(), std::genenv()
#include <iostream> // std::cerr, std::endl #include <iostream> // std::cerr, std::endl
#include <map>
#include <string> #include <string>
void IgnoreSignals(); void IgnoreSignals();
...@@ -210,7 +210,7 @@ void IgnoreSignals() ...@@ -210,7 +210,7 @@ void IgnoreSignals()
struct sigaction act; // NOLINT(cppcoreguidelines-pro-type-member-init) struct sigaction act; // NOLINT(cppcoreguidelines-pro-type-member-init)
// clang-format off // clang-format off
std::map<std::string, int> ignoredSignals = absl::flat_hash_map<std::string, int> ignoredSignals =
{ {
{ "PIPE", SIGPIPE }, { "PIPE", SIGPIPE },
{ "HUP", SIGHUP }, { "HUP", SIGHUP },
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论