Let a viewer pick the simulcast layer of a Voelin stream
The streamer chose each viewer's layer from its bandwidth estimate, and a
viewer could neither see which layers there were nor ask for one: the watch
screen's quality picker only asked for a keyframe.
A Voelin streamer with several layers now lists them in its offer, in a
session-level SDP attribute, `a=x-voelin-layers:<id>/<WxH or
scale>/<bitrate>[/<fps>] ...`, added to the SDP str0m makes (peer.rs is
untouched). A Voelin viewer reports them (WatchEvent::Layers,
Event::WatchLayers) and asks for one with Command::SetWatchLayer, which
sends `{"cmd":"x-voelin-layer","args":{"layer":<id or null>}}` through
streamsignaling. The streamer moves that viewer to the layer at its next
keyframe and keeps it there whatever the estimate says, without letting it
lower the layer's bitrate for everyone else; null ("Auto") hands the
choice back to the estimate. The watch screen's picker now drives it.
Official clients are not affected. libwebrtc skips session attributes it
does not know: headless Chromium 152 answers an offer carrying the line
and decodes as before (browser interop test, which now sends it). A viewer
sends the request only to a streamer whose offer had the attribute, and
only Voelin streamers add it, so official streamers never get the signal;
which codecs are offered does not change.
Tests: two sessions with peers on loopback switch the viewer to layer 1
and back on request; a streamer whose offer lists no layers is never
asked; the attribute round-trips. Through the TeamSpeak 6 dev server,
`voelinctl stream watch --layer 1` against a two-layer placeholder stream
kept the viewer on layer 1 at an estimate that fits layer 0.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
2159b38786
commit
8acf920369
13 files changed
+450
-19
No files matched your search
@@ -132,6 +132,10 @@ pub enum StreamCommand {
|
||||
/// Save the last decoded picture as PNG.
|
||||
#[arg(long)]
|
||||
save_frame: Option<PathBuf>,
|
||||
/// Ask for this simulcast layer (by id) once the streamer's offer
|
||||
/// lists its layers (Voelin streamers with several do).
|
||||
#[arg(long)]
|
||||
layer: Option<u16>,
|
||||
},
|
||||
}
|
||||
|
||||
@@ -281,8 +285,9 @@ pub async fn run(con: &mut Connection, args: &StreamArgs) -> Result<()> {
|
||||
StreamCommand::List { settle_ms } => {
|
||||
list(con, &mut driver, Duration::from_millis(*settle_ms)).await
|
||||
}
|
||||
StreamCommand::Watch { id, streamer_nick, expect_frames, timeout, save_frame } => {
|
||||
let target = Target { id: id.clone(), streamer_nick: streamer_nick.clone() };
|
||||
StreamCommand::Watch { id, streamer_nick, expect_frames, timeout, save_frame, layer } => {
|
||||
let target =
|
||||
Target { id: id.clone(), streamer_nick: streamer_nick.clone(), layer: *layer };
|
||||
let timeout = timeout.map(Duration::from_secs);
|
||||
let expect = *expect_frames;
|
||||
let save = save_frame.as_deref();
|
||||
@@ -727,6 +732,8 @@ async fn list(con: &mut Connection, driver: &mut Driver, settle: Duration) -> Re
|
||||
struct Target {
|
||||
id: Option<String>,
|
||||
streamer_nick: Option<String>,
|
||||
/// The simulcast layer to ask for.
|
||||
layer: Option<u16>,
|
||||
}
|
||||
|
||||
impl Target {
|
||||
@@ -859,6 +866,16 @@ async fn watch(
|
||||
}
|
||||
match event {
|
||||
WatchEvent::Accepted => println!("accepted, connecting"),
|
||||
WatchEvent::Layers(layers) => {
|
||||
println!(
|
||||
"layers offered: {:?}",
|
||||
layers.iter().map(|l| l.id).collect::<Vec<_>>()
|
||||
);
|
||||
if let Some(layer) = target.layer {
|
||||
driver.streams.set_watch_layer(&id, Some(layer))?;
|
||||
println!("asked for layer {layer}");
|
||||
}
|
||||
}
|
||||
WatchEvent::Connected => println!("connected"),
|
||||
WatchEvent::Frame(f) => {
|
||||
match f.kind {
|
||||
|
||||
Reference in new issue
Block a user