Browse Source

Fixed formatting

Paul-Louis Ageneau 6 years ago
parent
commit
3a96b355d5
4 changed files with 27 additions and 30 deletions
  1. 12 13
      src/icetransport.cpp
  2. 2 2
      src/icetransport.hpp
  3. 9 13
      src/message.hpp
  4. 4 2
      src/transport.hpp

+ 12 - 13
src/icetransport.cpp

@@ -35,8 +35,8 @@ using std::weak_ptr;
 
 
 IceTransport::IceTransport(const IceConfiguration &config, Description::Role role,
 IceTransport::IceTransport(const IceConfiguration &config, Description::Role role,
                            candidate_callback candidateCallback, ready_callback ready)
                            candidate_callback candidateCallback, ready_callback ready)
-    : mRole(role), mCandidateCallback(std::move(candidateCallback)), mReadyCallback(ready),
-      mNiceAgent(nullptr, nullptr), mMainLoop(nullptr, nullptr) {
+    : mRole(role), mNiceAgent(nullptr, nullptr), mMainLoop(nullptr, nullptr),
+      mCandidateCallback(std::move(candidateCallback)), mReadyCallback(ready) {
 
 
 	auto logLevelFlags = GLogLevelFlags(G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL | G_LOG_FLAG_RECURSION);
 	auto logLevelFlags = GLogLevelFlags(G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL | G_LOG_FLAG_RECURSION);
 	g_log_set_handler(nullptr, logLevelFlags, LogCallback, this);
 	g_log_set_handler(nullptr, logLevelFlags, LogCallback, this);
@@ -75,7 +75,7 @@ IceTransport::IceTransport(const IceConfiguration &config, Description::Role rol
 			continue;
 			continue;
 
 
 		for (auto p = result; p; p = p->ai_next) {
 		for (auto p = result; p; p = p->ai_next) {
-			if(p->ai_family == AF_INET) {
+			if (p->ai_family == AF_INET) {
 				char nodebuffer[MAX_NUMERICNODE_LEN];
 				char nodebuffer[MAX_NUMERICNODE_LEN];
 				char servbuffer[MAX_NUMERICSERV_LEN];
 				char servbuffer[MAX_NUMERICSERV_LEN];
 				if (getnameinfo(p->ai_addr, p->ai_addrlen, nodebuffer, MAX_NUMERICNODE_LEN,
 				if (getnameinfo(p->ai_addr, p->ai_addrlen, nodebuffer, MAX_NUMERICNODE_LEN,
@@ -91,8 +91,8 @@ IceTransport::IceTransport(const IceConfiguration &config, Description::Role rol
 		}
 		}
 
 
 		freeaddrinfo(result);
 		freeaddrinfo(result);
-	    if (success)
-		    break;
+		if (success)
+			break;
 	}
 	}
 
 
 	g_signal_connect(G_OBJECT(mNiceAgent.get()), "component-state-changed",
 	g_signal_connect(G_OBJECT(mNiceAgent.get()), "component-state-changed",
@@ -104,11 +104,11 @@ IceTransport::IceTransport(const IceConfiguration &config, Description::Role rol
 
 
 	mStreamId = nice_agent_add_stream(mNiceAgent.get(), 1);
 	mStreamId = nice_agent_add_stream(mNiceAgent.get(), 1);
 	if (mStreamId == 0)
 	if (mStreamId == 0)
-	    throw std::runtime_error("Failed to add a stream");
+		throw std::runtime_error("Failed to add a stream");
 
 
-    nice_agent_set_stream_name(mNiceAgent.get(), mStreamId, "application");
-    nice_agent_set_port_range(mNiceAgent.get(), mStreamId, 1,
-                              config.portRangeBegin, config.portRangeEnd);
+	nice_agent_set_stream_name(mNiceAgent.get(), mStreamId, "application");
+	nice_agent_set_port_range(mNiceAgent.get(), mStreamId, 1, config.portRangeBegin,
+	                          config.portRangeEnd);
 
 
 	nice_agent_attach_recv(mNiceAgent.get(), mStreamId, 1, g_main_loop_get_context(mMainLoop.get()),
 	nice_agent_attach_recv(mNiceAgent.get(), mStreamId, 1, g_main_loop_get_context(mMainLoop.get()),
 	                       RecvCallback, this);
 	                       RecvCallback, this);
@@ -212,13 +212,12 @@ void IceTransport::StateChangedCallback(NiceAgent *agent, guint streamId, guint
 void IceTransport::RecvCallback(NiceAgent *agent, guint streamId, guint componentId, guint len,
 void IceTransport::RecvCallback(NiceAgent *agent, guint streamId, guint componentId, guint len,
                                 gchar *buf, gpointer userData) {
                                 gchar *buf, gpointer userData) {
 	auto iceTransport = static_cast<rtc::IceTransport *>(userData);
 	auto iceTransport = static_cast<rtc::IceTransport *>(userData);
-	iceTransport->incoming(reinterpret_cast<std::byte *>(buf), len);
+	iceTransport->incoming(reinterpret_cast<byte *>(buf), len);
 }
 }
 
 
-void IceTransport::LogCallback(const gchar *logDomain, GLogLevelFlags logLevel, const gchar *message,
-                 gpointer userData) {
+void IceTransport::LogCallback(const gchar *logDomain, GLogLevelFlags logLevel,
+                               const gchar *message, gpointer userData) {
 	std::cout << message << std::endl;
 	std::cout << message << std::endl;
 }
 }
 
 
 } // namespace rtc
 } // namespace rtc
-

+ 2 - 2
src/icetransport.hpp

@@ -91,10 +91,10 @@ private:
 	                                 guint state, gpointer userData);
 	                                 guint state, gpointer userData);
 	static void RecvCallback(NiceAgent *agent, guint stream_id, guint component_id, guint len,
 	static void RecvCallback(NiceAgent *agent, guint stream_id, guint component_id, guint len,
 	                         gchar *buf, gpointer userData);
 	                         gchar *buf, gpointer userData);
-	static void LogCallback(const gchar *log_domain, GLogLevelFlags log_level, const gchar *message, gpointer user_data);
+	static void LogCallback(const gchar *log_domain, GLogLevelFlags log_level, const gchar *message,
+	                        gpointer user_data);
 };
 };
 
 
 } // namespace rtc
 } // namespace rtc
 
 
 #endif
 #endif
-

+ 9 - 13
src/message.hpp

@@ -30,30 +30,26 @@ namespace rtc {
 struct Message : binary {
 struct Message : binary {
 	enum Type { Binary, String, Control };
 	enum Type { Binary, String, Control };
 
 
-        template <typename Iterator>
-        Message(Iterator begin_, Iterator end_, Type type_ = Binary,
-                unsigned int stream_ = 0,
-                std::shared_ptr<Reliability> reliability_ = nullptr)
-            : binary(begin_, end_), type(type_), stream(stream_),
-              reliability(reliability_) {}
-
-        Type type;
+	template <typename Iterator>
+	Message(Iterator begin_, Iterator end_, Type type_ = Binary, unsigned int stream_ = 0,
+	        std::shared_ptr<Reliability> reliability_ = nullptr)
+	    : binary(begin_, end_), type(type_), stream(stream_), reliability(reliability_) {}
+
+	Type type;
 	unsigned int stream;
 	unsigned int stream;
-        std::shared_ptr<Reliability> reliability;
+	std::shared_ptr<Reliability> reliability;
 };
 };
 
 
 using message_ptr = std::shared_ptr<const Message>;
 using message_ptr = std::shared_ptr<const Message>;
 using message_callback = std::function<void(message_ptr message)>;
 using message_callback = std::function<void(message_ptr message)>;
 
 
 template <typename Iterator>
 template <typename Iterator>
-message_ptr make_message(Iterator begin, Iterator end,
-                         Message::Type type = Message::Binary,
+message_ptr make_message(Iterator begin, Iterator end, Message::Type type = Message::Binary,
                          unsigned int stream = 0,
                          unsigned int stream = 0,
                          std::shared_ptr<Reliability> reliability = nullptr) {
                          std::shared_ptr<Reliability> reliability = nullptr) {
-  return std::make_shared<Message>(begin, end, type, stream, reliability);
+	return std::make_shared<Message>(begin, end, type, stream, reliability);
 }
 }
 
 
 } // namespace rtc
 } // namespace rtc
 
 
 #endif
 #endif
-

+ 4 - 2
src/transport.hpp

@@ -38,7 +38,10 @@ public:
 	void onRecv(message_callback callback) { mRecvCallback = std::move(callback); }
 	void onRecv(message_callback callback) { mRecvCallback = std::move(callback); }
 
 
 protected:
 protected:
-	void recv(message_ptr message) { if(mRecvCallback) mRecvCallback(message); }
+	void recv(message_ptr message) {
+		if (mRecvCallback)
+			mRecvCallback(message);
+	}
 
 
 	virtual void incoming(message_ptr message) = 0;
 	virtual void incoming(message_ptr message) = 0;
 	virtual void outgoing(message_ptr message) { getLower()->send(message); }
 	virtual void outgoing(message_ptr message) { getLower()->send(message); }
@@ -63,4 +66,3 @@ private:
 } // namespace rtc
 } // namespace rtc
 
 
 #endif
 #endif
-