Browse Source

Reformatting

Paul-Louis Ageneau 3 years ago
parent
commit
70fcafc50c
49 changed files with 249 additions and 223 deletions
  1. 2 0
      examples/streamer/helpers.hpp
  2. 1 1
      include/rtc/channel.hpp
  3. 1 4
      include/rtc/configuration.hpp
  4. 0 5
      include/rtc/datachannel.hpp
  5. 1 1
      include/rtc/h264packetizationhandler.hpp
  6. 10 6
      include/rtc/h264rtppacketizer.hpp
  7. 18 8
      include/rtc/mediahandlerelement.hpp
  8. 1 1
      include/rtc/mediahandlerrootelement.hpp
  9. 1 2
      include/rtc/message.hpp
  10. 2 2
      include/rtc/nalunit.hpp
  11. 1 1
      include/rtc/opuspacketizationhandler.hpp
  12. 5 3
      include/rtc/opusrtppacketizer.hpp
  13. 1 1
      include/rtc/peerconnection.hpp
  14. 4 3
      include/rtc/rtcpnackresponder.hpp
  15. 4 3
      include/rtc/rtcpsrreporter.hpp
  16. 0 3
      include/rtc/track.hpp
  17. 1 3
      src/candidate.cpp
  18. 5 13
      src/channel.cpp
  19. 0 1
      src/global.cpp
  20. 2 1
      src/h264packetizationhandler.cpp
  21. 41 36
      src/h264rtppacketizer.cpp
  22. 2 2
      src/impl/datachannel.hpp
  23. 5 7
      src/impl/dtlssrtptransport.cpp
  24. 2 2
      src/impl/dtlssrtptransport.hpp
  25. 3 4
      src/impl/dtlstransport.hpp
  26. 1 1
      src/impl/icetransport.cpp
  27. 2 2
      src/impl/icetransport.hpp
  28. 1 1
      src/impl/logcounter.cpp
  29. 1 1
      src/impl/logcounter.hpp
  30. 5 4
      src/impl/peerconnection.cpp
  31. 1 2
      src/impl/queue.hpp
  32. 1 1
      src/impl/sctptransport.hpp
  33. 15 19
      src/impl/sha.cpp
  34. 1 1
      src/impl/socket.hpp
  35. 1 1
      src/impl/tcptransport.cpp
  36. 1 1
      src/impl/threadpool.cpp
  37. 0 1
      src/impl/tls.hpp
  38. 2 1
      src/impl/verifiedtlstransport.hpp
  39. 2 2
      src/impl/websocket.cpp
  40. 9 5
      src/impl/wshandshake.cpp
  41. 7 8
      src/mediachainablehandler.cpp
  42. 33 18
      src/mediahandlerelement.cpp
  43. 18 17
      src/nalunit.cpp
  44. 1 1
      src/opuspacketizationhandler.cpp
  45. 5 3
      src/opusrtppacketizer.cpp
  46. 18 11
      src/rtcpnackresponder.cpp
  47. 4 2
      src/rtcpreceivingsession.cpp
  48. 6 5
      src/rtcpsrreporter.cpp
  49. 1 2
      src/rtppacketizer.cpp

+ 2 - 0
examples/streamer/helpers.hpp

@@ -21,6 +21,8 @@
 
 #include "rtc/rtc.hpp"
 
