2017-12-17 12:26:17 +00:00
|
|
|
// Copyright (C) 2017 Sebastian Dröge <sebastian@centricular.com>
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
|
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
|
|
// option. This file may not be copied, modified, or distributed
|
|
|
|
// except according to those terms.
|
|
|
|
|
2020-11-21 13:46:48 +00:00
|
|
|
use crate::Plugin;
|
|
|
|
use crate::PluginFlags;
|
|
|
|
use crate::Structure;
|
|
|
|
use crate::StructureRef;
|
2017-12-17 12:26:17 +00:00
|
|
|
|
|
|
|
use glib::translate::*;
|
2019-05-11 10:13:33 +00:00
|
|
|
use glib::IsA;
|
2017-12-17 12:26:17 +00:00
|
|
|
|
|
|
|
impl Plugin {
|
|
|
|
pub fn get_cache_data(&self) -> Option<&StructureRef> {
|
|
|
|
unsafe {
|
2020-11-21 13:46:48 +00:00
|
|
|
let cache_data = ffi::gst_plugin_get_cache_data(self.to_glib_none().0);
|
2017-12-17 12:26:17 +00:00
|
|
|
if cache_data.is_null() {
|
|
|
|
None
|
|
|
|
} else {
|
|
|
|
Some(StructureRef::from_glib_borrow(cache_data))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn set_cache_data(&self, cache_data: Structure) {
|
|
|
|
unsafe {
|
2020-11-21 13:46:48 +00:00
|
|
|
ffi::gst_plugin_set_cache_data(self.to_glib_none().0, cache_data.into_ptr());
|
2017-12-17 12:26:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-05-11 10:13:33 +00:00
|
|
|
|
|
|
|
pub trait GstPluginExtManual: 'static {
|
|
|
|
fn get_plugin_flags(&self) -> PluginFlags;
|
2020-04-11 16:33:34 +00:00
|
|
|
|
|
|
|
fn get_plugin_name(&self) -> glib::GString;
|
2019-05-11 10:13:33 +00:00
|
|
|
}
|
|
|
|
|
2020-11-21 13:46:48 +00:00
|
|
|
impl<O: IsA<crate::Plugin>> GstPluginExtManual for O {
|
2019-05-11 10:13:33 +00:00
|
|
|
fn get_plugin_flags(&self) -> PluginFlags {
|
|
|
|
unsafe {
|
2020-11-21 13:46:48 +00:00
|
|
|
let ptr: *mut ffi::GstObject = self.as_ptr() as *mut _;
|
|
|
|
let _guard = crate::utils::MutexGuard::lock(&(*ptr).lock);
|
2019-05-11 10:13:33 +00:00
|
|
|
from_glib((*ptr).flags)
|
|
|
|
}
|
|
|
|
}
|
2020-04-11 16:33:34 +00:00
|
|
|
|
|
|
|
fn get_plugin_name(&self) -> glib::GString {
|
2020-11-21 13:46:48 +00:00
|
|
|
unsafe { from_glib_none(ffi::gst_plugin_get_name(self.as_ref().to_glib_none().0)) }
|
2020-04-11 16:33:34 +00:00
|
|
|
}
|
2019-05-11 10:13:33 +00:00
|
|
|
}
|