Fall back to the next decoder at runtime; recover from losses
A watched stream now decodes with the best decoder of its codec and, when it fails, with the next of the codec's ladder, without ending the watch: three failures in a row (errors, or ten frames without a picture) replace it, the keyframe that failed starts the next one at once, and otherwise a keyframe is asked for. Each switch is logged with its reason, and DecodeStats tells the decoder in use. The official client's H.264 has B-frames and rare keyframes, and the pipeline dropped every frame after a loss or an error until the next keyframe, which such an encoder seldom sends. Decoders that conceal what a loss leaves missing (FFmpeg's H.264 and HEVC) now go on decoding while a keyframe is asked for; the others still skip to it. Whenever one is wanted it is asked for again every half second until it comes, also while no frame arrives, instead of once per skipped frame. Pictures come from a small pool and go to the callback as Arc<VideoFrame>: decoders write into a free one (decode_into), and a consumer that converts and drops each picture, as the app does, costs no allocations. Settings stream.hardware_decoding and stream.decoder_backend choose the decoders like the encoder settings (decoder_preference); the app applies them when they change, to streams watched from then on. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
66a2b8329b
commit
289e7d4e6b
5 files changed
+404
-55
No files matched your search
@@ -17,7 +17,10 @@ use anyhow::{Context, Result};
|
||||
use slint::{ComponentHandle, ModelRc, VecModel};
|
||||
use tokio::runtime::Runtime;
|
||||
use tracing::warn;
|
||||
use voelin_core::settings::{AUDIO, CRASH_REPORTS, Settings};
|
||||
use voelin_core::media::decoder_preference;
|
||||
use voelin_core::settings::{
|
||||
AUDIO, CRASH_REPORTS, STREAM_DECODER_BACKEND, STREAM_HARDWARE_DECODING, Settings,
|
||||
};
|
||||
use voelin_core::stream::StreamInfo;
|
||||
use voelin_core::{
|
||||
AudioSettings, Command, Engine, Event, History, HistoryMessage, SessionState, VoiceState,
|
||||
@@ -559,7 +562,8 @@ pub fn run(options: RunOptions) -> Result<()> {
|
||||
if settings.global_ptt {
|
||||
ptt.set(Some(settings.ptt_key.clone()));
|
||||
}
|
||||
let video = Video::new(&dir, settings.openh264);
|
||||
let mut video = Video::new(&dir, settings.openh264);
|
||||
video.set_decoder_preference(decoder_preference(&prefs));
|
||||
let switches = crate::dev::Switches::from_env();
|
||||
let app = App {
|
||||
ui: ui.as_weak(),
|
||||
@@ -730,6 +734,8 @@ impl App {
|
||||
self.playback = self.prefs.get(&CLIENT_PLAYBACK);
|
||||
} else if appearance_keys().iter().any(|k| k.name() == key) {
|
||||
self.apply_appearance();
|
||||
} else if key == STREAM_HARDWARE_DECODING.name() || key == STREAM_DECODER_BACKEND.name() {
|
||||
self.video.set_decoder_preference(decoder_preference(&self.prefs));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user