From 5fa961f5b9f60d631246f67375040eb7dd39ec01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Sat, 29 Jul 2017 15:21:25 +0100 Subject: [PATCH] Add TagSetter and Preset bindings --- Gir_Gst.toml | 2 + gstreamer/src/auto/mod.rs | 10 +++ gstreamer/src/auto/preset.rs | 117 +++++++++++++++++++++++++++++++ gstreamer/src/auto/tag_setter.rs | 99 ++++++++++++++++++++++++++ gstreamer/src/lib.rs | 4 +- gstreamer/src/tag_setter.rs | 40 +++++++++++ 6 files changed, 271 insertions(+), 1 deletion(-) create mode 100644 gstreamer/src/auto/preset.rs create mode 100644 gstreamer/src/auto/tag_setter.rs create mode 100644 gstreamer/src/tag_setter.rs diff --git a/Gir_Gst.toml b/Gir_Gst.toml index 131823162..f2a2bfb63 100644 --- a/Gir_Gst.toml +++ b/Gir_Gst.toml @@ -56,6 +56,8 @@ generate = [ "Gst.SchedulingFlags", "Gst.IteratorResult", "Gst.ChildProxy", + "Gst.Preset", + "Gst.TagSetter", ] manual = [ diff --git a/gstreamer/src/auto/mod.rs b/gstreamer/src/auto/mod.rs index d93e3319b..032cff466 100644 --- a/gstreamer/src/auto/mod.rs +++ b/gstreamer/src/auto/mod.rs @@ -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; } diff --git a/gstreamer/src/auto/preset.rs b/gstreamer/src/auto/preset.rs new file mode 100644 index 000000000..d3f6fe6e0 --- /dev/null +++ b/gstreamer/src/auto/preset.rs @@ -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); + + match fn { + get_type => || ffi::gst_preset_get_type(), + } +} + +impl Preset { + pub fn get_app_dir() -> Option { + 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; + + fn get_preset_names(&self) -> Vec; + + fn get_property_names(&self) -> Vec; + + 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>>(&self, name: &str, tag: &str, value: P) -> bool; +} + +impl> 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 { + 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 { + unsafe { + FromGlibPtrContainer::from_glib_full(ffi::gst_preset_get_preset_names(self.to_glib_none().0)) + } + } + + fn get_property_names(&self) -> Vec { + 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>>(&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)) + } + } +} diff --git a/gstreamer/src/auto/tag_setter.rs b/gstreamer/src/auto/tag_setter.rs new file mode 100644 index 000000000..47cce12ea --- /dev/null +++ b/gstreamer/src/auto/tag_setter.rs @@ -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): 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; + + 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> 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 { + 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()); + } + } +} diff --git a/gstreamer/src/lib.rs b/gstreamer/src/lib.rs index c87366661..a0cb4fd65 100644 --- a/gstreamer/src/lib.rs +++ b/gstreamer/src/lib.rs @@ -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; diff --git a/gstreamer/src/tag_setter.rs b/gstreamer/src/tag_setter.rs new file mode 100644 index 000000000..b31e07871 --- /dev/null +++ b/gstreamer/src/tag_setter.rs @@ -0,0 +1,40 @@ +// Copyright (C) 2017 Sebastian Dröge +// +// 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 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> 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, + ); + } + } +}