Merge the development branch: decoders, watching from the channel list

Both sides kept. From the development branch: FFmpeg's decoders at
runtime (hardware first, then software, then built-in) with the settings
stream.hardware_decoding and stream.decoder_backend, applied to the
video when they change, and watching a streaming user's stream from the
channel list, their dialog and the member card.

video.rs keeps set_decoder_preference and leaves out encoder_report:
the Integrations page asks a copy of the codecs for the report on a
thread of its own (FFmpeg's probe can take a while), not on the UI
thread.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
selikhovandClaude Opus 5.5 committed 2026-10-04 03:33:33 +03:00
commit 87c8d6c686
37 files changed
+2839 -158

No files matched your search

+12 -2
View File
@@ -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,
@@ -414,6 +417,9 @@ pub(crate) struct App {
pub share_error: String,
/// The stream in the viewer.
pub watch: Option<Watch>,
/// A client whose stream was asked for before it was known (session,
/// client): watched when the lookup brings it.
pub pending_watch: Option<(i64, u16)>,
/// Stream volume in percent, kept between streams.
pub stream_volume: f32,
/// `VOELIN_DEMO_STREAM`: the viewer shows a local test stream.
@@ -592,7 +598,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(),
@@ -624,6 +631,7 @@ pub fn run(options: RunOptions) -> Result<()> {
share_busy: false,
share_error: String::new(),
watch: None,
pending_watch: None,
stream_volume: 100.0,
demo: switches.demo_stream,
demo_ui: switches.demo_ui,
@@ -776,6 +784,8 @@ impl App {
} else if key == voelin_core::settings::STREAM_AUDIO_SOURCES.name() {
// A running share mixes the new sources (streams.rs).
self.share_audio_changed();
} else if key == STREAM_HARDWARE_DECODING.name() || key == STREAM_DECODER_BACKEND.name() {
self.video.set_decoder_preference(decoder_preference(&self.prefs));
}
self.page_setting_changed(key);
}
+5
View File
@@ -22,6 +22,11 @@ pub(super) fn wire(ui: &MainWindow) {
bridge.on_watch_stream(|id| {
with_app(|app| app.watch_stream(id.to_string()));
});
bridge.on_watch_client(|client| {
if let Ok(client) = u16::try_from(client) {
with_app(|app| app.watch_client(client));
}
});
bridge.on_show_viewer(|| {
with_app(|app| app.show_viewer(true));
});
+5
View File
@@ -70,6 +70,7 @@ impl App {
volume: playback.volume * 100.0,
muted: playback.muted,
known: uid.is_some(),
streaming: client.streaming == Some(true),
})
})
.unwrap_or_default();
@@ -91,6 +92,10 @@ impl App {
self.open_member(-1);
}
}
"watch" => {
self.open_member(-1);
self.watch_client(client_id);
}
"poke" => {
self.command(|session| Command::Poke {
session,
+1
View File
@@ -207,6 +207,7 @@ impl App {
name: info.nickname.into(),
volume: playback.volume * 100.0,
muted: playback.muted,
streaming: info.streaming == Some(true),
});
}
true
+31 -1
View File
@@ -179,10 +179,19 @@ impl App {
.iter()
.find(|s| view.state.own_client != Some(s.streamer.0))
.map(|s| s.id.clone());
// A client whose stream was asked for while it was looked up.
let pending = self
.pending_watch
.filter(|(s, _)| *s == session as i64)
.and_then(|(_, client)| streams.iter().find(|s| s.streamer.0 == client))
.map(|s| s.id.clone());
view.streams = streams;
self.refresh_streams();
self.refresh_servers();
if autowatch && let Some(id) = first {
if let Some(id) = pending {
self.pending_watch = None;
self.watch_stream(id);
} else if autowatch && let Some(id) = first {
self.watch_stream(id);
}
}
@@ -763,6 +772,27 @@ impl App {
self.refresh_tree();
}
/// Watch the stream of `client` (a click on a streaming user in the
/// channel tree or the members): at once if it is known, else as soon as
/// the lookup brings it (it may have started in another channel or
/// before we joined).
pub(crate) fn watch_client(&mut self, client: u16) {
let Some(session) = self.current else { return };
let Some(view) = self.sessions.get(&session) else { return };
if view.state.own_client == Some(client) {
return;
}
if let Some(id) = view.streams.iter().find(|s| s.streamer.0 == client).map(|s| s.id.clone())
{
self.pending_watch = None;
self.watch_stream(id);
} else if view.presence.clients.get(&client).is_some_and(|c| c.streaming == Some(true)) {
let name = view.nickname(client);
self.pending_watch = Some((session, client));
self.set_status(format!("Looking up {name}'s stream…"));
}
}
/// `VOELIN_OPEN=watch`: watch the first stream of our channel.
pub(crate) fn watch_first_stream(&mut self) {
let Some(id) = self.view().and_then(|v| {
+30 -7
View File
@@ -13,8 +13,8 @@ use tracing::warn;
use voelin_core::media::voelin_media::capture::{CaptureSource, SourceId};
use voelin_core::media::voelin_media::{Codec, Codecs, VideoFrame, convert};
use voelin_core::media::{
self, AudioSourceSpec, EncoderPreference, Latest, LocalPreview, Streamer, StreamerConfig,
StreamerConfigUpdate, Viewer, peer_config, preferred_codec, stream_codec,
self, AudioSourceSpec, DecoderPreference, EncoderPreference, Latest, LocalPreview, Streamer,
StreamerConfig, StreamerConfigUpdate, Viewer, peer_config, preferred_codec, stream_codec,
};
use voelin_core::stream::{LayerSpec, PeerConfig};
use voelin_core::studio::Studio;
@@ -62,6 +62,9 @@ pub(crate) struct Video {
/// automatic), from the settings.
encoder: EncoderPreference,
codec: Option<Codec>,
/// Which decoders to use (`stream.hardware_decoding`,
/// `stream.decoder_backend`).
decoder: DecoderPreference,
/// Sources of the share dialog, by index.
sources: Vec<ShareEntry>,
}
@@ -75,6 +78,7 @@ impl Video {
codecs: Arc::new(Codecs::new()),
encoder: EncoderPreference::default(),
codec: None,
decoder: DecoderPreference::default(),
#[cfg(not(target_os = "android"))]
openh264_dir: data_dir.join("openh264"),
#[cfg(not(target_os = "android"))]
@@ -107,6 +111,17 @@ impl Video {
self.codec = codec;
}
/// Decode with other decoders (`stream.hardware_decoding`,
/// `stream.decoder_backend`): streams watched from now on.
pub fn set_decoder_preference(&mut self, decoder: DecoderPreference) {
if decoder != self.decoder {
let mut codecs = (*self.codecs).clone();
codecs.set_decoder_preference(decoder.clone());
self.codecs = Arc::new(codecs);
self.decoder = decoder;
}
}
/// Whether H.264 works, and a line for the settings page.
pub fn h264_status(&self) -> (bool, String) {
#[cfg(target_os = "android")]
@@ -133,7 +148,11 @@ impl Video {
use openh264::State;
if !enabled {
self.h264 = State::Off;
self.codecs = Arc::new(Codecs::new().with_preference(self.encoder.clone()));
self.codecs = Arc::new(
Codecs::new()
.with_preference(self.encoder.clone())
.with_decoder_preference(self.decoder.clone()),
);
return;
}
if matches!(self.h264, State::Loaded(_) | State::Downloading) {
@@ -149,8 +168,12 @@ impl Video {
#[cfg(not(target_os = "android"))]
fn loaded(&mut self, library: openh264::OpenH264) {
self.h264 = openh264::State::Loaded(library.path().to_owned());
self.codecs =
Arc::new(Codecs::new().with_openh264(library).with_preference(self.encoder.clone()));
self.codecs = Arc::new(
Codecs::new()
.with_openh264(library)
.with_preference(self.encoder.clone())
.with_decoder_preference(self.decoder.clone()),
);
}
/// Download Cisco's OpenH264 (only on the user's request). `done` runs
@@ -337,8 +360,8 @@ impl Video {
fn deliver(
pictures: Arc<Latest<Picture>>,
wake: impl Fn() + Send + Sync + 'static,
) -> impl FnMut(VideoFrame) + Send + 'static {
move |frame: VideoFrame| {
) -> impl FnMut(Arc<VideoFrame>) + Send + 'static {
move |frame: Arc<VideoFrame>| {
let mut buffer = Picture::new(frame.width, frame.height);
let stride = frame.width as usize * 4;
if let Err(e) = convert::to_rgba(&frame, buffer.make_mut_bytes(), stride) {