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
f2ffd761fc
commit
8d14b0d5be
13 files changed
+450
-19
No files matched your search
@@ -243,6 +243,14 @@ pub enum Command {
|
||||
session: SessionId,
|
||||
stream_id: String,
|
||||
},
|
||||
/// Watch simulcast layer `layer` of a stream (`None`: as the bandwidth
|
||||
/// allows). Only for a stream whose [`Event::WatchLayers`] listed
|
||||
/// layers; otherwise an [`Event::Error`].
|
||||
SetWatchLayer {
|
||||
session: SessionId,
|
||||
stream_id: String,
|
||||
layer: Option<LayerId>,
|
||||
},
|
||||
/// Playback volume of a watched stream's audio, linear (1 = unchanged,
|
||||
/// up to 4).
|
||||
SetStreamVolume {
|
||||
@@ -552,6 +560,15 @@ pub enum Event {
|
||||
stream_id: String,
|
||||
state: WatchState,
|
||||
},
|
||||
/// The simulcast layers a watched stream offers (a Voelin streamer with
|
||||
/// several lists them; empty: none to choose from), and the one we asked
|
||||
/// for with [`Command::SetWatchLayer`] (`None`: as the bandwidth allows).
|
||||
WatchLayers {
|
||||
session: SessionId,
|
||||
stream_id: String,
|
||||
layers: Vec<LayerSpec>,
|
||||
layer: Option<LayerId>,
|
||||
},
|
||||
/// A setting was set or reset (by anyone: a command, the UI through
|
||||
/// [`Engine::settings`], …). Read the new value from the settings.
|
||||
SettingChanged {
|
||||
@@ -944,6 +961,7 @@ fn command_session(command: &Command) -> SessionId {
|
||||
| Command::WatchStream { session, .. }
|
||||
| Command::LeaveStream { session, .. }
|
||||
| Command::RequestStreamKeyframe { session, .. }
|
||||
| Command::SetWatchLayer { session, .. }
|
||||
| Command::SetStreamVolume { session, .. }
|
||||
| Command::SetClientVolume { session, .. }
|
||||
| Command::SetClientMuted { session, .. }
|
||||
|
||||
@@ -463,6 +463,9 @@ impl Session {
|
||||
Command::RequestStreamKeyframe { stream_id, .. } => {
|
||||
self.stream_input(StreamInput::RequestKeyframe { stream_id });
|
||||
}
|
||||
Command::SetWatchLayer { stream_id, layer, .. } => {
|
||||
self.stream_input(StreamInput::WatchLayer { stream_id, layer });
|
||||
}
|
||||
// Kept for streams started later, also without a connection.
|
||||
Command::SetStreamLayers { layers, .. } => {
|
||||
self.stream_layers = layers.clone();
|
||||
|
||||
@@ -160,6 +160,10 @@ pub(crate) enum StreamInput {
|
||||
RequestKeyframe {
|
||||
stream_id: String,
|
||||
},
|
||||
WatchLayer {
|
||||
stream_id: String,
|
||||
layer: Option<LayerId>,
|
||||
},
|
||||
/// Simulcast layers of our stream (now and for streams started later).
|
||||
Layers(Vec<LayerSpec>),
|
||||
/// SRTP profile order of new connections.
|
||||
@@ -369,6 +373,10 @@ impl StreamTask {
|
||||
self.streams.request_keyframe(&stream_id);
|
||||
Ok(())
|
||||
}
|
||||
StreamInput::WatchLayer { stream_id, layer } => self
|
||||
.streams
|
||||
.set_watch_layer(&stream_id, layer)
|
||||
.map(|()| self.watch_layers(&stream_id)),
|
||||
StreamInput::Layers(layers) => {
|
||||
self.layers = layers.clone();
|
||||
// Without a stream they are used for the next one.
|
||||
@@ -537,6 +545,7 @@ impl StreamTask {
|
||||
}
|
||||
WatchState::Ended(reason)
|
||||
}
|
||||
WatchEvent::Layers(_) => return self.watch_layers(&id),
|
||||
WatchEvent::Frame(frame) => {
|
||||
if let (MediaKind::Audio, Some(audio)) = (frame.kind, &self.audio) {
|
||||
audio.send(AudioIn::StreamAudio {
|
||||
@@ -554,6 +563,17 @@ impl StreamTask {
|
||||
}
|
||||
}
|
||||
|
||||
/// Tell the layers of watched stream `id` and the one we asked for.
|
||||
fn watch_layers(&self, id: &str) {
|
||||
let Some(watched) = self.streams.watching().find(|v| v.id() == id) else { return };
|
||||
self.emit(Event::WatchLayers {
|
||||
session: self.session,
|
||||
stream_id: id.to_owned(),
|
||||
layers: watched.layers().to_vec(),
|
||||
layer: watched.layer(),
|
||||
});
|
||||
}
|
||||
|
||||
/// The answer `stream.permissions` gives to a join request; `None`: ask.
|
||||
fn join_decision(&self, viewer: ClientId) -> Option<bool> {
|
||||
match *self.settings.current().get_arc(&STREAM_PERMISSIONS) {
|
||||
|
||||
Reference in new issue
Block a user