+#include <shared_mutex>
+
 struct ClientTrackData {
     std::shared_ptr<rtc::Track> track;
 	std::shared_ptr<rtc::RtcpSrReporter> sender;

+ 1 - 1
include/rtc/channel.hpp

@@ -58,7 +58,7 @@ public:
 	// Extended API
 	optional<message_variant> receive(); // only if onMessage unset
 	optional<message_variant> peek();    // only if onMessage unset
-	size_t availableAmount() const;           // total size available to receive
+	size_t availableAmount() const;      // total size available to receive
 	void onAvailable(std::function<void()> callback);
 
 protected:

+ 1 - 4
include/rtc/configuration.hpp

@@ -70,10 +70,7 @@ enum class CertificateType {
 	Rsa = RTC_CERTIFICATE_RSA
 };
 
-enum class TransportPolicy {
-	All = RTC_TRANSPORT_POLICY_ALL,
-	Relay = RTC_TRANSPORT_POLICY_RELAY
-};
+enum class TransportPolicy { All = RTC_TRANSPORT_POLICY_ALL, Relay = RTC_TRANSPORT_POLICY_RELAY };
 
 struct RTC_CPP_EXPORT Configuration {
 	// ICE settings

+ 0 - 5
include/rtc/datachannel.hpp

@@ -24,12 +24,7 @@
 #include "message.hpp"
 #include "reliability.hpp"
 
-#include <atomic>
-#include <chrono>
-#include <functional>
-#include <shared_mutex>
 #include <type_traits>
-#include <shared_mutex>
 
 namespace rtc {
 

+ 1 - 1
include/rtc/h264packetizationhandler.hpp

@@ -22,8 +22,8 @@
 #if RTC_ENABLE_MEDIA
 
 #include "h264rtppacketizer.hpp"
-#include "nalunit.hpp"
 #include "mediachainablehandler.hpp"
+#include "nalunit.hpp"
 
 namespace rtc {
 

+ 10 - 6
include/rtc/h264rtppacketizer.hpp

@@ -21,14 +21,15 @@
 
 #if RTC_ENABLE_MEDIA
 
+#include "mediahandlerrootelement.hpp"
 #include "nalunit.hpp"
 #include "rtppacketizer.hpp"
-#include "mediahandlerrootelement.hpp"
 
 namespace rtc {
 
 /// RTP packetization of h264 payload
-class RTC_CPP_EXPORT H264RtpPacketizer final : public RtpPacketizer, public MediaHandlerRootElement {
+class RTC_CPP_EXPORT H264RtpPacketizer final : public RtpPacketizer,
+                                               public MediaHandlerRootElement {
 	shared_ptr<NalUnits> splitMessage(binary_ptr message);
 	const uint16_t maximumFragmentSize;
 
@@ -44,8 +45,9 @@ public:
 		Length              // first 4 bytes is nal unit length
 	};
 
-	H264RtpPacketizer(H264RtpPacketizer::Separator separator, shared_ptr<RtpPacketizationConfig> rtpConfig,
-					  uint16_t maximumFragmentSize = NalUnits::defaultMaximumFragmentSize);
+	H264RtpPacketizer(H264RtpPacketizer::Separator separator,
+	                  shared_ptr<RtpPacketizationConfig> rtpConfig,
+	                  uint16_t maximumFragmentSize = NalUnits::defaultMaximumFragmentSize);
 
 	/// Constructs h264 payload packetizer with given RTP configuration.
 	/// @note RTP configuration is used in packetization process which may change some configuration
@@ -53,9 +55,11 @@ public:
 	/// @param rtpConfig  RTP configuration
 	/// @param maximumFragmentSize maximum size of one NALU fragment
 	H264RtpPacketizer(shared_ptr<RtpPacketizationConfig> rtpConfig,
-					  uint16_t maximumFragmentSize = NalUnits::defaultMaximumFragmentSize);
+	                  uint16_t maximumFragmentSize = NalUnits::defaultMaximumFragmentSize);
+
+	ChainedOutgoingProduct processOutgoingBinaryMessage(ChainedMessagesProduct messages,
+	                                                    message_ptr control) override;
 
-	ChainedOutgoingProduct processOutgoingBinaryMessage(ChainedMessagesProduct messages, message_ptr control) override;
 private:
 	const Separator separator;
 };

+ 18 - 8
include/rtc/mediahandlerelement.hpp

@@ -34,33 +34,39 @@ RTC_CPP_EXPORT ChainedMessagesProduct make_chained_messages_product(message_ptr
 
 /// Ougoing messages
 struct RTC_CPP_EXPORT ChainedOutgoingProduct {
-	ChainedOutgoingProduct(ChainedMessagesProduct messages = nullptr, message_ptr control = nullptr);
+	ChainedOutgoingProduct(ChainedMessagesProduct messages = nullptr,
+	                       message_ptr control = nullptr);
 	const ChainedMessagesProduct messages;
 	const message_ptr control;
 };
 
 /// Incoming messages with response
 struct RTC_CPP_EXPORT ChainedIncomingProduct {
-	ChainedIncomingProduct(ChainedMessagesProduct incoming = nullptr, ChainedMessagesProduct outgoing = nullptr);
+	ChainedIncomingProduct(ChainedMessagesProduct incoming = nullptr,
+	                       ChainedMessagesProduct outgoing = nullptr);
 	const ChainedMessagesProduct incoming;
 	const ChainedOutgoingProduct outgoing;
 };
 
 /// Incoming control messages with response
 struct RTC_CPP_EXPORT ChainedIncomingControlProduct {
-	ChainedIncomingControlProduct(message_ptr incoming, optional<ChainedOutgoingProduct> outgoing = nullopt);
+	ChainedIncomingControlProduct(message_ptr incoming,
+	                              optional<ChainedOutgoingProduct> outgoing = nullopt);
 	const message_ptr incoming;
 	const optional<ChainedOutgoingProduct> outgoing;
 };
 
 /// Chainable handler
-class RTC_CPP_EXPORT MediaHandlerElement: public std::enable_shared_from_this<MediaHandlerElement> {
+class RTC_CPP_EXPORT MediaHandlerElement
+    : public std::enable_shared_from_this<MediaHandlerElement> {
 	shared_ptr<MediaHandlerElement> upstream = nullptr;
 	shared_ptr<MediaHandlerElement> downstream = nullptr;
 
-	void prepareAndSendResponse(optional<ChainedOutgoingProduct> outgoing, std::function<bool (ChainedOutgoingProduct)> send);
+	void prepareAndSendResponse(optional<ChainedOutgoingProduct> outgoing,
+	                            std::function<bool(ChainedOutgoingProduct)> send);
 
 	void removeFromChain();
+
 public:
 	MediaHandlerElement();
 
@@ -70,8 +76,11 @@ public:
 	optional<ChainedOutgoingProduct> processOutgoingResponse(ChainedOutgoingProduct messages);
 
 	// Process incoming and ougoing messages
-	message_ptr formIncomingControlMessage(message_ptr message, std::function<bool (ChainedOutgoingProduct)> send);
-	ChainedMessagesProduct formIncomingBinaryMessage(ChainedMessagesProduct messages, std::function<bool (ChainedOutgoingProduct)> send);
+	message_ptr formIncomingControlMessage(message_ptr message,
+	                                       std::function<bool(ChainedOutgoingProduct)> send);
+	ChainedMessagesProduct
+	formIncomingBinaryMessage(ChainedMessagesProduct messages,
+	                          std::function<bool(ChainedOutgoingProduct)> send);
 	message_ptr formOutgoingControlMessage(message_ptr message);
 	optional<ChainedOutgoingProduct> formOutgoingBinaryMessage(ChainedOutgoingProduct product);
 
@@ -94,7 +103,8 @@ public:
 	/// @param messages current message
 	/// @param control current control message
 	/// @returns Modified binary message and control message
-	virtual ChainedOutgoingProduct processOutgoingBinaryMessage(ChainedMessagesProduct messages, message_ptr control);
+	virtual ChainedOutgoingProduct processOutgoingBinaryMessage(ChainedMessagesProduct messages,
+	                                                            message_ptr control);
 
 	/// Set given element as upstream to this
 	/// @param upstream Upstream element

+ 1 - 1
include/rtc/mediahandlerrootelement.hpp

@@ -28,7 +28,7 @@ namespace rtc {
 /// Chainable message handler
 class RTC_CPP_EXPORT MediaHandlerRootElement : public MediaHandlerElement {
 public:
-	MediaHandlerRootElement() { }
+	MediaHandlerRootElement() {}
 
 	/// Reduce multiple messages into one message
 	/// @param messages Messages to reduce

+ 1 - 2
include/rtc/message.hpp

@@ -54,8 +54,7 @@ inline size_t message_size_func(const message_ptr &m) {
 
 template <typename Iterator>
 message_ptr make_message(Iterator begin, Iterator end, Message::Type type = Message::Binary,
-                         unsigned int stream = 0,
-                         shared_ptr<Reliability> reliability = nullptr) {
+                         unsigned int stream = 0, shared_ptr<Reliability> reliability = nullptr) {
 	auto message = std::make_shared<Message>(begin, end, type);
 	message->stream = stream;
 	message->reliability = reliability;

+ 2 - 2
include/rtc/nalunit.hpp

@@ -101,8 +101,8 @@ struct RTC_CPP_EXPORT NalUnitFragmentA : NalUnit {
 	NalUnitFragmentA(FragmentType type, bool forbiddenBit, uint8_t nri, uint8_t unitType,
 	                 binary data);
 
-	static std::vector<shared_ptr<NalUnitFragmentA>>
-	fragmentsFrom(shared_ptr<NalUnit> nalu, uint16_t maximumFragmentSize);
+	static std::vector<shared_ptr<NalUnitFragmentA>> fragmentsFrom(shared_ptr<NalUnit> nalu,
+	                                                               uint16_t maximumFragmentSize);
 
 	uint8_t unitType() { return fragmentHeader()->unitType(); }
 

+ 1 - 1
include/rtc/opuspacketizationhandler.hpp

@@ -21,8 +21,8 @@
 
 #if RTC_ENABLE_MEDIA
 
-#include "opusrtppacketizer.hpp"
 #include "mediachainablehandler.hpp"
+#include "opusrtppacketizer.hpp"
 
 namespace rtc {
 

+ 5 - 3
include/rtc/opusrtppacketizer.hpp

@@ -21,13 +21,14 @@
 
 #if RTC_ENABLE_MEDIA
 
-#include "rtppacketizer.hpp"
 #include "mediahandlerrootelement.hpp"
+#include "rtppacketizer.hpp"
 
 namespace rtc {
 
 /// RTP packetizer for opus
-class RTC_CPP_EXPORT OpusRtpPacketizer final : public RtpPacketizer, public MediaHandlerRootElement {
+class RTC_CPP_EXPORT OpusRtpPacketizer final : public RtpPacketizer,
+                                               public MediaHandlerRootElement {
 public:
 	/// default clock rate used in opus RTP communication
 	inline static const uint32_t defaultClockRate = 48 * 1000;
@@ -48,7 +49,8 @@ public:
 	/// @param messages opus samples
 	/// @param control RTCP
 	/// @returns RTP packets and unchanged `control`
-	ChainedOutgoingProduct processOutgoingBinaryMessage(ChainedMessagesProduct messages, message_ptr control) override;
+	ChainedOutgoingProduct processOutgoingBinaryMessage(ChainedMessagesProduct messages,
+	                                                    message_ptr control) override;
 };
 
 } // namespace rtc

+ 1 - 1
include/rtc/peerconnection.hpp

@@ -20,10 +20,10 @@
 #define RTC_PEER_CONNECTION_H
 
 #include "candidate.hpp"
+#include "common.hpp"
 #include "configuration.hpp"
 #include "datachannel.hpp"
 #include "description.hpp"
-#include "common.hpp"
 #include "message.hpp"
 #include "reliability.hpp"
 #include "track.hpp"

+ 4 - 3
include/rtc/rtcpnackresponder.hpp

@@ -23,12 +23,12 @@
 
 #include "mediahandlerelement.hpp"
 
-#include <unordered_map>
 #include <queue>
+#include <unordered_map>
 
 namespace rtc {
 
-class RTC_CPP_EXPORT RtcpNackResponder final: public MediaHandlerElement {
+class RTC_CPP_EXPORT RtcpNackResponder final : public MediaHandlerElement {
 
 	/// Packet storage
 	class RTC_CPP_EXPORT Storage {
@@ -85,7 +85,8 @@ public:
 	/// @param messages RTP packets
 	/// @param control RTCP
 	/// @returns Unchanged RTP and RTCP
-	ChainedOutgoingProduct processOutgoingBinaryMessage(ChainedMessagesProduct messages, message_ptr control) override;
+	ChainedOutgoingProduct processOutgoingBinaryMessage(ChainedMessagesProduct messages,
+	                                                    message_ptr control) override;
 };
 
 } // namespace rtc

+ 4 - 3
include/rtc/rtcpsrreporter.hpp

@@ -21,13 +21,13 @@
 
 #if RTC_ENABLE_MEDIA
 
+#include "mediahandlerelement.hpp"
 #include "message.hpp"
 #include "rtppacketizationconfig.hpp"
-#include "mediahandlerelement.hpp"
 
 namespace rtc {
 
-class RTC_CPP_EXPORT RtcpSrReporter final: public MediaHandlerElement {
+class RTC_CPP_EXPORT RtcpSrReporter final : public MediaHandlerElement {
 
 	bool needsToReport = false;
 
@@ -51,7 +51,8 @@ public:
 
 	RtcpSrReporter(shared_ptr<RtpPacketizationConfig> rtpConfig);
 
-	ChainedOutgoingProduct processOutgoingBinaryMessage(ChainedMessagesProduct messages, message_ptr control) override;
+	ChainedOutgoingProduct processOutgoingBinaryMessage(ChainedMessagesProduct messages,
+	                                                    message_ptr control) override;
 
 	/// Set `needsToReport` flag. Sender report will be sent before next RTP packet with same
 	/// timestamp.

+ 0 - 3
include/rtc/track.hpp

@@ -25,9 +25,6 @@
 #include "mediahandler.hpp"
 #include "message.hpp"
 
-#include <atomic>
-#include <shared_mutex>
-
 namespace rtc {
 
 namespace impl {

+ 1 - 3
src/candidate.cpp

@@ -221,9 +221,7 @@ Candidate::operator string() const {
 }
 
 bool Candidate::operator==(const Candidate &other) const {
-	return (mFoundation == other.mFoundation &&
-	        mService == other.mService &&
-	        mNode == other.mNode);
+	return (mFoundation == other.mFoundation && mService == other.mService && mNode == other.mNode);
 }
 
 bool Candidate::operator!=(const Candidate &other) const {

+ 5 - 13
src/channel.cpp

@@ -18,14 +18,12 @@
 
 #include "channel.hpp"
 
-#include "impl/internals.hpp"
 #include "impl/channel.hpp"
+#include "impl/internals.hpp"
 
 namespace rtc {
 
-Channel::~Channel() {
-	impl()->resetCallbacks();
-}
+Channel::~Channel() { impl()->resetCallbacks(); }
 
 Channel::Channel(impl_ptr<impl::Channel> impl) : CheshireCat<impl::Channel>(std::move(impl)) {}
 
@@ -61,17 +59,11 @@ void Channel::setBufferedAmountLowThreshold(size_t amount) {
 	impl()->bufferedAmountLowThreshold = amount;
 }
 
-optional<message_variant> Channel::receive() {
-	return impl()->receive();
-}
+optional<message_variant> Channel::receive() { return impl()->receive(); }
 
-optional<message_variant> Channel::peek() {
-	return impl()->peek();
-}
+optional<message_variant> Channel::peek() { return impl()->peek(); }
 
-size_t Channel::availableAmount() const {
-	return impl()->availableAmount();
-}
+size_t Channel::availableAmount() const { return impl()->availableAmount(); }
 
 void Channel::onAvailable(std::function<void()> callback) { impl()->availableCallback = callback; }
 

+ 0 - 1
src/global.cpp

@@ -120,4 +120,3 @@ RTC_CPP_EXPORT std::ostream &operator<<(std::ostream &out, rtc::LogLevel level)
 	}
 	return out;
 }
-

+ 2 - 1
src/h264packetizationhandler.cpp

@@ -22,7 +22,8 @@
 
 namespace rtc {
 
-H264PacketizationHandler::H264PacketizationHandler(shared_ptr<H264RtpPacketizer> packetizer): MediaChainableHandler(packetizer) { }
+H264PacketizationHandler::H264PacketizationHandler(shared_ptr<H264RtpPacketizer> packetizer)
+    : MediaChainableHandler(packetizer) {}
 
 } // namespace rtc
 

+ 41 - 36
src/h264rtppacketizer.cpp

@@ -42,40 +42,40 @@ typedef enum {
 } NalUnitStartSequenceMatch;
 
 NalUnitStartSequenceMatch StartSequenceMatchSucc(NalUnitStartSequenceMatch match, byte _byte,
-												 H264RtpPacketizer::Separator separator) {
+                                                 H264RtpPacketizer::Separator separator) {
 	assert(separator != H264RtpPacketizer::Separator::Length);
 	auto byte = (uint8_t)_byte;
 	auto detectShort = separator == H264RtpPacketizer::Separator::ShortStartSequence ||
-	separator == H264RtpPacketizer::Separator::StartSequence;
+	                   separator == H264RtpPacketizer::Separator::StartSequence;
 	auto detectLong = separator == H264RtpPacketizer::Separator::LongStartSequence ||
-	separator == H264RtpPacketizer::Separator::StartSequence;
+	                  separator == H264RtpPacketizer::Separator::StartSequence;
 	switch (match) {
-		case NUSM_noMatch:
-			if (byte == 0x00) {
-				return NUSM_firstZero;
-			}
-			break;
-		case NUSM_firstZero:
-			if (byte == 0x00) {
-				return NUSM_secondZero;
-			}
-			break;
-		case NUSM_secondZero:
-			if (byte == 0x00 && detectLong) {
-				return NUSM_thirdZero;
-			} else if (byte == 0x01 && detectShort) {
-				return NUSM_shortMatch;
-			}
-			break;
-		case NUSM_thirdZero:
-			if (byte == 0x01 && detectLong) {
-				return NUSM_longMatch;
-			}
-			break;
-		case NUSM_shortMatch:
+	case NUSM_noMatch:
+		if (byte == 0x00) {
+			return NUSM_firstZero;
+		}
+		break;
+	case NUSM_firstZero:
+		if (byte == 0x00) {
+			return NUSM_secondZero;
+		}
+		break;
+	case NUSM_secondZero:
+		if (byte == 0x00 && detectLong) {
+			return NUSM_thirdZero;
+		} else if (byte == 0x01 && detectShort) {
 			return NUSM_shortMatch;
-		case NUSM_longMatch:
+		}
+		break;
+	case NUSM_thirdZero:
+		if (byte == 0x01 && detectLong) {
 			return NUSM_longMatch;
+		}
+		break;
+	case NUSM_shortMatch:
+		return NUSM_shortMatch;
+	case NUSM_longMatch:
+		return NUSM_longMatch;
 	}
 	return NUSM_noMatch;
 }
@@ -139,16 +139,21 @@ shared_ptr<NalUnits> H264RtpPacketizer::splitMessage(binary_ptr message) {
 }
 
 H264RtpPacketizer::H264RtpPacketizer(shared_ptr<RtpPacketizationConfig> rtpConfig,
-									 uint16_t maximumFragmentSize)
-: RtpPacketizer(rtpConfig), MediaHandlerRootElement(), maximumFragmentSize(maximumFragmentSize), separator(Separator::Length) {}
-
-H264RtpPacketizer::H264RtpPacketizer(H264RtpPacketizer::Separator separator, shared_ptr<RtpPacketizationConfig> rtpConfig,
-									 uint16_t maximumFragmentSize)
-: RtpPacketizer(rtpConfig), MediaHandlerRootElement(), maximumFragmentSize(maximumFragmentSize), separator(separator) {}
-
-ChainedOutgoingProduct H264RtpPacketizer::processOutgoingBinaryMessage(ChainedMessagesProduct messages, message_ptr control) {
+                                     uint16_t maximumFragmentSize)
+    : RtpPacketizer(rtpConfig), MediaHandlerRootElement(), maximumFragmentSize(maximumFragmentSize),
+      separator(Separator::Length) {}
+
+H264RtpPacketizer::H264RtpPacketizer(H264RtpPacketizer::Separator separator,
+                                     shared_ptr<RtpPacketizationConfig> rtpConfig,
+                                     uint16_t maximumFragmentSize)
+    : RtpPacketizer(rtpConfig), MediaHandlerRootElement(), maximumFragmentSize(maximumFragmentSize),
+      separator(separator) {}
+
+ChainedOutgoingProduct
+H264RtpPacketizer::processOutgoingBinaryMessage(ChainedMessagesProduct messages,
+                                                message_ptr control) {
 	ChainedMessagesProduct packets = std::make_shared<std::vector<binary_ptr>>();
-	for (auto message: *messages) {
+	for (auto message : *messages) {
 		auto nalus = splitMessage(message);
 		auto fragments = nalus->generateFragments(maximumFragmentSize);
 		if (fragments.size() == 0) {

+ 2 - 2
src/impl/datachannel.hpp

@@ -82,8 +82,8 @@ protected:
 struct NegotiatedDataChannel final : public DataChannel {
 	NegotiatedDataChannel(weak_ptr<PeerConnection> pc, uint16_t stream, string label,
 	                      string protocol, Reliability reliability);
-	NegotiatedDataChannel(weak_ptr<PeerConnection> pc,
-	                      weak_ptr<SctpTransport> transport, uint16_t stream);
+	NegotiatedDataChannel(weak_ptr<PeerConnection> pc, weak_ptr<SctpTransport> transport,
+	                      uint16_t stream);
 	~NegotiatedDataChannel();
 
 	void open(impl_ptr<SctpTransport> transport) override;

+ 5 - 7
src/impl/dtlssrtptransport.cpp

@@ -18,8 +18,8 @@
 
 #include "dtlssrtptransport.hpp"
 #include "logcounter.hpp"
-#include "tls.hpp"
 #include "rtp.hpp"
+#include "tls.hpp"
 
 #if RTC_ENABLE_MEDIA
 
@@ -32,12 +32,11 @@ using std::to_string;
 namespace rtc::impl {
 
 static LogCounter COUNTER_MEDIA_TRUNCATED(plog::warning,
-                                               "Number of truncated SRT(C)P packets received");
+                                          "Number of truncated SRT(C)P packets received");
 static LogCounter
     COUNTER_UNKNOWN_PACKET_TYPE(plog::warning,
                                 "Number of RTP packets received with an unknown packet type");
-static LogCounter COUNTER_SRTCP_REPLAY(plog::warning,
-                                            "Number of SRTCP replay packets received");
+static LogCounter COUNTER_SRTCP_REPLAY(plog::warning, "Number of SRTCP replay packets received");
 static LogCounter
     COUNTER_SRTCP_AUTH_FAIL(plog::warning,
                             "Number of SRTCP packets received that failed authentication checks");
@@ -57,8 +56,7 @@ void DtlsSrtpTransport::Init() { srtp_init(); }
 void DtlsSrtpTransport::Cleanup() { srtp_shutdown(); }
 
 DtlsSrtpTransport::DtlsSrtpTransport(shared_ptr<IceTransport> lower,
-                                     shared_ptr<Certificate> certificate,
-                                     optional<size_t> mtu,
+                                     shared_ptr<Certificate> certificate, optional<size_t> mtu,
                                      verifier_callback verifierCallback,
                                      message_callback srtpRecvCallback,
                                      state_callback stateChangeCallback)
@@ -324,6 +322,6 @@ void DtlsSrtpTransport::postHandshake() {
 	mInitDone = true;
 }
 
-} // namespace rtc
+} // namespace rtc::impl
 
 #endif

+ 2 - 2
src/impl/dtlssrtptransport.hpp

@@ -19,8 +19,8 @@
 #ifndef RTC_IMPL_DTLS_SRTP_TRANSPORT_H
 #define RTC_IMPL_DTLS_SRTP_TRANSPORT_H
 
-#include "dtlstransport.hpp"
 #include "common.hpp"
+#include "dtlstransport.hpp"
 
 #if RTC_ENABLE_MEDIA
 
@@ -60,7 +60,7 @@ private:
 	std::mutex sendMutex;
 };
 
-} // namespace rtc
+} // namespace rtc::impl
 
 #endif
 

+ 3 - 4
src/impl/dtlstransport.hpp

@@ -42,9 +42,8 @@ public:
 
 	using verifier_callback = std::function<bool(const std::string &fingerprint)>;
 
-	DtlsTransport(shared_ptr<IceTransport> lower, certificate_ptr certificate,
-	              optional<size_t> mtu, verifier_callback verifierCallback,
-	              state_callback stateChangeCallback);
+	DtlsTransport(shared_ptr<IceTransport> lower, certificate_ptr certificate, optional<size_t> mtu,
+	              verifier_callback verifierCallback, state_callback stateChangeCallback);
 	~DtlsTransport();
 
 	virtual void start() override;
@@ -95,6 +94,6 @@ protected:
 #endif
 };
 
-} // namespace rtc
+} // namespace rtc::impl
 
 #endif

+ 1 - 1
src/impl/icetransport.cpp

@@ -559,7 +559,7 @@ Description IceTransport::getLocalDescription(Description::Type type) const {
 	             type == Description::Type::Offer ? TRUE : FALSE, nullptr);
 
 	unique_ptr<gchar[], void (*)(void *)> sdp(nice_agent_generate_local_sdp(mNiceAgent.get()),
-	                                               g_free);
+	                                          g_free);
 
 	// RFC 5763: The endpoint that is the offerer MUST use the setup attribute value of
 	// setup:actpass.

+ 2 - 2
src/impl/icetransport.hpp

@@ -20,9 +20,9 @@
 #define RTC_IMPL_ICE_TRANSPORT_H
 
 #include "candidate.hpp"
+#include "common.hpp"
 #include "configuration.hpp"
 #include "description.hpp"
-#include "common.hpp"
 #include "peerconnection.hpp"
 #include "transport.hpp"
 
@@ -115,6 +115,6 @@ private:
 #endif
 };
 
-} // namespace rtc
+} // namespace rtc::impl
 
 #endif

+ 1 - 1
src/impl/logcounter.cpp

@@ -47,4 +47,4 @@ LogCounter &LogCounter::operator++(int) {
 	return *this;
 }
 
-} // namespace rtc
+} // namespace rtc::impl

+ 1 - 1
src/impl/logcounter.hpp

@@ -46,6 +46,6 @@ public:
 	LogCounter &operator++(int);
 };
 
-} // namespace rtc
+} // namespace rtc::impl
 
 #endif // RTC_SERVER_LOGCOUNTER_HPP

+ 5 - 4
src/impl/peerconnection.cpp

@@ -21,8 +21,8 @@
 #include "certificate.hpp"
 #include "common.hpp"
 #include "dtlstransport.hpp"
-#include "internals.hpp"
 #include "icetransport.hpp"
+#include "internals.hpp"
 #include "logcounter.hpp"
 #include "peerconnection.hpp"
 #include "processor.hpp"
@@ -187,7 +187,7 @@ shared_ptr<DtlsTransport> PeerConnection::initDtlsTransport() {
 		PLOG_VERBOSE << "Starting DTLS transport";
 
 		auto lower = std::atomic_load(&mIceTransport);
-		if(!lower)
+		if (!lower)
 			throw std::logic_error("No underlying ICE transport for DTLS transport");
 
 		auto certificate = mCertificate.get();
@@ -262,7 +262,7 @@ shared_ptr<SctpTransport> PeerConnection::initSctpTransport() {
 		PLOG_VERBOSE << "Starting SCTP transport";
 
 		auto lower = std::atomic_load(&mDtlsTransport);
-		if(!lower)
+		if (!lower)
 			throw std::logic_error("No underlying DTLS transport for SCTP transport");
 
 		auto remote = remoteDescription();
@@ -901,7 +901,8 @@ void PeerConnection::processLocalCandidate(Candidate candidate) {
 	if (!mLocalDescription)
 		throw std::logic_error("Got a local candidate without local description");
 
-	if(config.iceTransportPolicy == TransportPolicy::Relay && candidate.type() != Candidate::Type::Relayed) {
+	if (config.iceTransportPolicy == TransportPolicy::Relay &&
+	    candidate.type() != Candidate::Type::Relayed) {
 		PLOG_VERBOSE << "Not issuing local candidate because of transport policy: " << candidate;
 		return;
 	}

+ 1 - 2
src/impl/queue.hpp

@@ -136,8 +136,7 @@ template <typename T> optional<T> Queue<T>::exchange(T element) {
 	return std::make_optional(std::move(element));
 }
 
-template <typename T>
-bool Queue<T>::wait(const optional<std::chrono::milliseconds> &duration) {
+template <typename T> bool Queue<T>::wait(const optional<std::chrono::milliseconds> &duration) {
 	std::unique_lock lock(mMutex);
 	if (duration)
 		mPopCondition.wait_for(lock, *duration, [this]() { return !mQueue.empty() || mStopping; });

+ 1 - 1
src/impl/sctptransport.hpp

@@ -20,10 +20,10 @@
 #define RTC_IMPL_SCTP_TRANSPORT_H
 
 #include "common.hpp"
+#include "configuration.hpp"
 #include "processor.hpp"
 #include "queue.hpp"
 #include "transport.hpp"
-#include "configuration.hpp"
 
 #include <condition_variable>
 #include <functional>

+ 15 - 19
src/impl/sha.cpp

@@ -33,37 +33,33 @@ namespace {
 binary Sha1(const byte *data, size_t size) {
 #if USE_GNUTLS
 
-binary output(SHA1_DIGEST_SIZE);
-struct sha1_ctx ctx;
-sha1_init(&ctx);
-sha1_update(&ctx, size, reinterpret_cast<const uint8_t*>(data));
-sha1_digest(&ctx, SHA1_DIGEST_SIZE, reinterpret_cast<uint8_t*>(output.data()));
-return output;
+	binary output(SHA1_DIGEST_SIZE);
+	struct sha1_ctx ctx;
+	sha1_init(&ctx);
+	sha1_update(&ctx, size, reinterpret_cast<const uint8_t *>(data));
+	sha1_digest(&ctx, SHA1_DIGEST_SIZE, reinterpret_cast<uint8_t *>(output.data()));
+	return output;
 
 #else // USE_GNUTLS==0
 
-binary output(SHA_DIGEST_LENGTH);
-SHA_CTX ctx;
-SHA1_Init(&ctx);
-SHA1_Update(&ctx, data, size);
-SHA1_Final(reinterpret_cast<unsigned char*>(output.data()), &ctx);
-return output;
+	binary output(SHA_DIGEST_LENGTH);
+	SHA_CTX ctx;
+	SHA1_Init(&ctx);
+	SHA1_Update(&ctx, data, size);
+	SHA1_Final(reinterpret_cast<unsigned char *>(output.data()), &ctx);
+	return output;
 
 #endif
 }
 
-}
-
-binary Sha1(const binary &input) {
-	return Sha1(input.data(), input.size());
-}
+} // namespace
 
+binary Sha1(const binary &input) { return Sha1(input.data(), input.size()); }
 
 binary Sha1(const string &input) {
-	return Sha1(reinterpret_cast<const byte*>(input.data()), input.size());
+	return Sha1(reinterpret_cast<const byte *>(input.data()), input.size());
 }
 
 } // namespace rtc::impl
 
 #endif
-

+ 1 - 1
src/impl/socket.hpp

@@ -33,8 +33,8 @@
 #include <winsock2.h>
 #include <ws2tcpip.h>
 //
-#include <windows.h>
 #include <iphlpapi.h>
+#include <windows.h>
 
 #ifdef __MINGW32__
 #include <sys/stat.h>

+ 1 - 1
src/impl/tcptransport.cpp

@@ -83,7 +83,7 @@ bool TcpTransport::stop() {
 
 bool TcpTransport::send(message_ptr message) {
 	std::unique_lock lock(mSockMutex);
-	if(state() == State::Connecting)
+	if (state() == State::Connecting)
 		throw std::runtime_error("Connection is not open");
 
 	if (state() != State::Connected)

+ 1 - 1
src/impl/threadpool.cpp

@@ -88,7 +88,7 @@ std::function<void()> ThreadPool::dequeue() {
 		--mBusyWorkers;
 		scope_guard guard([&]() { ++mBusyWorkers; });
 		mWaitingCondition.notify_all();
-		if(time)
+		if (time)
 			mTasksCondition.wait_until(lock, *time);
 		else
 			mTasksCondition.wait(lock);

+ 0 - 1
src/impl/tls.hpp

@@ -58,7 +58,6 @@ gnutls_datum_t make_datum(char *data, size_t size);
 #include <openssl/bio.h>
 #include <openssl/bn.h>
 #include <openssl/ec.h>
-#include <openssl/ec.h>
 #include <openssl/err.h>
 #include <openssl/pem.h>
 #include <openssl/rsa.h>

+ 2 - 1
src/impl/verifiedtlstransport.hpp

@@ -27,7 +27,8 @@ namespace rtc::impl {
 
 class VerifiedTlsTransport final : public TlsTransport {
 public:
-	VerifiedTlsTransport(shared_ptr<TcpTransport> lower, string host, certificate_ptr certificate, state_callback callback);
+	VerifiedTlsTransport(shared_ptr<TcpTransport> lower, string host, certificate_ptr certificate,
+	                     state_callback callback);
 	~VerifiedTlsTransport();
 };
 

+ 2 - 2
src/impl/websocket.cpp

@@ -267,8 +267,8 @@ shared_ptr<TlsTransport> WebSocket::initTlsTransport() {
 
 		shared_ptr<TlsTransport> transport;
 		if (verify)
-			transport = std::make_shared<VerifiedTlsTransport>(lower, mHostname.value(), mCertificate,
-			                                                   stateChangeCallback);
+			transport = std::make_shared<VerifiedTlsTransport>(lower, mHostname.value(),
+			                                                   mCertificate, stateChangeCallback);
 		else
 			transport =
 			    std::make_shared<TlsTransport>(lower, mHostname, mCertificate, stateChangeCallback);

+ 9 - 5
src/impl/wshandshake.cpp

@@ -130,7 +130,7 @@ string WsHandshake::generateHttpResponse() {
 namespace {
 
 string GetHttpErrorName(int responseCode) {
-	switch(responseCode) {
+	switch (responseCode) {
 	case 400:
 		return "Bad Request";
 	case 404:
@@ -146,20 +146,24 @@ string GetHttpErrorName(int responseCode) {
 	}
 }
 
-}
+} // namespace
 
 string WsHandshake::generateHttpError(int responseCode) {
 	std::unique_lock lock(mMutex);
 
 	const string error = to_string(responseCode) + " " + GetHttpErrorName(responseCode);
 
-	const string out = "HTTP/1.1 " + error + "\r\n"
+	const string out = "HTTP/1.1 " + error +
+	                   "\r\n"
 	                   "Server: libdatachannel\r\n"
 	                   "Connection: upgrade\r\n"
 	                   "Upgrade: websocket\r\n"
 	                   "Content-Type: text/plain\r\n"
-	                   "Content-Length: " + to_string(error.size()) + "\r\n"
-	                   "Access-Control-Allow-Origin: *\r\n\r\n" + error;
+	                   "Content-Length: " +
+	                   to_string(error.size()) +
+	                   "\r\n"
+	                   "Access-Control-Allow-Origin: *\r\n\r\n" +
+	                   error;
 
 	return out;
 }

+ 7 - 8
src/mediachainablehandler.cpp

@@ -26,18 +26,17 @@
 
 namespace rtc {
 
-MediaChainableHandler::MediaChainableHandler(shared_ptr<MediaHandlerRootElement> root): MediaHandler(), root(root), leaf(root) { }
+MediaChainableHandler::MediaChainableHandler(shared_ptr<MediaHandlerRootElement> root)
+    : MediaHandler(), root(root), leaf(root) {}
 
-MediaChainableHandler::~MediaChainableHandler() {
-	leaf->recursiveRemoveChain();
-}
+MediaChainableHandler::~MediaChainableHandler() { leaf->recursiveRemoveChain(); }
 
 bool MediaChainableHandler::sendProduct(ChainedOutgoingProduct product) {
 	bool result = true;
 	if (product.control) {
 		assert(product.control->type == Message::Control);
 		auto sendResult = send(product.control);
-		if(!sendResult) {
+		if (!sendResult) {
 			LOG_DEBUG << "Failed to send control message";
 		}
 		result = result && sendResult;
@@ -50,7 +49,7 @@ bool MediaChainableHandler::sendProduct(ChainedOutgoingProduct product) {
 				LOG_DEBUG << "Invalid message to send " << i + 1 << "/" << messages->size();
 			}
 			auto sendResult = send(make_message(*message));
-			if(!sendResult) {
+			if (!sendResult) {
 				LOG_DEBUG << "Failed to send message " << i + 1 << "/" << messages->size();
 			}
 			result = result && sendResult;
@@ -89,7 +88,7 @@ message_ptr MediaChainableHandler::handleOutgoingBinary(message_ptr msg) {
 	}
 	auto outgoing = optOutgoing.value();
 	if (outgoing.control) {
-		if(!send(outgoing.control)) {
+		if (!send(outgoing.control)) {
 			LOG_DEBUG << "Failed to send control message";
 		}
 	}
@@ -103,7 +102,7 @@ message_ptr MediaChainableHandler::handleOutgoingBinary(message_ptr msg) {
 		if (!message) {
 			LOG_DEBUG << "Invalid message to send " << i + 1 << "/" << outgoing.messages->size();
 		}
-		if(!send(make_message(*message))) {
+		if (!send(make_message(*message))) {
 			LOG_DEBUG << "Failed to send message " << i + 1 << "/" << outgoing.messages->size();
 		}
 	}

+ 33 - 18
src/mediahandlerelement.cpp

@@ -36,15 +36,17 @@ ChainedMessagesProduct make_chained_messages_product(message_ptr msg) {
 }
 
 ChainedOutgoingProduct::ChainedOutgoingProduct(ChainedMessagesProduct messages, message_ptr control)
-: messages(messages), control(control) { }
+    : messages(messages), control(control) {}
 
-ChainedIncomingProduct::ChainedIncomingProduct(ChainedMessagesProduct incoming, ChainedMessagesProduct outgoing)
-: incoming(incoming), outgoing(outgoing) { }
+ChainedIncomingProduct::ChainedIncomingProduct(ChainedMessagesProduct incoming,
+                                               ChainedMessagesProduct outgoing)
+    : incoming(incoming), outgoing(outgoing) {}
 
-ChainedIncomingControlProduct::ChainedIncomingControlProduct(message_ptr incoming, optional<ChainedOutgoingProduct> outgoing)
-: incoming(incoming), outgoing(outgoing) { }
+ChainedIncomingControlProduct::ChainedIncomingControlProduct(
+    message_ptr incoming, optional<ChainedOutgoingProduct> outgoing)
+    : incoming(incoming), outgoing(outgoing) {}
 
-MediaHandlerElement::MediaHandlerElement() { }
+MediaHandlerElement::MediaHandlerElement() {}
 
 void MediaHandlerElement::removeFromChain() {
 	if (upstream) {
@@ -68,10 +70,12 @@ void MediaHandlerElement::recursiveRemoveChain() {
 	removeFromChain();
 }
 
-optional<ChainedOutgoingProduct> MediaHandlerElement::processOutgoingResponse(ChainedOutgoingProduct messages) {
+optional<ChainedOutgoingProduct>
+MediaHandlerElement::processOutgoingResponse(ChainedOutgoingProduct messages) {
 	if (messages.messages) {
 		if (upstream) {
-			auto msgs = upstream->formOutgoingBinaryMessage(ChainedOutgoingProduct(messages.messages, messages.control));
+			auto msgs = upstream->formOutgoingBinaryMessage(
+			    ChainedOutgoingProduct(messages.messages, messages.control));
 			if (msgs.has_value()) {
 				return msgs.value();
 			} else {
@@ -98,12 +102,13 @@ optional<ChainedOutgoingProduct> MediaHandlerElement::processOutgoingResponse(Ch
 	}
 }
 
-void MediaHandlerElement::prepareAndSendResponse(optional<ChainedOutgoingProduct> outgoing, std::function<bool (ChainedOutgoingProduct)> send) {
+void MediaHandlerElement::prepareAndSendResponse(optional<ChainedOutgoingProduct> outgoing,
+                                                 std::function<bool(ChainedOutgoingProduct)> send) {
 	if (outgoing.has_value()) {
 		auto message = outgoing.value();
 		auto response = processOutgoingResponse(message);
 		if (response.has_value()) {
-			if(!send(response.value())) {
+			if (!send(response.value())) {
 				LOG_DEBUG << "Send failed";
 			}
 		} else {
@@ -112,7 +117,9 @@ void MediaHandlerElement::prepareAndSendResponse(optional<ChainedOutgoingProduct
 	}
 }
 
-message_ptr MediaHandlerElement::formIncomingControlMessage(message_ptr message, std::function<bool (ChainedOutgoingProduct)> send) {
+message_ptr
+MediaHandlerElement::formIncomingControlMessage(message_ptr message,
+                                                std::function<bool(ChainedOutgoingProduct)> send) {
 	assert(message);
 	auto product = processIncomingControlMessage(message);
 	prepareAndSendResponse(product.outgoing, send);
@@ -127,7 +134,9 @@ message_ptr MediaHandlerElement::formIncomingControlMessage(message_ptr message,
 	}
 }
 
-ChainedMessagesProduct MediaHandlerElement::formIncomingBinaryMessage(ChainedMessagesProduct messages, std::function<bool (ChainedOutgoingProduct)> send) {
+ChainedMessagesProduct
+MediaHandlerElement::formIncomingBinaryMessage(ChainedMessagesProduct messages,
+                                               std::function<bool(ChainedOutgoingProduct)> send) {
 	assert(messages && !messages->empty());
 	auto product = processIncomingBinaryMessage(messages);
 	prepareAndSendResponse(product.outgoing, send);
@@ -146,7 +155,7 @@ message_ptr MediaHandlerElement::formOutgoingControlMessage(message_ptr message)
 	assert(message);
 	auto newMessage = processOutgoingControlMessage(message);
 	assert(newMessage);
-	if(!newMessage) {
+	if (!newMessage) {
 		LOG_ERROR << "Failed to generate outgoing message";
 		return nullptr;
 	}
@@ -157,7 +166,8 @@ message_ptr MediaHandlerElement::formOutgoingControlMessage(message_ptr message)
 	}
 }
 
-optional<ChainedOutgoingProduct> MediaHandlerElement::formOutgoingBinaryMessage(ChainedOutgoingProduct product) {
+optional<ChainedOutgoingProduct>
+MediaHandlerElement::formOutgoingBinaryMessage(ChainedOutgoingProduct product) {
 	assert(product.messages && !product.messages->empty());
 	auto newProduct = processOutgoingBinaryMessage(product.messages, product.control);
 	assert(!product.control || newProduct.control);
@@ -177,7 +187,8 @@ optional<ChainedOutgoingProduct> MediaHandlerElement::formOutgoingBinaryMessage(
 	}
 }
 
-ChainedIncomingControlProduct MediaHandlerElement::processIncomingControlMessage(message_ptr messages) {
+ChainedIncomingControlProduct
+MediaHandlerElement::processIncomingControlMessage(message_ptr messages) {
 	return {messages};
 }
 
@@ -185,15 +196,19 @@ message_ptr MediaHandlerElement::processOutgoingControlMessage(message_ptr messa
 	return messages;
 }
 
-ChainedIncomingProduct MediaHandlerElement::processIncomingBinaryMessage(ChainedMessagesProduct messages) {
+ChainedIncomingProduct
+MediaHandlerElement::processIncomingBinaryMessage(ChainedMessagesProduct messages) {
 	return {messages};
 }
 
-ChainedOutgoingProduct MediaHandlerElement::processOutgoingBinaryMessage(ChainedMessagesProduct messages, message_ptr control) {
+ChainedOutgoingProduct
+MediaHandlerElement::processOutgoingBinaryMessage(ChainedMessagesProduct messages,
+                                                  message_ptr control) {
 	return {messages, control};
 }
 
-shared_ptr<MediaHandlerElement> MediaHandlerElement::chainWith(shared_ptr<MediaHandlerElement> upstream) {
+shared_ptr<MediaHandlerElement>
+MediaHandlerElement::chainWith(shared_ptr<MediaHandlerElement> upstream) {
 	assert(this->upstream == nullptr);
 	assert(upstream->downstream == nullptr);
 	this->upstream = upstream;

+ 18 - 17
src/nalunit.cpp

@@ -27,8 +27,8 @@
 namespace rtc {
 
 NalUnitFragmentA::NalUnitFragmentA(FragmentType type, bool forbiddenBit, uint8_t nri,
-								   uint8_t unitType, binary data)
-: NalUnit(data.size() + 2) {
+                                   uint8_t unitType, binary data)
+    : NalUnit(data.size() + 2) {
 	setForbiddenBit(forbiddenBit);
 	setNRI(nri);
 	fragmentIndicator()->setUnitType(NalUnitFragmentA::nal_type_fu_A);
@@ -37,8 +37,8 @@ NalUnitFragmentA::NalUnitFragmentA(FragmentType type, bool forbiddenBit, uint8_t
 	copy(data.begin(), data.end(), begin() + 2);
 }
 
-std::vector<shared_ptr<NalUnitFragmentA>> NalUnitFragmentA::fragmentsFrom(shared_ptr<NalUnit> nalu,
-																			   uint16_t maximumFragmentSize) {
+std::vector<shared_ptr<NalUnitFragmentA>>
+NalUnitFragmentA::fragmentsFrom(shared_ptr<NalUnit> nalu, uint16_t maximumFragmentSize) {
 	assert(nalu->size() > maximumFragmentSize);
 	if (nalu->size() <= maximumFragmentSize) {
 		// we need to change `maximum_fragment_size` to have at least two fragments
@@ -69,7 +69,8 @@ std::vector<shared_ptr<NalUnitFragmentA>> NalUnitFragmentA::fragmentsFrom(shared
 			fragmentType = FragmentType::End;
 		}
 		fragmentData = {payload.begin() + offset, payload.begin() + offset + maximumFragmentSize};
-		auto fragment = std::make_shared<NalUnitFragmentA>(fragmentType, f, nri, naluType, fragmentData);
+		auto fragment =
+		    std::make_shared<NalUnitFragmentA>(fragmentType, f, nri, naluType, fragmentData);
 		result.push_back(fragment);
 		offset += maximumFragmentSize;
 	}
@@ -79,17 +80,17 @@ std::vector<shared_ptr<NalUnitFragmentA>> NalUnitFragmentA::fragmentsFrom(shared
 void NalUnitFragmentA::setFragmentType(FragmentType type) {
 	fragmentHeader()->setReservedBit6(false);
 	switch (type) {
-		case FragmentType::Start:
-			fragmentHeader()->setStart(true);
-			fragmentHeader()->setEnd(false);
-			break;
-		case FragmentType::End:
-			fragmentHeader()->setStart(false);
-			fragmentHeader()->setEnd(true);
-			break;
-		default:
-			fragmentHeader()->setStart(false);
-			fragmentHeader()->setEnd(false);
+	case FragmentType::Start:
+		fragmentHeader()->setStart(true);
+		fragmentHeader()->setEnd(false);
+		break;
+	case FragmentType::End:
+		fragmentHeader()->setStart(false);
+		fragmentHeader()->setEnd(true);
+		break;
+	default:
+		fragmentHeader()->setStart(false);
+		fragmentHeader()->setEnd(false);
 	}
 }
 
@@ -98,7 +99,7 @@ std::vector<shared_ptr<binary>> NalUnits::generateFragments(uint16_t maximumFrag
 	for (auto nalu : *this) {
 		if (nalu->size() > maximumFragmentSize) {
 			std::vector<shared_ptr<NalUnitFragmentA>> fragments =
-			NalUnitFragmentA::fragmentsFrom(nalu, maximumFragmentSize);
+			    NalUnitFragmentA::fragmentsFrom(nalu, maximumFragmentSize);
 			result.insert(result.end(), fragments.begin(), fragments.end());
 		} else {
 			result.push_back(nalu);

+ 1 - 1
src/opuspacketizationhandler.cpp

@@ -23,7 +23,7 @@
 namespace rtc {
 
 OpusPacketizationHandler::OpusPacketizationHandler(shared_ptr<OpusRtpPacketizer> packetizer)
-: MediaChainableHandler(packetizer) { }
+    : MediaChainableHandler(packetizer) {}
 
 } // namespace rtc
 

+ 5 - 3
src/opusrtppacketizer.cpp

@@ -25,17 +25,19 @@
 namespace rtc {
 
 OpusRtpPacketizer::OpusRtpPacketizer(shared_ptr<RtpPacketizationConfig> rtpConfig)
-: RtpPacketizer(rtpConfig), MediaHandlerRootElement() {}
+    : RtpPacketizer(rtpConfig), MediaHandlerRootElement() {}
 
 binary_ptr OpusRtpPacketizer::packetize(binary_ptr payload, [[maybe_unused]] bool setMark) {
 	assert(!setMark);
 	return RtpPacketizer::packetize(payload, false);
 }
 
-ChainedOutgoingProduct OpusRtpPacketizer::processOutgoingBinaryMessage(ChainedMessagesProduct messages, message_ptr control) {
+ChainedOutgoingProduct
+OpusRtpPacketizer::processOutgoingBinaryMessage(ChainedMessagesProduct messages,
+                                                message_ptr control) {
 	ChainedMessagesProduct packets = make_chained_messages_product();
 	packets->reserve(messages->size());
-	for (auto message: *messages) {
+	for (auto message : *messages) {
 		packets->push_back(packetize(message, false));
 	}
 	return {packets, control};

+ 18 - 11
src/rtcpnackresponder.cpp

@@ -26,19 +26,21 @@
 
 namespace rtc {
 
-RtcpNackResponder::Storage::Element::Element(binary_ptr packet, uint16_t sequenceNumber, shared_ptr<Element> next)
-: packet(packet), sequenceNumber(sequenceNumber), next(next) { }
+RtcpNackResponder::Storage::Element::Element(binary_ptr packet, uint16_t sequenceNumber,
+                                             shared_ptr<Element> next)
+    : packet(packet), sequenceNumber(sequenceNumber), next(next) {}
 
 unsigned RtcpNackResponder::Storage::size() { return storage.size(); }
 
-RtcpNackResponder::Storage::Storage(unsigned _maximumSize): maximumSize(_maximumSize) {
+RtcpNackResponder::Storage::Storage(unsigned _maximumSize) : maximumSize(_maximumSize) {
 	assert(maximumSize > 0);
 	storage.reserve(maximumSize);
 }
 
 optional<binary_ptr> RtcpNackResponder::Storage::get(uint16_t sequenceNumber) {
 	auto position = storage.find(sequenceNumber);
-	return position != storage.end() ? std::make_optional(storage.at(sequenceNumber)->packet) : nullopt;
+	return position != storage.end() ? std::make_optional(storage.at(sequenceNumber)->packet)
+	                                 : nullopt;
 }
 
 void RtcpNackResponder::Storage::store(binary_ptr packet) {
@@ -71,9 +73,10 @@ void RtcpNackResponder::Storage::store(binary_ptr packet) {
 }
 
 RtcpNackResponder::RtcpNackResponder(unsigned maxStoredPacketCount)
-: MediaHandlerElement(), storage(std::make_shared<Storage>(maxStoredPacketCount)) { }
+    : MediaHandlerElement(), storage(std::make_shared<Storage>(maxStoredPacketCount)) {}
 
-ChainedIncomingControlProduct RtcpNackResponder::processIncomingControlMessage(message_ptr message) {
+ChainedIncomingControlProduct
+RtcpNackResponder::processIncomingControlMessage(message_ptr message) {
 	optional<ChainedOutgoingProduct> optPackets = ChainedOutgoingProduct(nullptr);
 	auto packets = make_chained_messages_product();
 
@@ -89,13 +92,15 @@ ChainedIncomingControlProduct RtcpNackResponder::processIncomingControlMessage(m
 		auto fieldsCount = nack->getSeqNoCount();
 
 		std::vector<uint16_t> missingSequenceNumbers{};
-		for(unsigned int i = 0; i < fieldsCount; i++) {
+		for (unsigned int i = 0; i < fieldsCount; i++) {
 			auto field = nack->parts[i];
 			auto newMissingSeqenceNumbers = field.getSequenceNumbers();
-			missingSequenceNumbers.insert(missingSequenceNumbers.end(), newMissingSeqenceNumbers.begin(), newMissingSeqenceNumbers.end());
+			missingSequenceNumbers.insert(missingSequenceNumbers.end(),
+			                              newMissingSeqenceNumbers.begin(),
+			                              newMissingSeqenceNumbers.end());
 		}
 		packets->reserve(packets->size() + missingSequenceNumbers.size());
-		for (auto sequenceNumber: missingSequenceNumbers) {
+		for (auto sequenceNumber : missingSequenceNumbers) {
 			auto optPacket = storage->get(sequenceNumber);
 			if (optPacket.has_value()) {
 				auto packet = optPacket.value();
@@ -111,8 +116,10 @@ ChainedIncomingControlProduct RtcpNackResponder::processIncomingControlMessage(m
 	}
 }
 
-ChainedOutgoingProduct RtcpNackResponder::processOutgoingBinaryMessage(ChainedMessagesProduct messages, message_ptr control) {
-	for (auto message: *messages) {
+ChainedOutgoingProduct
+RtcpNackResponder::processOutgoingBinaryMessage(ChainedMessagesProduct messages,
+                                                message_ptr control) {
+	for (auto message : *messages) {
 		storage->store(message);
 	}
 	return {messages, control};

+ 4 - 2
src/rtcpreceivingsession.cpp

@@ -37,8 +37,10 @@ namespace rtc {
 
 static impl::LogCounter COUNTER_BAD_RTP_HEADER(plog::warning, "Number of malformed RTP headers");
 static impl::LogCounter COUNTER_UNKNOWN_PPID(plog::warning, "Number of Unknown PPID messages");
-static impl::LogCounter COUNTER_BAD_NOTIF_LEN(plog::warning, "Number of Bad-Lengthed notifications");
-static impl::LogCounter COUNTER_BAD_SCTP_STATUS(plog::warning, "Number of unknown SCTP_STATUS errors");
+static impl::LogCounter COUNTER_BAD_NOTIF_LEN(plog::warning,
+                                              "Number of Bad-Lengthed notifications");
+static impl::LogCounter COUNTER_BAD_SCTP_STATUS(plog::warning,
+                                                "Number of unknown SCTP_STATUS errors");
 
 message_ptr RtcpReceivingSession::outgoing(message_ptr ptr) { return ptr; }
 

+ 6 - 5
src/rtcpsrreporter.cpp

@@ -20,12 +20,13 @@
 
 #include "rtcpsrreporter.hpp"
 
-#include <cmath>
 #include <cassert>
+#include <cmath>
 
 namespace rtc {
 
-ChainedOutgoingProduct RtcpSrReporter::processOutgoingBinaryMessage(ChainedMessagesProduct messages, message_ptr control) {
+ChainedOutgoingProduct RtcpSrReporter::processOutgoingBinaryMessage(ChainedMessagesProduct messages,
+                                                                    message_ptr control) {
 	if (needsToReport) {
 		auto timestamp = rtpConfig->timestamp;
 		auto sr = getSenderReport(timestamp);
@@ -36,7 +37,7 @@ ChainedOutgoingProduct RtcpSrReporter::processOutgoingBinaryMessage(ChainedMessa
 		}
 		needsToReport = false;
 	}
-	for (auto message: *messages) {
+	for (auto message : *messages) {
 		auto rtp = reinterpret_cast<RTP *>(message->data());
 		addToReport(rtp, message->size());
 	}
@@ -55,7 +56,7 @@ void RtcpSrReporter::addToReport(RTP *rtp, uint32_t rtpSize) {
 }
 
 RtcpSrReporter::RtcpSrReporter(shared_ptr<RtpPacketizationConfig> rtpConfig)
-: MediaHandlerElement(), rtpConfig(rtpConfig) {}
+    : MediaHandlerElement(), rtpConfig(rtpConfig) {}
 
 uint64_t RtcpSrReporter::secondsToNTP(double seconds) {
 	return std::round(seconds * double(uint64_t(1) << 32));
@@ -66,7 +67,7 @@ void RtcpSrReporter::setNeedsToReport() { needsToReport = true; }
 message_ptr RtcpSrReporter::getSenderReport(uint32_t timestamp) {
 	auto srSize = RTCP_SR::Size(0);
 	auto msg = make_message(srSize + RTCP_SDES::Size({{uint8_t(rtpConfig->cname.size())}}),
-							Message::Type::Control);
+	                        Message::Type::Control);
 	auto sr = reinterpret_cast<RTCP_SR *>(msg->data());
 	auto timestamp_s = rtpConfig->timestampToSeconds(timestamp);
 	auto currentTime = timeOffset + timestamp_s;

+ 1 - 2
src/rtppacketizer.cpp

@@ -24,8 +24,7 @@
 
 namespace rtc {
 
-RtpPacketizer::RtpPacketizer(shared_ptr<RtpPacketizationConfig> rtpConfig)
-    : rtpConfig(rtpConfig) {}
+RtpPacketizer::RtpPacketizer(shared_ptr<RtpPacketizationConfig> rtpConfig) : rtpConfig(rtpConfig) {}
 
 binary_ptr RtpPacketizer::packetize(shared_ptr<binary> payload, bool setMark) {
 	auto msg = std::make_shared<binary>(rtpHeaderSize + payload->size());