Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/sdroege/gst-plugin-rs.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/audio
diff options
context:
space:
mode:
authorVivia Nikolaidou <vivia@ahiru.eu>2022-08-09 14:18:12 +0300
committerVivia Nikolaidou <vivia@ahiru.eu>2022-08-09 22:01:10 +0300
commit8ee8ae581aae44860bb891d5be3d567c19e49ef2 (patch)
tree387173b673798d2f7359c074b098bea33b01e24d /audio
parent247702b76d645c1ccdebe5727b31d461ec7bd598 (diff)
audio: Use gst_audio::AudioCapsBuilder in some plugins
Simplify caps creation codes
Diffstat (limited to 'audio')
-rw-r--r--audio/audiofx/src/audioecho/imp.rs16
-rw-r--r--audio/audiofx/src/audioloudnorm/imp.rs9
-rw-r--r--audio/audiofx/src/audiornnoise/imp.rs9
-rw-r--r--audio/audiofx/src/ebur128level/imp.rs26
-rw-r--r--audio/claxon/src/claxondec/imp.rs23
-rw-r--r--audio/claxon/tests/claxondec.rs10
-rw-r--r--audio/csound/src/filter/imp.rs8
7 files changed, 43 insertions, 58 deletions
diff --git a/audio/audiofx/src/audioecho/imp.rs b/audio/audiofx/src/audioecho/imp.rs
index d44874a3..1108f881 100644
--- a/audio/audiofx/src/audioecho/imp.rs
+++ b/audio/audiofx/src/audioecho/imp.rs
@@ -12,7 +12,7 @@ use gst::subclass::prelude::*;
use gst_base::subclass::prelude::*;
use std::sync::Mutex;
-use std::{cmp, i32, u64};
+use std::{cmp, u64};
use byte_slice_cast::*;
@@ -209,17 +209,9 @@ impl ElementImpl for AudioEcho {
fn pad_templates() -> &'static [gst::PadTemplate] {
static PAD_TEMPLATES: Lazy<Vec<gst::PadTemplate>> = Lazy::new(|| {
- let caps = gst::Caps::builder("audio/x-raw")
- .field(
- "format",
- gst::List::new([
- gst_audio::AUDIO_FORMAT_F32.to_str(),
- gst_audio::AUDIO_FORMAT_F64.to_str(),
- ]),
- )
- .field("rate", gst::IntRange::new(0, i32::MAX))
- .field("channels", gst::IntRange::new(0, i32::MAX))
- .field("layout", "interleaved")
+ let caps = gst_audio::AudioCapsBuilder::new()
+ .format_list([gst_audio::AUDIO_FORMAT_F32, gst_audio::AUDIO_FORMAT_F64])
+ .layout(gst_audio::AudioLayout::Interleaved)
.build();
let src_pad_template = gst::PadTemplate::new(
"src",
diff --git a/audio/audiofx/src/audioloudnorm/imp.rs b/audio/audiofx/src/audioloudnorm/imp.rs
index 63aced37..44b2618e 100644
--- a/audio/audiofx/src/audioloudnorm/imp.rs
+++ b/audio/audiofx/src/audioloudnorm/imp.rs
@@ -1880,11 +1880,10 @@ impl ElementImpl for AudioLoudNorm {
fn pad_templates() -> &'static [gst::PadTemplate] {
static PAD_TEMPLATES: Lazy<Vec<gst::PadTemplate>> = Lazy::new(|| {
- let caps = gst::Caps::builder("audio/x-raw")
- .field("format", gst_audio::AUDIO_FORMAT_F64.to_str())
- .field("rate", 192_000i32)
- .field("channels", gst::IntRange::new(1, std::i32::MAX))
- .field("layout", "interleaved")
+ let caps = gst_audio::AudioCapsBuilder::new()
+ .format(gst_audio::AUDIO_FORMAT_F64)
+ .rate(192_000)
+ .layout(gst_audio::AudioLayout::Interleaved)
.build();
let src_pad_template = gst::PadTemplate::new(
"src",
diff --git a/audio/audiofx/src/audiornnoise/imp.rs b/audio/audiofx/src/audiornnoise/imp.rs
index 3633ec35..d27bf063 100644
--- a/audio/audiofx/src/audiornnoise/imp.rs
+++ b/audio/audiofx/src/audiornnoise/imp.rs
@@ -224,11 +224,10 @@ impl ElementImpl for AudioRNNoise {
fn pad_templates() -> &'static [gst::PadTemplate] {
static PAD_TEMPLATES: Lazy<Vec<gst::PadTemplate>> = Lazy::new(|| {
- let caps = gst::Caps::builder("audio/x-raw")
- .field("format", gst_audio::AUDIO_FORMAT_F32.to_str())
- .field("rate", 48000)
- .field("channels", gst::IntRange::new(1, std::i32::MAX))
- .field("layout", "interleaved")
+ let caps = gst_audio::AudioCapsBuilder::new()
+ .format(gst_audio::AUDIO_FORMAT_F32)
+ .rate(48000)
+ .layout(gst_audio::AudioLayout::Interleaved)
.build();
let src_pad_template = gst::PadTemplate::new(
"src",
diff --git a/audio/audiofx/src/ebur128level/imp.rs b/audio/audiofx/src/ebur128level/imp.rs
index a8b176cc..989c5f7b 100644
--- a/audio/audiofx/src/ebur128level/imp.rs
+++ b/audio/audiofx/src/ebur128level/imp.rs
@@ -250,21 +250,21 @@ impl ElementImpl for EbuR128Level {
fn pad_templates() -> &'static [gst::PadTemplate] {
static PAD_TEMPLATES: Lazy<Vec<gst::PadTemplate>> = Lazy::new(|| {
- let caps = gst::Caps::builder("audio/x-raw")
- .field(
- "format",
- gst::List::new([
- gst_audio::AUDIO_FORMAT_S16.to_str(),
- gst_audio::AUDIO_FORMAT_S32.to_str(),
- gst_audio::AUDIO_FORMAT_F32.to_str(),
- gst_audio::AUDIO_FORMAT_F64.to_str(),
- ]),
- )
- .field("layout", gst::List::new(["interleaved", "non-interleaved"]))
+ let caps = gst_audio::AudioCapsBuilder::new()
+ .format_list([
+ gst_audio::AUDIO_FORMAT_S16,
+ gst_audio::AUDIO_FORMAT_S32,
+ gst_audio::AUDIO_FORMAT_F32,
+ gst_audio::AUDIO_FORMAT_F64,
+ ])
// Limit from ebur128
- .field("rate", gst::IntRange::new(1i32, 2_822_400))
+ .rate_range(1..2_822_400)
// Limit from ebur128
- .field("channels", gst::IntRange::new(1i32, 64))
+ .channels_range(1..64)
+ .layout_list([
+ gst_audio::AudioLayout::Interleaved,
+ gst_audio::AudioLayout::NonInterleaved,
+ ])
.build();
let src_pad_template = gst::PadTemplate::new(
"src",
diff --git a/audio/claxon/src/claxondec/imp.rs b/audio/claxon/src/claxondec/imp.rs
index 76ae65f1..d2c05f6e 100644
--- a/audio/claxon/src/claxondec/imp.rs
+++ b/audio/claxon/src/claxondec/imp.rs
@@ -76,19 +76,16 @@ impl ElementImpl for ClaxonDec {
)
.unwrap();
- let src_caps = gst::Caps::builder("audio/x-raw")
- .field(
- "format",
- gst::List::new([
- gst_audio::AudioFormat::S8.to_str(),
- gst_audio::AUDIO_FORMAT_S16.to_str(),
- gst_audio::AUDIO_FORMAT_S2432.to_str(),
- gst_audio::AUDIO_FORMAT_S32.to_str(),
- ]),
- )
- .field("rate", gst::IntRange::new(1i32, 655_350))
- .field("channels", gst::IntRange::new(1i32, 8))
- .field("layout", "interleaved")
+ let src_caps = gst_audio::AudioCapsBuilder::new()
+ .format_list([
+ gst_audio::AudioFormat::S8,
+ gst_audio::AUDIO_FORMAT_S16,
+ gst_audio::AUDIO_FORMAT_S2432,
+ gst_audio::AUDIO_FORMAT_S32,
+ ])
+ .rate_range(1..655_350)
+ .channels_range(1..8)
+ .layout(gst_audio::AudioLayout::Interleaved)
.build();
let src_pad_template = gst::PadTemplate::new(
"src",
diff --git a/audio/claxon/tests/claxondec.rs b/audio/claxon/tests/claxondec.rs
index 307dd197..31b327ea 100644
--- a/audio/claxon/tests/claxondec.rs
+++ b/audio/claxon/tests/claxondec.rs
@@ -31,11 +31,11 @@ fn test_mono_s16() {
assert_eq!(
caps,
- gst::Caps::builder("audio/x-raw")
- .field("format", gst_audio::AUDIO_FORMAT_S16.to_str())
- .field("rate", 44_100i32)
- .field("channels", 1i32)
- .field("layout", "interleaved")
+ gst_audio::AudioCapsBuilder::new()
+ .layout(gst_audio::AudioLayout::Interleaved)
+ .format(gst_audio::AUDIO_FORMAT_S16)
+ .rate(44_100)
+ .channels(1)
.build()
);
}
diff --git a/audio/csound/src/filter/imp.rs b/audio/csound/src/filter/imp.rs
index 2761f7e8..4972fea3 100644
--- a/audio/csound/src/filter/imp.rs
+++ b/audio/csound/src/filter/imp.rs
@@ -453,11 +453,9 @@ impl ElementImpl for CsoundFilter {
fn pad_templates() -> &'static [gst::PadTemplate] {
static PAD_TEMPLATES: Lazy<Vec<gst::PadTemplate>> = Lazy::new(|| {
- let caps = gst::Caps::builder("audio/x-raw")
- .field("format", gst_audio::AUDIO_FORMAT_F64.to_str())
- .field("rate", gst::IntRange::new(1, i32::MAX))
- .field("channels", gst::IntRange::new(1, i32::MAX))
- .field("layout", "interleaved")
+ let caps = gst_audio::AudioCapsBuilder::new()
+ .format(gst_audio::AUDIO_FORMAT_F64)
+ .layout(gst_audio::AudioLayout::Interleaved)
.build();
let src_pad_template = gst::PadTemplate::new(
"src",