Scaffold C++20 screencast project with Meson, agent workflow, and phase plan

This commit is contained in:
2026-08-28 21:54:32 +02:00
commit 742611b841
25 changed files with 1322 additions and 0 deletions
+35
View File
@@ -0,0 +1,35 @@
#pragma once
#include <functional>
#include <memory>
#include <string>
namespace sc {
struct DiscoveredPeer {
std::string service_name;
std::string host;
uint16_t signaling_port = 0;
};
class DiscoveryService {
public:
using PeerCallback = std::function<void ( const DiscoveredPeer & )>;
virtual ~DiscoveryService () = default;
// Announce this peer on the LAN.
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 void stop () = 0;
};
class DiscoveryFactory {
public:
static std::unique_ptr<DiscoveryService> create_avahi ();
};
} // namespace sc
+33
View File
@@ -0,0 +1,33 @@
#pragma once
#include <cstdint>
#include <span>
#include <vector>
namespace sc {
// Minimal RTP header (RFC 3550) without extensions.
struct RtpHeader {
uint8_t version = 2;
bool padding = false;
bool extension = false;
uint8_t csrc_count = 0;
bool marker = false;
uint7_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;
};
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;
};
} // namespace sc
+47
View File
@@ -0,0 +1,47 @@
#pragma once
#include "screencast/network/transport.h"
#include <functional>
#include <memory>
#include <string>
namespace sc {
// JSON-based control messages exchanged before or during a session.
struct SessionOffer {
std::string session_id;
std::string codec_name;
int width = 0;
int height = 0;
int frame_rate_num = 30;
int frame_rate_den = 1;
Endpoint rtp_endpoint;
};
struct SessionAnswer {
std::string session_id;
Endpoint rtp_endpoint;
};
using SignalingMessage = std::variant<SessionOffer, SessionAnswer>;
class SignalingChannel {
public:
using MessageCallback = std::function<void ( const SignalingMessage & )>;
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;
};
class SignalingFactory {
public:
static std::unique_ptr<SignalingChannel> create_websocket_client ();
static std::unique_ptr<SignalingChannel> create_websocket_server ( uint16_t port );
};
} // namespace sc
+43
View File
@@ -0,0 +1,43 @@
#pragma once
#include "screencast/network/rtp_packet.h"
#include <cstdint>
#include <functional>
#include <memory>
#include <string>
namespace sc {
struct Endpoint {
std::string address;
uint16_t port = 0;
};
// UDP transport for RTP packets. Owned by the sender or receiver pipeline.
class RtpTransport {
public:
using ReceiveCallback = std::function<void ( RtpPacket )>;
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;
// Send a packet to the configured peer.
virtual bool send ( const RtpPacket &packet ) = 0;
// Set the peer endpoint dynamically (e.g. after signaling).
virtual void set_peer ( const Endpoint &peer ) = 0;
// Stop the transport and close sockets.
virtual void stop () = 0;
};
class RtpTransportFactory {
public:
static std::unique_ptr<RtpTransport> create ();
};
} // namespace sc