diff --git a/Gir_Gst.toml b/Gir_Gst.toml index 64763e459..b0a5ceed3 100644 --- a/Gir_Gst.toml +++ b/Gir_Gst.toml @@ -51,6 +51,7 @@ generate = [ "Gst.PadProbeReturn", "Gst.CapsIntersectMode", "Gst.BufferFlags", + "Gst.SegmentFlags", ] manual = [ diff --git a/gstreamer/src/auto/flags.rs b/gstreamer/src/auto/flags.rs index 5b56638e7..e4b198597 100644 --- a/gstreamer/src/auto/flags.rs +++ b/gstreamer/src/auto/flags.rs @@ -193,6 +193,59 @@ impl SetValue for SeekFlags { } } +bitflags! { + pub struct SegmentFlags: u32 { + const SEGMENT_FLAG_NONE = 0; + const SEGMENT_FLAG_RESET = 1; + const SEGMENT_FLAG_TRICKMODE = 16; + const SEGMENT_FLAG_SKIP = 16; + const SEGMENT_FLAG_SEGMENT = 8; + const SEGMENT_FLAG_TRICKMODE_KEY_UNITS = 128; + const SEGMENT_FLAG_TRICKMODE_NO_AUDIO = 256; + } +} + +#[doc(hidden)] +impl ToGlib for SegmentFlags { + type GlibType = ffi::GstSegmentFlags; + + fn to_glib(&self) -> ffi::GstSegmentFlags { + ffi::GstSegmentFlags::from_bits_truncate(self.bits()) + } +} + +#[doc(hidden)] +impl FromGlib for SegmentFlags { + fn from_glib(value: ffi::GstSegmentFlags) -> SegmentFlags { + skip_assert_initialized!(); + SegmentFlags::from_bits_truncate(value.bits()) + } +} + +impl StaticType for SegmentFlags { + fn static_type() -> Type { + unsafe { from_glib(ffi::gst_segment_flags_get_type()) } + } +} + +impl<'a> FromValueOptional<'a> for SegmentFlags { + unsafe fn from_value_optional(value: &Value) -> Option { + Some(FromValue::from_value(value)) + } +} + +impl<'a> FromValue<'a> for SegmentFlags { + unsafe fn from_value(value: &Value) -> Self { + from_glib(ffi::GstSegmentFlags::from_bits_truncate(gobject_ffi::g_value_get_flags(value.to_glib_none().0))) + } +} + +impl SetValue for SegmentFlags { + unsafe fn set_value(value: &mut Value, this: &Self) { + gobject_ffi::g_value_set_flags(value.to_glib_none_mut().0, this.to_glib().bits()) + } +} + bitflags! { pub struct StreamFlags: u32 { const STREAM_FLAG_NONE = 0; diff --git a/gstreamer/src/auto/mod.rs b/gstreamer/src/auto/mod.rs index 8fe0e0559..a59abfaef 100644 --- a/gstreamer/src/auto/mod.rs +++ b/gstreamer/src/auto/mod.rs @@ -153,6 +153,14 @@ pub use self::flags::SEEK_FLAG_SNAP_AFTER; pub use self::flags::SEEK_FLAG_SNAP_NEAREST; pub use self::flags::SEEK_FLAG_TRICKMODE_KEY_UNITS; pub use self::flags::SEEK_FLAG_TRICKMODE_NO_AUDIO; +pub use self::flags::SegmentFlags; +pub use self::flags::SEGMENT_FLAG_NONE; +pub use self::flags::SEGMENT_FLAG_RESET; +pub use self::flags::SEGMENT_FLAG_TRICKMODE; +pub use self::flags::SEGMENT_FLAG_SKIP; +pub use self::flags::SEGMENT_FLAG_SEGMENT; +pub use self::flags::SEGMENT_FLAG_TRICKMODE_KEY_UNITS; +pub use self::flags::SEGMENT_FLAG_TRICKMODE_NO_AUDIO; pub use self::flags::StreamFlags; pub use self::flags::STREAM_FLAG_NONE; pub use self::flags::STREAM_FLAG_SPARSE; diff --git a/gstreamer/src/lib.rs b/gstreamer/src/lib.rs index 7abd91fa0..28097af8a 100644 --- a/gstreamer/src/lib.rs +++ b/gstreamer/src/lib.rs @@ -64,6 +64,7 @@ mod bin; mod bus; mod pad; mod gobject; +mod segment; pub use bin::BinExtManual; pub use pad::{PadExtManual, PadProbeId, PadProbeInfo, PadProbeData, PAD_PROBE_ID_INVALID}; pub use gobject::GObjectExtManualGst; diff --git a/gstreamer/src/segment.rs b/gstreamer/src/segment.rs new file mode 100644 index 000000000..a4785c96d --- /dev/null +++ b/gstreamer/src/segment.rs @@ -0,0 +1,147 @@ +// 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 Segment; +use SegmentFlags; +use Format; + +use glib::translate::{from_glib, ToGlib, ToGlibPtr, ToGlibPtrMut}; + +impl Segment { + pub fn set_flags(&mut self, flags: SegmentFlags) { + unsafe { + (*self.to_glib_none_mut().0).flags = flags.to_glib(); + } + } + + pub fn get_flags(&self) -> SegmentFlags { + unsafe { + from_glib((*self.to_glib_none().0).flags) + } + } + + pub fn set_rate(&mut self, rate: f64) { + unsafe { + (*self.to_glib_none_mut().0).rate = rate; + } + } + + pub fn get_rate(&self) -> f64 { + unsafe { + (*self.to_glib_none().0).rate + } + } + + pub fn set_applied_rate(&mut self, applied_rate: f64) { + unsafe { + (*self.to_glib_none_mut().0).applied_rate = applied_rate; + } + } + + pub fn get_applied_rate(&self) -> f64 { + unsafe { + (*self.to_glib_none().0).applied_rate + } + } + + pub fn set_format(&mut self, format: Format) { + unsafe { + (*self.to_glib_none_mut().0).format = format.to_glib(); + } + } + + pub fn get_format(&self) -> Format { + unsafe { + from_glib((*self.to_glib_none().0).format) + } + } + + pub fn set_base(&mut self, base: u64) { + unsafe { + (*self.to_glib_none_mut().0).base = base; + } + } + + pub fn get_base(&self) -> u64 { + unsafe { + (*self.to_glib_none().0).base + } + } + + pub fn set_offset(&mut self, offset: u64) { + unsafe { + (*self.to_glib_none_mut().0).offset = offset; + } + } + + pub fn get_offset(&self) -> u64 { + unsafe { + (*self.to_glib_none().0).offset + } + } + + pub fn set_start(&mut self, start: u64) { + unsafe { + (*self.to_glib_none_mut().0).start = start; + } + } + + pub fn get_start(&self) -> u64 { + unsafe { + (*self.to_glib_none().0).start + } + } + + pub fn set_stop(&mut self, stop: u64) { + unsafe { + (*self.to_glib_none_mut().0).stop = stop; + } + } + + pub fn get_stop(&self) -> u64 { + unsafe { + (*self.to_glib_none().0).stop + } + } + + pub fn set_time(&mut self, time: u64) { + unsafe { + (*self.to_glib_none_mut().0).time = time; + } + } + + pub fn get_time(&self) -> u64 { + unsafe { + (*self.to_glib_none().0).time + } + } + + pub fn set_position(&mut self, position: u64) { + unsafe { + (*self.to_glib_none_mut().0).position = position; + } + } + + pub fn get_position(&self) -> u64 { + unsafe { + (*self.to_glib_none().0).position + } + } + + pub fn set_duration(&mut self, duration: u64) { + unsafe { + (*self.to_glib_none_mut().0).duration = duration; + } + } + + pub fn get_duration(&self) -> u64 { + unsafe { + (*self.to_glib_none().0).duration + } + } +}