Implement some more missing API now that we have Structure

This commit is contained in:
Sebastian Dröge 2017-07-11 00:26:27 +03:00
parent 8f49779329
commit 4964495b03
3 changed files with 132 additions and 28 deletions

View file

@ -42,7 +42,6 @@ generate = [
"Gst.DeviceMonitor", "Gst.DeviceMonitor",
"Gst.DeviceProvider", "Gst.DeviceProvider",
"Gst.DeviceProviderFactory", "Gst.DeviceProviderFactory",
"Gst.Stream",
"Gst.StreamCollection", "Gst.StreamCollection",
"Gst.StreamType", "Gst.StreamType",
"Gst.StreamFlags", "Gst.StreamFlags",
@ -252,6 +251,15 @@ status = "generate"
# Caps is not a GObject # Caps is not a GObject
ignore = true ignore = true
[[object]]
name = "Gst.Stream"
status = "generate"
[[object.property]]
name = "caps"
# Caps is not a GObject
ignore = true
[[object]] [[object]]
name = "Gst.Plugin" name = "Gst.Plugin"
status = "generate" status = "generate"

View file

@ -1,6 +1,7 @@
// This file was generated by gir (33e9567+) from gir-files (???) // This file was generated by gir (33e9567+) from gir-files (???)
// DO NOT EDIT // DO NOT EDIT
#[cfg(feature = "v1_10")]
use Caps; use Caps;
use Object; use Object;
use StreamFlags; use StreamFlags;
@ -66,10 +67,6 @@ pub trait StreamExt {
//#[cfg(feature = "v1_10")] //#[cfg(feature = "v1_10")]
//fn set_tags<'a, P: Into<Option<&'a /*Ignored*/TagList>>>(&self, tags: P); //fn set_tags<'a, P: Into<Option<&'a /*Ignored*/TagList>>>(&self, tags: P);
fn get_property_caps(&self) -> Option<&Caps>;
fn set_property_caps(&self, caps: Option<&Caps>);
fn get_property_stream_flags(&self) -> StreamFlags; fn get_property_stream_flags(&self) -> StreamFlags;
fn set_property_stream_flags(&self, stream_flags: StreamFlags); fn set_property_stream_flags(&self, stream_flags: StreamFlags);
@ -147,20 +144,6 @@ impl<O: IsA<Stream> + IsA<glib::object::Object>> StreamExt for O {
// unsafe { TODO: call ffi::gst_stream_set_tags() } // unsafe { TODO: call ffi::gst_stream_set_tags() }
//} //}
fn get_property_caps(&self) -> Option<&Caps> {
let mut value = Value::from(None::<&Caps>);
unsafe {
gobject_ffi::g_object_get_property(self.to_glib_none().0, "caps".to_glib_none().0, value.to_glib_none_mut().0);
}
value.get()
}
fn set_property_caps(&self, caps: Option<&Caps>) {
unsafe {
gobject_ffi::g_object_set_property(self.to_glib_none().0, "caps".to_glib_none().0, Value::from(caps).to_glib_none().0);
}
}
fn get_property_stream_flags(&self) -> StreamFlags { fn get_property_stream_flags(&self) -> StreamFlags {
let mut value = Value::from(&0u32); let mut value = Value::from(&0u32);
unsafe { unsafe {

View file

@ -10,6 +10,7 @@ use ffi;
use Object; use Object;
use Element; use Element;
use miniobject::*; use miniobject::*;
use structure::*;
use std::ptr; use std::ptr;
use std::mem; use std::mem;
@ -41,7 +42,12 @@ impl MessageRef {
} }
} }
// TODO get_structure() pub fn get_structure(&self) -> &StructureRef {
unsafe {
let structure = ffi::gst_message_get_structure(self.as_mut_ptr());
StructureRef::from_glib_borrow(structure)
}
}
pub fn view(&self) -> MessageView { pub fn view(&self) -> MessageView {
let type_ = unsafe { (*self.as_ptr()).type_ }; let type_ = unsafe { (*self.as_ptr()).type_ };
@ -196,7 +202,20 @@ impl<'a> Error<'a> {
} }
} }
// TODO get_details() #[cfg(feature = "v1_10")]
pub fn get_details(&self) -> Option<&StructureRef> {
unsafe {
let mut details = ptr::null();
ffi::gst_message_parse_error_details(self.0.as_mut_ptr(), &mut details);
if details.is_null() {
None
} else {
Some(StructureRef::from_glib_borrow(details))
}
}
}
} }
pub struct Warning<'a>(&'a MessageRef); pub struct Warning<'a>(&'a MessageRef);
@ -221,7 +240,20 @@ impl<'a> Warning<'a> {
} }
} }
// TODO get_details() #[cfg(feature = "v1_10")]
pub fn get_details(&self) -> Option<&StructureRef> {
unsafe {
let mut details = ptr::null();
ffi::gst_message_parse_error_details(self.0.as_mut_ptr(), &mut details);
if details.is_null() {
None
} else {
Some(StructureRef::from_glib_borrow(details))
}
}
}
} }
pub struct Info<'a>(&'a MessageRef); pub struct Info<'a>(&'a MessageRef);
@ -246,7 +278,20 @@ impl<'a> Info<'a> {
} }
} }
// TODO get_details() #[cfg(feature = "v1_10")]
pub fn get_details(&self) -> Option<&StructureRef> {
unsafe {
let mut details = ptr::null();
ffi::gst_message_parse_error_details(self.0.as_mut_ptr(), &mut details);
if details.is_null() {
None
} else {
Some(StructureRef::from_glib_borrow(details))
}
}
}
} }
pub struct Tag<'a>(&'a MessageRef); pub struct Tag<'a>(&'a MessageRef);
@ -758,6 +803,7 @@ pub struct ErrorBuilder<'a> {
seqnum: Option<u32>, seqnum: Option<u32>,
error: &'a glib::Error, error: &'a glib::Error,
debug: Option<&'a str>, debug: Option<&'a str>,
details: Option<Structure>,
} }
impl<'a> ErrorBuilder<'a> { impl<'a> ErrorBuilder<'a> {
pub fn new(error: &'a glib::Error) -> Self { pub fn new(error: &'a glib::Error) -> Self {
@ -766,6 +812,7 @@ impl<'a> ErrorBuilder<'a> {
seqnum: None, seqnum: None,
error: error, error: error,
debug: None, debug: None,
details: None,
} }
} }
@ -776,9 +823,29 @@ impl<'a> ErrorBuilder<'a> {
} }
} }
// TODO details #[cfg(feature = "v1_10")]
pub fn details(self, details: Structure) -> Self {
Self {
details: Some(details),
.. self
}
}
message_builder_generic_impl!(|s: &mut Self, src| ffi::gst_message_new_error(src, mut_override(s.error.to_glib_none().0), s.debug.to_glib_none().0)); message_builder_generic_impl!(|s: &mut Self, src| {
#[cfg(feature = "v1_10")]
{
let details = match s.details.take() {
None => ptr::null_mut(),
Some(details) => details.into_ptr(),
};
ffi::gst_message_new_error_with_details(src, mut_override(s.error.to_glib_none().0), s.debug.to_glib_none().0, details)
}
#[cfg(not(feature = "v1_10"))]
{
ffi::gst_message_new_error(src, mut_override(s.error.to_glib_none().0), s.debug.to_glib_none().0)
}
});
} }
pub struct WarningBuilder<'a> { pub struct WarningBuilder<'a> {
@ -786,6 +853,7 @@ pub struct WarningBuilder<'a> {
seqnum: Option<u32>, seqnum: Option<u32>,
error: &'a glib::Error, error: &'a glib::Error,
debug: Option<&'a str>, debug: Option<&'a str>,
details: Option<Structure>,
} }
impl<'a> WarningBuilder<'a> { impl<'a> WarningBuilder<'a> {
pub fn new(error: &'a glib::Error) -> Self { pub fn new(error: &'a glib::Error) -> Self {
@ -794,6 +862,7 @@ impl<'a> WarningBuilder<'a> {
seqnum: None, seqnum: None,
error: error, error: error,
debug: None, debug: None,
details: None,
} }
} }
@ -804,7 +873,29 @@ impl<'a> WarningBuilder<'a> {
} }
} }
message_builder_generic_impl!(|s: &mut Self, src| ffi::gst_message_new_warning(src, mut_override(s.error.to_glib_none().0), s.debug.to_glib_none().0)); #[cfg(feature = "v1_10")]
pub fn details(self, details: Structure) -> Self {
Self {
details: Some(details),
.. self
}
}
message_builder_generic_impl!(|s: &mut Self, src| {
#[cfg(feature = "v1_10")]
{
let details = match s.details.take() {
None => ptr::null_mut(),
Some(details) => details.into_ptr(),
};
ffi::gst_message_new_warning_with_details(src, mut_override(s.error.to_glib_none().0), s.debug.to_glib_none().0, details)
}
#[cfg(not(feature = "v1_10"))]
{
ffi::gst_message_new_warning(src, mut_override(s.error.to_glib_none().0), s.debug.to_glib_none().0)
}
});
} }
pub struct InfoBuilder<'a> { pub struct InfoBuilder<'a> {
@ -812,6 +903,7 @@ pub struct InfoBuilder<'a> {
seqnum: Option<u32>, seqnum: Option<u32>,
error: &'a glib::Error, error: &'a glib::Error,
debug: Option<&'a str>, debug: Option<&'a str>,
details: Option<Structure>,
} }
impl<'a> InfoBuilder<'a> { impl<'a> InfoBuilder<'a> {
pub fn new(error: &'a glib::Error) -> Self { pub fn new(error: &'a glib::Error) -> Self {
@ -820,6 +912,7 @@ impl<'a> InfoBuilder<'a> {
seqnum: None, seqnum: None,
error: error, error: error,
debug: None, debug: None,
details: None,
} }
} }
@ -830,9 +923,29 @@ impl<'a> InfoBuilder<'a> {
} }
} }
// TODO details #[cfg(feature = "v1_10")]
pub fn details(self, details: Structure) -> Self {
Self {
details: Some(details),
.. self
}
}
message_builder_generic_impl!(|s: &mut Self, src| ffi::gst_message_new_warning(src, mut_override(s.error.to_glib_none().0), s.debug.to_glib_none().0)); message_builder_generic_impl!(|s: &mut Self, src| {
#[cfg(feature = "v1_10")]
{
let details = match s.details.take() {
None => ptr::null_mut(),
Some(details) => details.into_ptr(),
};
ffi::gst_message_new_info_with_details(src, mut_override(s.error.to_glib_none().0), s.debug.to_glib_none().0, details)
}
#[cfg(not(feature = "v1_10"))]
{
ffi::gst_message_new_info(src, mut_override(s.error.to_glib_none().0), s.debug.to_glib_none().0)
}
});
} }
pub struct TagBuilder<'a> { pub struct TagBuilder<'a> {