gstreamer/
plugin.rs

1// Take a look at the license at the top of the repository in the LICENSE file.
2
3use glib::{prelude::*, translate::*};
4
5use crate::{ffi, prelude::*, Plugin, PluginFlags, StructureRef};
6
7impl Plugin {
8    /// Gets the plugin specific data cache. If it is [`None`] there is no cached data
9    /// stored. This is the case when the registry is getting rebuilt.
10    ///
11    /// # Returns
12    ///
13    /// The cached data as a
14    /// [`Structure`][crate::Structure] or [`None`].
15    #[doc(alias = "get_cache_data")]
16    #[doc(alias = "gst_plugin_get_cache_data")]
17    pub fn cache_data(&self) -> Option<&StructureRef> {
18        unsafe {
19            let cache_data = ffi::gst_plugin_get_cache_data(self.to_glib_none().0);
20            if cache_data.is_null() {
21                None
22            } else {
23                Some(StructureRef::from_glib_borrow(cache_data))
24            }
25        }
26    }
27
28    #[doc(alias = "get_plugin_flags")]
29    pub fn plugin_flags(&self) -> PluginFlags {
30        unsafe {
31            let ptr: *mut ffi::GstObject = self.as_ptr() as *mut _;
32            let _guard = self.object_lock();
33            from_glib((*ptr).flags)
34        }
35    }
36}