2
0
Эх сурвалжийг харах

Moved operator<< to rtc namespace

Paul-Louis Ageneau 1 жил өмнө
parent
commit
f4635b0d57

+ 5 - 5
include/rtc/candidate.hpp

@@ -67,11 +67,11 @@ private:
 	uint16_t mPort;
 };
 
-} // namespace rtc
-
-RTC_CPP_EXPORT std::ostream &operator<<(std::ostream &out, const rtc::Candidate &candidate);
-RTC_CPP_EXPORT std::ostream &operator<<(std::ostream &out, const rtc::Candidate::Type &type);
+RTC_CPP_EXPORT std::ostream &operator<<(std::ostream &out, const Candidate &candidate);
+RTC_CPP_EXPORT std::ostream &operator<<(std::ostream &out, const Candidate::Type &type);
 RTC_CPP_EXPORT std::ostream &operator<<(std::ostream &out,
-                                        const rtc::Candidate::TransportType &transportType);
+                                        const Candidate::TransportType &transportType);
+
+} // namespace rtc
 
 #endif

+ 5 - 6
include/rtc/description.hpp

@@ -314,12 +314,11 @@ private:
 	bool mEnded = false;
 };
 
-} // namespace rtc
+RTC_CPP_EXPORT std::ostream &operator<<(std::ostream &out, const Description &description);
+RTC_CPP_EXPORT std::ostream &operator<<(std::ostream &out, Description::Type type);
+RTC_CPP_EXPORT std::ostream &operator<<(std::ostream &out, Description::Role role);
+RTC_CPP_EXPORT std::ostream &operator<<(std::ostream &out, const Description::Direction &direction);
 
-RTC_CPP_EXPORT std::ostream &operator<<(std::ostream &out, const rtc::Description &description);
-RTC_CPP_EXPORT std::ostream &operator<<(std::ostream &out, rtc::Description::Type type);
-RTC_CPP_EXPORT std::ostream &operator<<(std::ostream &out, rtc::Description::Role role);
-RTC_CPP_EXPORT std::ostream &operator<<(std::ostream &out,
-                                        const rtc::Description::Direction &direction);
+} // namespace rtc
 
 #endif

+ 2 - 2
include/rtc/global.hpp

@@ -52,8 +52,8 @@ struct SctpSettings {
 
 RTC_CPP_EXPORT void SetSctpSettings(SctpSettings s);
 
-} // namespace rtc
+RTC_CPP_EXPORT std::ostream &operator<<(std::ostream &out, LogLevel level);
 
-RTC_CPP_EXPORT std::ostream &operator<<(std::ostream &out, rtc::LogLevel level);
+} // namespace rtc
 
 #endif

+ 5 - 7
include/rtc/peerconnection.hpp

@@ -120,13 +120,11 @@ public:
 	optional<std::chrono::milliseconds> rtt();
 };
 
-} // namespace rtc
+RTC_CPP_EXPORT std::ostream &operator<<(std::ostream &out, PeerConnection::State state);
+RTC_CPP_EXPORT std::ostream &operator<<(std::ostream &out, PeerConnection::IceState state);
+RTC_CPP_EXPORT std::ostream &operator<<(std::ostream &out, PeerConnection::GatheringState state);
+RTC_CPP_EXPORT std::ostream &operator<<(std::ostream &out, PeerConnection::SignalingState state);
 
-RTC_CPP_EXPORT std::ostream &operator<<(std::ostream &out, rtc::PeerConnection::State state);
-RTC_CPP_EXPORT std::ostream &operator<<(std::ostream &out, rtc::PeerConnection::IceState state);
-RTC_CPP_EXPORT std::ostream &operator<<(std::ostream &out,
-                                        rtc::PeerConnection::GatheringState state);
-RTC_CPP_EXPORT std::ostream &operator<<(std::ostream &out,
-                                        rtc::PeerConnection::SignalingState state);
+} // namespace rtc
 
 #endif

+ 15 - 15
src/candidate.cpp

@@ -248,40 +248,40 @@ optional<uint16_t> Candidate::port() const {
 	return isResolved() ? std::make_optional(mPort) : nullopt;
 }
 
