1 // Copyright (C) 2017 Sebastian Dröge <sebastian@centricular.com>
2 //
3 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
4 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
5 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
6 // option. This file may not be copied, modified, or distributed
7 // except according to those terms.
8 
9 use gst_sys;
10 use Plugin;
11 use PluginFlags;
12 use Structure;
13 use StructureRef;
14 
15 use glib::translate::*;
16 use glib::IsA;
17 
18 impl Plugin {
get_cache_data(&self) -> Option<&StructureRef>19     pub fn get_cache_data(&self) -> Option<&StructureRef> {
20         unsafe {
21             let cache_data = gst_sys::gst_plugin_get_cache_data(self.to_glib_none().0);
22             if cache_data.is_null() {
23                 None
24             } else {
25                 Some(StructureRef::from_glib_borrow(cache_data))
26             }
27         }
28     }
29 
set_cache_data(&self, cache_data: Structure)30     pub fn set_cache_data(&self, cache_data: Structure) {
31         unsafe {
32             gst_sys::gst_plugin_set_cache_data(self.to_glib_none().0, cache_data.into_ptr());
33         }
34     }
35 }
36 
37 pub trait GstPluginExtManual: 'static {
get_plugin_flags(&self) -> PluginFlags38     fn get_plugin_flags(&self) -> PluginFlags;
39 
get_plugin_name(&self) -> glib::GString40     fn get_plugin_name(&self) -> glib::GString;
41 }
42 
43 impl<O: IsA<::Plugin>> GstPluginExtManual for O {
get_plugin_flags(&self) -> PluginFlags44     fn get_plugin_flags(&self) -> PluginFlags {
45         unsafe {
46             let ptr: *mut gst_sys::GstObject = self.as_ptr() as *mut _;
47             let _guard = ::utils::MutexGuard::lock(&(*ptr).lock);
48             from_glib((*ptr).flags)
49         }
50     }
51 
get_plugin_name(&self) -> glib::GString52     fn get_plugin_name(&self) -> glib::GString {
53         unsafe { from_glib_none(gst_sys::gst_plugin_get_name(self.as_ref().to_glib_none().0)) }
54     }
55 }
56