Find and watch streams in every channel, without a gateway
The server announces a stream only to the clients in the streamer's
channel. Voelin looked up streams that started before it joined
(`requeststreaminfo`), but only in its own channel, so a stream anywhere
else on the server appeared only through a gateway's directory. The
official client lists and joins them without one: `requeststreaminfo`
answers from any channel, and a `joinstreamrequest` from another channel
reaches the streamer (confirmed on the TS6 dev server with the probe).
- Discovery follows every streaming client on the server: it looks up
the streams of clients in other channels as soon as they stream, keeps
them when we or they change channels, and drops them when the streamer
stops or leaves.
- The streams panel lists every channel's streams, ours first, the
others with their channel ("by X · in Gaming"); clients still being
looked up show in any channel. The viewer's note names the stream's
channel instead of claiming it can only be watched from there.
- As a streamer with `stream.permissions = channel` (the default), our
channel is let in and viewers from other channels are asked, as the
setting's description ("who may watch without being asked") says;
they were refused before.
Tested: discovery unit tests for the new rules; the engine's permission
test; the app headless (no gateway) on the TS6 dev server found and played
a stream in another channel and one that started before it joined;
scripts/it-smoke.sh gains a step where a viewer in the default channel
watches a stream in another channel.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
cacb023ccf
commit
f61c34b42c
10 files changed
+162
-67
No files matched your search
@@ -248,6 +248,19 @@ impl SessionView {
|
||||
self.capabilities.streams && self.state.voice == VoiceState::Connected
|
||||
}
|
||||
|
||||
/// The channel a client is in.
|
||||
pub fn channel_of(&self, client: u16) -> Option<u64> {
|
||||
self.presence.clients.get(&client).map(|c| c.channel)
|
||||
}
|
||||
|
||||
/// The name of a client's channel when it is not ours; empty in ours.
|
||||
pub fn other_channel_name(&self, client: u16) -> String {
|
||||
self.channel_of(client)
|
||||
.filter(|c| Some(*c) != self.state.own_channel)
|
||||
.and_then(|c| self.presence.channels.get(&c))
|
||||
.map_or_else(String::new, |c| c.name.clone())
|
||||
}
|
||||
|
||||
/// A client's nickname, or its id.
|
||||
pub fn nickname(&self, client: u16) -> String {
|
||||
self.presence
|
||||
|
||||
@@ -215,7 +215,12 @@ impl App {
|
||||
let current = self.current;
|
||||
let mut items: Vec<StreamItem> = Vec::new();
|
||||
if let Some(view) = view.filter(|v| v.streams_available()) {
|
||||
for s in &view.streams {
|
||||
// Every channel's streams (they can be watched from anywhere),
|
||||
// ours first.
|
||||
let own_channel = view.state.own_channel;
|
||||
let mut streams: Vec<_> = view.streams.iter().collect();
|
||||
streams.sort_by_key(|s| view.channel_of(s.streamer.0) != own_channel);
|
||||
for s in streams {
|
||||
let watching = self
|
||||
.watch
|
||||
.as_ref()
|
||||
@@ -224,6 +229,7 @@ impl App {
|
||||
id: s.id.clone().into(),
|
||||
name: s.name.clone().into(),
|
||||
streamer: view.nickname(s.streamer.0).into(),
|
||||
channel: view.other_channel_name(s.streamer.0).into(),
|
||||
streamer_id: i32::from(s.streamer.0),
|
||||
viewers: view.stream_viewers.get(&s.id).map_or(0, |v| *v as i32),
|
||||
audio: s.audio,
|
||||
@@ -239,20 +245,17 @@ impl App {
|
||||
bitrate: bitrate_text(s.bitrate).into(),
|
||||
});
|
||||
}
|
||||
// Streams that started before we joined: the server did not
|
||||
// announce them, and the engine is looking them up (they arrive
|
||||
// in `StreamsChanged` like the others). Until then only the
|
||||
// streaming flag is known.
|
||||
let channel = view.state.own_channel;
|
||||
// Streams that started before we joined, or in another channel:
|
||||
// the server did not announce them, and the engine is looking
|
||||
// them up (they arrive in `StreamsChanged` like the others).
|
||||
// Until then only the streaming flag is known.
|
||||
for c in view.presence.clients.values() {
|
||||
let announced = view.streams.iter().any(|s| s.streamer.0 == c.id);
|
||||
if c.streaming == Some(true)
|
||||
&& Some(c.channel) == channel
|
||||
&& !announced && view.state.own_client != Some(c.id)
|
||||
{
|
||||
if c.streaming == Some(true) && !announced && view.state.own_client != Some(c.id) {
|
||||
items.push(StreamItem {
|
||||
name: c.nickname.clone().into(),
|
||||
streamer: c.nickname.clone().into(),
|
||||
channel: view.other_channel_name(c.id).into(),
|
||||
streamer_id: i32::from(c.id),
|
||||
..StreamItem::default()
|
||||
});
|
||||
@@ -346,6 +349,11 @@ impl App {
|
||||
.and_then(|v| v.streams.iter().find(|s| s.id == watch.stream_id))
|
||||
.map_or(-1, |s| i32::from(s.streamer.0));
|
||||
bridge.set_viewer_streamer_id(streamer);
|
||||
let channel = u16::try_from(streamer).ok().and_then(|id| {
|
||||
let view = self.view()?;
|
||||
view.presence.channels.get(&view.channel_of(id)?).map(|c| c.name.clone())
|
||||
});
|
||||
bridge.set_viewer_channel(channel.unwrap_or_default().into());
|
||||
bridge.set_viewer_elapsed(watch.elapsed().into());
|
||||
let viewers = self.view().and_then(|v| v.stream_viewers.get(&watch.stream_id)).copied();
|
||||
bridge.set_viewer_count(viewers.unwrap_or(0) as i32);
|
||||
|
||||
@@ -217,12 +217,15 @@ export struct BookmarkForm {
|
||||
query-password: string,
|
||||
}
|
||||
|
||||
// A stream in our channel. An empty id: a client that streams, but whose
|
||||
// stream is still being looked up (it started before we joined).
|
||||
// A stream on the server, ours first: a stream can be watched from any
|
||||
// channel. An empty id: a client that streams, but whose stream is still
|
||||
// being looked up (it started before we joined, or in another channel).
|
||||
export struct StreamItem {
|
||||
id: string,
|
||||
name: string,
|
||||
streamer: string,
|
||||
// The streamer's channel when it is not ours; empty in ours.
|
||||
channel: string,
|
||||
// The streamer's client id (their avatar in the members).
|
||||
streamer-id: int,
|
||||
// How many watch it (the gateway's directory; 0 unknown).
|
||||
@@ -384,6 +387,8 @@ export global Bridge {
|
||||
in property <string> viewer-title;
|
||||
// Who streams it (their client id: -1 unknown).
|
||||
in property <string> viewer-streamer;
|
||||
// The voice channel the watched stream is in.
|
||||
in property <string> viewer-channel;
|
||||
in property <int> viewer-streamer-id: -1;
|
||||
// Shown instead of (or over) the picture: waiting, ended, errors.
|
||||
in property <string> viewer-status;
|
||||
|
||||
@@ -50,7 +50,10 @@ component StreamCard inherits Rectangle {
|
||||
overflow: elide;
|
||||
}
|
||||
Text {
|
||||
text: stream.id == "" ? @tr("Started before you joined; looking it up…") : stream.own ? @tr("your stream") : stream.audio ? @tr("by {} · with sound", stream.streamer) : @tr("by {}", stream.streamer);
|
||||
text: stream.id == "" ? (stream.channel == "" ? @tr("Started before you joined; looking it up…") : @tr("In {}; looking it up…", stream.channel))
|
||||
: stream.own ? @tr("your stream")
|
||||
: stream.channel != "" ? @tr("by {} · in {}", stream.streamer, stream.channel)
|
||||
: stream.audio ? @tr("by {} · with sound", stream.streamer) : @tr("by {}", stream.streamer);
|
||||
color: Theme.text-muted;
|
||||
font-size: Theme.font-sm;
|
||||
overflow: elide;
|
||||
@@ -150,7 +153,7 @@ export component StreamsPanel inherits VerticalLayout {
|
||||
}
|
||||
}
|
||||
if Bridge.streams.length == 0: Text {
|
||||
text: @tr("No streams in your channel.");
|
||||
text: @tr("No streams on this server.");
|
||||
color: Theme.text-muted;
|
||||
font-size: Theme.font-sm;
|
||||
}
|
||||
@@ -425,7 +428,7 @@ component StreamInfo inherits VerticalLayout {
|
||||
}
|
||||
|
||||
// The stream we watch. With the shell: the channel's header, the player,
|
||||
// a note that the stream belongs to the channel, and its chat below. In
|
||||
// a note on the channel the stream belongs to, and its chat below. In
|
||||
// full screen and on a phone: the player alone.
|
||||
export component StreamViewer inherits Rectangle {
|
||||
// Reading our own width here would loop through the layout, so the
|
||||
@@ -465,8 +468,9 @@ export component StreamViewer inherits Rectangle {
|
||||
padding-bottom: Theme.space-3;
|
||||
StreamPlayer { }
|
||||
}
|
||||
// Streams on TeamSpeak belong to the channel.
|
||||
if Bridge.own-channel != "": HorizontalLayout {
|
||||
// Streams on TeamSpeak belong to a channel (and can be watched from
|
||||
// any channel; the streamer decides who may).
|
||||
if Bridge.viewer-channel != "": HorizontalLayout {
|
||||
padding-left: Theme.space-4;
|
||||
padding-right: Theme.space-4;
|
||||
Rectangle {
|
||||
@@ -486,7 +490,7 @@ export component StreamViewer inherits Rectangle {
|
||||
y: (parent.height - self.height) / 2;
|
||||
}
|
||||
Text {
|
||||
text: @tr("This stream is only available while you're in the {} voice channel.", Bridge.own-channel);
|
||||
text: Bridge.viewer-channel == Bridge.own-channel ? @tr("Streamed in your voice channel, {}. The streamer decides who may watch.", Bridge.viewer-channel) : @tr("Streamed in the {} voice channel. The streamer decides who may watch.", Bridge.viewer-channel);
|
||||
color: Theme.text-secondary;
|
||||
font-size: Theme.font-sm;
|
||||
vertical-alignment: center;
|
||||
|
||||
Reference in new issue
Block a user