From 86d2f2ce1f5dbe34aa43d8ba84fa108e392f92a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Fri, 2 May 2025 15:45:25 +0300 Subject: [PATCH] fmp4mux: Write lmsg as compatible brand into the last fragment While this is only defined as such in DASH, it's used more widely and shouldn't hurt to always have it there. Part-of: --- mux/fmp4/src/fmp4mux/boxes.rs | 10 +++++++--- mux/fmp4/src/fmp4mux/imp.rs | 1 + mux/fmp4/src/fmp4mux/mod.rs | 3 +++ 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/mux/fmp4/src/fmp4mux/boxes.rs b/mux/fmp4/src/fmp4mux/boxes.rs index 322d062b9..745016153 100644 --- a/mux/fmp4/src/fmp4mux/boxes.rs +++ b/mux/fmp4/src/fmp4mux/boxes.rs @@ -1818,11 +1818,15 @@ pub(super) fn create_fmp4_fragment_header( ) -> Result<(gst::Buffer, u64), Error> { let mut v = vec![]; - // Don't write a `styp` if this is only a chunk. - if !cfg.chunk { - let (brand, compatible_brands) = + // Don't write a `styp` if this is only a chunk unless it's the last. + if !cfg.chunk || cfg.last_fragment { + let (brand, mut compatible_brands) = brands_from_variant_and_caps(cfg.variant, cfg.streams.iter().map(|s| &s.caps)); + if cfg.last_fragment { + compatible_brands.push(b"lmsg"); + } + write_box(&mut v, b"styp", |v| { // major brand v.extend(brand); diff --git a/mux/fmp4/src/fmp4mux/imp.rs b/mux/fmp4/src/fmp4mux/imp.rs index d1c75b377..0e60a9d7c 100644 --- a/mux/fmp4/src/fmp4mux/imp.rs +++ b/mux/fmp4/src/fmp4mux/imp.rs @@ -3211,6 +3211,7 @@ impl FMP4Mux { chunk: !fragment_start, streams: streams.as_slice(), buffers: interleaved_buffers.as_slice(), + last_fragment: at_eos, }) .map_err(|err| { gst::error!( diff --git a/mux/fmp4/src/fmp4mux/mod.rs b/mux/fmp4/src/fmp4mux/mod.rs index 7b6d9dac3..995314be4 100644 --- a/mux/fmp4/src/fmp4mux/mod.rs +++ b/mux/fmp4/src/fmp4mux/mod.rs @@ -240,6 +240,9 @@ pub(crate) struct FragmentHeaderConfiguration<'a> { streams: &'a [FragmentHeaderStream], buffers: &'a [Buffer], + + /// If this is for the last fragment. + last_fragment: bool, } #[derive(Debug)]