mirror of
https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs.git
synced 2025-06-08 00:18:56 +00:00
create plugin_register_static in plugin_define!
This commit is contained in:
parent
cee861f341
commit
e4acf61af3
1 changed files with 25 additions and 4 deletions
|
@ -12,7 +12,10 @@ macro_rules! plugin_define(
|
||||||
$version:expr, $license:expr, $source:expr,
|
$version:expr, $license:expr, $source:expr,
|
||||||
$package:expr, $origin:expr, $release_datetime:expr) => {
|
$package:expr, $origin:expr, $release_datetime:expr) => {
|
||||||
pub mod plugin_desc {
|
pub mod plugin_desc {
|
||||||
use $crate::glib::translate::{from_glib_borrow, ToGlib};
|
use $crate::glib::translate::{from_glib_borrow, ToGlib, from_glib};
|
||||||
|
|
||||||
|
const MAJOR_VERSION: i32 = 1;
|
||||||
|
const MINOR_VERSION: i32 = 8;
|
||||||
|
|
||||||
// Not using c_char here because it requires the libc crate
|
// Not using c_char here because it requires the libc crate
|
||||||
#[allow(non_camel_case_types)]
|
#[allow(non_camel_case_types)]
|
||||||
|
@ -25,8 +28,8 @@ macro_rules! plugin_define(
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
#[allow(non_upper_case_globals)]
|
#[allow(non_upper_case_globals)]
|
||||||
pub static gst_plugin_desc: GstPluginDesc = GstPluginDesc($crate::gst_ffi::GstPluginDesc {
|
pub static gst_plugin_desc: GstPluginDesc = GstPluginDesc($crate::gst_ffi::GstPluginDesc {
|
||||||
major_version: 1,
|
major_version: MAJOR_VERSION,
|
||||||
minor_version: 8,
|
minor_version: MINOR_VERSION,
|
||||||
name: $name as *const u8 as *const c_char,
|
name: $name as *const u8 as *const c_char,
|
||||||
description: $description as *const u8 as *const c_char,
|
description: $description as *const u8 as *const c_char,
|
||||||
plugin_init: Some(plugin_init_trampoline),
|
plugin_init: Some(plugin_init_trampoline),
|
||||||
|
@ -39,6 +42,23 @@ macro_rules! plugin_define(
|
||||||
_gst_reserved: [0 as $crate::glib_ffi::gpointer; 4],
|
_gst_reserved: [0 as $crate::glib_ffi::gpointer; 4],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
pub fn plugin_register_static() -> bool {
|
||||||
|
unsafe {
|
||||||
|
from_glib($crate::gst_ffi::gst_plugin_register_static(
|
||||||
|
MAJOR_VERSION,
|
||||||
|
MINOR_VERSION,
|
||||||
|
$name as *const u8 as *const c_char,
|
||||||
|
$description as *const u8 as *const c_char,
|
||||||
|
Some(plugin_init_trampoline),
|
||||||
|
$version as *const u8 as *const c_char,
|
||||||
|
$license as *const u8 as *const c_char,
|
||||||
|
$source as *const u8 as *const c_char,
|
||||||
|
$package as *const u8 as *const c_char,
|
||||||
|
$origin as *const u8 as *const c_char,
|
||||||
|
))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
unsafe extern "C" fn plugin_init_trampoline(plugin: *mut $crate::gst_ffi::GstPlugin) -> $crate::glib_ffi::gboolean {
|
unsafe extern "C" fn plugin_init_trampoline(plugin: *mut $crate::gst_ffi::GstPlugin) -> $crate::glib_ffi::gboolean {
|
||||||
use std::panic::{self, AssertUnwindSafe};
|
use std::panic::{self, AssertUnwindSafe};
|
||||||
|
|
||||||
|
@ -51,7 +71,7 @@ macro_rules! plugin_define(
|
||||||
gst_error!(cat, "Failed to register plugin: {}", err);
|
gst_error!(cat, "Failed to register plugin: {}", err);
|
||||||
$crate::glib_ffi::GFALSE
|
$crate::glib_ffi::GFALSE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
let cat = $crate::gst::DebugCategory::get("GST_PLUGIN_LOADING").unwrap();
|
let cat = $crate::gst::DebugCategory::get("GST_PLUGIN_LOADING").unwrap();
|
||||||
if let Some(cause) = err.downcast_ref::<&str>() {
|
if let Some(cause) = err.downcast_ref::<&str>() {
|
||||||
|
@ -67,5 +87,6 @@ macro_rules! plugin_define(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
pub use plugin_desc::plugin_register_static;
|
||||||
};
|
};
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in a new issue