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:
selikhovandClaude Opus 5.5 committed 2026-10-03 22:01:10 +03:00
1 parent cacb023ccf
commit f61c34b42c
10 files changed
+162 -67

No files matched your search

+13
View File
@@ -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
+18 -10
View File
@@ -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);