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

Brings the FFmpeg decoder ladder and watching a streaming user's stream
from the channel list. app.rs kept both sides: the identity import
before the identity is chosen (with the development switches read
there) and the video's decoder preference from the settings.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
selikhovandClaude Opus 5.5 committed 2026-10-04 03:19:46 +03:00
commit 599c55fda6
37 files changed
+2842 -159

No files matched your search

+13 -2
View File
@@ -17,7 +17,11 @@ use anyhow::{Context, Result};
use slint::{ComponentHandle, ModelRc, VecModel};
use tokio::runtime::Runtime;
use tracing::warn;
use voelin_core::settings::{AUDIO, CRASH_REPORTS, IDENTITY_IMPORT, Settings};
use voelin_core::media::decoder_preference;
use voelin_core::settings::{
AUDIO, CRASH_REPORTS, IDENTITY_IMPORT, STREAM_DECODER_BACKEND, STREAM_HARDWARE_DECODING,
Settings,
};
use voelin_core::stream::StreamInfo;
use voelin_core::{
AudioSettings, Command, Engine, Event, History, HistoryMessage, SessionState, VoiceState,
@@ -388,6 +392,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.
@@ -576,7 +583,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 app = App {
ui: ui.as_weak(),
store,
@@ -608,6 +616,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,
@@ -754,6 +763,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));
}
}
+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| {
+32 -8
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, EncoderReport, 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"))]
@@ -108,7 +112,19 @@ impl Video {
self.codec = codec;
}
/// Every encoder backend, what works and why the rest does not.
/// 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;
}
}
/// Every encoder and decoder backend, what works and why the rest does
/// not.
#[allow(dead_code, reason = "for the integrations page")]
pub fn encoder_report(&self) -> EncoderReport {
self.codecs.report()
@@ -140,7 +156,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) {
@@ -156,8 +176,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
@@ -344,8 +368,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) {