1 | // This file was generated by gir (https://github.com/gtk-rs/gir) |
2 | // from gir-files (https://github.com/gtk-rs/gir-files) |
3 | // from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git) |
4 | // DO NOT EDIT |
5 | |
6 | use crate::{Object, PluginDependencyFlags, Structure}; |
7 | use glib::translate::*; |
8 | use std::{fmt, ptr}; |
9 | |
10 | glib::wrapper! { |
11 | #[doc (alias = "GstPlugin" )] |
12 | pub struct Plugin(Object<ffi::GstPlugin, ffi::GstPluginClass>) @extends Object; |
13 | |
14 | match fn { |
15 | type_ => || ffi::gst_plugin_get_type(), |
16 | } |
17 | } |
18 | |
19 | impl Plugin { |
20 | #[doc (alias = "gst_plugin_add_dependency" )] |
21 | pub fn add_dependency( |
22 | &self, |
23 | env_vars: &[&str], |
24 | paths: &[&str], |
25 | names: &[&str], |
26 | flags: PluginDependencyFlags, |
27 | ) { |
28 | unsafe { |
29 | ffi::gst_plugin_add_dependency( |
30 | self.to_glib_none().0, |
31 | env_vars.to_glib_none().0, |
32 | paths.to_glib_none().0, |
33 | names.to_glib_none().0, |
34 | flags.into_glib(), |
35 | ); |
36 | } |
37 | } |
38 | |
39 | #[doc (alias = "gst_plugin_add_dependency_simple" )] |
40 | pub fn add_dependency_simple( |
41 | &self, |
42 | env_vars: Option<&str>, |
43 | paths: Option<&str>, |
44 | names: Option<&str>, |
45 | flags: PluginDependencyFlags, |
46 | ) { |
47 | unsafe { |
48 | ffi::gst_plugin_add_dependency_simple( |
49 | self.to_glib_none().0, |
50 | env_vars.to_glib_none().0, |
51 | paths.to_glib_none().0, |
52 | names.to_glib_none().0, |
53 | flags.into_glib(), |
54 | ); |
55 | } |
56 | } |
57 | |
58 | #[doc (alias = "gst_plugin_get_description" )] |
59 | #[doc (alias = "get_description" )] |
60 | pub fn description(&self) -> glib::GString { |
61 | unsafe { from_glib_none(ffi::gst_plugin_get_description(self.to_glib_none().0)) } |
62 | } |
63 | |
64 | #[doc (alias = "gst_plugin_get_filename" )] |
65 | #[doc (alias = "get_filename" )] |
66 | pub fn filename(&self) -> Option<std::path::PathBuf> { |
67 | unsafe { from_glib_none(ffi::gst_plugin_get_filename(self.to_glib_none().0)) } |
68 | } |
69 | |
70 | #[doc (alias = "gst_plugin_get_license" )] |
71 | #[doc (alias = "get_license" )] |
72 | pub fn license(&self) -> glib::GString { |
73 | unsafe { from_glib_none(ffi::gst_plugin_get_license(self.to_glib_none().0)) } |
74 | } |
75 | |
76 | #[doc (alias = "gst_plugin_get_name" )] |
77 | #[doc (alias = "get_name" )] |
78 | pub fn plugin_name(&self) -> glib::GString { |
79 | unsafe { from_glib_none(ffi::gst_plugin_get_name(self.to_glib_none().0)) } |
80 | } |
81 | |
82 | #[doc (alias = "gst_plugin_get_origin" )] |
83 | #[doc (alias = "get_origin" )] |
84 | pub fn origin(&self) -> glib::GString { |
85 | unsafe { from_glib_none(ffi::gst_plugin_get_origin(self.to_glib_none().0)) } |
86 | } |
87 | |
88 | #[doc (alias = "gst_plugin_get_package" )] |
89 | #[doc (alias = "get_package" )] |
90 | pub fn package(&self) -> glib::GString { |
91 | unsafe { from_glib_none(ffi::gst_plugin_get_package(self.to_glib_none().0)) } |
92 | } |
93 | |
94 | #[doc (alias = "gst_plugin_get_release_date_string" )] |
95 | #[doc (alias = "get_release_date_string" )] |
96 | pub fn release_date_string(&self) -> Option<glib::GString> { |
97 | unsafe { |
98 | from_glib_none(ffi::gst_plugin_get_release_date_string( |
99 | self.to_glib_none().0, |
100 | )) |
101 | } |
102 | } |
103 | |
104 | #[doc (alias = "gst_plugin_get_source" )] |
105 | #[doc (alias = "get_source" )] |
106 | pub fn source(&self) -> glib::GString { |
107 | unsafe { from_glib_none(ffi::gst_plugin_get_source(self.to_glib_none().0)) } |
108 | } |
109 | |
110 | #[doc (alias = "gst_plugin_get_version" )] |
111 | #[doc (alias = "get_version" )] |
112 | pub fn version(&self) -> glib::GString { |
113 | unsafe { from_glib_none(ffi::gst_plugin_get_version(self.to_glib_none().0)) } |
114 | } |
115 | |
116 | #[doc (alias = "gst_plugin_is_loaded" )] |
117 | pub fn is_loaded(&self) -> bool { |
118 | unsafe { from_glib(ffi::gst_plugin_is_loaded(self.to_glib_none().0)) } |
119 | } |
120 | |
121 | #[doc (alias = "gst_plugin_load" )] |
122 | pub fn load(&self) -> Result<Plugin, glib::BoolError> { |
123 | unsafe { |
124 | Option::<_>::from_glib_full(ffi::gst_plugin_load(self.to_glib_none().0)) |
125 | .ok_or_else(|| glib::bool_error!("Failed to load plugin" )) |
126 | } |
127 | } |
128 | |
129 | #[doc (alias = "gst_plugin_set_cache_data" )] |
130 | pub fn set_cache_data(&self, cache_data: Structure) { |
131 | unsafe { |
132 | ffi::gst_plugin_set_cache_data(self.to_glib_none().0, cache_data.into_glib_ptr()); |
133 | } |
134 | } |
135 | |
136 | #[doc (alias = "gst_plugin_load_by_name" )] |
137 | pub fn load_by_name(name: &str) -> Result<Plugin, glib::BoolError> { |
138 | assert_initialized_main_thread!(); |
139 | unsafe { |
140 | Option::<_>::from_glib_full(ffi::gst_plugin_load_by_name(name.to_glib_none().0)) |
141 | .ok_or_else(|| glib::bool_error!("Failed to load plugin" )) |
142 | } |
143 | } |
144 | |
145 | #[doc (alias = "gst_plugin_load_file" )] |
146 | pub fn load_file(filename: impl AsRef<std::path::Path>) -> Result<Plugin, glib::Error> { |
147 | assert_initialized_main_thread!(); |
148 | unsafe { |
149 | let mut error = ptr::null_mut(); |
150 | let ret = ffi::gst_plugin_load_file(filename.as_ref().to_glib_none().0, &mut error); |
151 | if error.is_null() { |
152 | Ok(from_glib_full(ret)) |
153 | } else { |
154 | Err(from_glib_full(error)) |
155 | } |
156 | } |
157 | } |
158 | } |
159 | |
160 | impl fmt::Display for Plugin { |
161 | #[inline ] |
162 | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { |
163 | f.write_str(&self.plugin_name()) |
164 | } |
165 | } |
166 | |
167 | unsafe impl Send for Plugin {} |
168 | unsafe impl Sync for Plugin {} |
169 | |