1// Take a look at the license at the top of the repository in the LICENSE file.
2
3use std::ffi::CStr;
4
5use glib::translate::*;
6
7use crate::{
8 DeviceProviderFactory, ELEMENT_METADATA_AUTHOR, ELEMENT_METADATA_DESCRIPTION,
9 ELEMENT_METADATA_DOC_URI, ELEMENT_METADATA_ICON_NAME, ELEMENT_METADATA_KLASS,
10 ELEMENT_METADATA_LONGNAME,
11};
12
13impl DeviceProviderFactory {
14 #[doc(alias = "gst_device_provider_factory_list_get_device_providers")]
15 pub fn factories(minrank: crate::Rank) -> glib::List<DeviceProviderFactory> {
16 assert_initialized_main_thread!();
17 unsafe {
18 FromGlibPtrContainer::from_glib_full(
19 ffi::gst_device_provider_factory_list_get_device_providers(minrank.into_glib()),
20 )
21 }
22 }
23
24 #[doc(alias = "gst_device_provider_factory_get_metadata")]
25 #[doc(alias = "get_metadata")]
26 pub fn metadata(&self, key: &str) -> Option<&str> {
27 unsafe {
28 let ptr = ffi::gst_device_provider_factory_get_metadata(
29 self.to_glib_none().0,
30 key.to_glib_none().0,
31 );
32
33 if ptr.is_null() {
34 None
35 } else {
36 Some(CStr::from_ptr(ptr).to_str().unwrap())
37 }
38 }
39 }
40
41 #[doc(alias = "get_longname")]
42 #[doc(alias = "gst_device_provider_factory_get_longname")]
43 pub fn longname(&self) -> &str {
44 self.metadata(ELEMENT_METADATA_LONGNAME).unwrap()
45 }
46
47 #[doc(alias = "get_klass")]
48 #[doc(alias = "gst_device_provider_factory_get_klass")]
49 pub fn klass(&self) -> &str {
50 self.metadata(ELEMENT_METADATA_KLASS).unwrap()
51 }
52
53 #[doc(alias = "get_description")]
54 #[doc(alias = "gst_device_provider_factory_get_description")]
55 pub fn description(&self) -> &str {
56 self.metadata(ELEMENT_METADATA_DESCRIPTION).unwrap()
57 }
58
59 #[doc(alias = "get_author")]
60 #[doc(alias = "gst_device_provider_factory_get_author")]
61 pub fn author(&self) -> &str {
62 self.metadata(ELEMENT_METADATA_AUTHOR).unwrap()
63 }
64
65 #[doc(alias = "get_documentation_uri")]
66 #[doc(alias = "gst_device_provider_factory_get_documentation_uri")]
67 pub fn documentation_uri(&self) -> Option<&str> {
68 self.metadata(ELEMENT_METADATA_DOC_URI)
69 }
70
71 #[doc(alias = "get_icon_name")]
72 #[doc(alias = "gst_device_provider_factory_get_icon_name")]
73 pub fn icon_name(&self) -> Option<&str> {
74 self.metadata(ELEMENT_METADATA_ICON_NAME)
75 }
76}
77