codec/audio: implement ChannelLayoutIter.best()
Is some cases the decoder channel layout is not supported by the selected encoder. A selection from the channel layouts supported by the encoder is needed. For this the method `best()` is introduced.
This commit is contained in:
parent
402657cbfb
commit
c8a38a926f
@ -121,6 +121,16 @@ impl ChannelLayoutIter {
|
||||
pub fn new(ptr: *const u64) -> Self {
|
||||
ChannelLayoutIter { ptr: ptr }
|
||||
}
|
||||
|
||||
pub fn best(self, max: i32) -> ChannelLayout {
|
||||
self.fold(::channel_layout::MONO, |acc, cur|
|
||||
if cur.channels() > cur.channels() && cur.channels() <= max {
|
||||
cur
|
||||
}
|
||||
else {
|
||||
acc
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl Iterator for ChannelLayoutIter {
|
||||
|
Loading…
x
Reference in New Issue
Block a user