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

gitlab.freedesktop.org/gstreamer/gst-plugins-rs.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVivia Nikolaidou <vivia@ahiru.eu>2022-10-13 21:02:04 +0300
committerVivia Nikolaidou <vivia@ahiru.eu>2022-10-13 22:24:57 +0300
commitf11b0fa5eb0d294f09d4dda7a052cf647f254688 (patch)
tree6c3bd1726dc87c6a7d97f2804e1423f4c33acf72 /tutorial/src
parent862c2af1d9e81743f659609552ad4d409fb9c1fb (diff)
plugins, examples, tutorials: Use AudioCapsBuilder and VideoCapsBuilder
Simplify caps creation code
Diffstat (limited to 'tutorial/src')
-rw-r--r--tutorial/src/rgb2gray/imp.rs33
-rw-r--r--tutorial/src/sinesrc/imp.rs15
2 files changed, 7 insertions, 41 deletions
diff --git a/tutorial/src/rgb2gray/imp.rs b/tutorial/src/rgb2gray/imp.rs
index 5fef8ce51..70e936658 100644
--- a/tutorial/src/rgb2gray/imp.rs
+++ b/tutorial/src/rgb2gray/imp.rs
@@ -14,7 +14,6 @@ use gst::subclass::prelude::*;
use gst_base::subclass::prelude::*;
use gst_video::subclass::prelude::*;
-use std::i32;
use std::sync::Mutex;
use once_cell::sync::Lazy;
@@ -197,23 +196,8 @@ impl ElementImpl for Rgb2Gray {
static PAD_TEMPLATES: Lazy<Vec<gst::PadTemplate>> = Lazy::new(|| {
// On the src pad, we can produce BGRx and GRAY8 of any
// width/height and with any framerate
- let caps = gst::Caps::builder("video/x-raw")
- .field(
- "format",
- gst::List::new([
- gst_video::VideoFormat::Bgrx.to_str(),
- gst_video::VideoFormat::Gray8.to_str(),
- ]),
- )
- .field("width", gst::IntRange::new(0, i32::MAX))
- .field("height", gst::IntRange::new(0, i32::MAX))
- .field(
- "framerate",
- gst::FractionRange::new(
- gst::Fraction::new(0, 1),
- gst::Fraction::new(i32::MAX, 1),
- ),
- )
+ let caps = gst_video::VideoCapsBuilder::new()
+ .format_list([gst_video::VideoFormat::Bgrx, gst_video::VideoFormat::Gray8])
.build();
// The src pad template must be named "src" for basetransform
// and specific a pad that is always there
@@ -227,17 +211,8 @@ impl ElementImpl for Rgb2Gray {
// On the sink pad, we can accept BGRx of any
// width/height and with any framerate
- let caps = gst::Caps::builder("video/x-raw")
- .field("format", gst_video::VideoFormat::Bgrx.to_str())
- .field("width", gst::IntRange::new(0, i32::MAX))
- .field("height", gst::IntRange::new(0, i32::MAX))
- .field(
- "framerate",
- gst::FractionRange::new(
- gst::Fraction::new(0, 1),
- gst::Fraction::new(i32::MAX, 1),
- ),
- )
+ let caps = gst_video::VideoCapsBuilder::new()
+ .format(gst_video::VideoFormat::Bgrx)
.build();
// The sink pad template must be named "sink" for basetransform
// and specific a pad that is always there
diff --git a/tutorial/src/sinesrc/imp.rs b/tutorial/src/sinesrc/imp.rs
index d87025ce4..38811fc49 100644
--- a/tutorial/src/sinesrc/imp.rs
+++ b/tutorial/src/sinesrc/imp.rs
@@ -19,7 +19,7 @@ use byte_slice_cast::*;
use std::ops::Rem;
use std::sync::Mutex;
-use std::{i32, u32};
+use std::u32;
use num_traits::cast::NumCast;
use num_traits::float::Float;
@@ -352,17 +352,8 @@ impl ElementImpl for SineSrc {
static PAD_TEMPLATES: Lazy<Vec<gst::PadTemplate>> = Lazy::new(|| {
// On the src pad, we can produce F32/F64 with any sample rate
// and any number of channels
- 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("layout", "interleaved")
- .field("rate", gst::IntRange::new(1, i32::MAX))
- .field("channels", gst::IntRange::new(1, i32::MAX))
+ let caps = gst_audio::AudioCapsBuilder::new_interleaved()
+ .format_list([gst_audio::AUDIO_FORMAT_F32, gst_audio::AUDIO_FORMAT_F64])
.build();
// The src pad template must be named "src" for basesrc
// and specific a pad that is always there