fix(state): add WebRTC support to wlr-screencopy backend
Fixes #1 -- --port mode with wlr-screencopy backend caused panic at negotiate_format() because self.args.output is None and .expect() was called unconditionally. Changes: - Introduce StreamingEncoder enum wrapping EncState (MP4) and SwEncState (WebRTC) with unified frames_rgb/encode_frame/flush API - Add WebRTC fields to State<S> (webrtc, webrtc_tx, webrtc_rx, webrtc_frames_sent) matching Portal backend pattern - State::new() returns Result<Self> for clean WebRtcState init failure - negotiate_format() branches on webrtc_tx: WebRTC path uses SwEncState::new_webrtc(), MP4 path unchanged (hardware VAAPI) - Add poll_webrtc() method to drive signaling + channel drain - Event loop calls poll_webrtc() each iteration - Fix pre-existing test/bench Args construction (Option<String> output, missing no_persist field)
This commit is contained in:
@@ -100,7 +100,7 @@ fn run_wlr_screencopy(args: Args) -> Result<()> {
|
||||
let qhandle = queue.handle();
|
||||
// State 是 wlr-screencopy 后端的核心状态机,
|
||||
// 内部管理输出探测、截屏请求、编码器构建、帧采集等阶段
|
||||
let mut state = State::new(gm, args, qhandle);
|
||||
let mut state = State::new(gm, args, qhandle)?;
|
||||
|
||||
// Extract the Wayland fd and consume any immediately-available events.
|
||||
// prepare_read() flushes outgoing requests; read() pulls whatever the
|
||||
@@ -246,6 +246,8 @@ fn run_wlr_screencopy(args: Args) -> Result<()> {
|
||||
// - Streaming: 正常采集中,请求下一帧
|
||||
state.queue_alloc_frame();
|
||||
|
||||
state.poll_webrtc()?;
|
||||
|
||||
// 状态机遇到致命错误时退出
|
||||
if state.errored {
|
||||
tracing::error!("Fatal error in state machine, exiting");
|
||||
|
||||
Reference in New Issue
Block a user