mirror of
https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs.git
synced 2024-11-10 20:31:10 +00:00
hlscmafsink: Add playlist-root-init property
Adding a property to allow setting base path for init fragment to be written in manifest file Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1773>
This commit is contained in:
parent
1d20028b00
commit
1675e517b3
4 changed files with 32 additions and 5 deletions
|
@ -2923,6 +2923,18 @@
|
|||
"type": "gchararray",
|
||||
"writable": true
|
||||
},
|
||||
"playlist-root-init": {
|
||||
"blurb": "Base path for the init fragment in the playlist file.",
|
||||
"conditionally-available": false,
|
||||
"construct": false,
|
||||
"construct-only": false,
|
||||
"controllable": false,
|
||||
"default": "NULL",
|
||||
"mutable": "null",
|
||||
"readable": true,
|
||||
"type": "gchararray",
|
||||
"writable": true
|
||||
},
|
||||
"playlist-type": {
|
||||
"blurb": "The type of the playlist to use. When VOD type is set, the playlist will be live until the pipeline ends execution.",
|
||||
"conditionally-available": false,
|
||||
|
|
|
@ -352,7 +352,7 @@ impl HlsBaseSink {
|
|||
Some((stream, location))
|
||||
}
|
||||
|
||||
pub fn get_segment_uri(&self, location: &str) -> String {
|
||||
pub fn get_segment_uri(&self, location: &str, prefix: Option<&str>) -> String {
|
||||
let settings = self.settings.lock().unwrap();
|
||||
let file_name = path::Path::new(&location)
|
||||
.file_name()
|
||||
|
@ -360,7 +360,9 @@ impl HlsBaseSink {
|
|||
.to_str()
|
||||
.unwrap();
|
||||
|
||||
if let Some(playlist_root) = &settings.playlist_root {
|
||||
if let Some(prefix) = prefix {
|
||||
format!("{prefix}/{file_name}")
|
||||
} else if let Some(playlist_root) = &settings.playlist_root {
|
||||
format!("{playlist_root}/{file_name}")
|
||||
} else {
|
||||
file_name.to_string()
|
||||
|
|
|
@ -50,6 +50,7 @@ struct HlsCmafSinkSettings {
|
|||
playlist_type: Option<MediaPlaylistType>,
|
||||
sync: bool,
|
||||
latency: gst::ClockTime,
|
||||
playlist_root_init: Option<String>,
|
||||
|
||||
cmafmux: gst::Element,
|
||||
appsink: gst_app::AppSink,
|
||||
|
@ -79,6 +80,7 @@ impl Default for HlsCmafSinkSettings {
|
|||
playlist_type: None,
|
||||
sync: DEFAULT_SYNC,
|
||||
latency: DEFAULT_LATENCY,
|
||||
playlist_root_init: None,
|
||||
cmafmux,
|
||||
appsink,
|
||||
}
|
||||
|
@ -145,6 +147,10 @@ impl ObjectImpl for HlsCmafSink {
|
|||
.maximum(i64::MAX as u64)
|
||||
.default_value(DEFAULT_LATENCY.nseconds())
|
||||
.build(),
|
||||
glib::ParamSpecString::builder("playlist-root-init")
|
||||
.nick("Playlist Root Init")
|
||||
.blurb("Base path for the init fragment in the playlist file.")
|
||||
.build(),
|
||||
]
|
||||
});
|
||||
|
||||
|
@ -187,6 +193,11 @@ impl ObjectImpl for HlsCmafSink {
|
|||
settings.latency = value.get().expect("type checked upstream");
|
||||
settings.cmafmux.set_property("latency", settings.latency);
|
||||
}
|
||||
"playlist-root-init" => {
|
||||
settings.playlist_root_init = value
|
||||
.get::<Option<String>>()
|
||||
.expect("type checked upstream");
|
||||
}
|
||||
_ => unimplemented!(),
|
||||
};
|
||||
}
|
||||
|
@ -203,6 +214,7 @@ impl ObjectImpl for HlsCmafSink {
|
|||
}
|
||||
"sync" => settings.sync.to_value(),
|
||||
"latency" => settings.latency.to_value(),
|
||||
"playlist-root-init" => settings.playlist_root_init.to_value(),
|
||||
_ => unimplemented!(),
|
||||
}
|
||||
}
|
||||
|
@ -419,7 +431,8 @@ impl HlsCmafSink {
|
|||
.ok_or_else(|| String::from("Error while getting fragment stream"))?
|
||||
.into_write();
|
||||
|
||||
let uri = base_imp!(self).get_segment_uri(&location);
|
||||
let uri =
|
||||
base_imp!(self).get_segment_uri(&location, settings.playlist_root_init.as_deref());
|
||||
|
||||
state.init_segment = Some(m3u8_rs::Map {
|
||||
uri,
|
||||
|
@ -450,7 +463,7 @@ impl HlsCmafSink {
|
|||
running_time: Option<gst::ClockTime>,
|
||||
location: String,
|
||||
) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||
let uri = base_imp!(self).get_segment_uri(&location);
|
||||
let uri = base_imp!(self).get_segment_uri(&location, None);
|
||||
let mut state = self.state.lock().unwrap();
|
||||
|
||||
let map = if state.new_header {
|
||||
|
|
|
@ -582,7 +582,7 @@ impl HlsSink3 {
|
|||
|
||||
let obj = self.obj();
|
||||
let base_imp = obj.upcast_ref::<HlsBaseSink>().imp();
|
||||
let uri = base_imp.get_segment_uri(&location);
|
||||
let uri = base_imp.get_segment_uri(&location, None);
|
||||
let _ = base_imp.add_segment(
|
||||
&location,
|
||||
running_time,
|
||||
|
|
Loading…
Reference in a new issue