-} // namespace rtc
-
-std::ostream &operator<<(std::ostream &out, const rtc::Candidate &candidate) {
-	return out << std::string(candidate);
+std::ostream &operator<<(std::ostream &out, const Candidate &candidate) {
+	return out << string(candidate);
 }
 
-std::ostream &operator<<(std::ostream &out, const rtc::Candidate::Type &type) {
+std::ostream &operator<<(std::ostream &out, const Candidate::Type &type) {
 	switch (type) {
-	case rtc::Candidate::Type::Host:
+	case Candidate::Type::Host:
 		return out << "host";
-	case rtc::Candidate::Type::PeerReflexive:
+	case Candidate::Type::PeerReflexive:
 		return out << "prflx";
-	case rtc::Candidate::Type::ServerReflexive:
+	case Candidate::Type::ServerReflexive:
 		return out << "srflx";
-	case rtc::Candidate::Type::Relayed:
+	case Candidate::Type::Relayed:
 		return out << "relay";
 	default:
 		return out << "unknown";
 	}
 }
 
-std::ostream &operator<<(std::ostream &out, const rtc::Candidate::TransportType &transportType) {
+std::ostream &operator<<(std::ostream &out, const Candidate::TransportType &transportType) {
 	switch (transportType) {
-	case rtc::Candidate::TransportType::Udp:
+	case Candidate::TransportType::Udp:
 		return out << "UDP";
-	case rtc::Candidate::TransportType::TcpActive:
+	case Candidate::TransportType::TcpActive:
 		return out << "TCP_active";
-	case rtc::Candidate::TransportType::TcpPassive:
+	case Candidate::TransportType::TcpPassive:
 		return out << "TCP_passive";
-	case rtc::Candidate::TransportType::TcpSo:
+	case Candidate::TransportType::TcpSo:
 		return out << "TCP_so";
-	case rtc::Candidate::TransportType::TcpUnknown:
+	case Candidate::TransportType::TcpUnknown:
 		return out << "TCP_unknown";
 	default:
 		return out << "unknown";
 	}
 }
+
+} // namespace rtc

+ 14 - 14
src/description.cpp

@@ -1347,18 +1347,16 @@ bool CertificateFingerprint::isValid() const {
 	return true;
 }
 
-} // namespace rtc
-
-std::ostream &operator<<(std::ostream &out, const rtc::Description &description) {
-	return out << std::string(description);
+std::ostream &operator<<(std::ostream &out, const Description &description) {
+	return out << string(description);
 }
 
-std::ostream &operator<<(std::ostream &out, rtc::Description::Type type) {
-	return out << rtc::Description::typeToString(type);
+std::ostream &operator<<(std::ostream &out, Description::Type type) {
+	return out << Description::typeToString(type);
 }
 
-std::ostream &operator<<(std::ostream &out, rtc::Description::Role role) {
-	using Role = rtc::Description::Role;
+std::ostream &operator<<(std::ostream &out, Description::Role role) {
+	using Role = Description::Role;
 	// Used for SDP generation, do not change
 	switch (role) {
 	case Role::Active:
@@ -1374,25 +1372,27 @@ std::ostream &operator<<(std::ostream &out, rtc::Description::Role role) {
 	return out;
 }
 
-std::ostream &operator<<(std::ostream &out, const rtc::Description::Direction &direction) {
+std::ostream &operator<<(std::ostream &out, const Description::Direction &direction) {
 	// Used for SDP generation, do not change
 	switch (direction) {
-	case rtc::Description::Direction::RecvOnly:
+	case Description::Direction::RecvOnly:
 		out << "recvonly";
 		break;
-	case rtc::Description::Direction::SendOnly:
+	case Description::Direction::SendOnly:
 		out << "sendonly";
 		break;
-	case rtc::Description::Direction::SendRecv:
+	case Description::Direction::SendRecv:
 		out << "sendrecv";
 		break;
-	case rtc::Description::Direction::Inactive:
+	case Description::Direction::Inactive:
 		out << "inactive";
 		break;
-	case rtc::Description::Direction::Unknown:
+	case Description::Direction::Unknown:
 	default:
 		out << "unknown";
 		break;
 	}
 	return out;
 }
+
+} // namespace rtc

+ 9 - 9
src/global.cpp

@@ -88,26 +88,24 @@ std::shared_future<void> Cleanup() { return impl::Init::Instance().cleanup(); }
 
 void SetSctpSettings(SctpSettings s) { impl::Init::Instance().setSctpSettings(std::move(s)); }
 
-} // namespace rtc
-
-RTC_CPP_EXPORT std::ostream &operator<<(std::ostream &out, rtc::LogLevel level) {
+RTC_CPP_EXPORT std::ostream &operator<<(std::ostream &out, LogLevel level) {
 	switch (level) {
-	case rtc::LogLevel::Fatal:
+	case LogLevel::Fatal:
 		out << "fatal";
 		break;
-	case rtc::LogLevel::Error:
+	case LogLevel::Error:
 		out << "error";
 		break;
-	case rtc::LogLevel::Warning:
+	case LogLevel::Warning:
 		out << "warning";
 		break;
-	case rtc::LogLevel::Info:
+	case LogLevel::Info:
 		out << "info";
 		break;
-	case rtc::LogLevel::Debug:
+	case LogLevel::Debug:
 		out << "debug";
 		break;
-	case rtc::LogLevel::Verbose:
+	case LogLevel::Verbose:
 		out << "verbose";
 		break;
 	default:
@@ -116,3 +114,5 @@ RTC_CPP_EXPORT std::ostream &operator<<(std::ostream &out, rtc::LogLevel level)
 	}
 	return out;
 }
+
+} // namespace rtc

+ 10 - 10
src/peerconnection.cpp

@@ -354,10 +354,8 @@ optional<std::chrono::milliseconds> PeerConnection::rtt() {
 	return sctpTransport ? sctpTransport->rtt() : nullopt;
 }
 
-} // namespace rtc
-
-std::ostream &operator<<(std::ostream &out, rtc::PeerConnection::State state) {
-	using State = rtc::PeerConnection::State;
+std::ostream &operator<<(std::ostream &out, PeerConnection::State state) {
+	using State = PeerConnection::State;
 	const char *str;
 	switch (state) {
 	case State::New:
@@ -385,8 +383,8 @@ std::ostream &operator<<(std::ostream &out, rtc::PeerConnection::State state) {
 	return out << str;
 }
 
-std::ostream &operator<<(std::ostream &out, rtc::PeerConnection::IceState state) {
-	using IceState = rtc::PeerConnection::IceState;
+std::ostream &operator<<(std::ostream &out, PeerConnection::IceState state) {
+	using IceState = PeerConnection::IceState;
 	const char *str;
 	switch (state) {
 	case IceState::New:
@@ -417,8 +415,8 @@ std::ostream &operator<<(std::ostream &out, rtc::PeerConnection::IceState state)
 	return out << str;
 }
 
-std::ostream &operator<<(std::ostream &out, rtc::PeerConnection::GatheringState state) {
-	using GatheringState = rtc::PeerConnection::GatheringState;
+std::ostream &operator<<(std::ostream &out, PeerConnection::GatheringState state) {
+	using GatheringState = PeerConnection::GatheringState;
 	const char *str;
 	switch (state) {
 	case GatheringState::New:
@@ -437,8 +435,8 @@ std::ostream &operator<<(std::ostream &out, rtc::PeerConnection::GatheringState
 	return out << str;
 }
 
-std::ostream &operator<<(std::ostream &out, rtc::PeerConnection::SignalingState state) {
-	using SignalingState = rtc::PeerConnection::SignalingState;
+std::ostream &operator<<(std::ostream &out, PeerConnection::SignalingState state) {
+	using SignalingState = PeerConnection::SignalingState;
 	const char *str;
 	switch (state) {
 	case SignalingState::Stable:
@@ -462,3 +460,5 @@ std::ostream &operator<<(std::ostream &out, rtc::PeerConnection::SignalingState
 	}
 	return out << str;
 }
+
+} // namespace rtc