mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer-rs.git
synced 2024-11-25 19:11:06 +00:00
Pad: allow handling Events in PadProbes
This commit is contained in:
parent
7d8f95971c
commit
3e8ecf4806
1 changed files with 26 additions and 5 deletions
|
@ -1133,8 +1133,14 @@ unsafe fn update_probe_info(
|
|||
assert_eq!(data_type, Some(Buffer::static_type()));
|
||||
// Buffer not consumed by probe; consume it here
|
||||
}
|
||||
None if data_type == Some(Buffer::static_type()) => {
|
||||
// Buffer consumed by probe
|
||||
Some(PadProbeData::Event(_)) => {
|
||||
assert_eq!(data_type, Some(Event::static_type()));
|
||||
// Event not consumed by probe; consume it here
|
||||
}
|
||||
None if data_type == Some(Buffer::static_type())
|
||||
|| data_type == Some(Event::static_type()) =>
|
||||
{
|
||||
// Buffer or Event consumed by probe
|
||||
}
|
||||
other => panic!(
|
||||
"Bad data for {:?} pad probe returning Handled: {:?}",
|
||||
|
@ -1999,6 +2005,19 @@ mod tests {
|
|||
});
|
||||
}
|
||||
|
||||
{
|
||||
let events = events.clone();
|
||||
pad.add_probe(::PadProbeType::EVENT_UPSTREAM, move |_, info| {
|
||||
if let Some(PadProbeData::Event(event)) = info.data.take() {
|
||||
let mut events = events.lock().unwrap();
|
||||
events.push(event);
|
||||
} else {
|
||||
unreachable!();
|
||||
}
|
||||
::PadProbeReturn::Handled
|
||||
});
|
||||
}
|
||||
|
||||
{
|
||||
let buffers = buffers.clone();
|
||||
let flow_override = flow_override;
|
||||
|
@ -2020,6 +2039,7 @@ mod tests {
|
|||
|
||||
pad.set_active(true).unwrap();
|
||||
|
||||
assert!(pad.send_event(::event::Latency::new(::ClockTime::from_nseconds(10))));
|
||||
assert!(pad.push_event(::event::StreamStart::new("test")));
|
||||
let segment = ::FormattedSegment::<::ClockTime>::new();
|
||||
assert!(pad.push_event(::event::Segment::new(segment.as_ref())));
|
||||
|
@ -2029,11 +2049,12 @@ mod tests {
|
|||
|
||||
let events = events.lock().unwrap();
|
||||
let buffers = buffers.lock().unwrap();
|
||||
assert_eq!(events.len(), 2);
|
||||
assert_eq!(events.len(), 3);
|
||||
assert_eq!(buffers.len(), 2);
|
||||
|
||||
assert_eq!(events[0].get_type(), ::EventType::StreamStart);
|
||||
assert_eq!(events[1].get_type(), ::EventType::Segment);
|
||||
assert_eq!(events[0].get_type(), ::EventType::Latency);
|
||||
assert_eq!(events[1].get_type(), ::EventType::StreamStart);
|
||||
assert_eq!(events[2].get_type(), ::EventType::Segment);
|
||||
|
||||
assert!(
|
||||
buffers.iter().all(|b| b.is_writable()),
|
||||
|
|
Loading…
Reference in a new issue