mirror of
https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs.git
synced 2024-11-22 11:30:59 +00:00
Simplify Formatted value handling
See https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1059
This commit is contained in:
parent
a1b87669f2
commit
5c5c15d36a
10 changed files with 31 additions and 60 deletions
|
@ -1455,7 +1455,7 @@ impl AggregatorImpl for FMP4Mux {
|
||||||
match query.view_mut() {
|
match query.view_mut() {
|
||||||
QueryViewMut::Seeking(q) => {
|
QueryViewMut::Seeking(q) => {
|
||||||
// We can't really handle seeking, it would break everything
|
// We can't really handle seeking, it would break everything
|
||||||
q.set(false, gst::ClockTime::ZERO.into(), gst::ClockTime::NONE);
|
q.set(false, gst::ClockTime::ZERO, gst::ClockTime::NONE);
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
_ => self.parent_src_query(aggregator, query),
|
_ => self.parent_src_query(aggregator, query),
|
||||||
|
|
|
@ -190,14 +190,8 @@ fn test_pull_range() {
|
||||||
// get the seeking capabilities
|
// get the seeking capabilities
|
||||||
let (seekable, start, stop) = q.result();
|
let (seekable, start, stop) = q.result();
|
||||||
assert!(seekable);
|
assert!(seekable);
|
||||||
assert_eq!(
|
assert_eq!(start, gst::format::Bytes(0).into());
|
||||||
start,
|
assert_eq!(stop, gst::format::Bytes(6043).into());
|
||||||
gst::GenericFormattedValue::Bytes(Some(gst::format::Bytes(0)))
|
|
||||||
);
|
|
||||||
assert_eq!(
|
|
||||||
stop,
|
|
||||||
gst::GenericFormattedValue::Bytes(Some(gst::format::Bytes(6043)))
|
|
||||||
);
|
|
||||||
|
|
||||||
// do pulls
|
// do pulls
|
||||||
let expected_array_1 = [
|
let expected_array_1 = [
|
||||||
|
|
|
@ -801,11 +801,7 @@ impl JsonGstParse {
|
||||||
|
|
||||||
if fmt == gst::Format::Time {
|
if fmt == gst::Format::Time {
|
||||||
if let Some(pull) = state.pull.as_ref() {
|
if let Some(pull) = state.pull.as_ref() {
|
||||||
q.set(
|
q.set(true, gst::ClockTime::ZERO, pull.duration);
|
||||||
true,
|
|
||||||
gst::GenericFormattedValue::Time(Some(gst::ClockTime::ZERO)),
|
|
||||||
gst::GenericFormattedValue::Time(pull.duration),
|
|
||||||
);
|
|
||||||
true
|
true
|
||||||
} else {
|
} else {
|
||||||
false
|
false
|
||||||
|
|
|
@ -266,14 +266,10 @@ impl SinkState {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
let end_ts = Option::zip(start_ts, duration)
|
let end_ts = start_ts.opt_saturating_add(duration);
|
||||||
.map(|(start_ts, duration)| start_ts.saturating_add(duration));
|
|
||||||
|
|
||||||
let (clipped_start_ts, clipped_end_ts) = self.segment.clip(start_ts, end_ts)?;
|
let (clipped_start_ts, clipped_end_ts) = self.segment.clip(start_ts, end_ts)?;
|
||||||
|
|
||||||
let clipped_duration = Option::zip(clipped_start_ts, clipped_end_ts)
|
let clipped_duration = clipped_end_ts.opt_sub(clipped_start_ts);
|
||||||
.map(|(clipped_start_ts, clipped_end_ts)| clipped_end_ts - clipped_start_ts);
|
|
||||||
|
|
||||||
if clipped_start_ts != start_ts || clipped_duration != buffer.duration() {
|
if clipped_start_ts != start_ts || clipped_duration != buffer.duration() {
|
||||||
let buffer = buffer.make_mut();
|
let buffer = buffer.make_mut();
|
||||||
buffer.set_pts(clipped_start_ts);
|
buffer.set_pts(clipped_start_ts);
|
||||||
|
@ -284,17 +280,13 @@ impl SinkState {
|
||||||
}
|
}
|
||||||
CapsInfo::None => {
|
CapsInfo::None => {
|
||||||
let start_ts = buffer.pts();
|
let start_ts = buffer.pts();
|
||||||
let end_ts = Option::zip(start_ts, buffer.duration())
|
let end_ts = start_ts.opt_saturating_add(buffer.duration());
|
||||||
.map(|(start_ts, duration)| start_ts.saturating_add(duration));
|
|
||||||
|
|
||||||
// Can only clip buffers completely away, i.e. drop them, if they're raw
|
// Can only clip buffers completely away, i.e. drop them, if they're raw
|
||||||
if let Some((clipped_start_ts, clipped_end_ts)) =
|
if let Some((clipped_start_ts, clipped_end_ts)) =
|
||||||
self.segment.clip(start_ts, end_ts)
|
self.segment.clip(start_ts, end_ts)
|
||||||
{
|
{
|
||||||
let clipped_duration = Option::zip(clipped_start_ts, clipped_end_ts).map(
|
let clipped_duration = clipped_end_ts.opt_sub(clipped_start_ts);
|
||||||
|(clipped_start_ts, clipped_end_ts)| clipped_end_ts - clipped_start_ts,
|
|
||||||
);
|
|
||||||
|
|
||||||
if clipped_start_ts != start_ts || clipped_duration != buffer.duration() {
|
if clipped_start_ts != start_ts || clipped_duration != buffer.duration() {
|
||||||
let buffer = buffer.make_mut();
|
let buffer = buffer.make_mut();
|
||||||
buffer.set_pts(clipped_start_ts);
|
buffer.set_pts(clipped_start_ts);
|
||||||
|
@ -719,12 +711,10 @@ impl FallbackSwitch {
|
||||||
}
|
}
|
||||||
|
|
||||||
if is_active {
|
if is_active {
|
||||||
if Option::zip(start_running_time, state.output_running_time).map_or(
|
if start_running_time
|
||||||
false,
|
.opt_lt(state.output_running_time)
|
||||||
|(start_running_time, output_running_time)| {
|
.unwrap_or(false)
|
||||||
start_running_time < output_running_time
|
{
|
||||||
},
|
|
||||||
) {
|
|
||||||
if raw_pad {
|
if raw_pad {
|
||||||
log!(
|
log!(
|
||||||
CAT,
|
CAT,
|
||||||
|
|
|
@ -210,10 +210,10 @@ impl BaseParseImpl for CdgParse {
|
||||||
Ok((gst::FlowSuccess::Ok, skip))
|
Ok((gst::FlowSuccess::Ok, skip))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn convert<V: Into<gst::GenericFormattedValue>>(
|
fn convert(
|
||||||
&self,
|
&self,
|
||||||
_element: &Self::Type,
|
_element: &Self::Type,
|
||||||
src_val: V,
|
src_val: impl FormattedValue,
|
||||||
dest_format: gst::Format,
|
dest_format: gst::Format,
|
||||||
) -> Option<gst::GenericFormattedValue> {
|
) -> Option<gst::GenericFormattedValue> {
|
||||||
let src_val = src_val.into();
|
let src_val = src_val.into();
|
||||||
|
|
|
@ -620,7 +620,7 @@ mod tests {
|
||||||
gst::init().unwrap();
|
gst::init().unwrap();
|
||||||
|
|
||||||
let mut segment = gst::FormattedSegment::<gst::ClockTime>::new();
|
let mut segment = gst::FormattedSegment::<gst::ClockTime>::new();
|
||||||
segment.set_start(Some(gst::ClockTime::from_nseconds(2)));
|
segment.set_start(gst::ClockTime::from_nseconds(2));
|
||||||
|
|
||||||
let pts = gst::ClockTime::from_nseconds(0);
|
let pts = gst::ClockTime::from_nseconds(0);
|
||||||
let duration = Some(gst::ClockTime::from_nseconds(10));
|
let duration = Some(gst::ClockTime::from_nseconds(10));
|
||||||
|
@ -639,7 +639,7 @@ mod tests {
|
||||||
gst::init().unwrap();
|
gst::init().unwrap();
|
||||||
|
|
||||||
let mut segment = gst::FormattedSegment::<gst::ClockTime>::new();
|
let mut segment = gst::FormattedSegment::<gst::ClockTime>::new();
|
||||||
segment.set_stop(Some(gst::ClockTime::from_nseconds(7)));
|
segment.set_stop(gst::ClockTime::from_nseconds(7));
|
||||||
|
|
||||||
let pts = gst::ClockTime::from_nseconds(0);
|
let pts = gst::ClockTime::from_nseconds(0);
|
||||||
let duration = Some(gst::ClockTime::from_nseconds(10));
|
let duration = Some(gst::ClockTime::from_nseconds(10));
|
||||||
|
@ -658,8 +658,8 @@ mod tests {
|
||||||
gst::init().unwrap();
|
gst::init().unwrap();
|
||||||
|
|
||||||
let mut segment = gst::FormattedSegment::<gst::ClockTime>::new();
|
let mut segment = gst::FormattedSegment::<gst::ClockTime>::new();
|
||||||
segment.set_start(Some(gst::ClockTime::from_nseconds(2)));
|
segment.set_start(gst::ClockTime::from_nseconds(2));
|
||||||
segment.set_stop(Some(gst::ClockTime::from_nseconds(7)));
|
segment.set_stop(gst::ClockTime::from_nseconds(7));
|
||||||
|
|
||||||
let pts = gst::ClockTime::from_nseconds(0);
|
let pts = gst::ClockTime::from_nseconds(0);
|
||||||
let duration = Some(gst::ClockTime::from_nseconds(10));
|
let duration = Some(gst::ClockTime::from_nseconds(10));
|
||||||
|
@ -678,7 +678,7 @@ mod tests {
|
||||||
gst::init().unwrap();
|
gst::init().unwrap();
|
||||||
|
|
||||||
let mut segment = gst::FormattedSegment::<gst::ClockTime>::new();
|
let mut segment = gst::FormattedSegment::<gst::ClockTime>::new();
|
||||||
segment.set_start(Some(gst::ClockTime::from_nseconds(15)));
|
segment.set_start(gst::ClockTime::from_nseconds(15));
|
||||||
|
|
||||||
let pts = gst::ClockTime::from_nseconds(0);
|
let pts = gst::ClockTime::from_nseconds(0);
|
||||||
let duration = Some(gst::ClockTime::from_nseconds(10));
|
let duration = Some(gst::ClockTime::from_nseconds(10));
|
||||||
|
@ -691,7 +691,7 @@ mod tests {
|
||||||
gst::init().unwrap();
|
gst::init().unwrap();
|
||||||
|
|
||||||
let mut segment = gst::FormattedSegment::<gst::ClockTime>::new();
|
let mut segment = gst::FormattedSegment::<gst::ClockTime>::new();
|
||||||
segment.set_stop(Some(gst::ClockTime::from_nseconds(10)));
|
segment.set_stop(gst::ClockTime::from_nseconds(10));
|
||||||
|
|
||||||
let pts = gst::ClockTime::from_nseconds(15);
|
let pts = gst::ClockTime::from_nseconds(15);
|
||||||
let duration = Some(gst::ClockTime::from_nseconds(10));
|
let duration = Some(gst::ClockTime::from_nseconds(10));
|
||||||
|
|
|
@ -548,12 +548,11 @@ impl MccParse {
|
||||||
// Update the last_timecode to the current one
|
// Update the last_timecode to the current one
|
||||||
state.last_timecode = Some(timecode);
|
state.last_timecode = Some(timecode);
|
||||||
|
|
||||||
let send_eos = state.segment.stop().map_or(false, |stop| {
|
let send_eos = state
|
||||||
buffer
|
.segment
|
||||||
.pts()
|
.stop()
|
||||||
.zip(buffer.duration())
|
.opt_lt(buffer.pts().opt_add(buffer.duration()))
|
||||||
.map_or(false, |(pts, duration)| pts + duration >= stop)
|
.unwrap_or(false);
|
||||||
});
|
|
||||||
|
|
||||||
// Drop our state mutex while we push out buffers or events
|
// Drop our state mutex while we push out buffers or events
|
||||||
drop(state);
|
drop(state);
|
||||||
|
@ -1061,11 +1060,7 @@ impl MccParse {
|
||||||
|
|
||||||
if fmt == gst::Format::Time {
|
if fmt == gst::Format::Time {
|
||||||
if let Some(pull) = state.pull.as_ref() {
|
if let Some(pull) = state.pull.as_ref() {
|
||||||
q.set(
|
q.set(true, gst::ClockTime::ZERO, pull.duration);
|
||||||
true,
|
|
||||||
gst::GenericFormattedValue::Time(gst::ClockTime::ZERO.into()),
|
|
||||||
gst::GenericFormattedValue::Time(pull.duration),
|
|
||||||
);
|
|
||||||
true
|
true
|
||||||
} else {
|
} else {
|
||||||
false
|
false
|
||||||
|
|
|
@ -938,11 +938,7 @@ impl SccParse {
|
||||||
|
|
||||||
if fmt == gst::Format::Time {
|
if fmt == gst::Format::Time {
|
||||||
if let Some(pull) = state.pull.as_ref() {
|
if let Some(pull) = state.pull.as_ref() {
|
||||||
q.set(
|
q.set(true, gst::ClockTime::ZERO, pull.duration);
|
||||||
true,
|
|
||||||
gst::GenericFormattedValue::Time(gst::ClockTime::ZERO.into()),
|
|
||||||
gst::GenericFormattedValue::Time(pull.duration),
|
|
||||||
);
|
|
||||||
true
|
true
|
||||||
} else {
|
} else {
|
||||||
false
|
false
|
||||||
|
|
|
@ -168,9 +168,9 @@ fn test_pull() {
|
||||||
1.0,
|
1.0,
|
||||||
gst::SeekFlags::FLUSH,
|
gst::SeekFlags::FLUSH,
|
||||||
gst::SeekType::Set,
|
gst::SeekType::Set,
|
||||||
gst::GenericFormattedValue::Time(Some(gst::ClockTime::SECOND)),
|
gst::ClockTime::SECOND,
|
||||||
gst::SeekType::Set,
|
gst::SeekType::Set,
|
||||||
gst::GenericFormattedValue::Time(Some(2 * gst::ClockTime::SECOND)),
|
2 * gst::ClockTime::SECOND,
|
||||||
));
|
));
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
|
|
|
@ -235,9 +235,9 @@ fn test_pull() {
|
||||||
1.0,
|
1.0,
|
||||||
gst::SeekFlags::FLUSH,
|
gst::SeekFlags::FLUSH,
|
||||||
gst::SeekType::Set,
|
gst::SeekType::Set,
|
||||||
gst::GenericFormattedValue::Time(Some(18 * gst::ClockTime::SECOND)),
|
18 * gst::ClockTime::SECOND,
|
||||||
gst::SeekType::Set,
|
gst::SeekType::Set,
|
||||||
gst::GenericFormattedValue::Time(Some(19 * gst::ClockTime::SECOND)),
|
19 * gst::ClockTime::SECOND,
|
||||||
));
|
));
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
|
|
Loading…
Reference in a new issue