From d27a04e0675b3ce9b2f5b885dd3a5a0b04ee7b47 Mon Sep 17 00:00:00 2001 From: Arun Raghavan Date: Fri, 13 Oct 2023 08:56:16 -0400 Subject: [PATCH] hlssink3: Close the playlist giostreamsink on stop if possible This is a property that will be available from GStreamer 1.24, and will ensure that we are able to flush the playlist during the READY->NULL transition instead of when the element is freed. Fixes: https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/issues/423 Part-of: --- net/hlssink3/src/imp.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/net/hlssink3/src/imp.rs b/net/hlssink3/src/imp.rs index 1c0cfeeb..7fafa648 100644 --- a/net/hlssink3/src/imp.rs +++ b/net/hlssink3/src/imp.rs @@ -627,6 +627,19 @@ impl Default for HlsSink3Settings { .property("sink", &giostreamsink) .build() .expect("Could not make element splitmuxsink"); + + // giostreamsink doesn't let go of its stream until the element is finalized, which might + // be too late for the calling application. Let's try to force it to close while tearing + // down the pipeline. + if giostreamsink.has_property("close-on-stop", Some(bool::static_type())) { + giostreamsink.set_property("close-on-stop", true); + } else { + gst::warning!( + CAT, + "hlssink3 may sometimes fail to write out the final playlist update. This can be fixed by using giostreamsink from GStreamer 1.24 or later." + ) + } + Self { location: String::from(DEFAULT_TS_LOCATION), target_duration: DEFAULT_TARGET_DURATION,