Explorar el Código

Code formatting

Paul-Louis Ageneau hace 1 año
padre
commit
4bb17395a2

+ 6 - 7
include/rtc/aacrtppacketizer.hpp

@@ -11,15 +11,14 @@
 
 #if RTC_ENABLE_MEDIA
 
-#include "mediahandlerrootelement.hpp"
 #include "mediachainablehandler.hpp"
+#include "mediahandlerrootelement.hpp"
 #include "rtppacketizer.hpp"
 
 namespace rtc {
 
 /// RTP packetizer for aac
-class RTC_CPP_EXPORT AACRtpPacketizer final : public RtpPacketizer,
-                                               public MediaHandlerRootElement {
+class RTC_CPP_EXPORT AACRtpPacketizer final : public RtpPacketizer, public MediaHandlerRootElement {
 public:
 	/// default clock rate used in aac RTP communication
 	inline static const uint32_t defaultClockRate = 48 * 1000;
@@ -48,10 +47,10 @@ public:
 class RTC_CPP_EXPORT AACPacketizationHandler final : public MediaChainableHandler {
 
 public:
-  /// Construct handler for aac packetization.
-  /// @param packetizer RTP packetizer for aac
-  AACPacketizationHandler(shared_ptr<AACRtpPacketizer> packetizer)
-      : MediaChainableHandler(packetizer) {}
+	/// Construct handler for aac packetization.
+	/// @param packetizer RTP packetizer for aac
+	AACPacketizationHandler(shared_ptr<AACRtpPacketizer> packetizer)
+	    : MediaChainableHandler(packetizer) {}
 };
 
 } // namespace rtc

+ 1 - 1
include/rtc/global.hpp

@@ -12,8 +12,8 @@
 #include "common.hpp"
 
 #include <chrono>
-#include <iostream>
 #include <future>
+#include <iostream>
 
 namespace rtc {
 

+ 2 - 3
include/rtc/h264rtppacketizer.hpp

@@ -23,14 +23,13 @@ class RTC_CPP_EXPORT H264RtpPacketizer final : public RtpPacketizer,
 	shared_ptr<NalUnits> splitMessage(binary_ptr message);
 	const uint16_t maximumFragmentSize;
 
-using Separator=NalUnit::Separator;
+	using Separator = NalUnit::Separator;
 
 public:
 	/// Default clock rate for H264 in RTP
 	inline static const uint32_t defaultClockRate = 90 * 1000;
 
-	H264RtpPacketizer(Separator separator,
-	                  shared_ptr<RtpPacketizationConfig> rtpConfig,
+	H264RtpPacketizer(Separator separator, shared_ptr<RtpPacketizationConfig> rtpConfig,
 	                  uint16_t maximumFragmentSize = NalUnits::defaultMaximumFragmentSize);
 
 	/// Constructs h264 payload packetizer with given RTP configuration.

+ 34 - 27
include/rtc/h265nalunit.hpp

@@ -23,39 +23,42 @@ namespace rtc {
 #define H265_FU_HEADER_SIZE 1
 /// Nalu header
 struct RTC_CPP_EXPORT H265NalUnitHeader {
-/*
-* nal_unit_header( ) { 
-* forbidden_zero_bit	f(1)
-* nal_unit_type			u(6)
-* nuh_layer_id			u(6)
-* nuh_temporal_id_plus1	u(3)
-}
-*/
-	uint8_t _first = 0; // high byte of header
+	/*
+	* nal_unit_header( ) {
+	* forbidden_zero_bit	f(1)
+	* nal_unit_type			u(6)
+	* nuh_layer_id			u(6)
+	* nuh_temporal_id_plus1	u(3)
+	}
+	*/
+	uint8_t _first = 0;  // high byte of header
 	uint8_t _second = 0; // low byte of header
 
 	bool forbiddenBit() const { return _first >> 7; }
 	uint8_t unitType() const { return (_first & 0b0111'1110) >> 1; }
 	uint8_t nuhLayerId() const { return ((_first & 0x1) << 5) | ((_second & 0b1111'1000) >> 3); }
-	uint8_t nuhTempIdPlus1() const { return _second & 0b111;}
+	uint8_t nuhTempIdPlus1() const { return _second & 0b111; }
 
 	void setForbiddenBit(bool isSet) { _first = (_first & 0x7F) | (isSet << 7); }
 	void setUnitType(uint8_t type) { _first = (_first & 0b1000'0001) | ((type & 0b11'1111) << 1); }
-	void setNuhLayerId(uint8_t nuhLayerId) { 
-			_first = (_first & 0b1111'1110) | ((nuhLayerId & 0b10'0000) >> 5);
-			_second = (_second & 0b0000'0111)	| ((nuhLayerId & 0b01'1111) << 3); }
-	void setNuhTempIdPlus1(uint8_t nuhTempIdPlus1) { _second = (_second & 0b1111'1000) | (nuhTempIdPlus1 & 0b111); }
+	void setNuhLayerId(uint8_t nuhLayerId) {
+		_first = (_first & 0b1111'1110) | ((nuhLayerId & 0b10'0000) >> 5);
+		_second = (_second & 0b0000'0111) | ((nuhLayerId & 0b01'1111) << 3);
+	}
+	void setNuhTempIdPlus1(uint8_t nuhTempIdPlus1) {
+		_second = (_second & 0b1111'1000) | (nuhTempIdPlus1 & 0b111);
+	}
 };
 
 /// Nalu fragment header
 struct RTC_CPP_EXPORT H265NalUnitFragmentHeader {
 	/*
-	* +---------------+
-	* |0|1|2|3|4|5|6|7|
-	* +-+-+-+-+-+-+-+-+
-	* |S|E|  FuType   |
-	* +---------------+
-	*/
+	 * +---------------+
+	 * |0|1|2|3|4|5|6|7|
+	 * +-+-+-+-+-+-+-+-+
+	 * |S|E|  FuType   |
+	 * +---------------+
+	 */
 	uint8_t _first = 0;
 
 	bool isStart() const { return _first >> 7; }
@@ -72,16 +75,18 @@ struct RTC_CPP_EXPORT H265NalUnitFragmentHeader {
 /// Nal unit
 struct RTC_CPP_EXPORT H265NalUnit : NalUnit {
 	H265NalUnit(const H265NalUnit &unit) = default;
-	H265NalUnit(size_t size, bool includingHeader = true) : NalUnit(size, includingHeader, NalUnit::Type::H265) {}
+	H265NalUnit(size_t size, bool includingHeader = true)
+	    : NalUnit(size, includingHeader, NalUnit::Type::H265) {}
 	H265NalUnit(binary &&data) : NalUnit(std::move(data)) {}
 	H265NalUnit() : NalUnit(NalUnit::Type::H265) {}
 
-	template <typename Iterator> H265NalUnit(Iterator begin_, Iterator end_) : NalUnit(begin_, end_) {}
+	template <typename Iterator>
+	H265NalUnit(Iterator begin_, Iterator end_) : NalUnit(begin_, end_) {}
 
 	bool forbiddenBit() const { return header()->forbiddenBit(); }
 	uint8_t unitType() const { return header()->unitType(); }
 	uint8_t nuhLayerId() const { return header()->nuhLayerId(); }
-	uint8_t nuhTempIdPlus1() const { return header()->nuhTempIdPlus1();}
+	uint8_t nuhTempIdPlus1() const { return header()->nuhTempIdPlus1(); }
 
 	binary payload() const {
 		assert(size() >= H265_NAL_HEADER_SIZE);
@@ -114,12 +119,12 @@ protected:
 /// Nal unit fragment A
 struct RTC_CPP_EXPORT H265NalUnitFragment : H265NalUnit {
 	static std::vector<shared_ptr<H265NalUnitFragment>> fragmentsFrom(shared_ptr<H265NalUnit> nalu,
-	                                                               uint16_t maximumFragmentSize);
+	                                                                  uint16_t maximumFragmentSize);
 
 	enum class FragmentType { Start, Middle, End };
 
 	H265NalUnitFragment(FragmentType type, bool forbiddenBit, uint8_t nuhLayerId,
-					 uint8_t nuhTempIdPlus1, uint8_t unitType, binary data);
+	                    uint8_t nuhTempIdPlus1, uint8_t unitType, binary data);
 
 	uint8_t unitType() const { return fragmentHeader()->unitType(); }
 
@@ -158,11 +163,13 @@ protected:
 	}
 
 	H265NalUnitFragmentHeader *fragmentHeader() {
-		return reinterpret_cast<H265NalUnitFragmentHeader *>(fragmentIndicator() + H265_NAL_HEADER_SIZE);
+		return reinterpret_cast<H265NalUnitFragmentHeader *>(fragmentIndicator() +
+		                                                     H265_NAL_HEADER_SIZE);
 	}
 
 	const H265NalUnitFragmentHeader *fragmentHeader() const {
-		return reinterpret_cast<const H265NalUnitFragmentHeader *>(fragmentIndicator() + H265_NAL_HEADER_SIZE);
+		return reinterpret_cast<const H265NalUnitFragmentHeader *>(fragmentIndicator() +
+		                                                           H265_NAL_HEADER_SIZE);
 	}
 };
 

+ 1 - 1
include/rtc/h265packetizationhandler.hpp

@@ -11,9 +11,9 @@
 
 #if RTC_ENABLE_MEDIA
 
+#include "h265nalunit.hpp"
 #include "h265rtppacketizer.hpp"
 #include "mediachainablehandler.hpp"
-#include "h265nalunit.hpp"
 
 namespace rtc {
 

+ 2 - 3
include/rtc/h265rtppacketizer.hpp

@@ -11,8 +11,8 @@
 
 #if RTC_ENABLE_MEDIA
 
-#include "mediahandlerrootelement.hpp"
 #include "h265nalunit.hpp"
+#include "mediahandlerrootelement.hpp"
 #include "rtppacketizer.hpp"
 
 namespace rtc {
@@ -27,8 +27,7 @@ public:
 	/// Default clock rate for H265 in RTP
 	inline static const uint32_t defaultClockRate = 90 * 1000;
 
-	H265RtpPacketizer(NalUnit::Separator separator,
-	                  shared_ptr<RtpPacketizationConfig> rtpConfig,
+	H265RtpPacketizer(NalUnit::Separator separator, shared_ptr<RtpPacketizationConfig> rtpConfig,
 	                  uint16_t maximumFragmentSize = H265NalUnits::defaultMaximumFragmentSize);
 
 	/// Constructs h265 payload packetizer with given RTP configuration.

+ 12 - 12
include/rtc/nalunit.hpp

@@ -62,16 +62,16 @@ static const size_t H264_NAL_HEADER_SIZE = 1;
 static const size_t H265_NAL_HEADER_SIZE = 2;
 /// Nal unit
 struct RTC_CPP_EXPORT NalUnit : binary {
-	typedef enum {
-		H264,
-		H265
-	} Type;
+	typedef enum { H264, H265 } Type;
 
 	NalUnit(const NalUnit &unit) = default;
 	NalUnit(size_t size, bool includingHeader = true, Type type = H264)
-		: binary(size + (includingHeader ? 0 : (type == H264? H264_NAL_HEADER_SIZE: H265_NAL_HEADER_SIZE))) {}
+	    : binary(size + (includingHeader
+	                         ? 0
+	                         : (type == H264 ? H264_NAL_HEADER_SIZE : H265_NAL_HEADER_SIZE))) {}
 	NalUnit(binary &&data) : binary(std::move(data)) {}
-	NalUnit(Type type = H264) : binary( type == H264? H264_NAL_HEADER_SIZE: H265_NAL_HEADER_SIZE) {}
+	NalUnit(Type type = H264)
+	    : binary(type == H264 ? H264_NAL_HEADER_SIZE : H265_NAL_HEADER_SIZE) {}
 	template <typename Iterator> NalUnit(Iterator begin_, Iterator end_) : binary(begin_, end_) {}
 
 	bool forbiddenBit() const { return header()->forbiddenBit(); }
@@ -101,14 +101,14 @@ struct RTC_CPP_EXPORT NalUnit : binary {
 		StartSequence = RTC_NAL_SEPARATOR_START_SEQUENCE, // LongStartSequence or ShortStartSequence
 	};
 
-	static NalUnitStartSequenceMatch StartSequenceMatchSucc(NalUnitStartSequenceMatch match, std::byte _byte, Separator separator)
-	{
+	static NalUnitStartSequenceMatch StartSequenceMatchSucc(NalUnitStartSequenceMatch match,
+	                                                        std::byte _byte, Separator separator) {
 		assert(separator != Separator::Length);
 		auto byte = (uint8_t)_byte;
-		auto detectShort = separator == Separator::ShortStartSequence ||
-		                   separator == Separator::StartSequence;
-		auto detectLong = separator == Separator::LongStartSequence ||
-		                  separator == Separator::StartSequence;
+		auto detectShort =
+		    separator == Separator::ShortStartSequence || separator == Separator::StartSequence;
+		auto detectLong =
+		    separator == Separator::LongStartSequence || separator == Separator::StartSequence;
 		switch (match) {
 		case NUSM_noMatch:
 			if (byte == 0x00) {

+ 2 - 1
include/rtc/peerconnection.hpp

@@ -96,7 +96,8 @@ public:
 	void setMediaHandler(shared_ptr<MediaHandler> handler);
 	shared_ptr<MediaHandler> getMediaHandler();
 
-	[[nodiscard]] shared_ptr<DataChannel> createDataChannel(string label, DataChannelInit init = {});
+	[[nodiscard]] shared_ptr<DataChannel> createDataChannel(string label,
+	                                                        DataChannelInit init = {});
 	void onDataChannel(std::function<void(std::shared_ptr<DataChannel> dataChannel)> callback);
 
 	[[nodiscard]] shared_ptr<Track> addTrack(Description::Media description);

+ 2 - 2
include/rtc/rtc.hpp

@@ -34,10 +34,10 @@
 #include "rtcpsrreporter.hpp"
 
 // Opus/AAC/h264/h265/AV1 streaming
+#include "aacrtppacketizer.hpp"
+#include "av1packetizationhandler.hpp"
 #include "h264packetizationhandler.hpp"
 #include "h265packetizationhandler.hpp"
-#include "av1packetizationhandler.hpp"
 #include "opuspacketizationhandler.hpp"
-#include "aacrtppacketizer.hpp"
 
 #endif // RTC_ENABLE_MEDIA

+ 0 - 1
include/rtc/rtppacketizationconfig.hpp

@@ -53,7 +53,6 @@ public:
 	///   3 - 270 degrees
 	uint8_t videoOrientation = 0;
 
-
 	// MID Extension Header
 	uint8_t midId = 0;
 	optional<std::string> mid;

+ 1 - 1
include/rtc/websocket.hpp

@@ -37,7 +37,7 @@ public:
 		optional<ProxyServer> proxyServer;   // only non-authenticated http supported for now
 		std::vector<string> protocols;
 		optional<std::chrono::milliseconds> connectionTimeout; // zero to disable
-		optional<std::chrono::milliseconds> pingInterval; // zero to disable
+		optional<std::chrono::milliseconds> pingInterval;      // zero to disable
 		optional<int> maxOutstandingPings;
 	};
 

+ 1 - 1
src/aacrtppacketizer.cpp

@@ -24,7 +24,7 @@ binary_ptr AACRtpPacketizer::packetize(binary_ptr payload, [[maybe_unused]] bool
 
 ChainedOutgoingProduct
 AACRtpPacketizer::processOutgoingBinaryMessage(ChainedMessagesProduct messages,
-                                                message_ptr control) {
+                                               message_ptr control) {
 	ChainedMessagesProduct packets = make_chained_messages_product();
 	packets->reserve(messages->size());
 	for (auto message : *messages) {

+ 7 - 7
src/capi.cpp

@@ -1079,8 +1079,10 @@ int rtcAddTrackEx(int pc, const rtcTrackInit *init) {
 				desc.addPCMACodec(init->payloadType);
 				break;
 			case RTC_CODEC_AAC:
-					desc.addAacCodec(init->payloadType, init->profile ? std::make_optional(string(init->profile)) : nullopt);
-					break;
+				desc.addAacCodec(init->payloadType, init->profile
+				                                        ? std::make_optional(string(init->profile))
+				                                        : nullopt);
+				break;
 			default:
 				break;
 			}
@@ -1208,8 +1210,7 @@ int rtcSetH264PacketizationHandler(int tr, const rtcPacketizationHandlerInit *in
 		auto maxFragmentSize = init && init->maxFragmentSize ? init->maxFragmentSize
 		                                                     : RTC_DEFAULT_MAXIMUM_FRAGMENT_SIZE;
 		auto packetizer = std::make_shared<H264RtpPacketizer>(
-		    static_cast<rtc::NalUnit::Separator>(nalSeparator), rtpConfig,
-		    maxFragmentSize);
+		    static_cast<rtc::NalUnit::Separator>(nalSeparator), rtpConfig, maxFragmentSize);
 		// create H264 handler
 		auto h264Handler = std::make_shared<H264PacketizationHandler>(packetizer);
 		emplaceMediaChainableHandler(h264Handler, tr);
@@ -1230,8 +1231,7 @@ int rtcSetH265PacketizationHandler(int tr, const rtcPacketizationHandlerInit *in
 		auto maxFragmentSize = init && init->maxFragmentSize ? init->maxFragmentSize
 		                                                     : RTC_DEFAULT_MAXIMUM_FRAGMENT_SIZE;
 		auto packetizer = std::make_shared<H265RtpPacketizer>(
-		    static_cast<rtc::NalUnit::Separator>(nalSeparator), rtpConfig,
-		    maxFragmentSize);
+		    static_cast<rtc::NalUnit::Separator>(nalSeparator), rtpConfig, maxFragmentSize);
 		// create H265 handler
 		auto h265Handler = std::make_shared<H265PacketizationHandler>(packetizer);
 		emplaceMediaChainableHandler(h265Handler, tr);
@@ -1273,7 +1273,7 @@ int rtcSetAACPacketizationHandler(int tr, const rtcPacketizationHandlerInit *ini
 		// set handler
 		track->setMediaHandler(aacHandler);
 		return RTC_ERR_SUCCESS;
-  });
+	});
 }
 
 int rtcChainRtcpSrReporter(int tr) {

+ 1 - 3
src/channel.cpp

@@ -49,9 +49,7 @@ void Channel::setBufferedAmountLowThreshold(size_t amount) {
 	impl()->bufferedAmountLowThreshold = amount;
 }
 
-void Channel::resetCallbacks() {
-	impl()->resetCallbacks();
-}
+void Channel::resetCallbacks() { impl()->resetCallbacks(); }
 
 optional<message_variant> Channel::receive() { return impl()->receive(); }
 

+ 1 - 1
src/configuration.cpp

@@ -70,7 +70,7 @@ IceServer::IceServer(const string &url) {
 	password = utils::url_decode(opt[8].value_or(""));
 
 	hostname = opt[10].value();
-	if(hostname.front() == '[' && hostname.back() == ']') {
+	if (hostname.front() == '[' && hostname.back() == ']') {
 		// IPv6 literal
 		hostname.erase(hostname.begin());
 		hostname.pop_back();

+ 2 - 1
src/global.cpp

@@ -54,7 +54,8 @@ struct LogAppender : public plog::IAppender {
 		auto formatted = plog::FuncMessageFormatter::format(record);
 		formatted.pop_back(); // remove newline
 
-		const auto& converted = plog::UTF8Converter::convert(formatted); // does nothing on non-Windows systems
+		const auto &converted =
+		    plog::UTF8Converter::convert(formatted); // does nothing on non-Windows systems
 
 		if (!callback(static_cast<LogLevel>(severity), converted))
 			std::cout << plog::severityToString(severity) << " " << converted << std::endl;

+ 5 - 5
src/h265nalunit.cpp

@@ -17,7 +17,7 @@
 namespace rtc {
 
 H265NalUnitFragment::H265NalUnitFragment(FragmentType type, bool forbiddenBit, uint8_t nuhLayerId,
-									uint8_t nuhTempIdPlus1, uint8_t unitType, binary data)
+                                         uint8_t nuhTempIdPlus1, uint8_t unitType, binary data)
     : H265NalUnit(data.size() + H265_NAL_HEADER_SIZE + H265_FU_HEADER_SIZE) {
 	setForbiddenBit(forbiddenBit);
 	setNuhLayerId(nuhLayerId);
@@ -37,9 +37,9 @@ H265NalUnitFragment::fragmentsFrom(shared_ptr<H265NalUnit> nalu, uint16_t maximu
 	// 3 bytes for FU indicator and FU header
 	maximumFragmentSize -= (H265_NAL_HEADER_SIZE + H265_FU_HEADER_SIZE);
 	auto f = nalu->forbiddenBit();
-	uint8_t nuhLayerId = nalu->nuhLayerId() & 0x3F; // 6 bits
+	uint8_t nuhLayerId = nalu->nuhLayerId() & 0x3F;        // 6 bits
 	uint8_t nuhTempIdPlus1 = nalu->nuhTempIdPlus1() & 0xE; // 3 bits
-	uint8_t naluType = nalu->unitType() & 0x3F; // 6 bits
+	uint8_t naluType = nalu->unitType() & 0x3F;            // 6 bits
 	auto payload = nalu->payload();
 	vector<shared_ptr<H265NalUnitFragment>> result{};
 	uint64_t offset = 0;
@@ -57,8 +57,8 @@ H265NalUnitFragment::fragmentsFrom(shared_ptr<H265NalUnit> nalu, uint16_t maximu
 			fragmentType = FragmentType::End;
 		}
 		fragmentData = {payload.begin() + offset, payload.begin() + offset + maximumFragmentSize};
-		auto fragment =
-		    std::make_shared<H265NalUnitFragment>(fragmentType, f, nuhLayerId, nuhTempIdPlus1, naluType, fragmentData);
+		auto fragment = std::make_shared<H265NalUnitFragment>(
+		    fragmentType, f, nuhLayerId, nuhTempIdPlus1, naluType, fragmentData);
 		result.push_back(fragment);
 		offset += maximumFragmentSize;
 	}

+ 2 - 2
src/impl/certificate.cpp

@@ -148,7 +148,7 @@ string make_fingerprint(gnutls_x509_crt_t crt) {
 }
 
 #elif USE_MBEDTLS
-string make_fingerprint(mbedtls_x509_crt* crt) {
+string make_fingerprint(mbedtls_x509_crt *crt) {
 	const int size = 32;
 	uint8_t buffer[size];
 	std::stringstream fingerprint;
@@ -425,7 +425,7 @@ Certificate Certificate::Generate(CertificateType type, const string &commonName
 		if (!pkey || !rsa || !exponent)
 			throw std::runtime_error("Unable to allocate structures for RSA key pair");
 
-		const unsigned int e = 65537;               // 2^16 + 1
+		const unsigned int e = 65537; // 2^16 + 1
 		if (!BN_set_word(exponent.get(), e) ||
 		    !RSA_generate_key_ex(rsa.get(), bits, exponent.get(), NULL) ||
 		    !EVP_PKEY_assign_RSA(pkey.get(),

+ 1 - 1
src/impl/certificate.hpp

@@ -60,7 +60,7 @@ private:
 string make_fingerprint(gnutls_certificate_credentials_t credentials);
 string make_fingerprint(gnutls_x509_crt_t crt);
 #elif USE_MBEDTLS
-string make_fingerprint(mbedtls_x509_crt* crt);
+string make_fingerprint(mbedtls_x509_crt *crt);
 #else
 string make_fingerprint(X509 *x509);
 #endif

+ 1 - 3
src/impl/datachannel.cpp

@@ -105,9 +105,7 @@ void DataChannel::close() {
 	resetCallbacks();
 }
 
-void DataChannel::remoteClose() {
-	close();
-}
+void DataChannel::remoteClose() { close(); }
 
 optional<message_variant> DataChannel::receive() {
 	auto next = mRecvQueue.pop();

+ 4 - 2
src/impl/dtlstransport.cpp

@@ -605,10 +605,12 @@ void DtlsTransport::doRecv() {
 	}
 }
 
-int DtlsTransport::CertificateCallback(void *ctx, mbedtls_x509_crt *crt, int /*depth*/, uint32_t */*flags*/) {
+int DtlsTransport::CertificateCallback(void *ctx, mbedtls_x509_crt *crt, int /*depth*/,
+                                       uint32_t * /*flags*/) {
 	auto this_ = static_cast<DtlsTransport *>(ctx);
 	string fingerprint = make_fingerprint(crt);
-	std::transform(fingerprint.begin(), fingerprint.end(), fingerprint.begin(), [](char c) { return char(std::toupper(c)); });
+	std::transform(fingerprint.begin(), fingerprint.end(), fingerprint.begin(),
+	               [](char c) { return char(std::toupper(c)); });
 	return this_->mVerifierCallback(fingerprint) ? 0 : 1;
 }
 

+ 3 - 2
src/impl/httpproxytransport.cpp

@@ -8,8 +8,8 @@
  */
 
 #include "httpproxytransport.hpp"
-#include "tcptransport.hpp"
 #include "http.hpp"
+#include "tcptransport.hpp"
 
 #if RTC_ENABLE_WEBSOCKET
 
@@ -118,7 +118,8 @@ size_t HttpProxyTransport::parseHttpResponse(std::byte *buffer, size_t size) {
 	status >> protocol >> code;
 
 	if (code != 200)
-		throw std::runtime_error("Unexpected response code " + to_string(code) + " from HTTP proxy");
+		throw std::runtime_error("Unexpected response code " + to_string(code) +
+		                         " from HTTP proxy");
 
 	return length;
 }

+ 1 - 1
src/impl/icetransport.cpp

@@ -407,7 +407,7 @@ IceTransport::IceTransport(const Configuration &config, candidate_callback candi
 
 	PLOG_DEBUG << "Initializing ICE transport (libnice)";
 
-	if(!MainLoop)
+	if (!MainLoop)
 		throw std::logic_error("Main loop for nice agent is not created");
 
 	// RFC 8445: The nomination process that was referred to as "aggressive nomination" in RFC 5245

+ 1 - 1
src/impl/init.cpp

@@ -43,7 +43,7 @@ struct Init::TokenPayload {
 	~TokenPayload() {
 		std::thread t(
 		    [](std::promise<void> promise) {
-				utils::this_thread::set_name("RTC cleanup");
+			    utils::this_thread::set_name("RTC cleanup");
 			    try {
 				    Init::Instance().doCleanup();
 				    promise.set_value();

+ 4 - 5
src/impl/peerconnection.cpp

@@ -446,7 +446,7 @@ void PeerConnection::forwardMessage(message_ptr message) {
 		if (found) {
 			// The stream is already used, the receiver must close the DataChannel
 			PLOG_WARNING << "Got open message on already used stream " << stream;
-			if(channel && !channel->isClosed())
+			if (channel && !channel->isClosed())
 				channel->close();
 			else
 				sctpTransport->closeStream(message->stream);
@@ -469,8 +469,7 @@ void PeerConnection::forwardMessage(message_ptr message) {
 
 		std::unique_lock lock(mDataChannelsMutex); // we are going to emplace
 		mDataChannels.emplace(stream, channel);
-	}
-	else if (!found) {
+	} else if (!found) {
 		if (message->type == Message::Reset)
 			return; // ignore
 
@@ -636,8 +635,8 @@ std::pair<shared_ptr<DataChannel>, bool> PeerConnection::findDataChannel(uint16_
 }
 
 bool PeerConnection::removeDataChannel(uint16_t stream) {
-		std::unique_lock lock(mDataChannelsMutex); // we are going to erase
-		return mDataChannels.erase(stream) != 0;
+	std::unique_lock lock(mDataChannelsMutex); // we are going to erase
+	return mDataChannels.erase(stream) != 0;
 }
 
 uint16_t PeerConnection::maxDataChannelStream() const {

+ 1 - 1
src/impl/sctptransport.cpp

@@ -447,7 +447,7 @@ void SctpTransport::incoming(message_ptr message) {
 		mWrittenCondition.wait(lock, [&]() { return mWrittenOnce || state() == State::Failed; });
 	}
 
-	if(state() == State::Failed)
+	if (state() == State::Failed)
 		return;
 
 	if (!message) {

+ 2 - 2
src/impl/tcpserver.cpp

@@ -21,7 +21,7 @@
 
 namespace rtc::impl {
 
-TcpServer::TcpServer(uint16_t port, const char* bindAddress) {
+TcpServer::TcpServer(uint16_t port, const char *bindAddress) {
 	PLOG_DEBUG << "Initializing TCP server";
 	listen(port, bindAddress);
 }
@@ -89,7 +89,7 @@ void TcpServer::close() {
 	}
 }
 
-void TcpServer::listen(uint16_t port, const char* bindAddress) {
+void TcpServer::listen(uint16_t port, const char *bindAddress) {
 	PLOG_DEBUG << "Listening on port " << port;
 
 	struct addrinfo hints = {};

+ 2 - 2
src/impl/tcpserver.hpp

@@ -21,7 +21,7 @@ namespace rtc::impl {
 
 class TcpServer final {
 public:
-	TcpServer(uint16_t port, const char* bindAddress = nullptr);
+	TcpServer(uint16_t port, const char *bindAddress = nullptr);
 	~TcpServer();
 
 	TcpServer(const TcpServer &other) = delete;
@@ -33,7 +33,7 @@ public:
 	uint16_t port() const { return mPort; }
 
 private:
-	void listen(uint16_t port, const char* bindAddress);
+	void listen(uint16_t port, const char *bindAddress);
 
 	uint16_t mPort;
 	socket_t mSock = INVALID_SOCKET;

+ 1 - 3
src/impl/tcptransport.cpp

@@ -58,9 +58,7 @@ TcpTransport::TcpTransport(socket_t sock, state_callback callback)
 	mService = serv;
 }
 
-TcpTransport::~TcpTransport() {
-	close();
-}
+TcpTransport::~TcpTransport() { close(); }
 
 void TcpTransport::onBufferedAmount(amount_callback callback) {
 	mBufferedAmountCallback = std::move(callback);

+ 1 - 1
src/impl/wshandshake.cpp

@@ -7,10 +7,10 @@
  */
 
 #include "wshandshake.hpp"
+#include "http.hpp"
 #include "internals.hpp"
 #include "sha.hpp"
 #include "utils.hpp"
-#include "http.hpp"
 
 #if RTC_ENABLE_WEBSOCKET
 

+ 1 - 3
src/peerconnection.cpp

@@ -51,9 +51,7 @@ const Configuration *PeerConnection::config() const { return &impl()->config; }
 
 PeerConnection::State PeerConnection::state() const { return impl()->state; }
 
-PeerConnection::IceState PeerConnection::iceState() const {
-	return impl()->iceState;
-}
+PeerConnection::IceState PeerConnection::iceState() const { return impl()->iceState; }
 
 PeerConnection::GatheringState PeerConnection::gatheringState() const {
 	return impl()->gatheringState;

+ 2 - 6
src/rtcpsrreporter.cpp

@@ -79,13 +79,9 @@ message_ptr RtcpSrReporter::getSenderReport(uint32_t timestamp) {
 	return msg;
 }
 
-void RtcpSrReporter::setNeedsToReport() {
-	mNeedsToReport = true;
-}
+void RtcpSrReporter::setNeedsToReport() { mNeedsToReport = true; }
 
-uint32_t RtcpSrReporter::lastReportedTimestamp() const {
-	return mLastReportedTimestamp;
-}
+uint32_t RtcpSrReporter::lastReportedTimestamp() const { return mLastReportedTimestamp; }
 
 } // namespace rtc
 

+ 4 - 2
src/rtp.cpp

@@ -130,7 +130,8 @@ void RtpExtensionHeader::setHeaderLength(uint16_t headerLength) {
 
 void RtpExtensionHeader::clearBody() { std::memset(getBody(), 0, getSize()); }
 
-void RtpExtensionHeader::writeOneByteHeader(size_t offset, uint8_t id, const byte *value, size_t size) {
+void RtpExtensionHeader::writeOneByteHeader(size_t offset, uint8_t id, const byte *value,
+                                            size_t size) {
 	if ((id == 0) || (id > 14) || (size == 0) || (size > 16) || ((offset + 1 + size) > getSize()))
 		return;
 	auto buf = getBody() + offset;
@@ -141,7 +142,8 @@ void RtpExtensionHeader::writeOneByteHeader(size_t offset, uint8_t id, const byt
 	std::memcpy(buf + 1, value, size);
 }
 
-void RtpExtensionHeader::writeCurrentVideoOrientation(size_t offset, const uint8_t id, uint8_t value) {
+void RtpExtensionHeader::writeCurrentVideoOrientation(size_t offset, const uint8_t id,
+                                                      uint8_t value) {
 	auto v = std::byte{value};
 	writeOneByteHeader(offset, id, &v, 1);
 }