e82e7853d1
Three changes to make the stream survive constrained links: Adaptive quality: the sender pipeline now tracks the PLI rate from the receiver. Every 5 seconds it evaluates: >0.5 PLI/s means the link is saturated (the receiver is dropping frames), so the CRF increases by 2 (lower quality, fewer bits) and the encoder restarts with a keyframe. <0.1 PLI/s means the link is stable, so the CRF decreases by 1 (better quality) and the encoder probes upward. Clamped to [user CRF, user CRF + 10] so quality never degrades below what the link can handle, and never exceeds what the user asked for. The adaptation is logged to stderr for visibility. Frame rate capping (--fps N): throttles the capture loop to N frames per second (0 = no cap; monitor rate). At 15fps instead of 60fps, the bandwidth requirement drops 4x at the same quality level. Desktop content is still smooth at 15-20fps. Tighter VBV: one frame period of buffer instead of two. A two-frame buffer lets a keyframe spike to twice the target rate in one burst, which overflows any constrained hop (Wi-Fi hotspot, slow switch) and cascades into PLI storms. One frame period keeps bursts within what the link can absorb in real time.
42 lines
1.2 KiB
C++
42 lines
1.2 KiB
C++
#pragma once
|
|
|
|
#include <cstdint>
|
|
#include <optional>
|
|
#include <string_view>
|
|
#include <variant>
|
|
|
|
namespace sc {
|
|
|
|
struct SendCommand {
|
|
std::string_view target = "monitor"; // monitor, window
|
|
std::string_view peer_address; // optional; empty means auto-discover
|
|
int bitrate_kbps = 4000; // VBV max bitrate
|
|
int crf = 22; // constant rate factor (quality)
|
|
int fps = 0; // 0 = no cap (capture rate)
|
|
};
|
|
|
|
struct ReceiveCommand {
|
|
std::string_view peer_address; // optional, informational
|
|
int local_rtp_port = 5004;
|
|
int signaling_port = 5005;
|
|
bool fullscreen = false;
|
|
bool software_decode = false; // --swdecode disables the hardware probe
|
|
};
|
|
|
|
struct DiscoverCommand {
|
|
int timeout_seconds = 3;
|
|
};
|
|
|
|
struct WaybarCommand {
|
|
bool toggle = false; // toggle streaming instead of printing status
|
|
};
|
|
|
|
using Command = std::variant<SendCommand, ReceiveCommand, DiscoverCommand, WaybarCommand>;
|
|
|
|
// Parse command line arguments. Prints usage and returns std::nullopt on error.
|
|
// `argv` is `char const* const*` so both `main`'s `char**` and const arrays
|
|
// convert implicitly.
|
|
std::optional<Command> parse_cli(int argc, const char* const argv[]);
|
|
|
|
} // namespace sc
|