mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer-rs.git
synced 2024-11-22 01:21:05 +00:00
audio: Add channel_mask() and default_channel_mask() to AudioCapsBuilder
Also use default_channel_mask() where applicable
This commit is contained in:
parent
b230d8aab6
commit
6f51444c1f
2 changed files with 22 additions and 1 deletions
|
@ -472,7 +472,7 @@ mod tests {
|
|||
.format(crate::AudioFormat::S16le)
|
||||
.rate(48000)
|
||||
.channels(2)
|
||||
.field("channel-mask", gst::Bitmask::new(0x3))
|
||||
.fallback_channel_mask()
|
||||
.build();
|
||||
let info = AudioInfo::from_caps(&caps).unwrap();
|
||||
assert_eq!(info.format(), crate::AudioFormat::S16le);
|
||||
|
|
|
@ -113,6 +113,27 @@ impl<T> AudioCapsBuilder<T> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn channel_mask(self, channel_mask: u64) -> Self {
|
||||
Self {
|
||||
builder: self
|
||||
.builder
|
||||
.field("channel-mask", gst::Bitmask::new(channel_mask)),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn fallback_channel_mask(self) -> Self {
|
||||
let channels = self.builder.structure().get::<i32>("channels");
|
||||
match channels {
|
||||
Ok(channels) => Self {
|
||||
builder: self.builder.field(
|
||||
"channel-mask",
|
||||
gst::Bitmask::new(crate::AudioChannelPosition::fallback_mask(channels as u32)),
|
||||
),
|
||||
},
|
||||
Err(e) => panic!("{:?}", e),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn field<V: ToSendValue + Sync>(self, name: &str, value: V) -> Self {
|
||||
Self {
|
||||
builder: self.builder.field(name, value),
|
||||
|
|
Loading…
Reference in a new issue