7be8d59d07
Add mDNS/DNS-SD discovery and JSON session negotiation so two peers on a LAN connect without hard-coded addresses. - Discovery (Avahi threaded-poll client): the receiver announces _screencast._tcp with its signaling port; senders browse and resolve peers. Strict lock ordering (poll lock before state mutex) keeps the callbacks deadlock-free; name collisions rename via avahi_alternative_service_name. - Signaling: one JSON object per newline-terminated TCP line. The receiver hosts a server (port 5005) and answers session offers with its RTP port; senders connect, offer, and stream to the negotiated endpoint. WebSocket was deferred: no WS library is installed, the skill permits plain TCP, and the wire format is transport-agnostic. - Dual-stack transports: this machine resolves its own services over IPv6, so getaddrinfo now runs AF_UNSPEC and listeners bind IPv6 with IPV6_V6ONLY=0 (IPv4 fallback), covering UDP and TCP alike. The signaling client shutdown now uses shutdown() so a reader blocked in recv() cannot hang the join (a plain close() does not wake it). - CLI: --discover lists receivers (deduped to one entry per host); --send auto-disovers when exactly one receiver is found; --peer targets a receiver directly; --signaling-port overrides the default. Validation: meson test 5/5 (new signaling round-trip test), valgrind clean. End-to-end over loopback: --discover finds the announced receiver, a probe negotiated a session and streamed 60 frames over both IPv4 and IPv6, and the receiver reported stream started. mDNS resolution was verified against avahi-browse as an independent reference.
62 lines
1.5 KiB
C++
62 lines
1.5 KiB
C++
#pragma once
|
|
|
|
#include "screencast/capture/capture.h"
|
|
#include "screencast/codec/decoder.h"
|
|
#include "screencast/codec/encoder.h"
|
|
#include "screencast/network/transport.h"
|
|
#include "screencast/render/renderer.h"
|
|
|
|
#include <memory>
|
|
#include <optional>
|
|
|
|
namespace sc {
|
|
|
|
struct SenderPipelineConfig {
|
|
CaptureTarget capture_target;
|
|
EncoderConfig encoder;
|
|
Endpoint local_rtp_endpoint;
|
|
std::optional<Endpoint> signaling_server;
|
|
// Where encoded RTP packets are sent. Defaults to the local loopback so
|
|
// a sender and receiver on one machine work without any configuration.
|
|
Endpoint peer_rtp_endpoint{"127.0.0.1", 5004};
|
|
};
|
|
|
|
struct ReceiverPipelineConfig {
|
|
DecoderConfig decoder;
|
|
Endpoint local_rtp_endpoint;
|
|
std::optional<Endpoint> peer_signaling;
|
|
RendererConfig renderer;
|
|
// TCP port the signaling server listens on (offers arrive here).
|
|
std::uint16_t signaling_port = 5005;
|
|
};
|
|
|
|
// Sender pipeline: capture → encode → packetize → RTP/UDP.
|
|
class SenderPipeline {
|
|
public:
|
|
explicit SenderPipeline(SenderPipelineConfig config);
|
|
~SenderPipeline();
|
|
|
|
bool start();
|
|
void stop();
|
|
|
|
private:
|
|
class Impl;
|
|
std::unique_ptr<Impl> impl_;
|
|
};
|
|
|
|
// Receiver pipeline: RTP/UDP → depacketize → decode → render.
|
|
class ReceiverPipeline {
|
|
public:
|
|
explicit ReceiverPipeline(ReceiverPipelineConfig config);
|
|
~ReceiverPipeline();
|
|
|
|
bool start();
|
|
void stop();
|
|
|
|
private:
|
|
class Impl;
|
|
std::unique_ptr<Impl> impl_;
|
|
};
|
|
|
|
} // namespace sc
|