Browse Source

Cleaned up rtc namespace use

Paul-Louis Ageneau 4 years ago
parent
commit
4428e3dc3e

+ 2 - 2
include/rtc/h264rtppacketizer.hpp

@@ -26,7 +26,7 @@
 namespace rtc {
 
 /// RTP packetization of h264 payload
-class RTC_CPP_EXPORT H264RtpPacketizer : public rtc::RtpPacketizer {
+class RTC_CPP_EXPORT H264RtpPacketizer : public RtpPacketizer {
 
 public:
 	/// Default clock rate for H264 in RTP
@@ -36,7 +36,7 @@ public:
 	/// @note RTP configuration is used in packetization process which may change some configuration
 	/// properties such as sequence number.
 	/// @param rtpConfig  RTP configuration
-	H264RtpPacketizer(std::shared_ptr<rtc::RtpPacketizationConfig> rtpConfig);
+	H264RtpPacketizer(std::shared_ptr<RtpPacketizationConfig> rtpConfig);
 };
 
 } // namespace rtc

+ 11 - 11
include/rtc/nalunit.hpp

@@ -60,22 +60,22 @@ private:
 #pragma pack(pop)
 
 /// Nal unit
-struct RTC_CPP_EXPORT NalUnit : rtc::binary {
+struct RTC_CPP_EXPORT NalUnit : binary {
 	NalUnit(const NalUnit &unit) = default;
 	NalUnit(size_t size, bool includingHeader = true)
-	    : rtc::binary(size + (includingHeader ? 0 : 1)) {}
+	    : binary(size + (includingHeader ? 0 : 1)) {}
 
 	template <typename Iterator>
-	NalUnit(Iterator begin_, Iterator end_) : rtc::binary(begin_, end_) {}
+	NalUnit(Iterator begin_, Iterator end_) : binary(begin_, end_) {}
 
-	NalUnit(rtc::binary &&data) : rtc::binary(std::move(data)) {}
+	NalUnit(binary &&data) : binary(std::move(data)) {}
 
-	NalUnit() : rtc::binary(1) {}
+	NalUnit() : binary(1) {}
 
 	bool forbiddenBit() { return header()->forbiddenBit(); }
 	uint8_t nri() { return header()->nri(); }
 	uint8_t unitType() { return header()->unitType(); }
-	rtc::binary payload() {
+	binary payload() {
 		assert(size() >= 1);
 		return {begin() + 1, end()};
 	}
@@ -83,7 +83,7 @@ struct RTC_CPP_EXPORT NalUnit : rtc::binary {
 	void setForbiddenBit(bool isSet) { header()->setForbiddenBit(isSet); }
 	void setNRI(uint8_t nri) { header()->setNRI(nri); }
 	void setUnitType(uint8_t type) { header()->setUnitType(type); }
-	void setPayload(rtc::binary payload) {
+	void setPayload(binary payload) {
 		assert(size() >= 1);
 		erase(begin() + 1, end());
 		insert(end(), payload.begin(), payload.end());
@@ -101,13 +101,13 @@ struct RTC_CPP_EXPORT NalUnitFragmentA : NalUnit {
 	enum class FragmentType { Start, Middle, End };
 
 	NalUnitFragmentA(FragmentType type, bool forbiddenBit, uint8_t nri, uint8_t unitType,
-	                 rtc::binary data);
+	                 binary data);
 
 	static std::vector<NalUnitFragmentA> fragmentsFrom(NalUnit nalu, uint16_t maximumFragmentSize);
 
 	uint8_t unitType() { return fragmentHeader()->unitType(); }
 
-	rtc::binary payload() {
+	binary payload() {
 		assert(size() >= 2);
 		return {begin() + 2, end()};
 	}
@@ -124,7 +124,7 @@ struct RTC_CPP_EXPORT NalUnitFragmentA : NalUnit {
 
 	void setUnitType(uint8_t type) { fragmentHeader()->setUnitType(type); }
 
-	void setPayload(rtc::binary payload) {
+	void setPayload(binary payload) {
 		assert(size() >= 2);
 		erase(begin() + 2, end());
 		insert(end(), payload.begin(), payload.end());
@@ -145,7 +145,7 @@ protected:
 class RTC_CPP_EXPORT NalUnits : public std::vector<NalUnit> {
 public:
 	static const uint16_t defaultMaximumFragmentSize = 1400;
-	std::vector<rtc::binary>
+	std::vector<binary>
 	generateFragments(uint16_t maximumFragmentSize = NalUnits::defaultMaximumFragmentSize);
 };
 

+ 3 - 2
src/datachannel.cpp

@@ -28,10 +28,11 @@
 #include <arpa/inet.h>
 #endif
 
-rtc::LogCounter COUNTER_USERNEG_OPEN_MESSAGE(
-    plog::warning, "Number of open messages for a user-negotiated DataChannel received");
 namespace rtc {
 
+LogCounter COUNTER_USERNEG_OPEN_MESSAGE(
+    plog::warning, "Number of open messages for a user-negotiated DataChannel received");
+
 using std::shared_ptr;
 using std::weak_ptr;
 using std::chrono::milliseconds;

+ 9 - 9
src/dtlssrtptransport.cpp

@@ -29,29 +29,29 @@ using std::shared_ptr;
 using std::to_integer;
 using std::to_string;
 
-static rtc::LogCounter COUNTER_MEDIA_TRUNCATED(plog::warning,
+namespace rtc {
+
+static LogCounter COUNTER_MEDIA_TRUNCATED(plog::warning,
                                                "Number of truncated SRT(C)P packets received");
-static rtc::LogCounter
+static LogCounter
     COUNTER_UNKNOWN_PACKET_TYPE(plog::warning,
                                 "Number of RTP packets received with an unknown packet type");
-static rtc::LogCounter COUNTER_SRTCP_REPLAY(plog::warning,
+static LogCounter COUNTER_SRTCP_REPLAY(plog::warning,
                                             "Number of SRTCP replay packets received");
-static rtc::LogCounter
+static LogCounter
     COUNTER_SRTCP_AUTH_FAIL(plog::warning,
                             "Number of SRTCP packets received that failed authentication checks");
-static rtc::LogCounter
+static LogCounter
     COUNTER_SRTCP_FAIL(plog::warning,
                        "Number of SRTCP packets received that had an unknown libSRTP failure");
-static rtc::LogCounter COUNTER_SRTP_REPLAY(plog::warning, "Number of SRTP replay packets received");
-static rtc::LogCounter
+static LogCounter COUNTER_SRTP_REPLAY(plog::warning, "Number of SRTP replay packets received");
+static LogCounter
     COUNTER_SRTP_AUTH_FAIL(plog::warning,
                            "Number of SRTP packets received that failed authentication checks");
 static rtc::LogCounter
     COUNTER_SRTP_FAIL(plog::warning,
                       "Number of SRTP packets received that had an unknown libSRTP failure");
 
-namespace rtc {
-
 void DtlsSrtpTransport::Init() { srtp_init(); }
 
 void DtlsSrtpTransport::Cleanup() { srtp_shutdown(); }

+ 2 - 2
src/h264packetizationhandler.cpp

@@ -76,7 +76,7 @@ NalUnitStartSequenceMatch StartSequenceMatchSucc(NalUnitStartSequenceMatch match
 
 message_ptr H264PacketizationHandler::incoming(message_ptr ptr) { return ptr; }
 
-shared_ptr<NalUnits> H264PacketizationHandler::splitMessage(rtc::message_ptr message) {
+shared_ptr<NalUnits> H264PacketizationHandler::splitMessage(message_ptr message) {
 	auto nalus = make_shared<NalUnits>();
 	if (separator == Separator::Length) {
 		unsigned long long index = 0;
@@ -157,7 +157,7 @@ message_ptr H264PacketizationHandler::outgoing(message_ptr ptr) {
 H264PacketizationHandler::H264PacketizationHandler(Separator separator,
                                                    std::shared_ptr<H264RtpPacketizer> packetizer,
                                                    uint16_t maximumFragmentSize)
-    : RtcpHandler(), rtc::RtcpSenderReporter(packetizer->rtpConfig), packetizer(packetizer),
+    : RtcpHandler(), RtcpSenderReporter(packetizer->rtpConfig), packetizer(packetizer),
       maximumFragmentSize(maximumFragmentSize), separator(separator) {
 
 	senderReportOutgoingCallback = [this](message_ptr msg) { outgoingCallback(msg); };

+ 8 - 4
src/logcounter.cpp

@@ -18,15 +18,17 @@
 
 #include "logcounter.hpp"
 
-rtc::LogCounter::LogCounter(plog::Severity severity, const std::string &text,
-                            std::chrono::seconds duration) {
+namespace rtc {
+
+LogCounter::LogCounter(plog::Severity severity, const std::string &text,
+                       std::chrono::seconds duration) {
 	mData = std::make_shared<LogData>();
 	mData->mDuration = duration;
 	mData->mSeverity = severity;
 	mData->mText = text;
 }
 
-rtc::LogCounter &rtc::LogCounter::operator++(int) {
+LogCounter &LogCounter::operator++(int) {
 	if (mData->mCount++ == 0) {
 		ThreadPool::Instance().schedule(
 		    mData->mDuration,
@@ -43,4 +45,6 @@ rtc::LogCounter &rtc::LogCounter::operator++(int) {
 		    mData);
 	}
 	return *this;
-}
+}
+
+} // namespace rtc

+ 3 - 0
src/logcounter.hpp

@@ -22,6 +22,9 @@
 #include "include.hpp"
 #include "threadpool.hpp"
 
+#include <atomic>
+#include <chrono>
+
 namespace rtc {
 
 class LogCounter {

+ 7 - 7
src/sctptransport.cpp

@@ -56,15 +56,15 @@ using namespace std::chrono;
 
 using std::shared_ptr;
 
-static rtc::LogCounter COUNTER_UNKNOWN_PPID(plog::warning,
-                                            "Number of SCTP packets received with an unknown PPID");
-static rtc::LogCounter
+namespace rtc {
+
+static LogCounter COUNTER_UNKNOWN_PPID(plog::warning,
+                                       "Number of SCTP packets received with an unknown PPID");
+static LogCounter
     COUNTER_BAD_NOTIF_LEN(plog::warning,
                           "Number of SCTP packets received with an bad notification length");
-static rtc::LogCounter COUNTER_BAD_SCTP_STATUS(plog::warning,
-                                               "Number of SCTP packets received with a bad status");
-
-namespace rtc {
+static LogCounter COUNTER_BAD_SCTP_STATUS(plog::warning,
+                                          "Number of SCTP packets received with a bad status");
 
 std::unordered_set<SctpTransport *> SctpTransport::Instances;
 std::shared_mutex SctpTransport::InstancesMutex;