gstreamer: typefind: add binding for gst_type_find_get_length()

This commit is contained in:
Guillaume Desmottes 2019-11-14 09:40:08 +05:30 committed by Sebastian Dröge
parent 043af60126
commit 1206dc5b15

View file

@ -83,6 +83,17 @@ impl<'a> TypeFind<'a> {
); );
} }
} }
pub fn get_length(&mut self) -> Option<u64> {
unsafe {
let len = gst_sys::gst_type_find_get_length(&mut self.0);
if len == 0 {
None
} else {
Some(len)
}
}
}
} }
unsafe impl<'a> Send for TypeFind<'a> {} unsafe impl<'a> Send for TypeFind<'a> {}
@ -270,6 +281,7 @@ mod tests {
None, None,
Some(&Caps::new_simple("test/test", &[])), Some(&Caps::new_simple("test/test", &[])),
|typefind| { |typefind| {
assert_eq!(typefind.get_length(), Some(8));
let mut found = false; let mut found = false;
if let Some(data) = typefind.peek(0, 8) { if let Some(data) = typefind.peek(0, 8) {
if data == b"abcdefgh" { if data == b"abcdefgh" {