style: add clang-format config and reformat scaffolding files

This commit is contained in:
2026-09-07 10:07:26 +02:00
parent 975e3b2974
commit 50369995c7
12 changed files with 100 additions and 64 deletions
+8 -7
View File
@@ -1,5 +1,6 @@
#pragma once
#include <cstdint>
#include <functional>
#include <memory>
#include <string>
@@ -14,22 +15,22 @@ struct DiscoveredPeer {
class DiscoveryService {
public:
using PeerCallback = std::function<void ( const DiscoveredPeer & )>;
using PeerCallback = std::function<void(const DiscoveredPeer&)>;
virtual ~DiscoveryService () = default;
virtual ~DiscoveryService() = default;
// Announce this peer on the LAN.
virtual bool announce ( const std::string &service_name, uint16_t signaling_port ) = 0;
virtual bool announce(const std::string& service_name, uint16_t signaling_port) = 0;
// Browse for peers; callback is invoked for each newly found service.
virtual bool browse ( PeerCallback on_peer ) = 0;
virtual bool browse(PeerCallback on_peer) = 0;
virtual void stop () = 0;
virtual void stop() = 0;
};
class DiscoveryFactory {
public:
static std::unique_ptr<DiscoveryService> create_avahi ();
static std::unique_ptr<DiscoveryService> create_avahi();
};
} // namespace sc
} // namespace sc
+7 -6
View File
@@ -1,6 +1,7 @@
#pragma once
#include <cstdint>
#include <optional>
#include <span>
#include <vector>
@@ -13,21 +14,21 @@ struct RtpHeader {
bool extension = false;
uint8_t csrc_count = 0;
bool marker = false;
uint7_t payload_type = 96; // dynamic
uint8_t payload_type = 96; // dynamic
uint16_t sequence_number = 0;
uint32_t timestamp = 0;
uint32_t ssrc = 0;
bool serialize ( std::span<std::byte, 12> out ) const noexcept;
static std::optional<RtpHeader> parse ( std::span<const std::byte, 12> in ) noexcept;
bool serialize(std::span<std::byte, 12> out) const noexcept;
static std::optional<RtpHeader> parse(std::span<const std::byte, 12> in) noexcept;
};
struct RtpPacket {
RtpHeader header;
std::vector<std::byte> payload;
std::vector<std::byte> serialize () const;
static std::optional<RtpPacket> parse ( std::span<const std::byte> in ) noexcept;
std::vector<std::byte> serialize() const;
static std::optional<RtpPacket> parse(std::span<const std::byte> in) noexcept;
};
} // namespace sc
} // namespace sc
+11 -9
View File
@@ -2,9 +2,11 @@
#include "screencast/network/transport.h"
#include <cstdint>
#include <functional>
#include <memory>
#include <string>
#include <variant>
namespace sc {
@@ -28,20 +30,20 @@ using SignalingMessage = std::variant<SessionOffer, SessionAnswer>;
class SignalingChannel {
public:
using MessageCallback = std::function<void ( const SignalingMessage & )>;
using MessageCallback = std::function<void(const SignalingMessage&)>;
virtual ~SignalingChannel () = default;
virtual ~SignalingChannel() = default;
virtual bool connect ( const Endpoint &server ) = 0;
virtual void send ( const SignalingMessage &message ) = 0;
virtual void on_message ( MessageCallback callback ) = 0;
virtual void disconnect () = 0;
virtual bool connect(const Endpoint& server) = 0;
virtual void send(const SignalingMessage& message) = 0;
virtual void on_message(MessageCallback callback) = 0;
virtual void disconnect() = 0;
};
class SignalingFactory {
public:
static std::unique_ptr<SignalingChannel> create_websocket_client ();
static std::unique_ptr<SignalingChannel> create_websocket_server ( uint16_t port );
static std::unique_ptr<SignalingChannel> create_websocket_client();
static std::unique_ptr<SignalingChannel> create_websocket_server(uint16_t port);
};
} // namespace sc
} // namespace sc
+8 -8
View File
@@ -17,27 +17,27 @@ struct Endpoint {
// UDP transport for RTP packets. Owned by the sender or receiver pipeline.
class RtpTransport {
public:
using ReceiveCallback = std::function<void ( RtpPacket )>;
using ReceiveCallback = std::function<void(RtpPacket)>;
virtual ~RtpTransport () = default;
virtual ~RtpTransport() = default;
// Bind locally and start the receive loop. Callback is invoked on the
// transport's thread.
virtual bool start ( const Endpoint &local_endpoint, ReceiveCallback on_receive ) = 0;
virtual bool start(const Endpoint& local_endpoint, ReceiveCallback on_receive) = 0;
// Send a packet to the configured peer.
virtual bool send ( const RtpPacket &packet ) = 0;
virtual bool send(const RtpPacket& packet) = 0;
// Set the peer endpoint dynamically (e.g. after signaling).
virtual void set_peer ( const Endpoint &peer ) = 0;
virtual void set_peer(const Endpoint& peer) = 0;
// Stop the transport and close sockets.
virtual void stop () = 0;
virtual void stop() = 0;
};
class RtpTransportFactory {
public:
static std::unique_ptr<RtpTransport> create ();
static std::unique_ptr<RtpTransport> create();
};
} // namespace sc
} // namespace sc