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: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1360>
This commit is contained in:
Arun Raghavan 2023-10-13 08:56:16 -04:00 committed by Arun Raghavan
parent a49a5dcb11
commit d27a04e067

View file

@ -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,