Add getters/setters for all the segment fields

This commit is contained in:
Sebastian Dröge 2017-07-28 17:47:23 +01:00
parent 7926257c3c
commit e3c9965eee
5 changed files with 210 additions and 0 deletions

View file

@ -51,6 +51,7 @@ generate = [
"Gst.PadProbeReturn",
"Gst.CapsIntersectMode",
"Gst.BufferFlags",
"Gst.SegmentFlags",
]
manual = [

View file

@ -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<ffi::GstSegmentFlags> 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<Self> {
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;

View file

@ -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;

View file

@ -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;

147
gstreamer/src/segment.rs Normal file
View file

@ -0,0 +1,147 @@
// 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 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
}
}
}