From 7a69a1137c190927e351205074b641d525e6ce25 Mon Sep 17 00:00:00 2001 From: Guillaume Desmottes Date: Tue, 4 Jun 2019 15:04:50 +0530 Subject: [PATCH] gstreamer: plugin_feature: use Rank enum --- Gir_Gst.toml | 8 +++++++ gstreamer/src/auto/plugin_feature.rs | 16 ------------- gstreamer/src/lib.rs | 3 +++ gstreamer/src/plugin_feature.rs | 36 ++++++++++++++++++++++++++++ 4 files changed, 47 insertions(+), 16 deletions(-) create mode 100644 gstreamer/src/plugin_feature.rs diff --git a/Gir_Gst.toml b/Gir_Gst.toml index ef6033455..a648070c0 100644 --- a/Gir_Gst.toml +++ b/Gir_Gst.toml @@ -1003,6 +1003,14 @@ status = "generate" name = "rank_compare_func" ignore = true + [[object.function]] + name = "get_rank" + ignore = true + + [[object.function]] + name = "set_rank" + ignore = true + [[object]] name = "Gst.Registry" status = "generate" diff --git a/gstreamer/src/auto/plugin_feature.rs b/gstreamer/src/auto/plugin_feature.rs index d407c4265..e51635e8c 100644 --- a/gstreamer/src/auto/plugin_feature.rs +++ b/gstreamer/src/auto/plugin_feature.rs @@ -29,11 +29,7 @@ pub trait PluginFeatureExt: 'static { fn get_plugin_name(&self) -> Option; - fn get_rank(&self) -> u32; - fn load(&self) -> Option; - - fn set_rank(&self, rank: u32); } impl> PluginFeatureExt for O { @@ -55,21 +51,9 @@ impl> PluginFeatureExt for O { } } - fn get_rank(&self) -> u32 { - unsafe { - gst_sys::gst_plugin_feature_get_rank(self.as_ref().to_glib_none().0) - } - } - fn load(&self) -> Option { unsafe { from_glib_full(gst_sys::gst_plugin_feature_load(self.as_ref().to_glib_none().0)) } } - - fn set_rank(&self, rank: u32) { - unsafe { - gst_sys::gst_plugin_feature_set_rank(self.as_ref().to_glib_none().0, rank); - } - } } diff --git a/gstreamer/src/lib.rs b/gstreamer/src/lib.rs index 28da386f8..44286c971 100644 --- a/gstreamer/src/lib.rs +++ b/gstreamer/src/lib.rs @@ -234,6 +234,8 @@ pub use enums::{ pub use gobject::GObjectExtManualGst; pub use pad::{PadExtManual, PadProbeData, PadProbeId, PadProbeInfo}; pub use parse_context::ParseContext; +mod plugin_feature; +pub use plugin_feature::PluginFeatureExtManual; pub use tag_setter::TagSetterExtManual; mod plugin; @@ -346,6 +348,7 @@ pub mod prelude { pub use object::GstObjectExtManual; pub use pad::PadExtManual; pub use param_spec::GstParamSpecExt; + pub use plugin_feature::PluginFeatureExtManual; pub use proxy_pad::ProxyPadExtManual; pub use tag_setter::TagSetterExtManual; pub use value::GstValueExt; diff --git a/gstreamer/src/plugin_feature.rs b/gstreamer/src/plugin_feature.rs new file mode 100644 index 000000000..ebfb5fe33 --- /dev/null +++ b/gstreamer/src/plugin_feature.rs @@ -0,0 +1,36 @@ +// Copyright (C) 2019 Guillaume Desmottes +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use PluginFeature; +use Rank; + +use glib::object::IsA; +use glib::translate::{from_glib, ToGlib, ToGlibPtr}; + +pub trait PluginFeatureExtManual: 'static { + fn get_rank(&self) -> Rank; + fn set_rank(&self, rank: Rank); +} + +impl> PluginFeatureExtManual for O { + fn get_rank(&self) -> Rank { + unsafe { + let rank = gst_sys::gst_plugin_feature_get_rank(self.as_ref().to_glib_none().0); + from_glib(rank as i32) + } + } + + fn set_rank(&self, rank: Rank) { + unsafe { + gst_sys::gst_plugin_feature_set_rank( + self.as_ref().to_glib_none().0, + rank.to_glib() as u32, + ); + } + } +}