Add TagSetter and Preset bindings

This commit is contained in:
Sebastian Dröge 2017-07-29 15:21:25 +01:00
parent 33ccfc7225
commit 5fa961f5b9
6 changed files with 271 additions and 1 deletions

View file

@ -56,6 +56,8 @@ generate = [
"Gst.SchedulingFlags",
"Gst.IteratorResult",
"Gst.ChildProxy",
"Gst.Preset",
"Gst.TagSetter",
]
manual = [

View file

@ -62,6 +62,10 @@ pub use self::pipeline::PipelineExt;
mod plugin;
pub use self::plugin::Plugin;
mod preset;
pub use self::preset::Preset;
pub use self::preset::PresetExt;
mod proxy_pad;
pub use self::proxy_pad::ProxyPad;
pub use self::proxy_pad::ProxyPadExt;
@ -80,6 +84,10 @@ pub use self::stream_collection::StreamCollection;
#[cfg(feature = "v1_10")]
pub use self::stream_collection::StreamCollectionExt;
mod tag_setter;
pub use self::tag_setter::TagSetter;
pub use self::tag_setter::TagSetterExt;
mod u_r_i_handler;
pub use self::u_r_i_handler::URIHandler;
pub use self::u_r_i_handler::URIHandlerExt;
@ -215,10 +223,12 @@ pub mod traits {
pub use super::PadExt;
pub use super::PadTemplateExt;
pub use super::PipelineExt;
pub use super::PresetExt;
pub use super::ProxyPadExt;
#[cfg(feature = "v1_10")]
pub use super::StreamExt;
#[cfg(feature = "v1_10")]
pub use super::StreamCollectionExt;
pub use super::TagSetterExt;
pub use super::URIHandlerExt;
}

View file

@ -0,0 +1,117 @@
// This file was generated by gir (a01311c+) from gir-files (???)
// DO NOT EDIT
use ffi;
use glib::object::IsA;
use glib::translate::*;
use glib_ffi;
use gobject_ffi;
use std::mem;
use std::ptr;
glib_wrapper! {
pub struct Preset(Object<ffi::GstPreset>);
match fn {
get_type => || ffi::gst_preset_get_type(),
}
}
impl Preset {
pub fn get_app_dir() -> Option<String> {
assert_initialized_main_thread!();
unsafe {
from_glib_none(ffi::gst_preset_get_app_dir())
}
}
pub fn set_app_dir(app_dir: &str) -> bool {
assert_initialized_main_thread!();
unsafe {
from_glib(ffi::gst_preset_set_app_dir(app_dir.to_glib_none().0))
}
}
}
unsafe impl Send for Preset {}
unsafe impl Sync for Preset {}
pub trait PresetExt {
fn delete_preset(&self, name: &str) -> bool;
fn get_meta(&self, name: &str, tag: &str) -> Option<String>;
fn get_preset_names(&self) -> Vec<String>;
fn get_property_names(&self) -> Vec<String>;
fn is_editable(&self) -> bool;
fn load_preset(&self, name: &str) -> bool;
fn rename_preset(&self, old_name: &str, new_name: &str) -> bool;
fn save_preset(&self, name: &str) -> bool;
fn set_meta<'a, P: Into<Option<&'a str>>>(&self, name: &str, tag: &str, value: P) -> bool;
}
impl<O: IsA<Preset>> PresetExt for O {
fn delete_preset(&self, name: &str) -> bool {
unsafe {
from_glib(ffi::gst_preset_delete_preset(self.to_glib_none().0, name.to_glib_none().0))
}
}
fn get_meta(&self, name: &str, tag: &str) -> Option<String> {
unsafe {
let mut value = ptr::null_mut();
let ret = from_glib(ffi::gst_preset_get_meta(self.to_glib_none().0, name.to_glib_none().0, tag.to_glib_none().0, &mut value));
if ret { Some(from_glib_full(value)) } else { None }
}
}
fn get_preset_names(&self) -> Vec<String> {
unsafe {
FromGlibPtrContainer::from_glib_full(ffi::gst_preset_get_preset_names(self.to_glib_none().0))
}
}
fn get_property_names(&self) -> Vec<String> {
unsafe {
FromGlibPtrContainer::from_glib_full(ffi::gst_preset_get_property_names(self.to_glib_none().0))
}
}
fn is_editable(&self) -> bool {
unsafe {
from_glib(ffi::gst_preset_is_editable(self.to_glib_none().0))
}
}
fn load_preset(&self, name: &str) -> bool {
unsafe {
from_glib(ffi::gst_preset_load_preset(self.to_glib_none().0, name.to_glib_none().0))
}
}
fn rename_preset(&self, old_name: &str, new_name: &str) -> bool {
unsafe {
from_glib(ffi::gst_preset_rename_preset(self.to_glib_none().0, old_name.to_glib_none().0, new_name.to_glib_none().0))
}
}
fn save_preset(&self, name: &str) -> bool {
unsafe {
from_glib(ffi::gst_preset_save_preset(self.to_glib_none().0, name.to_glib_none().0))
}
}
fn set_meta<'a, P: Into<Option<&'a str>>>(&self, name: &str, tag: &str, value: P) -> bool {
let value = value.into();
let value = value.to_glib_none();
unsafe {
from_glib(ffi::gst_preset_set_meta(self.to_glib_none().0, name.to_glib_none().0, tag.to_glib_none().0, value.0))
}
}
}

View file

@ -0,0 +1,99 @@
// This file was generated by gir (a01311c+) from gir-files (???)
// DO NOT EDIT
use Element;
use Object;
use TagList;
use TagMergeMode;
use ffi;
use glib::object::IsA;
use glib::translate::*;
use glib_ffi;
use gobject_ffi;
use std::mem;
use std::ptr;
glib_wrapper! {
pub struct TagSetter(Object<ffi::GstTagSetter>): Element, Object;
match fn {
get_type => || ffi::gst_tag_setter_get_type(),
}
}
unsafe impl Send for TagSetter {}
unsafe impl Sync for TagSetter {}
pub trait TagSetterExt {
//fn add_tag_valist(&self, mode: TagMergeMode, tag: &str, var_args: /*Unknown conversion*//*Unimplemented*/Unsupported);
//fn add_tag_valist_values(&self, mode: TagMergeMode, tag: &str, var_args: /*Unknown conversion*//*Unimplemented*/Unsupported);
//fn add_tag_value(&self, mode: TagMergeMode, tag: &str, value: /*Ignored*/&glib::Value);
//fn add_tag_values(&self, mode: TagMergeMode, tag: &str, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs);
//fn add_tags(&self, mode: TagMergeMode, tag: &str, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs);
fn get_tag_list(&self) -> Option<TagList>;
fn get_tag_merge_mode(&self) -> TagMergeMode;
fn merge_tags(&self, list: &TagList, mode: TagMergeMode);
fn reset_tags(&self);
fn set_tag_merge_mode(&self, mode: TagMergeMode);
}
impl<O: IsA<TagSetter>> TagSetterExt for O {
//fn add_tag_valist(&self, mode: TagMergeMode, tag: &str, var_args: /*Unknown conversion*//*Unimplemented*/Unsupported) {
// unsafe { TODO: call ffi::gst_tag_setter_add_tag_valist() }
//}
//fn add_tag_valist_values(&self, mode: TagMergeMode, tag: &str, var_args: /*Unknown conversion*//*Unimplemented*/Unsupported) {
// unsafe { TODO: call ffi::gst_tag_setter_add_tag_valist_values() }
//}
//fn add_tag_value(&self, mode: TagMergeMode, tag: &str, value: /*Ignored*/&glib::Value) {
// unsafe { TODO: call ffi::gst_tag_setter_add_tag_value() }
//}
//fn add_tag_values(&self, mode: TagMergeMode, tag: &str, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs) {
// unsafe { TODO: call ffi::gst_tag_setter_add_tag_values() }
//}
//fn add_tags(&self, mode: TagMergeMode, tag: &str, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs) {
// unsafe { TODO: call ffi::gst_tag_setter_add_tags() }
//}
fn get_tag_list(&self) -> Option<TagList> {
unsafe {
from_glib_none(ffi::gst_tag_setter_get_tag_list(self.to_glib_none().0))
}
}
fn get_tag_merge_mode(&self) -> TagMergeMode {
unsafe {
from_glib(ffi::gst_tag_setter_get_tag_merge_mode(self.to_glib_none().0))
}
}
fn merge_tags(&self, list: &TagList, mode: TagMergeMode) {
unsafe {
ffi::gst_tag_setter_merge_tags(self.to_glib_none().0, list.to_glib_none().0, mode.to_glib());
}
}
fn reset_tags(&self) {
unsafe {
ffi::gst_tag_setter_reset_tags(self.to_glib_none().0);
}
}
fn set_tag_merge_mode(&self, mode: TagMergeMode) {
unsafe {
ffi::gst_tag_setter_set_tag_merge_mode(self.to_glib_none().0, mode.to_glib());
}
}
}

View file

@ -74,12 +74,14 @@ mod segment;
mod proxy_pad;
mod ghost_pad;
mod child_proxy;
mod tag_setter;
mod iterator;
pub use element::ElementExtManual;
pub use bin::BinExtManual;
pub use pad::{PadExtManual, PadProbeId, PadProbeInfo, PadProbeData, PAD_PROBE_ID_INVALID};
pub use gobject::GObjectExtManualGst;
pub use child_proxy::ChildProxyExtManual;
mod iterator;
pub use tag_setter::TagSetterExtManual;
pub use self::iterator::Iterator;
mod value;

View file

@ -0,0 +1,40 @@
// 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.
use ffi;
use TagSetter;
use TagMergeMode;
use glib::object::IsA;
use glib::translate::*;
use glib::value::{ToValue};
use tags::*;
pub trait TagSetterExtManual {
fn add<'a, T: Tag<'a>>(&mut self, value: T::TagType, mode: TagMergeMode)
where
T::TagType: ToValue;
}
impl<O: IsA<TagSetter>> TagSetterExtManual for O {
fn add<'a, T: Tag<'a>>(&mut self, value: T::TagType, mode: TagMergeMode)
where
T::TagType: ToValue,
{
unsafe {
let v = value.to_value();
ffi::gst_tag_setter_add_tag_value(
self.to_glib_none().0,
mode.to_glib(),
T::tag_name().to_glib_none().0,
v.to_glib_none().0,
);
}
}
}