diff --git a/gstreamer/Gir.toml b/gstreamer/Gir.toml index 8f503e379..4ad129e9e 100644 --- a/gstreamer/Gir.toml +++ b/gstreamer/Gir.toml @@ -1113,6 +1113,11 @@ final_type = true # Use glib::List as return type manual = true + [[object.function]] + name = "get_metadata" + # Use str as return type + manual = true + [[object]] name = "Gst.TypeFindFactory" status = "generate" @@ -1139,6 +1144,11 @@ final_type = true # Use glib::List as return type manual = true + [[object.function]] + name = "get_metadata" + # Use str as return type + manual = true + [[object]] name = "Gst.DeviceProvider" status = "generate" diff --git a/gstreamer/src/auto/device_provider_factory.rs b/gstreamer/src/auto/device_provider_factory.rs index b5ac8c831..7d51607b8 100644 --- a/gstreamer/src/auto/device_provider_factory.rs +++ b/gstreamer/src/auto/device_provider_factory.rs @@ -33,17 +33,6 @@ impl DeviceProviderFactory { } } - #[doc(alias = "gst_device_provider_factory_get_metadata")] - #[doc(alias = "get_metadata")] - pub fn metadata(&self, key: &str) -> Option { - unsafe { - from_glib_none(ffi::gst_device_provider_factory_get_metadata( - self.to_glib_none().0, - key.to_glib_none().0, - )) - } - } - #[doc(alias = "gst_device_provider_factory_get_metadata_keys")] #[doc(alias = "get_metadata_keys")] pub fn metadata_keys(&self) -> Vec { diff --git a/gstreamer/src/auto/element_factory.rs b/gstreamer/src/auto/element_factory.rs index 9e702af11..ec2f314ed 100644 --- a/gstreamer/src/auto/element_factory.rs +++ b/gstreamer/src/auto/element_factory.rs @@ -81,17 +81,6 @@ impl ElementFactory { } } - #[doc(alias = "gst_element_factory_get_metadata")] - #[doc(alias = "get_metadata")] - pub fn metadata(&self, key: &str) -> Option { - unsafe { - from_glib_none(ffi::gst_element_factory_get_metadata( - self.to_glib_none().0, - key.to_glib_none().0, - )) - } - } - #[doc(alias = "gst_element_factory_get_metadata_keys")] #[doc(alias = "get_metadata_keys")] pub fn metadata_keys(&self) -> Vec { diff --git a/gstreamer/src/device_provider_factory.rs b/gstreamer/src/device_provider_factory.rs index 2e1809c21..2b3a7a6b4 100644 --- a/gstreamer/src/device_provider_factory.rs +++ b/gstreamer/src/device_provider_factory.rs @@ -1,7 +1,14 @@ // Take a look at the license at the top of the repository in the LICENSE file. use crate::DeviceProviderFactory; +use crate::ELEMENT_METADATA_AUTHOR; +use crate::ELEMENT_METADATA_DESCRIPTION; +use crate::ELEMENT_METADATA_DOC_URI; +use crate::ELEMENT_METADATA_ICON_NAME; +use crate::ELEMENT_METADATA_KLASS; +use crate::ELEMENT_METADATA_LONGNAME; use glib::translate::*; +use std::ffi::CStr; impl DeviceProviderFactory { #[doc(alias = "gst_device_provider_factory_list_get_device_providers")] @@ -13,4 +20,57 @@ impl DeviceProviderFactory { ) } } + + #[doc(alias = "gst_device_provider_factory_get_metadata")] + #[doc(alias = "get_metadata")] + pub fn metadata(&self, key: &str) -> Option<&str> { + unsafe { + let ptr = ffi::gst_device_provider_factory_get_metadata( + self.to_glib_none().0, + key.to_glib_none().0, + ); + + if ptr.is_null() { + None + } else { + Some(CStr::from_ptr(ptr).to_str().unwrap()) + } + } + } + + #[doc(alias = "get_longname")] + #[doc(alias = "gst_device_provider_factory_get_longname")] + pub fn longname(&self) -> &str { + self.metadata(&ELEMENT_METADATA_LONGNAME).unwrap() + } + + #[doc(alias = "get_klass")] + #[doc(alias = "gst_device_provider_factory_get_klass")] + pub fn klass(&self) -> &str { + self.metadata(&ELEMENT_METADATA_KLASS).unwrap() + } + + #[doc(alias = "get_description")] + #[doc(alias = "gst_device_provider_factory_get_description")] + pub fn description(&self) -> &str { + self.metadata(&ELEMENT_METADATA_DESCRIPTION).unwrap() + } + + #[doc(alias = "get_author")] + #[doc(alias = "gst_device_provider_factory_get_author")] + pub fn author(&self) -> &str { + self.metadata(&ELEMENT_METADATA_AUTHOR).unwrap() + } + + #[doc(alias = "get_documentation_uri")] + #[doc(alias = "gst_device_provider_factory_get_documentation_uri")] + pub fn documentation_uri(&self) -> Option<&str> { + self.metadata(&ELEMENT_METADATA_DOC_URI) + } + + #[doc(alias = "get_icon_name")] + #[doc(alias = "gst_device_provider_factory_get_icon_name")] + pub fn icon_name(&self) -> Option<&str> { + self.metadata(&ELEMENT_METADATA_ICON_NAME) + } } diff --git a/gstreamer/src/element_factory.rs b/gstreamer/src/element_factory.rs index 95554c74b..6cc12d056 100644 --- a/gstreamer/src/element_factory.rs +++ b/gstreamer/src/element_factory.rs @@ -1,5 +1,13 @@ // Take a look at the license at the top of the repository in the LICENSE file. +use crate::ELEMENT_METADATA_AUTHOR; +use crate::ELEMENT_METADATA_DESCRIPTION; +use crate::ELEMENT_METADATA_DOC_URI; +use crate::ELEMENT_METADATA_ICON_NAME; +use crate::ELEMENT_METADATA_KLASS; +use crate::ELEMENT_METADATA_LONGNAME; +use std::ffi::CStr; + #[cfg(any(feature = "v1_20", feature = "dox"))] use crate::Element; use crate::ElementFactory; @@ -97,4 +105,55 @@ impl ElementFactory { )) } } + + #[doc(alias = "gst_element_factory_get_metadata")] + #[doc(alias = "get_metadata")] + pub fn metadata(&self, key: &str) -> Option<&str> { + unsafe { + let ptr = + ffi::gst_element_factory_get_metadata(self.to_glib_none().0, key.to_glib_none().0); + + if ptr.is_null() { + None + } else { + Some(CStr::from_ptr(ptr).to_str().unwrap()) + } + } + } + + #[doc(alias = "get_longname")] + #[doc(alias = "gst_element_factory_get_longname")] + pub fn longname(&self) -> &str { + self.metadata(&ELEMENT_METADATA_LONGNAME).unwrap() + } + + #[doc(alias = "get_klass")] + #[doc(alias = "gst_element_factory_get_klass")] + pub fn klass(&self) -> &str { + self.metadata(&ELEMENT_METADATA_KLASS).unwrap() + } + + #[doc(alias = "get_description")] + #[doc(alias = "gst_element_factory_get_description")] + pub fn description(&self) -> &str { + self.metadata(&ELEMENT_METADATA_DESCRIPTION).unwrap() + } + + #[doc(alias = "get_author")] + #[doc(alias = "gst_element_factory_get_author")] + pub fn author(&self) -> &str { + self.metadata(&ELEMENT_METADATA_AUTHOR).unwrap() + } + + #[doc(alias = "get_documentation_uri")] + #[doc(alias = "gst_element_factory_get_documentation_uri")] + pub fn documentation_uri(&self) -> Option<&str> { + self.metadata(&ELEMENT_METADATA_DOC_URI) + } + + #[doc(alias = "get_icon_name")] + #[doc(alias = "gst_element_factory_get_icon_name")] + pub fn icon_name(&self) -> Option<&str> { + self.metadata(&ELEMENT_METADATA_ICON_NAME) + } }