Merge the development branch: share menu, codec order, segmentation
Brings in the Share button's menu (Share screen / Stream Studio) and the removal of the separate Stream Studio button from the headers, the codecs every TeamSpeak client decodes ahead of H.264, the portal fix and person segmentation. The phone header keeps this branch's voice-channel button and hides the bell on the voice screen, and loses the Stream Studio button as the development branch wants. The studio's test table takes the segmentation rows and the Android camera row. MediaCodec follows the new codec order with no code change (Codecs orders every hardware factory's codecs); its description and docs/media.md now say so, including what that means on a phone without a hardware VP8, VP9 or AV1 encoder. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
commit
698e5f911e
35 files changed
+24436
-224
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))
|
||||
}
|
||||
|
||||
@@ -2870,6 +2880,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,
|
||||
);
|
||||
|
||||
|
||||
Reference in new issue
Block a user