Commit 29d4e3a5 authored by Sebastian Dröge's avatar Sebastian Dröge 🍵

Handle bufferlists in pad probes

And fix replacing of the previous buffer/bufferlist
parent a76c51ac
...@@ -10,7 +10,9 @@ use Pad; ...@@ -10,7 +10,9 @@ use Pad;
use PadProbeType; use PadProbeType;
use PadProbeReturn; use PadProbeReturn;
use Buffer; use Buffer;
use BufferList;
use FlowReturn; use FlowReturn;
use miniobject::MiniObject;
use std::cell::RefCell; use std::cell::RefCell;
use std::mem::transmute; use std::mem::transmute;
...@@ -54,7 +56,7 @@ pub struct PadProbeInfo { ...@@ -54,7 +56,7 @@ pub struct PadProbeInfo {
pub enum PadProbeData { pub enum PadProbeData {
Buffer(Buffer), Buffer(Buffer),
// BufferList(&BufferList), BufferList(BufferList),
// Query(&Query), // Query(&Query),
// Event(&Event), // Event(&Event),
Unknown, Unknown,
...@@ -165,6 +167,11 @@ unsafe extern "C" fn trampoline_pad_probe( ...@@ -165,6 +167,11 @@ unsafe extern "C" fn trampoline_pad_probe(
Some(PadProbeData::Buffer( Some(PadProbeData::Buffer(
from_glib_borrow(data as *const ffi::GstBuffer), from_glib_borrow(data as *const ffi::GstBuffer),
)) ))
} else if (*data).type_ == BufferList::static_type().to_glib() {
data_type = Some(BufferList::static_type());
Some(PadProbeData::BufferList(
from_glib_borrow(data as *const ffi::GstBufferList),
))
} else { } else {
Some(PadProbeData::Unknown) Some(PadProbeData::Unknown)
} }
...@@ -176,7 +183,23 @@ unsafe extern "C" fn trampoline_pad_probe( ...@@ -176,7 +183,23 @@ unsafe extern "C" fn trampoline_pad_probe(
match probe_info.data { match probe_info.data {
Some(PadProbeData::Buffer(buffer)) => { Some(PadProbeData::Buffer(buffer)) => {
assert_eq!(data_type, Some(Buffer::static_type())); assert_eq!(data_type, Some(Buffer::static_type()));
(*info).data = buffer.into_ptr() as *mut libc::c_void; if (*info).data != buffer.as_mut_ptr() as *mut _ {
ffi::gst_mini_object_unref((*info).data as *mut _);
(*info).data = buffer.into_ptr() as *mut libc::c_void;
}
}
Some(PadProbeData::BufferList(bufferlist)) => {
assert_eq!(data_type, Some(BufferList::static_type()));
if (*info).data != bufferlist.as_mut_ptr() as *mut _ {
ffi::gst_mini_object_unref((*info).data as *mut _);
(*info).data = bufferlist.into_ptr() as *mut libc::c_void;
}
}
None => {
if !(*info).data.is_null() {
ffi::gst_mini_object_unref((*info).data as *mut _);
(*info).data = ptr::null_mut();
}
} }
_ => (), _ => (),
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment