Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.freedesktop.org/gstreamer/gst-plugins-rs.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/mux
diff options
context:
space:
mode:
authorGuillaume Desmottes <guillaume.desmottes@onestream.live>2023-01-25 12:59:52 +0300
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>2023-01-25 15:29:30 +0300
commitabe4efc4a2239d2063cdf8b06c9428aaccbff90f (patch)
treed971c1c30c4501fce3945fabe0f7c4359a92ddd6 /mux
parent3b4c48d9f55ae5bfb6eb4fe485edf54f8916d955 (diff)
fmp4mux: add 'offset-to-zero' property
Add it only to 'isofmp4mux', the onvif variant already does this and CMAF and DASH are always single-stream so you rely on inter-container synchronization via the running-time. Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1063>
Diffstat (limited to 'mux')
-rw-r--r--mux/fmp4/src/fmp4mux/imp.rs50
1 files changed, 46 insertions, 4 deletions
diff --git a/mux/fmp4/src/fmp4mux/imp.rs b/mux/fmp4/src/fmp4mux/imp.rs
index 7ebca1948..db76d4bca 100644
--- a/mux/fmp4/src/fmp4mux/imp.rs
+++ b/mux/fmp4/src/fmp4mux/imp.rs
@@ -109,6 +109,7 @@ struct Settings {
interleave_bytes: Option<u64>,
interleave_time: Option<gst::ClockTime>,
movie_timescale: u32,
+ offset_to_zero: bool,
}
impl Default for Settings {
@@ -121,6 +122,7 @@ impl Default for Settings {
interleave_bytes: DEFAULT_INTERLEAVE_BYTES,
interleave_time: DEFAULT_INTERLEAVE_TIME,
movie_timescale: 0,
+ offset_to_zero: false,
}
}
}
@@ -1387,11 +1389,11 @@ impl FMP4Mux {
let (mut interleaved_buffers, mut streams) =
self.interleave_buffers(settings, drained_streams)?;
- // Offset stream start time to start at 0 in ONVIF mode instead of using the UTC time
- // verbatim. This would be used for the tfdt box later.
+ // Offset stream start time to start at 0 in ONVIF mode, or if 'offset-to-zero' is enabled,
+ // instead of using the UTC time verbatim. This would be used for the tfdt box later.
// FIXME: Should this use the original DTS-or-PTS running time instead?
// That might be negative though!
- if self.obj().class().as_ref().variant == super::Variant::ONVIF {
+ if self.obj().class().as_ref().variant == super::Variant::ONVIF || settings.offset_to_zero {
let offset = if let Some(start_dts) = state.start_dts {
std::cmp::min(start_dts, state.earliest_pts.unwrap())
} else {
@@ -2522,7 +2524,47 @@ impl ObjectSubclass for ISOFMP4Mux {
type ParentType = super::FMP4Mux;
}
-impl ObjectImpl for ISOFMP4Mux {}
+impl ObjectImpl for ISOFMP4Mux {
+ fn properties() -> &'static [glib::ParamSpec] {
+ static PROPERTIES: Lazy<Vec<glib::ParamSpec>> = Lazy::new(|| {
+ vec![glib::ParamSpecBoolean::builder("offset-to-zero")
+ .nick("Offset to Zero")
+ .blurb("Offsets all streams so that the earliest stream starts at 0")
+ .mutable_ready()
+ .build()]
+ });
+
+ &PROPERTIES
+ }
+
+ fn property(&self, _id: usize, pspec: &glib::ParamSpec) -> glib::Value {
+ let obj = self.obj();
+ let fmp4mux = obj.upcast_ref::<super::FMP4Mux>().imp();
+
+ match pspec.name() {
+ "offset-to-zero" => {
+ let settings = fmp4mux.settings.lock().unwrap();
+ settings.offset_to_zero.to_value()
+ }
+
+ _ => unimplemented!(),
+ }
+ }
+
+ fn set_property(&self, _id: usize, value: &glib::Value, pspec: &glib::ParamSpec) {
+ let obj = self.obj();
+ let fmp4mux = obj.upcast_ref::<super::FMP4Mux>().imp();
+
+ match pspec.name() {
+ "offset-to-zero" => {
+ let mut settings = fmp4mux.settings.lock().unwrap();
+ settings.offset_to_zero = value.get().expect("type checked upstream");
+ }
+
+ _ => unimplemented!(),
+ }
+ }
+}
impl GstObjectImpl for ISOFMP4Mux {}