#pragma once #include "screencast/network/error.h" #include "screencast/network/transport.h" #include #include #include #include #include namespace sc { // JSON-based control messages exchanged before or during a session. The wire // format is one JSON object per newline-terminated TCP line; a WebSocket // transport can replace TCP in a later phase without changing these types. struct SessionOffer { std::string session_id; std::string codec_name; int width = 0; // informational; the stream carries its own SPS/PPS int height = 0; int frame_rate_num = 30; int frame_rate_den = 1; Endpoint rtp_endpoint; // unused by the receiver; kept for symmetry }; struct SessionAnswer { std::string session_id; // The address may be empty: the sender then targets the address of its // signaling connection and the port carried here. Endpoint rtp_endpoint; }; // Picture Loss Indication: the receiver asks the sender for a keyframe // after discarding a damaged frame. struct SessionPli { std::string session_id; }; using SignalingMessage = std::variant; class SignalingChannel { public: using MessageCallback = std::function; virtual ~SignalingChannel() = default; // Client channels connect to a receiver's signaling server. 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: // A client channel that connects to a receiver's signaling server. static NetworkResult> create_client(); // A server channel listening on the given port; it keeps the most // recent connection as its active peer. static NetworkResult> create_server(uint16_t port); }; } // namespace sc