util/samples: use ChannelLayout

This commit is contained in:
meh
2015-06-01 20:32:11 +02:00
parent 956ed014d7
commit d737ccdc37
2 changed files with 10 additions and 4 deletions

View File

@ -98,11 +98,11 @@ impl Audio {
}
pub fn samples(&self) -> Samples {
Samples::wrap(self.ptr as *mut AVPicture, self.format(), self.rate(), self.sample_number(), self.channels())
Samples::wrap(self.ptr as *mut AVPicture, self.format(), self.rate(), self.sample_number(), self.channels(), self.channel_layout())
}
pub fn samples_mut(&mut self) -> Samples {
Samples::wrap(self.ptr as *mut AVPicture, self.format(), self.rate(), self.sample_number(), self.channels())
Samples::wrap(self.ptr as *mut AVPicture, self.format(), self.rate(), self.sample_number(), self.channels(), self.channel_layout())
}
}

View File

@ -5,7 +5,7 @@ use std::marker::{Reflect, PhantomData};
use ffi::*;
use ::util::format::Sample;
use ::Error;
use ::{Error, ChannelLayout};
pub struct Samples<'a> {
pub ptr: *mut AVPicture,
@ -14,12 +14,13 @@ pub struct Samples<'a> {
rate: u32,
number: usize,
channels: u16,
layout: ChannelLayout,
_marker: PhantomData<&'a ()>,
}
impl<'a> Samples<'a> {
pub fn wrap(ptr: *mut AVPicture, format: Sample, rate: u32, number: usize, channels: u16) -> Self {
pub fn wrap(ptr: *mut AVPicture, format: Sample, rate: u32, number: usize, channels: u16, layout: ChannelLayout) -> Self {
Samples {
ptr: ptr,
@ -27,6 +28,7 @@ impl<'a> Samples<'a> {
rate: rate,
number: number,
channels: channels,
layout: layout,
_marker: PhantomData,
}
@ -48,6 +50,10 @@ impl<'a> Samples<'a> {
self.channels
}
pub fn channel_layout(&self) -> ChannelLayout {
self.layout
}
pub fn is_planar(&self) -> bool {
self.format.is_planar()
}