Merge the development branch: share menu, portal rows, every channel's streams
Both sides kept. From the development branch: the share dialog's portal
rows ("Same as last time" restores the portal's last choice), the Share
button's menu with the Stream Studio in it instead of a button of its
own in the desktop top bar and the phone header, the codec order,
person segmentation for the studio, and streams of every channel.
The phone header keeps this wave's search button next to the bell; the
studio button goes as on the development branch. video.rs keeps the
development branch's imports without EncoderReport, which the
Integrations page now asks the codecs for itself. The Devices page
lists the capture sources without the restore row.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
commit
4bff98ca27
43 files changed
+24589
-287
No files matched your search
@@ -142,29 +142,37 @@ pub fn peer_config(codecs: &Codecs, mut config: PeerConfig) -> PeerConfig {
|
||||
config
|
||||
}
|
||||
|
||||
/// Whether every official TeamSpeak client decodes `codec`: their WebRTC
|
||||
/// stack has VP8, VP9 and AV1 decoders built in. H.264 needs an OpenH264
|
||||
/// library the official client downloads at start-up and may not get; it
|
||||
/// still answers H.264 then, and decodes nothing (libwebrtc's
|
||||
/// `NullVideoDecoder`). HEVC needs a hardware decoder.
|
||||
pub fn decoded_everywhere(codec: Codec) -> bool {
|
||||
matches!(codec, Codec::Vp8 | Codec::Vp9 | Codec::Av1)
|
||||
}
|
||||
|
||||
/// What a streamer with `primary` as its stream codec offers, in order:
|
||||
/// `primary`, the codecs of hardware encoders, VP8 through libvpx (every
|
||||
/// TeamSpeak client decodes it), and HEVC last (for peers that take nothing
|
||||
/// else). Other software encoders are only ever the stream codec, so no
|
||||
/// viewer's answer starts one of them on top of it.
|
||||
/// `primary`; the codecs of hardware encoders and VP8 through libvpx that
|
||||
/// every TeamSpeak client decodes ([`decoded_everywhere`]), so that a
|
||||
/// viewer, which answers with the first codec it supports, never picks
|
||||
/// H.264 while one of them is there; H.264 from hardware; HEVC last (for
|
||||
/// peers that take nothing else). Other software encoders are only ever the
|
||||
/// stream codec, so no viewer's answer starts one of them on top of it.
|
||||
pub fn offer_codecs(codecs: &Codecs, primary: Codec) -> Vec<Codec> {
|
||||
let mut offer = vec![primary];
|
||||
let mut hevc = false;
|
||||
for (codec, backend) in codecs.encoders() {
|
||||
let cheap = codecs.is_hardware(backend)
|
||||
|| (codec == Codec::Vp8 && backend == voelin_media::EncoderBackend::Libvpx);
|
||||
if !cheap || offer.contains(&codec) {
|
||||
continue;
|
||||
}
|
||||
if codec == Codec::H265 {
|
||||
hevc = true;
|
||||
} else {
|
||||
if cheap && !offer.contains(&codec) {
|
||||
offer.push(codec);
|
||||
}
|
||||
}
|
||||
if hevc && primary != Codec::H265 {
|
||||
offer.push(Codec::H265);
|
||||
}
|
||||
// Stable: the encoder preference orders codecs of the same rank.
|
||||
offer[1..].sort_by_key(|&codec| match codec {
|
||||
_ if decoded_everywhere(codec) => 0,
|
||||
Codec::H265 => 2,
|
||||
_ => 1,
|
||||
});
|
||||
offer
|
||||
}
|
||||
|
||||
@@ -180,12 +188,14 @@ pub fn encoder_preference(settings: &crate::settings::Settings) -> voelin_media:
|
||||
|
||||
/// The stream codec: `configured` if we can encode it, else the first codec
|
||||
/// of the encoder preference (hardware first when enabled; VP8 through
|
||||
/// libvpx without hardware), never HEVC (offered last only). Put it first in
|
||||
/// `PeerConfig::video_codecs` before [`peer_config`].
|
||||
/// libvpx without hardware) that every TeamSpeak client decodes
|
||||
/// ([`decoded_everywhere`]), else any but HEVC (offered last only). Put it
|
||||
/// first in `PeerConfig::video_codecs` before [`peer_config`].
|
||||
pub fn preferred_codec(codecs: &Codecs, configured: Option<Codec>) -> Option<Codec> {
|
||||
let encodable = codecs.encoder_codecs();
|
||||
configured
|
||||
.filter(|c| encodable.contains(c))
|
||||
.or_else(|| encodable.iter().copied().find(|&c| decoded_everywhere(c)))
|
||||
.or_else(|| encodable.into_iter().find(|c| *c != Codec::H265))
|
||||
}
|
||||
|
||||
@@ -2827,6 +2837,21 @@ mod tests {
|
||||
if all.encoder_codecs().contains(&Codec::H264) && !offer.contains(&Codec::H264) {
|
||||
assert_eq!(offer_codecs(&all, Codec::H264)[..2], [Codec::H264, Codec::Vp8]);
|
||||
}
|
||||
// Whatever this machine has: codecs every TeamSpeak client decodes
|
||||
// come before H.264, HEVC last, and the automatic stream codec is
|
||||
// one of the first.
|
||||
let rank = |c: &Codec| match c {
|
||||
_ if decoded_everywhere(*c) => 0,
|
||||
Codec::H265 => 2,
|
||||
_ => 1,
|
||||
};
|
||||
let ranks: Vec<_> = offer[1..].iter().map(rank).collect();
|
||||
assert!(ranks.is_sorted(), "{offer:?}");
|
||||
assert!(preferred_codec(&all, None).is_some_and(decoded_everywhere), "{all:?}");
|
||||
assert_eq!(
|
||||
preferred_codec(&all, Some(Codec::H264)).is_some(),
|
||||
all.encoder_codecs().contains(&Codec::H264)
|
||||
);
|
||||
}
|
||||
|
||||
/// A sink whose viewers chose `codecs`; keeps every video frame with its
|
||||
|
||||
@@ -964,7 +964,8 @@ pub enum CodecChoice {
|
||||
pub static STREAM_CODEC: Key<CodecChoice> = Key::new(
|
||||
"stream.codec",
|
||||
Kind::Choice(&["auto", "vp8", "vp9", "h264", "av1"]),
|
||||
"Video codec of our stream.",
|
||||
"Video codec of our stream. Official TeamSpeak clients always decode VP8, VP9 and AV1; \
|
||||
H.264 only when they could download OpenH264.",
|
||||
CodecChoice::default,
|
||||
);
|
||||
|
||||
@@ -1047,7 +1048,8 @@ pub enum StreamPermissions {
|
||||
/// Friends (contacts marked friend) are accepted; others are shown to
|
||||
/// the user ([`crate::Event::StreamViewerRequest`]).
|
||||
Friends,
|
||||
/// Clients in our channel are accepted, others denied.
|
||||
/// Clients in our channel are accepted; others (a stream can be watched
|
||||
/// from any channel) are shown to the user.
|
||||
#[default]
|
||||
Channel,
|
||||
/// Every join request is denied.
|
||||
|
||||
@@ -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