| 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::{ffi, Object, PluginDependencyFlags, Structure}; |
| 7 | use glib::translate::*; |
| 8 | |
| 9 | glib::wrapper! { |
| 10 | #[doc (alias = "GstPlugin" )] |
| 11 | pub struct Plugin(Object<ffi::GstPlugin, ffi::GstPluginClass>) @extends Object; |
| 12 | |
| 13 | match fn { |
| 14 | type_ => || ffi::gst_plugin_get_type(), |
| 15 | } |
| 16 | } |
| 17 | |
| 18 | impl Plugin { |
| 19 | #[doc (alias = "gst_plugin_add_dependency" )] |
| 20 | pub fn add_dependency( |
| 21 | &self, |
| 22 | env_vars: &[&str], |
| 23 | paths: &[&str], |
| 24 | names: &[&str], |
| 25 | flags: PluginDependencyFlags, |
| 26 | ) { |
| 27 | unsafe { |
| 28 | ffi::gst_plugin_add_dependency( |
| 29 | self.to_glib_none().0, |
| 30 | env_vars.to_glib_none().0, |
| 31 | paths.to_glib_none().0, |
| 32 | names.to_glib_none().0, |
| 33 | flags.into_glib(), |
| 34 | ); |
| 35 | } |
| 36 | } |
| 37 | |
| 38 | #[doc (alias = "gst_plugin_add_dependency_simple" )] |
| 39 | pub fn add_dependency_simple( |
| 40 | &self, |
| 41 | env_vars: Option<&str>, |
| 42 | paths: Option<&str>, |
| 43 | names: Option<&str>, |
| 44 | flags: PluginDependencyFlags, |
| 45 | ) { |
| 46 | unsafe { |
| 47 | ffi::gst_plugin_add_dependency_simple( |
| 48 | self.to_glib_none().0, |
| 49 | env_vars.to_glib_none().0, |
| 50 | paths.to_glib_none().0, |
| 51 | names.to_glib_none().0, |
| 52 | flags.into_glib(), |
| 53 | ); |
| 54 | } |
| 55 | } |
| 56 | |
| 57 | #[cfg (feature = "v1_24" )] |
| 58 | #[cfg_attr (docsrs, doc(cfg(feature = "v1_24" )))] |
| 59 | #[doc (alias = "gst_plugin_add_status_error" )] |
| 60 | pub fn add_status_error(&self, message: &str) { |
| 61 | unsafe { |
| 62 | ffi::gst_plugin_add_status_error(self.to_glib_none().0, message.to_glib_none().0); |
| 63 | } |
| 64 | } |
| 65 | |
| 66 | #[cfg (feature = "v1_24" )] |
| 67 | #[cfg_attr (docsrs, doc(cfg(feature = "v1_24" )))] |
| 68 | #[doc (alias = "gst_plugin_add_status_info" )] |
| 69 | pub fn add_status_info(&self, message: &str) { |
| 70 | unsafe { |
| 71 | ffi::gst_plugin_add_status_info(self.to_glib_none().0, message.to_glib_none().0); |
| 72 | } |
| 73 | } |
| 74 | |
| 75 | #[cfg (feature = "v1_24" )] |
| 76 | #[cfg_attr (docsrs, doc(cfg(feature = "v1_24" )))] |
| 77 | #[doc (alias = "gst_plugin_add_status_warning" )] |
| 78 | pub fn add_status_warning(&self, message: &str) { |
| 79 | unsafe { |
| 80 | ffi::gst_plugin_add_status_warning(self.to_glib_none().0, message.to_glib_none().0); |
| 81 | } |
| 82 | } |
| 83 | |
| 84 | #[doc (alias = "gst_plugin_get_description" )] |
| 85 | #[doc (alias = "get_description" )] |
| 86 | pub fn description(&self) -> glib::GString { |
| 87 | unsafe { from_glib_none(ffi::gst_plugin_get_description(self.to_glib_none().0)) } |
| 88 | } |
| 89 | |
| 90 | #[doc (alias = "gst_plugin_get_filename" )] |
| 91 | #[doc (alias = "get_filename" )] |
| 92 | pub fn filename(&self) -> Option<std::path::PathBuf> { |
| 93 | unsafe { from_glib_none(ffi::gst_plugin_get_filename(self.to_glib_none().0)) } |
| 94 | } |
| 95 | |
| 96 | #[doc (alias = "gst_plugin_get_license" )] |
| 97 | #[doc (alias = "get_license" )] |
| 98 | pub fn license(&self) -> glib::GString { |
| 99 | unsafe { from_glib_none(ffi::gst_plugin_get_license(self.to_glib_none().0)) } |
| 100 | } |
| 101 | |
| 102 | #[doc (alias = "gst_plugin_get_name" )] |
| 103 | #[doc (alias = "get_name" )] |
| 104 | pub fn plugin_name(&self) -> glib::GString { |
| 105 | unsafe { from_glib_none(ffi::gst_plugin_get_name(self.to_glib_none().0)) } |
| 106 | } |
| 107 | |
| 108 | #[doc (alias = "gst_plugin_get_origin" )] |
| 109 | #[doc (alias = "get_origin" )] |
| 110 | pub fn origin(&self) -> glib::GString { |
| 111 | unsafe { from_glib_none(ffi::gst_plugin_get_origin(self.to_glib_none().0)) } |
| 112 | } |
| 113 | |
| 114 | #[doc (alias = "gst_plugin_get_package" )] |
| 115 | #[doc (alias = "get_package" )] |
| 116 | pub fn package(&self) -> glib::GString { |
| 117 | unsafe { from_glib_none(ffi::gst_plugin_get_package(self.to_glib_none().0)) } |
| 118 | } |
| 119 | |
| 120 | #[doc (alias = "gst_plugin_get_release_date_string" )] |
| 121 | #[doc (alias = "get_release_date_string" )] |
| 122 | pub fn release_date_string(&self) -> Option<glib::GString> { |
| 123 | unsafe { |
| 124 | from_glib_none(ffi::gst_plugin_get_release_date_string( |
| 125 | self.to_glib_none().0, |
| 126 | )) |
| 127 | } |
| 128 | } |
| 129 | |
| 130 | #[doc (alias = "gst_plugin_get_source" )] |
| 131 | #[doc (alias = "get_source" )] |
| 132 | pub fn source(&self) -> glib::GString { |
| 133 | unsafe { from_glib_none(ffi::gst_plugin_get_source(self.to_glib_none().0)) } |
| 134 | } |
| 135 | |
| 136 | #[cfg (feature = "v1_24" )] |
| 137 | #[cfg_attr (docsrs, doc(cfg(feature = "v1_24" )))] |
| 138 | #[doc (alias = "gst_plugin_get_status_errors" )] |
| 139 | #[doc (alias = "get_status_errors" )] |
| 140 | pub fn status_errors(&self) -> Vec<glib::GString> { |
| 141 | unsafe { |
| 142 | FromGlibPtrContainer::from_glib_full(ffi::gst_plugin_get_status_errors( |
| 143 | self.to_glib_none().0, |
| 144 | )) |
| 145 | } |
| 146 | } |
| 147 | |
| 148 | #[cfg (feature = "v1_24" )] |
| 149 | #[cfg_attr (docsrs, doc(cfg(feature = "v1_24" )))] |
| 150 | #[doc (alias = "gst_plugin_get_status_infos" )] |
| 151 | #[doc (alias = "get_status_infos" )] |
| 152 | pub fn status_infos(&self) -> Vec<glib::GString> { |
| 153 | unsafe { |
| 154 | FromGlibPtrContainer::from_glib_full(ffi::gst_plugin_get_status_infos( |
| 155 | self.to_glib_none().0, |
| 156 | )) |
| 157 | } |
| 158 | } |
| 159 | |
| 160 | #[cfg (feature = "v1_24" )] |
| 161 | #[cfg_attr (docsrs, doc(cfg(feature = "v1_24" )))] |
| 162 | #[doc (alias = "gst_plugin_get_status_warnings" )] |
| 163 | #[doc (alias = "get_status_warnings" )] |
| 164 | pub fn status_warnings(&self) -> Vec<glib::GString> { |
| 165 | unsafe { |
| 166 | FromGlibPtrContainer::from_glib_full(ffi::gst_plugin_get_status_warnings( |
| 167 | self.to_glib_none().0, |
| 168 | )) |
| 169 | } |
| 170 | } |
| 171 | |
| 172 | #[doc (alias = "gst_plugin_get_version" )] |
| 173 | #[doc (alias = "get_version" )] |
| 174 | pub fn version(&self) -> glib::GString { |
| 175 | unsafe { from_glib_none(ffi::gst_plugin_get_version(self.to_glib_none().0)) } |
| 176 | } |
| 177 | |
| 178 | #[doc (alias = "gst_plugin_is_loaded" )] |
| 179 | pub fn is_loaded(&self) -> bool { |
| 180 | unsafe { from_glib(ffi::gst_plugin_is_loaded(self.to_glib_none().0)) } |
| 181 | } |
| 182 | |
| 183 | #[doc (alias = "gst_plugin_load" )] |
| 184 | pub fn load(&self) -> Result<Plugin, glib::BoolError> { |
| 185 | unsafe { |
| 186 | Option::<_>::from_glib_full(ffi::gst_plugin_load(self.to_glib_none().0)) |
| 187 | .ok_or_else(|| glib::bool_error!("Failed to load plugin" )) |
| 188 | } |
| 189 | } |
| 190 | |
| 191 | #[doc (alias = "gst_plugin_set_cache_data" )] |
| 192 | pub fn set_cache_data(&self, cache_data: Structure) { |
| 193 | unsafe { |
| 194 | ffi::gst_plugin_set_cache_data(self.to_glib_none().0, cache_data.into_glib_ptr()); |
| 195 | } |
| 196 | } |
| 197 | |
| 198 | #[doc (alias = "gst_plugin_load_by_name" )] |
| 199 | pub fn load_by_name(name: &str) -> Result<Plugin, glib::BoolError> { |
| 200 | assert_initialized_main_thread!(); |
| 201 | unsafe { |
| 202 | Option::<_>::from_glib_full(ffi::gst_plugin_load_by_name(name.to_glib_none().0)) |
| 203 | .ok_or_else(|| glib::bool_error!("Failed to load plugin" )) |
| 204 | } |
| 205 | } |
| 206 | |
| 207 | #[doc (alias = "gst_plugin_load_file" )] |
| 208 | pub fn load_file(filename: impl AsRef<std::path::Path>) -> Result<Plugin, glib::Error> { |
| 209 | assert_initialized_main_thread!(); |
| 210 | unsafe { |
| 211 | let mut error = std::ptr::null_mut(); |
| 212 | let ret = ffi::gst_plugin_load_file(filename.as_ref().to_glib_none().0, &mut error); |
| 213 | if error.is_null() { |
| 214 | Ok(from_glib_full(ret)) |
| 215 | } else { |
| 216 | Err(from_glib_full(error)) |
| 217 | } |
| 218 | } |
| 219 | } |
| 220 | } |
| 221 | |
| 222 | impl std::fmt::Display for Plugin { |
| 223 | #[inline ] |
| 224 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { |
| 225 | f.write_str(&self.plugin_name()) |
| 226 | } |
| 227 | } |
| 228 | |
| 229 | unsafe impl Send for Plugin {} |
| 230 | unsafe impl Sync for Plugin {} |
| 231 | |