From 2b33885c1eeaaf4420e2d139418a8f565329756a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Thu, 10 Aug 2017 01:39:55 +0300 Subject: [PATCH] Add some more convenience API to AudioInfo --- gstreamer-audio/src/audio_info.rs | 44 +++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/gstreamer-audio/src/audio_info.rs b/gstreamer-audio/src/audio_info.rs index 5819a6323..6e3c871ab 100644 --- a/gstreamer-audio/src/audio_info.rs +++ b/gstreamer-audio/src/audio_info.rs @@ -176,6 +176,10 @@ impl AudioInfo { from_glib(self.0.layout) } + pub fn flags(&self) -> ::AudioFlags { + from_glib(self.0.flags) + } + pub fn rate(&self) -> u32 { self.0.rate as u32 } @@ -188,6 +192,42 @@ impl AudioInfo { self.0.bpf as u32 } + pub fn bps(&self) -> u32 { + (self.format_info().depth() as u32) >> 3 + } + + pub fn depth(&self) -> i32 { + self.format_info().depth() + } + + pub fn width(&self) -> i32 { + self.format_info().width() + } + + pub fn endianness(&self) -> ::AudioEndianness { + self.format_info().endianness() + } + + pub fn is_big_endian(&self) -> bool { + self.format_info().is_big_endian() + } + + pub fn is_little_endian(&self) -> bool { + self.format_info().is_little_endian() + } + + pub fn is_float(&self) -> bool { + self.format_info().is_float() + } + + pub fn is_integer(&self) -> bool { + self.format_info().is_integer() + } + + pub fn is_signed(&self) -> bool { + self.format_info().is_signed() + } + pub fn positions(&self) -> Vec<::AudioChannelPosition> { let mut v = Vec::with_capacity(self.0.channels as usize); for i in 0..(self.0.channels as usize) { @@ -196,6 +236,10 @@ impl AudioInfo { v } + + pub fn is_unpositioned(&self) -> bool { + self.flags().contains(::AUDIO_FLAG_UNPOSITIONED) + } } impl Clone for AudioInfo {