gstreamer: plugin_feature: use Rank enum

This commit is contained in:
Guillaume Desmottes 2019-06-04 15:04:50 +05:30 committed by Sebastian Dröge
parent 1cd733fb0b
commit 7a69a1137c
4 changed files with 47 additions and 16 deletions

View file

@ -1003,6 +1003,14 @@ status = "generate"
name = "rank_compare_func" name = "rank_compare_func"
ignore = true ignore = true
[[object.function]]
name = "get_rank"
ignore = true
[[object.function]]
name = "set_rank"
ignore = true
[[object]] [[object]]
name = "Gst.Registry" name = "Gst.Registry"
status = "generate" status = "generate"

View file

@ -29,11 +29,7 @@ pub trait PluginFeatureExt: 'static {
fn get_plugin_name(&self) -> Option<GString>; fn get_plugin_name(&self) -> Option<GString>;
fn get_rank(&self) -> u32;
fn load(&self) -> Option<PluginFeature>; fn load(&self) -> Option<PluginFeature>;
fn set_rank(&self, rank: u32);
} }
impl<O: IsA<PluginFeature>> PluginFeatureExt for O { impl<O: IsA<PluginFeature>> PluginFeatureExt for O {
@ -55,21 +51,9 @@ impl<O: IsA<PluginFeature>> 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<PluginFeature> { fn load(&self) -> Option<PluginFeature> {
unsafe { unsafe {
from_glib_full(gst_sys::gst_plugin_feature_load(self.as_ref().to_glib_none().0)) 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);
}
}
} }

View file

@ -234,6 +234,8 @@ pub use enums::{
pub use gobject::GObjectExtManualGst; pub use gobject::GObjectExtManualGst;
pub use pad::{PadExtManual, PadProbeData, PadProbeId, PadProbeInfo}; pub use pad::{PadExtManual, PadProbeData, PadProbeId, PadProbeInfo};
pub use parse_context::ParseContext; pub use parse_context::ParseContext;
mod plugin_feature;
pub use plugin_feature::PluginFeatureExtManual;
pub use tag_setter::TagSetterExtManual; pub use tag_setter::TagSetterExtManual;
mod plugin; mod plugin;
@ -346,6 +348,7 @@ pub mod prelude {
pub use object::GstObjectExtManual; pub use object::GstObjectExtManual;
pub use pad::PadExtManual; pub use pad::PadExtManual;
pub use param_spec::GstParamSpecExt; pub use param_spec::GstParamSpecExt;
pub use plugin_feature::PluginFeatureExtManual;
pub use proxy_pad::ProxyPadExtManual; pub use proxy_pad::ProxyPadExtManual;
pub use tag_setter::TagSetterExtManual; pub use tag_setter::TagSetterExtManual;
pub use value::GstValueExt; pub use value::GstValueExt;

View file

@ -0,0 +1,36 @@
// Copyright (C) 2019 Guillaume Desmottes <guillaume.desmottes@collabora.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.
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<O: IsA<PluginFeature>> 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,
);
}
}
}