mirror of
https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs.git
synced 2024-11-25 13:01:07 +00:00
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>
This commit is contained in:
parent
3b4c48d9f5
commit
abe4efc4a2
2 changed files with 60 additions and 4 deletions
|
@ -1668,6 +1668,20 @@
|
||||||
"presence": "always"
|
"presence": "always"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"properties": {
|
||||||
|
"offset-to-zero": {
|
||||||
|
"blurb": "Offsets all streams so that the earliest stream starts at 0",
|
||||||
|
"conditionally-available": false,
|
||||||
|
"construct": false,
|
||||||
|
"construct-only": false,
|
||||||
|
"controllable": false,
|
||||||
|
"default": "false",
|
||||||
|
"mutable": "ready",
|
||||||
|
"readable": true,
|
||||||
|
"type": "gboolean",
|
||||||
|
"writable": true
|
||||||
|
}
|
||||||
|
},
|
||||||
"rank": "primary"
|
"rank": "primary"
|
||||||
},
|
},
|
||||||
"onviffmp4mux": {
|
"onviffmp4mux": {
|
||||||
|
|
|
@ -109,6 +109,7 @@ struct Settings {
|
||||||
interleave_bytes: Option<u64>,
|
interleave_bytes: Option<u64>,
|
||||||
interleave_time: Option<gst::ClockTime>,
|
interleave_time: Option<gst::ClockTime>,
|
||||||
movie_timescale: u32,
|
movie_timescale: u32,
|
||||||
|
offset_to_zero: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for Settings {
|
impl Default for Settings {
|
||||||
|
@ -121,6 +122,7 @@ impl Default for Settings {
|
||||||
interleave_bytes: DEFAULT_INTERLEAVE_BYTES,
|
interleave_bytes: DEFAULT_INTERLEAVE_BYTES,
|
||||||
interleave_time: DEFAULT_INTERLEAVE_TIME,
|
interleave_time: DEFAULT_INTERLEAVE_TIME,
|
||||||
movie_timescale: 0,
|
movie_timescale: 0,
|
||||||
|
offset_to_zero: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1387,11 +1389,11 @@ impl FMP4Mux {
|
||||||
let (mut interleaved_buffers, mut streams) =
|
let (mut interleaved_buffers, mut streams) =
|
||||||
self.interleave_buffers(settings, drained_streams)?;
|
self.interleave_buffers(settings, drained_streams)?;
|
||||||
|
|
||||||
// Offset stream start time to start at 0 in ONVIF mode instead of using the UTC time
|
// Offset stream start time to start at 0 in ONVIF mode, or if 'offset-to-zero' is enabled,
|
||||||
// verbatim. This would be used for the tfdt box later.
|
// 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?
|
// FIXME: Should this use the original DTS-or-PTS running time instead?
|
||||||
// That might be negative though!
|
// 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 {
|
let offset = if let Some(start_dts) = state.start_dts {
|
||||||
std::cmp::min(start_dts, state.earliest_pts.unwrap())
|
std::cmp::min(start_dts, state.earliest_pts.unwrap())
|
||||||
} else {
|
} else {
|
||||||
|
@ -2522,7 +2524,47 @@ impl ObjectSubclass for ISOFMP4Mux {
|
||||||
type ParentType = super::FMP4Mux;
|
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 {}
|
impl GstObjectImpl for ISOFMP4Mux {}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue