30538fba73
Two quality improvements: Preset: ultrafast -> veryfast. Unlocks Main profile with CABAC entropy coding, hexagonal motion search, 3 reference frames, and adaptive quantization — typically 30-40% better quality at the same bitrate. The desktop handles the extra encoding cost trivially (150+ fps at 1080p). Downscaling: the receiver now advertises its display resolution in the signaling answer (display_width/display_height, 0 = unknown). When the capture exceeds the display (e.g. 2256x1504 source on a 1920x1080 receiver), the sender scales down preserving aspect ratio before encoding — the same sws_scale pass that already converts the pixel format also handles the resolution change, so there is no extra step. This concentrates the entire bitrate into pixels the display actually shows (~2.7x more bits per visible pixel at 4000 kbps when going from 2256x1504 to 1620x1080). The renderer caches the display size during window creation (native monitor resolution in fullscreen/KMSDRM; window size otherwise). The receiver includes it in every signaling answer; the sender pipeline computes aspect-preserving, even-rounded scaled dimensions when the display is smaller than the capture. meson test 5/5 in both configurations, valgrind clean.
45 lines
1.2 KiB
C++
45 lines
1.2 KiB
C++
#pragma once
|
|
|
|
#include "screencast/codec/decoder.h"
|
|
#include "screencast/render/error.h"
|
|
|
|
#include <memory>
|
|
#include <string>
|
|
|
|
namespace sc {
|
|
|
|
struct RendererConfig {
|
|
std::string window_title = "screencast receiver";
|
|
int initial_width = 1280;
|
|
int initial_height = 720;
|
|
// Borderless fullscreen. On the headless KMSDRM backend (no window
|
|
// manager) fullscreen is enabled automatically.
|
|
bool fullscreen = false;
|
|
};
|
|
|
|
class Renderer {
|
|
public:
|
|
virtual ~Renderer() = default;
|
|
|
|
// Present one decoded frame. Returns false if the window was closed.
|
|
virtual bool present(const DecodedFrame& frame) = 0;
|
|
|
|
// The display resolution (native monitor size in fullscreen mode).
|
|
// Used by the receiver to tell the sender what resolution to encode at.
|
|
virtual int display_width() const = 0;
|
|
virtual int display_height() const = 0;
|
|
|
|
// Pump events (window close, resize). Non-blocking.
|
|
virtual bool poll_events() = 0;
|
|
|
|
// Destroy the window and release GPU resources.
|
|
virtual void shutdown() = 0;
|
|
};
|
|
|
|
class RendererFactory {
|
|
public:
|
|
static RendererResult<std::unique_ptr<Renderer>> create(const RendererConfig& config);
|
|
};
|
|
|
|
} // namespace sc
|