forked from mirrors/gstreamer-rs
Add some more bindings related to buffers and taglists
This commit is contained in:
parent
e73f57cd31
commit
80265967f7
6 changed files with 117 additions and 61 deletions
41
Gir_Gst.toml
41
Gir_Gst.toml
|
@ -58,7 +58,6 @@ generate = [
|
|||
manual = [
|
||||
"GLib.Error",
|
||||
"GLib.Source",
|
||||
"Gst.Message",
|
||||
"Gst.Structure",
|
||||
]
|
||||
|
||||
|
@ -117,6 +116,21 @@ name = "Gst.Caps"
|
|||
status = "manual"
|
||||
ref_mode = "ref"
|
||||
|
||||
[[object]]
|
||||
name = "Gst.Buffer"
|
||||
status = "manual"
|
||||
ref_mode = "ref"
|
||||
|
||||
[[object]]
|
||||
name = "Gst.Message"
|
||||
status = "manual"
|
||||
ref_mode = "ref"
|
||||
|
||||
[[object]]
|
||||
name = "Gst.TagList"
|
||||
status = "manual"
|
||||
ref_mode = "ref"
|
||||
|
||||
[[object]]
|
||||
name = "Gst.Clock"
|
||||
status = "generate"
|
||||
|
@ -268,6 +282,26 @@ status = "generate"
|
|||
# Don't use a ulong
|
||||
ignore = true
|
||||
|
||||
[[object.function]]
|
||||
name = "chain"
|
||||
# Move buffer
|
||||
ignore = true
|
||||
|
||||
[[object.function]]
|
||||
name = "push"
|
||||
# Move buffer
|
||||
ignore = true
|
||||
|
||||
[[object.function]]
|
||||
name = "pull_range"
|
||||
# Buffer can be NULL
|
||||
ignore = true
|
||||
|
||||
[[object.function]]
|
||||
name = "get_range"
|
||||
# Buffer can be NULL
|
||||
ignore = true
|
||||
|
||||
[[object]]
|
||||
name = "Gst.Stream"
|
||||
status = "generate"
|
||||
|
@ -277,6 +311,11 @@ status = "generate"
|
|||
# Caps is not a GObject
|
||||
ignore = true
|
||||
|
||||
[[object.property]]
|
||||
name = "tags"
|
||||
# TagList is not a GObject
|
||||
ignore = true
|
||||
|
||||
[[object]]
|
||||
name = "Gst.Plugin"
|
||||
status = "generate"
|
||||
|
|
|
@ -50,7 +50,7 @@ impl Bus {
|
|||
// unsafe { TODO: call ffi::gst_bus_add_watch_full() }
|
||||
//}
|
||||
|
||||
//pub fn async_signal_func<P: Into<Option</*Unimplemented*/Fundamental: Pointer>>>(&self, message: &mut Message, data: P) -> bool {
|
||||
//pub fn async_signal_func<P: Into<Option</*Unimplemented*/Fundamental: Pointer>>>(&self, message: &Message, data: P) -> bool {
|
||||
// unsafe { TODO: call ffi::gst_bus_async_signal_func() }
|
||||
//}
|
||||
|
||||
|
@ -84,7 +84,7 @@ impl Bus {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn post(&self, message: &mut Message) -> bool {
|
||||
pub fn post(&self, message: &Message) -> bool {
|
||||
unsafe {
|
||||
from_glib(ffi::gst_bus_post(self.to_glib_none().0, message.to_glib_full()))
|
||||
}
|
||||
|
@ -106,7 +106,7 @@ impl Bus {
|
|||
// unsafe { TODO: call ffi::gst_bus_set_sync_handler() }
|
||||
//}
|
||||
|
||||
//pub fn sync_signal_handler<P: Into<Option</*Unimplemented*/Fundamental: Pointer>>>(&self, message: &mut Message, data: P) -> BusSyncReply {
|
||||
//pub fn sync_signal_handler<P: Into<Option</*Unimplemented*/Fundamental: Pointer>>>(&self, message: &Message, data: P) -> BusSyncReply {
|
||||
// unsafe { TODO: call ffi::gst_bus_sync_signal_handler() }
|
||||
//}
|
||||
|
||||
|
|
|
@ -156,7 +156,7 @@ pub trait ElementExt {
|
|||
|
||||
fn no_more_pads(&self);
|
||||
|
||||
fn post_message(&self, message: &mut Message) -> bool;
|
||||
fn post_message(&self, message: &Message) -> bool;
|
||||
|
||||
fn provide_clock(&self) -> Option<Clock>;
|
||||
|
||||
|
@ -426,7 +426,7 @@ impl<O: IsA<Element> + IsA<glib::object::Object>> ElementExt for O {
|
|||
}
|
||||
}
|
||||
|
||||
fn post_message(&self, message: &mut Message) -> bool {
|
||||
fn post_message(&self, message: &Message) -> bool {
|
||||
unsafe {
|
||||
from_glib(ffi::gst_element_post_message(self.to_glib_none().0, message.to_glib_full()))
|
||||
}
|
||||
|
|
|
@ -74,8 +74,6 @@ pub trait PadExt {
|
|||
|
||||
fn can_link<P: IsA<Pad>>(&self, sinkpad: &P) -> bool;
|
||||
|
||||
//fn chain(&self, buffer: /*Ignored*/&mut Buffer) -> FlowReturn;
|
||||
|
||||
//fn chain_list(&self, list: /*Ignored*/&mut BufferList) -> FlowReturn;
|
||||
|
||||
fn check_reconfigure(&self) -> bool;
|
||||
|
@ -110,8 +108,6 @@ pub trait PadExt {
|
|||
|
||||
fn get_peer(&self) -> Option<Pad>;
|
||||
|
||||
//fn get_range(&self, offset: u64, size: u32, buffer: /*Ignored*/Buffer) -> FlowReturn;
|
||||
|
||||
//fn get_sticky_event(&self, event_type: /*Ignored*/EventType, idx: u32) -> /*Ignored*/Option<Event>;
|
||||
|
||||
#[cfg(feature = "v1_10")]
|
||||
|
@ -168,10 +164,6 @@ pub trait PadExt {
|
|||
|
||||
//fn proxy_query_caps(&self, query: /*Ignored*/&mut Query) -> bool;
|
||||
|
||||
//fn pull_range(&self, offset: u64, size: u32, buffer: /*Ignored*/Buffer) -> FlowReturn;
|
||||
|
||||
//fn push(&self, buffer: /*Ignored*/&mut Buffer) -> FlowReturn;
|
||||
|
||||
//fn push_event(&self, event: /*Ignored*/&mut Event) -> bool;
|
||||
|
||||
//fn push_list(&self, list: /*Ignored*/&mut BufferList) -> FlowReturn;
|
||||
|
@ -256,10 +248,6 @@ impl<O: IsA<Pad> + IsA<glib::object::Object>> PadExt for O {
|
|||
}
|
||||
}
|
||||
|
||||
//fn chain(&self, buffer: /*Ignored*/&mut Buffer) -> FlowReturn {
|
||||
// unsafe { TODO: call ffi::gst_pad_chain() }
|
||||
//}
|
||||
|
||||
//fn chain_list(&self, list: /*Ignored*/&mut BufferList) -> FlowReturn {
|
||||
// unsafe { TODO: call ffi::gst_pad_chain_list() }
|
||||
//}
|
||||
|
@ -352,10 +340,6 @@ impl<O: IsA<Pad> + IsA<glib::object::Object>> PadExt for O {
|
|||
}
|
||||
}
|
||||
|
||||
//fn get_range(&self, offset: u64, size: u32, buffer: /*Ignored*/Buffer) -> FlowReturn {
|
||||
// unsafe { TODO: call ffi::gst_pad_get_range() }
|
||||
//}
|
||||
|
||||
//fn get_sticky_event(&self, event_type: /*Ignored*/EventType, idx: u32) -> /*Ignored*/Option<Event> {
|
||||
// unsafe { TODO: call ffi::gst_pad_get_sticky_event() }
|
||||
//}
|
||||
|
@ -506,14 +490,6 @@ impl<O: IsA<Pad> + IsA<glib::object::Object>> PadExt for O {
|
|||
// unsafe { TODO: call ffi::gst_pad_proxy_query_caps() }
|
||||
//}
|
||||
|
||||
//fn pull_range(&self, offset: u64, size: u32, buffer: /*Ignored*/Buffer) -> FlowReturn {
|
||||
// unsafe { TODO: call ffi::gst_pad_pull_range() }
|
||||
//}
|
||||
|
||||
//fn push(&self, buffer: /*Ignored*/&mut Buffer) -> FlowReturn {
|
||||
// unsafe { TODO: call ffi::gst_pad_push() }
|
||||
//}
|
||||
|
||||
//fn push_event(&self, event: /*Ignored*/&mut Event) -> bool {
|
||||
// unsafe { TODO: call ffi::gst_pad_push_event() }
|
||||
//}
|
||||
|
|
|
@ -6,6 +6,8 @@ use Caps;
|
|||
use Object;
|
||||
use StreamFlags;
|
||||
use StreamType;
|
||||
#[cfg(feature = "v1_10")]
|
||||
use TagList;
|
||||
use ffi;
|
||||
use glib;
|
||||
use glib::Value;
|
||||
|
@ -55,8 +57,8 @@ pub trait StreamExt {
|
|||
#[cfg(feature = "v1_10")]
|
||||
fn get_stream_type(&self) -> StreamType;
|
||||
|
||||
//#[cfg(feature = "v1_10")]
|
||||
//fn get_tags(&self) -> /*Ignored*/Option<TagList>;
|
||||
#[cfg(feature = "v1_10")]
|
||||
fn get_tags(&self) -> Option<TagList>;
|
||||
|
||||
#[cfg(feature = "v1_10")]
|
||||
fn set_caps<'a, P: Into<Option<&'a Caps>>>(&self, caps: P);
|
||||
|
@ -67,8 +69,8 @@ pub trait StreamExt {
|
|||
#[cfg(feature = "v1_10")]
|
||||
fn set_stream_type(&self, stream_type: StreamType);
|
||||
|
||||
//#[cfg(feature = "v1_10")]
|
||||
//fn set_tags<'a, P: Into<Option<&'a /*Ignored*/TagList>>>(&self, tags: P);
|
||||
#[cfg(feature = "v1_10")]
|
||||
fn set_tags<'a, P: Into<Option<&'a TagList>>>(&self, tags: P);
|
||||
|
||||
fn get_property_stream_flags(&self) -> StreamFlags;
|
||||
|
||||
|
@ -79,10 +81,6 @@ pub trait StreamExt {
|
|||
fn get_property_stream_type(&self) -> StreamType;
|
||||
|
||||
fn set_property_stream_type(&self, stream_type: StreamType);
|
||||
|
||||
//fn get_property_tags(&self) -> /*Ignored*/Option<TagList>;
|
||||
|
||||
//fn set_property_tags(&self, tags: /*Ignored*/Option<&TagList>);
|
||||
}
|
||||
|
||||
impl<O: IsA<Stream> + IsA<glib::object::Object>> StreamExt for O {
|
||||
|
@ -114,10 +112,12 @@ impl<O: IsA<Stream> + IsA<glib::object::Object>> StreamExt for O {
|
|||
}
|
||||
}
|
||||
|
||||
//#[cfg(feature = "v1_10")]
|
||||
//fn get_tags(&self) -> /*Ignored*/Option<TagList> {
|
||||
// unsafe { TODO: call ffi::gst_stream_get_tags() }
|
||||
//}
|
||||
#[cfg(feature = "v1_10")]
|
||||
fn get_tags(&self) -> Option<TagList> {
|
||||
unsafe {
|
||||
from_glib_full(ffi::gst_stream_get_tags(self.to_glib_none().0))
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "v1_10")]
|
||||
fn set_caps<'a, P: Into<Option<&'a Caps>>>(&self, caps: P) {
|
||||
|
@ -142,10 +142,14 @@ impl<O: IsA<Stream> + IsA<glib::object::Object>> StreamExt for O {
|
|||
}
|
||||
}
|
||||
|
||||
//#[cfg(feature = "v1_10")]
|
||||
//fn set_tags<'a, P: Into<Option<&'a /*Ignored*/TagList>>>(&self, tags: P) {
|
||||
// unsafe { TODO: call ffi::gst_stream_set_tags() }
|
||||
//}
|
||||
#[cfg(feature = "v1_10")]
|
||||
fn set_tags<'a, P: Into<Option<&'a TagList>>>(&self, tags: P) {
|
||||
let tags = tags.into();
|
||||
let tags = tags.to_glib_none();
|
||||
unsafe {
|
||||
ffi::gst_stream_set_tags(self.to_glib_none().0, tags.0);
|
||||
}
|
||||
}
|
||||
|
||||
fn get_property_stream_flags(&self) -> StreamFlags {
|
||||
let mut value = Value::from(&0u32);
|
||||
|
@ -184,18 +188,4 @@ impl<O: IsA<Stream> + IsA<glib::object::Object>> StreamExt for O {
|
|||
gobject_ffi::g_object_set_property(self.to_glib_none().0, "stream-type".to_glib_none().0, Value::from(&stream_type).to_glib_none().0);
|
||||
}
|
||||
}
|
||||
|
||||
//fn get_property_tags(&self) -> /*Ignored*/Option<TagList> {
|
||||
// let mut value = Value::from(None::<&/*Ignored*/TagList>);
|
||||
// unsafe {
|
||||
// gobject_ffi::g_object_get_property(self.to_glib_none().0, "tags".to_glib_none().0, value.to_glib_none_mut().0);
|
||||
// }
|
||||
// value.get()
|
||||
//}
|
||||
|
||||
//fn set_property_tags(&self, tags: /*Ignored*/Option<&TagList>) {
|
||||
// unsafe {
|
||||
// gobject_ffi::g_object_set_property(self.to_glib_none().0, "tags".to_glib_none().0, Value::from(tags).to_glib_none().0);
|
||||
// }
|
||||
//}
|
||||
}
|
||||
|
|
|
@ -10,12 +10,15 @@ use Pad;
|
|||
use PadProbeType;
|
||||
use PadProbeReturn;
|
||||
use Buffer;
|
||||
use FlowReturn;
|
||||
|
||||
use std::cell::RefCell;
|
||||
use std::mem::transmute;
|
||||
use std::ptr;
|
||||
|
||||
use glib::{IsA, StaticType};
|
||||
use glib::translate::{ToGlib, FromGlib, from_glib, from_glib_none, from_glib_borrow};
|
||||
use glib::translate::{ToGlib, FromGlib, from_glib, from_glib_none, from_glib_borrow,
|
||||
from_glib_full};
|
||||
use glib::source::CallbackGuard;
|
||||
use glib_ffi::gpointer;
|
||||
|
||||
|
@ -62,6 +65,12 @@ pub trait PadExtManual {
|
|||
where
|
||||
F: FnMut(&Pad, &mut PadProbeInfo) -> PadProbeReturn + Send + Sync + 'static;
|
||||
fn remove_probe(&self, id: PadProbeId);
|
||||
|
||||
fn chain(&self, buffer: Buffer) -> FlowReturn;
|
||||
fn push(&self, buffer: Buffer) -> FlowReturn;
|
||||
|
||||
fn pull_range(&self, offset: u64, size: u32) -> Result<Buffer, FlowReturn>;
|
||||
fn get_range(&self, offset: u64, size: u32) -> Result<Buffer, FlowReturn>;
|
||||
}
|
||||
|
||||
impl<O: IsA<Pad>> PadExtManual for O {
|
||||
|
@ -87,6 +96,48 @@ impl<O: IsA<Pad>> PadExtManual for O {
|
|||
ffi::gst_pad_remove_probe(self.to_glib_none().0, id.to_glib());
|
||||
}
|
||||
}
|
||||
|
||||
fn chain(&self, buffer: Buffer) -> FlowReturn {
|
||||
unsafe { from_glib(ffi::gst_pad_chain(self.to_glib_none().0, buffer.into_ptr())) }
|
||||
}
|
||||
|
||||
fn push(&self, buffer: Buffer) -> FlowReturn {
|
||||
unsafe { from_glib(ffi::gst_pad_push(self.to_glib_none().0, buffer.into_ptr())) }
|
||||
}
|
||||
|
||||
fn get_range(&self, offset: u64, size: u32) -> Result<Buffer, FlowReturn> {
|
||||
unsafe {
|
||||
let mut buffer = ptr::null_mut();
|
||||
let ret = from_glib(ffi::gst_pad_get_range(
|
||||
self.to_glib_none().0,
|
||||
offset,
|
||||
size,
|
||||
&mut buffer,
|
||||
));
|
||||
if ret == FlowReturn::Ok {
|
||||
Ok(from_glib_full(buffer))
|
||||
} else {
|
||||
Err(ret)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn pull_range(&self, offset: u64, size: u32) -> Result<Buffer, FlowReturn> {
|
||||
unsafe {
|
||||
let mut buffer = ptr::null_mut();
|
||||
let ret = from_glib(ffi::gst_pad_pull_range(
|
||||
self.to_glib_none().0,
|
||||
offset,
|
||||
size,
|
||||
&mut buffer,
|
||||
));
|
||||
if ret == FlowReturn::Ok {
|
||||
Ok(from_glib_full(buffer))
|
||||
} else {
|
||||
Err(ret)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
unsafe extern "C" fn trampoline_pad_probe(
|
||||
|
|
Loading…
Reference in a new issue