From 08c026cea6f6f2d53aff8239c043976ebbd973e7 Mon Sep 17 00:00:00 2001 From: Jochen Henneberg Date: Mon, 18 Nov 2024 10:43:08 +0100 Subject: [PATCH] fmp4mux: Accept tag updates before stream starts Tag updates should be done if either the tag is set before the stream started or if tag changes are allowed while the stream is already running. Fixes #629 Part-of: --- mux/fmp4/src/fmp4mux/imp.rs | 48 ++++++++++++++++++++++--------------- 1 file changed, 29 insertions(+), 19 deletions(-) diff --git a/mux/fmp4/src/fmp4mux/imp.rs b/mux/fmp4/src/fmp4mux/imp.rs index d67e7563..016ed072 100644 --- a/mux/fmp4/src/fmp4mux/imp.rs +++ b/mux/fmp4/src/fmp4mux/imp.rs @@ -3670,20 +3670,21 @@ impl AggregatorImpl for FMP4Mux { let language_code = Some(language_code); // If the language changed and we have buffers - // trigger caps change - if state.language_code != language_code - && !state.streams.is_empty() - && self.header_update_allowed("language code") - { - state.language_code = language_code; - state.need_new_header = true; + // trigger header update + if state.language_code != language_code { + if state.streams.is_empty() { + state.language_code = language_code; + } else if self.header_update_allowed("language code") { + state.language_code = language_code; + state.need_new_header = true; - if let Some(stream) = state - .streams - .iter_mut() - .find(|s| *aggregator_pad == s.sinkpad) - { - stream.tag_changed = true; + if let Some(stream) = state + .streams + .iter_mut() + .find(|s| *aggregator_pad == s.sinkpad) + { + stream.tag_changed = true; + } } } } @@ -3720,12 +3721,21 @@ impl AggregatorImpl for FMP4Mux { // If the orientation changed and we have buffers // trigger caps change - if state.orientation != orientation - && !state.streams.is_empty() - && self.header_update_allowed("orientation") - { - state.orientation = orientation; - state.need_new_header = true; + if state.orientation != orientation { + if state.streams.is_empty() { + state.orientation = orientation; + } else if self.header_update_allowed("orientation") { + state.orientation = orientation; + state.need_new_header = true; + + if let Some(stream) = state + .streams + .iter_mut() + .find(|s| *aggregator_pad == s.sinkpad) + { + stream.tag_changed = true; + } + } } }