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
@@ -4,13 +4,16 @@
|
||||
//! The voice task forwards stream notifications here and sends the resulting
|
||||
//! commands. Only started for TeamSpeak 6 servers.
|
||||
//!
|
||||
//! Streams that started before we joined are looked up on the server
|
||||
//! (`requeststreaminfo`) and in the session's gateway directory: its
|
||||
//! registered entries (stream id and streamer) are handed to the stream
|
||||
//! sessions ([`voelin_stream::Streams::discovered`]) for streamers in our
|
||||
//! channel, and a [`StreamLookup`] answers for the gateway when the server
|
||||
//! cannot. Our own stream's life (live, viewers, ended) goes back to the
|
||||
//! session ([`OwnStreamEvent`]), which keeps its directory entry.
|
||||
//! The streams of the whole server are listed, in every channel: a stream can
|
||||
//! be watched from any channel, as with the official client. Streams that
|
||||
//! started before we joined, and streams in other channels (the server
|
||||
//! announces a stream only in its channel), are looked up on the server
|
||||
//! (`requeststreaminfo`), so no gateway is needed. A gateway's directory is a
|
||||
//! second source: its registered entries (stream id and streamer) are handed
|
||||
//! to the stream sessions ([`voelin_stream::Streams::discovered`]), and a
|
||||
//! [`StreamLookup`] answers for the gateway when the server cannot. Our own
|
||||
//! stream's life (live, viewers, ended) goes back to the session
|
||||
//! ([`OwnStreamEvent`]), which keeps its directory entry.
|
||||
|
||||
use std::collections::{BTreeMap, BTreeSet};
|
||||
use std::fmt;
|
||||
@@ -554,10 +557,11 @@ impl StreamTask {
|
||||
StreamPermissions::Nobody => Some(false),
|
||||
// Friends are let in; others: ask.
|
||||
StreamPermissions::Friends => self.friends.contains(&viewer.0).then_some(true),
|
||||
// Our channel is let in; viewers from other channels: ask.
|
||||
StreamPermissions::Channel => {
|
||||
let discovery = self.streams.discovery();
|
||||
let own = discovery.own_channel();
|
||||
Some(own.is_some() && discovery.channel_of(viewer) == own)
|
||||
(own.is_some() && discovery.channel_of(viewer) == own).then_some(true)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1016,7 +1020,8 @@ mod tests {
|
||||
assert_eq!(parse_kind("game"), StreamKind::Screen);
|
||||
}
|
||||
|
||||
/// `stream.permissions` answers join requests (`friends`: friends only, others are asked).
|
||||
/// `stream.permissions` answers join requests (`friends` and `channel`:
|
||||
/// those are let in, others are asked).
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn permissions_answer_join_requests() {
|
||||
let in_channels = |streamer: u64, viewer: u64| {
|
||||
@@ -1028,7 +1033,7 @@ mod tests {
|
||||
for (permissions, viewer_channel, friend, expected) in [
|
||||
(StreamPermissions::Everyone, 2, false, Some(true)),
|
||||
(StreamPermissions::Channel, 1, false, Some(true)),
|
||||
(StreamPermissions::Channel, 2, false, Some(false)),
|
||||
(StreamPermissions::Channel, 2, false, None),
|
||||
(StreamPermissions::Nobody, 1, false, Some(false)),
|
||||
(StreamPermissions::Friends, 1, false, None),
|
||||
(StreamPermissions::Friends, 2, true, Some(true)),
|
||||
|
||||
Reference in new issue
Block a user