audio, video: Use AudioCapsBuilder::new_interleaved where applicable

Further code simplification
This commit is contained in:
Vivia Nikolaidou 2022-08-10 13:45:52 +03:00
parent bdaa39e267
commit 07cbc2f025
7 changed files with 8 additions and 16 deletions

View file

@ -209,9 +209,8 @@ impl ElementImpl for AudioEcho {
fn pad_templates() -> &'static [gst::PadTemplate] { fn pad_templates() -> &'static [gst::PadTemplate] {
static PAD_TEMPLATES: Lazy<Vec<gst::PadTemplate>> = Lazy::new(|| { static PAD_TEMPLATES: Lazy<Vec<gst::PadTemplate>> = Lazy::new(|| {
let caps = gst_audio::AudioCapsBuilder::new() let caps = gst_audio::AudioCapsBuilder::new_interleaved()
.format_list([gst_audio::AUDIO_FORMAT_F32, gst_audio::AUDIO_FORMAT_F64]) .format_list([gst_audio::AUDIO_FORMAT_F32, gst_audio::AUDIO_FORMAT_F64])
.layout(gst_audio::AudioLayout::Interleaved)
.build(); .build();
let src_pad_template = gst::PadTemplate::new( let src_pad_template = gst::PadTemplate::new(
"src", "src",

View file

@ -1880,10 +1880,9 @@ impl ElementImpl for AudioLoudNorm {
fn pad_templates() -> &'static [gst::PadTemplate] { fn pad_templates() -> &'static [gst::PadTemplate] {
static PAD_TEMPLATES: Lazy<Vec<gst::PadTemplate>> = Lazy::new(|| { static PAD_TEMPLATES: Lazy<Vec<gst::PadTemplate>> = Lazy::new(|| {
let caps = gst_audio::AudioCapsBuilder::new() let caps = gst_audio::AudioCapsBuilder::new_interleaved()
.format(gst_audio::AUDIO_FORMAT_F64) .format(gst_audio::AUDIO_FORMAT_F64)
.rate(192_000) .rate(192_000)
.layout(gst_audio::AudioLayout::Interleaved)
.build(); .build();
let src_pad_template = gst::PadTemplate::new( let src_pad_template = gst::PadTemplate::new(
"src", "src",

View file

@ -224,10 +224,9 @@ impl ElementImpl for AudioRNNoise {
fn pad_templates() -> &'static [gst::PadTemplate] { fn pad_templates() -> &'static [gst::PadTemplate] {
static PAD_TEMPLATES: Lazy<Vec<gst::PadTemplate>> = Lazy::new(|| { static PAD_TEMPLATES: Lazy<Vec<gst::PadTemplate>> = Lazy::new(|| {
let caps = gst_audio::AudioCapsBuilder::new() let caps = gst_audio::AudioCapsBuilder::new_interleaved()
.format(gst_audio::AUDIO_FORMAT_F32) .format(gst_audio::AUDIO_FORMAT_F32)
.rate(48000) .rate(48000)
.layout(gst_audio::AudioLayout::Interleaved)
.build(); .build();
let src_pad_template = gst::PadTemplate::new( let src_pad_template = gst::PadTemplate::new(
"src", "src",

View file

@ -76,7 +76,7 @@ impl ElementImpl for ClaxonDec {
) )
.unwrap(); .unwrap();
let src_caps = gst_audio::AudioCapsBuilder::new() let src_caps = gst_audio::AudioCapsBuilder::new_interleaved()
.format_list([ .format_list([
gst_audio::AudioFormat::S8, gst_audio::AudioFormat::S8,
gst_audio::AUDIO_FORMAT_S16, gst_audio::AUDIO_FORMAT_S16,
@ -85,7 +85,6 @@ impl ElementImpl for ClaxonDec {
]) ])
.rate_range(1..655_350) .rate_range(1..655_350)
.channels_range(1..8) .channels_range(1..8)
.layout(gst_audio::AudioLayout::Interleaved)
.build(); .build();
let src_pad_template = gst::PadTemplate::new( let src_pad_template = gst::PadTemplate::new(
"src", "src",

View file

@ -31,8 +31,7 @@ fn test_mono_s16() {
assert_eq!( assert_eq!(
caps, caps,
gst_audio::AudioCapsBuilder::new() gst_audio::AudioCapsBuilder::new_interleaved()
.layout(gst_audio::AudioLayout::Interleaved)
.format(gst_audio::AUDIO_FORMAT_S16) .format(gst_audio::AUDIO_FORMAT_S16)
.rate(44_100) .rate(44_100)
.channels(1) .channels(1)

View file

@ -453,9 +453,8 @@ impl ElementImpl for CsoundFilter {
fn pad_templates() -> &'static [gst::PadTemplate] { fn pad_templates() -> &'static [gst::PadTemplate] {
static PAD_TEMPLATES: Lazy<Vec<gst::PadTemplate>> = Lazy::new(|| { static PAD_TEMPLATES: Lazy<Vec<gst::PadTemplate>> = Lazy::new(|| {
let caps = gst_audio::AudioCapsBuilder::new() let caps = gst_audio::AudioCapsBuilder::new_interleaved()
.format(gst_audio::AUDIO_FORMAT_F64) .format(gst_audio::AUDIO_FORMAT_F64)
.layout(gst_audio::AudioLayout::Interleaved)
.build(); .build();
let src_pad_template = gst::PadTemplate::new( let src_pad_template = gst::PadTemplate::new(
"src", "src",

View file

@ -215,8 +215,7 @@ impl ElementImpl for FlvDemux {
.build(), .build(),
); );
caps.append( caps.append(
gst_audio::AudioCapsBuilder::new() gst_audio::AudioCapsBuilder::new_interleaved()
.layout(gst_audio::AudioLayout::Interleaved)
.format_list([gst_audio::AudioFormat::U8, gst_audio::AudioFormat::S16le]) .format_list([gst_audio::AudioFormat::U8, gst_audio::AudioFormat::S16le])
.build(), .build(),
); );
@ -1280,8 +1279,7 @@ impl AudioFormat {
// Assume little-endian for "PCM_NE", it's probably more common and we have no // Assume little-endian for "PCM_NE", it's probably more common and we have no
// way to know what the endianness of the system creating the stream was // way to know what the endianness of the system creating the stream was
Some( Some(
gst_audio::AudioCapsBuilder::new() gst_audio::AudioCapsBuilder::new_interleaved()
.layout(gst_audio::AudioLayout::Interleaved)
.format(if self.width == 8 { .format(if self.width == 8 {
gst_audio::AudioFormat::U8 gst_audio::AudioFormat::U8
} else { } else {