diff --git a/docs/plugins/gst_plugins_cache.json b/docs/plugins/gst_plugins_cache.json index c0880b61..c5c81281 100644 --- a/docs/plugins/gst_plugins_cache.json +++ b/docs/plugins/gst_plugins_cache.json @@ -2111,7 +2111,15 @@ "presence": "always" } }, - "rank": "primary" + "rank": "primary", + "signals": { + "send-headers": { + "action": true, + "args": [], + "return-type": "void", + "when": "last" + } + } }, "dashmp4mux": { "author": "Sebastian Dröge ", diff --git a/mux/fmp4/src/fmp4mux/imp.rs b/mux/fmp4/src/fmp4mux/imp.rs index 7df90c95..2012f4f8 100644 --- a/mux/fmp4/src/fmp4mux/imp.rs +++ b/mux/fmp4/src/fmp4mux/imp.rs @@ -2398,6 +2398,7 @@ impl FMP4Mux { fmp4_header = Some(buffer); + gst::debug!(CAT, imp = self, "Headers will be sent now"); state.sent_headers = true; } @@ -3631,6 +3632,8 @@ impl FMP4MuxImpl for ISOFMP4Mux { const VARIANT: super::Variant = super::Variant::ISO; } +static CMAF_SIGNAL_SEND_HEADERS: &str = "send-headers"; + #[derive(Default)] pub(crate) struct CMAFMux; @@ -3641,7 +3644,31 @@ impl ObjectSubclass for CMAFMux { type ParentType = super::FMP4Mux; } -impl ObjectImpl for CMAFMux {} +impl ObjectImpl for CMAFMux { + fn signals() -> &'static [glib::subclass::Signal] { + static SIGNALS: Lazy> = Lazy::new(|| { + vec![glib::subclass::Signal::builder(CMAF_SIGNAL_SEND_HEADERS) + .action() + .class_handler(|_token, args| { + let element = args[0].get::().expect("signal arg"); + let imp = element.imp(); + let mut state = imp.state.lock().unwrap(); + + state.sent_headers = false; + gst::debug!( + CAT, + obj = element, + "Init headers will be re-sent alongside the next chunk" + ); + + None + }) + .build()] + }); + + SIGNALS.as_ref() + } +} impl GstObjectImpl for CMAFMux {}