From 4964495b03c4a13226ae3af62be38880a3730ea7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Tue, 11 Jul 2017 00:26:27 +0300 Subject: [PATCH] Implement some more missing API now that we have Structure --- Gir_Gst.toml | 10 ++- gstreamer/src/auto/stream.rs | 19 +---- gstreamer/src/message.rs | 131 ++++++++++++++++++++++++++++++++--- 3 files changed, 132 insertions(+), 28 deletions(-) diff --git a/Gir_Gst.toml b/Gir_Gst.toml index e63d6ce97..272c22b95 100644 --- a/Gir_Gst.toml +++ b/Gir_Gst.toml @@ -42,7 +42,6 @@ generate = [ "Gst.DeviceMonitor", "Gst.DeviceProvider", "Gst.DeviceProviderFactory", - "Gst.Stream", "Gst.StreamCollection", "Gst.StreamType", "Gst.StreamFlags", @@ -252,6 +251,15 @@ status = "generate" # Caps is not a GObject ignore = true +[[object]] +name = "Gst.Stream" +status = "generate" + + [[object.property]] + name = "caps" + # Caps is not a GObject + ignore = true + [[object]] name = "Gst.Plugin" status = "generate" diff --git a/gstreamer/src/auto/stream.rs b/gstreamer/src/auto/stream.rs index d3e18eb42..72f0ddaca 100644 --- a/gstreamer/src/auto/stream.rs +++ b/gstreamer/src/auto/stream.rs @@ -1,6 +1,7 @@ // This file was generated by gir (33e9567+) from gir-files (???) // DO NOT EDIT +#[cfg(feature = "v1_10")] use Caps; use Object; use StreamFlags; @@ -66,10 +67,6 @@ pub trait StreamExt { //#[cfg(feature = "v1_10")] //fn set_tags<'a, P: Into>>(&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 set_property_stream_flags(&self, stream_flags: StreamFlags); @@ -147,20 +144,6 @@ impl + IsA> StreamExt for O { // 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 { let mut value = Value::from(&0u32); unsafe { diff --git a/gstreamer/src/message.rs b/gstreamer/src/message.rs index 93e29bc19..e5719a6f6 100644 --- a/gstreamer/src/message.rs +++ b/gstreamer/src/message.rs @@ -10,6 +10,7 @@ use ffi; use Object; use Element; use miniobject::*; +use structure::*; use std::ptr; 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 { 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); @@ -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); @@ -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); @@ -758,6 +803,7 @@ pub struct ErrorBuilder<'a> { seqnum: Option, error: &'a glib::Error, debug: Option<&'a str>, + details: Option, } impl<'a> ErrorBuilder<'a> { pub fn new(error: &'a glib::Error) -> Self { @@ -766,6 +812,7 @@ impl<'a> ErrorBuilder<'a> { seqnum: None, error: error, 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> { @@ -786,6 +853,7 @@ pub struct WarningBuilder<'a> { seqnum: Option, error: &'a glib::Error, debug: Option<&'a str>, + details: Option, } impl<'a> WarningBuilder<'a> { pub fn new(error: &'a glib::Error) -> Self { @@ -794,6 +862,7 @@ impl<'a> WarningBuilder<'a> { seqnum: None, error: error, 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> { @@ -812,6 +903,7 @@ pub struct InfoBuilder<'a> { seqnum: Option, error: &'a glib::Error, debug: Option<&'a str>, + details: Option, } impl<'a> InfoBuilder<'a> { pub fn new(error: &'a glib::Error) -> Self { @@ -820,6 +912,7 @@ impl<'a> InfoBuilder<'a> { seqnum: None, error: error, 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> {