Find TeamSpeak 6 streams that started before we joined

The server announces a stream (notifystreamstarted) only to the clients in
the streamer's channel when it starts. A client that connects or enters the
channel later saw the streamer's client_is_streaming flag but could not
watch. The probe (docs/research/ts6-late-join.md) found that
`requeststreaminfo clid=<streamer>` answers with notifystreaminfo, one part
per stream of the client, from any channel.

voelin-stream gets a discovery module. Streams::update_clients takes the
clients on the server (channel and streaming flag), keeps the directory to
the streams in our channel, and looks up the streams of streamers in our
channel we were not told about: after connecting, after we or they change
channels, and when an announcement did not come. The answer fills the
directory like an announcement, so Event::StreamsChanged lists the stream
and it is watched like any other. Where streams are looked up is a
StreamLookup trait (the server now; a gateway directory can plug in with
Streams::add_lookup and report through Streams::discovered).
notifystreamupdated (updatestream) now updates the directory.

The engine and `voelinctl stream list/watch` feed the client list in. The
declarations learn the notifystreaminfo answer's fields, notifystreamupdated
and requeststreaminfo. Tests: a fake-server session test and an engine live
test with a viewer that arrives after the stream is live, discovery unit
tests, parsing of the server's answers; it-smoke gets a late-viewer step.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NJvYyRmTjKcb9i8eyYXK5G
This commit is contained in:
Claude committed 2026-09-27 03:41:20 +00:00
1 parent a6cfee9948
commit 47878a3ac0
15 files changed
+977 -76

No files matched your search

+27 -19
View File
@@ -11,7 +11,6 @@ use clap::{Args, Subcommand};
use futures::prelude::*;
use tokio::io::{AsyncBufReadExt, BufReader, Lines, Stdin};
use tokio::time::{Instant, Interval, sleep_until};
use tsclientlib::events::{Event, PropertyId};
use tsclientlib::prelude::*;
use tsclientlib::{ClientId, Connection, MessageHandle, StreamItem};
use voelin_core::media::voelin_media::capture::SourceId;
@@ -22,8 +21,9 @@ use voelin_core::media::{
};
use voelin_model::ServerFlavor;
use voelin_stream::{
EndReason, FrameSource, MediaKind, Output, PeerConfig, Request, StreamEvent, StreamInfo,
StreamNotification, StreamSetup, StreamerEvent, StreamerOptions, Streams, WatchEvent,
ClientState, EndReason, FrameSource, MediaKind, Output, PeerConfig, Request, StreamEvent,
StreamInfo, StreamNotification, StreamSetup, StreamerEvent, StreamerOptions, Streams,
WatchEvent,
};
#[derive(Args, Debug, Clone)]
@@ -123,6 +123,7 @@ pub async fn run(con: &mut Connection, args: &StreamArgs) -> Result<()> {
let config = peer_config(&codecs, config);
let codec = stream_codec(&codecs, &config);
let mut driver = Driver { streams: Streams::new(own, config), pending: HashMap::new() };
driver.sync_clients(con)?;
let result = match &args.command {
StreamCommand::Start {
name,
@@ -279,24 +280,26 @@ impl Driver {
self.streams.request_failed(&request, &e.to_string());
}
}
StreamItem::BookEvents(events) => {
let state = con.get_state()?;
for e in &events {
if let Event::PropertyChanged {
id: PropertyId::ClientIsStreaming(clid), ..
} = e && let Some(streaming) =
state.clients.get(clid).and_then(|c| c.is_streaming)
{
self.streams.set_client_streaming(*clid, streaming);
}
}
self.streams.retain_streamers(|c| state.clients.contains_key(&c));
}
StreamItem::BookEvents(_) => self.sync_clients(con)?,
_ => {}
}
Ok(())
}
/// Tell the sessions the clients on the server: streams of clients that
/// left, stopped or are not in our channel are dropped; streams that
/// started before we came are looked up.
fn sync_clients(&mut self, con: &Connection) -> Result<()> {
let state = con.get_state()?;
let clients = state
.clients
.values()
.map(|c| (c.id.0, ClientState { channel: c.channel.0, streaming: c.is_streaming }))
.collect();
self.streams.update_clients(clients);
Ok(())
}
/// Send the sessions' requests; returns their events.
fn flush(&mut self, con: &mut Connection) -> Result<Vec<StreamEvent>> {
let mut events = Vec::new();
@@ -472,12 +475,17 @@ async fn list(con: &mut Connection, driver: &mut Driver, settle: Duration) -> Re
if s.audio { ", audio" } else { "" }
);
}
// Streams that started before we connected are only known by the flag.
// Streamers in our channel known only by the flag: the lookup failed or
// did not answer in time.
let state = con.get_state()?;
let channel = state.clients.get(&state.own_client).map(|c| c.channel);
let mut unannounced = 0;
for c in state.clients.values() {
if c.is_streaming == Some(true) && !streams.iter().any(|s| s.streamer == c.id) {
println!("? {} (clid {}) is streaming; id not announced to us", c.name, c.id.0);
if c.is_streaming == Some(true)
&& Some(c.channel) == channel
&& !streams.iter().any(|s| s.streamer == c.id)
{
println!("? {} (clid {}) is streaming; id not known", c.name, c.id.0);
unannounced += 1;
}
}