From 33ccfc722512807250e075f1c7e5d596341fa5b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Sat, 29 Jul 2017 15:11:44 +0100 Subject: [PATCH] Add GDateTime bindings --- Gir_Gst.toml | 5 + gstreamer/src/auto/date_time.rs | 185 ++++++++++++++++++++++++++++++++ gstreamer/src/auto/mod.rs | 3 + 3 files changed, 193 insertions(+) create mode 100644 gstreamer/src/auto/date_time.rs diff --git a/Gir_Gst.toml b/Gir_Gst.toml index c5b03f453..131823162 100644 --- a/Gir_Gst.toml +++ b/Gir_Gst.toml @@ -141,6 +141,11 @@ name = "Gst.Query" status = "manual" ref_mode = "ref" +[[object]] +name = "Gst.DateTime" +status = "generate" +concurrency = "send" + [[object]] name = "Gst.Clock" status = "generate" diff --git a/gstreamer/src/auto/date_time.rs b/gstreamer/src/auto/date_time.rs new file mode 100644 index 000000000..1422343f4 --- /dev/null +++ b/gstreamer/src/auto/date_time.rs @@ -0,0 +1,185 @@ +// This file was generated by gir (a01311c+) from gir-files (???) +// DO NOT EDIT + +use ffi; +use glib::translate::*; +use glib_ffi; +use gobject_ffi; +use std::mem; +use std::ptr; + +glib_wrapper! { + pub struct DateTime(Shared); + + match fn { + ref => |ptr| ffi::gst_date_time_ref(ptr), + unref => |ptr| ffi::gst_date_time_unref(ptr), + get_type => || ffi::gst_date_time_get_type(), + } +} + +impl DateTime { + pub fn new(tzoffset: f32, year: i32, month: i32, day: i32, hour: i32, minute: i32, seconds: f64) -> DateTime { + assert_initialized_main_thread!(); + unsafe { + from_glib_full(ffi::gst_date_time_new(tzoffset, year, month, day, hour, minute, seconds)) + } + } + + //pub fn new_from_g_date_time(dt: /*Ignored*/&glib::DateTime) -> DateTime { + // unsafe { TODO: call ffi::gst_date_time_new_from_g_date_time() } + //} + + pub fn new_from_iso8601_string(string: &str) -> DateTime { + assert_initialized_main_thread!(); + unsafe { + from_glib_full(ffi::gst_date_time_new_from_iso8601_string(string.to_glib_none().0)) + } + } + + pub fn new_from_unix_epoch_local_time(secs: i64) -> DateTime { + assert_initialized_main_thread!(); + unsafe { + from_glib_full(ffi::gst_date_time_new_from_unix_epoch_local_time(secs)) + } + } + + pub fn new_from_unix_epoch_utc(secs: i64) -> DateTime { + assert_initialized_main_thread!(); + unsafe { + from_glib_full(ffi::gst_date_time_new_from_unix_epoch_utc(secs)) + } + } + + pub fn new_local_time(year: i32, month: i32, day: i32, hour: i32, minute: i32, seconds: f64) -> DateTime { + assert_initialized_main_thread!(); + unsafe { + from_glib_full(ffi::gst_date_time_new_local_time(year, month, day, hour, minute, seconds)) + } + } + + pub fn new_now_local_time() -> DateTime { + assert_initialized_main_thread!(); + unsafe { + from_glib_full(ffi::gst_date_time_new_now_local_time()) + } + } + + pub fn new_now_utc() -> DateTime { + assert_initialized_main_thread!(); + unsafe { + from_glib_full(ffi::gst_date_time_new_now_utc()) + } + } + + pub fn new_y(year: i32) -> DateTime { + assert_initialized_main_thread!(); + unsafe { + from_glib_full(ffi::gst_date_time_new_y(year)) + } + } + + pub fn new_ym(year: i32, month: i32) -> DateTime { + assert_initialized_main_thread!(); + unsafe { + from_glib_full(ffi::gst_date_time_new_ym(year, month)) + } + } + + pub fn new_ymd(year: i32, month: i32, day: i32) -> DateTime { + assert_initialized_main_thread!(); + unsafe { + from_glib_full(ffi::gst_date_time_new_ymd(year, month, day)) + } + } + + pub fn get_day(&self) -> i32 { + unsafe { + ffi::gst_date_time_get_day(self.to_glib_none().0) + } + } + + pub fn get_hour(&self) -> i32 { + unsafe { + ffi::gst_date_time_get_hour(self.to_glib_none().0) + } + } + + pub fn get_microsecond(&self) -> i32 { + unsafe { + ffi::gst_date_time_get_microsecond(self.to_glib_none().0) + } + } + + pub fn get_minute(&self) -> i32 { + unsafe { + ffi::gst_date_time_get_minute(self.to_glib_none().0) + } + } + + pub fn get_month(&self) -> i32 { + unsafe { + ffi::gst_date_time_get_month(self.to_glib_none().0) + } + } + + pub fn get_second(&self) -> i32 { + unsafe { + ffi::gst_date_time_get_second(self.to_glib_none().0) + } + } + + pub fn get_time_zone_offset(&self) -> f32 { + unsafe { + ffi::gst_date_time_get_time_zone_offset(self.to_glib_none().0) + } + } + + pub fn get_year(&self) -> i32 { + unsafe { + ffi::gst_date_time_get_year(self.to_glib_none().0) + } + } + + pub fn has_day(&self) -> bool { + unsafe { + from_glib(ffi::gst_date_time_has_day(self.to_glib_none().0)) + } + } + + pub fn has_month(&self) -> bool { + unsafe { + from_glib(ffi::gst_date_time_has_month(self.to_glib_none().0)) + } + } + + pub fn has_second(&self) -> bool { + unsafe { + from_glib(ffi::gst_date_time_has_second(self.to_glib_none().0)) + } + } + + pub fn has_time(&self) -> bool { + unsafe { + from_glib(ffi::gst_date_time_has_time(self.to_glib_none().0)) + } + } + + pub fn has_year(&self) -> bool { + unsafe { + from_glib(ffi::gst_date_time_has_year(self.to_glib_none().0)) + } + } + + //pub fn to_g_date_time(&self) -> /*Ignored*/Option { + // unsafe { TODO: call ffi::gst_date_time_to_g_date_time() } + //} + + pub fn to_iso8601_string(&self) -> Option { + unsafe { + from_glib_full(ffi::gst_date_time_to_iso8601_string(self.to_glib_none().0)) + } + } +} + +unsafe impl Send for DateTime {} diff --git a/gstreamer/src/auto/mod.rs b/gstreamer/src/auto/mod.rs index f7c174193..d93e3319b 100644 --- a/gstreamer/src/auto/mod.rs +++ b/gstreamer/src/auto/mod.rs @@ -84,6 +84,9 @@ mod u_r_i_handler; pub use self::u_r_i_handler::URIHandler; pub use self::u_r_i_handler::URIHandlerExt; +mod date_time; +pub use self::date_time::DateTime; + mod segment; pub use self::segment::Segment;