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:
authorSebastian Dröge <sebastian@centricular.com>2021-11-06 10:34:10 +0300
committerSebastian Dröge <sebastian@centricular.com>2021-11-06 10:34:10 +0300
commitd9bda62a4720c0539a443a4e489645e9bb4af1eb (patch)
treed59eef871715fda4a9b37e355909a345dbd598d0 /tutorial
parentc99b7785f941fa4f9388a88e52d74c0fa34129ec (diff)
Update for GLib/GStreamer API changes
And clean up a lot of related property/caps/structure code.
Diffstat (limited to 'tutorial')
-rw-r--r--tutorial/src/progressbin/imp.rs2
-rw-r--r--tutorial/src/rgb2gray/imp.rs62
-rw-r--r--tutorial/src/sinesrc/imp.rs27
-rw-r--r--tutorial/tutorial-1.md62
-rw-r--r--tutorial/tutorial-2.md27
5 files changed, 81 insertions, 99 deletions
diff --git a/tutorial/src/progressbin/imp.rs b/tutorial/src/progressbin/imp.rs
index aebf2f3cf..9546fc400 100644
--- a/tutorial/src/progressbin/imp.rs
+++ b/tutorial/src/progressbin/imp.rs
@@ -64,7 +64,7 @@ impl ObjectSubclass for ProgressBin {
// Create the progressreport element.
let progress = gst::ElementFactory::make("progressreport", Some("progress")).unwrap();
// Don't let progressreport print to stdout itself
- progress.set_property("silent", &true).unwrap();
+ progress.set_property("silent", true).unwrap();
// Return an instance of our struct
Self {
diff --git a/tutorial/src/rgb2gray/imp.rs b/tutorial/src/rgb2gray/imp.rs
index b6ba9a3ed..06d90dc2d 100644
--- a/tutorial/src/rgb2gray/imp.rs
+++ b/tutorial/src/rgb2gray/imp.rs
@@ -205,27 +205,24 @@ 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::new_simple(
- "video/x-raw",
- &[
- (
- "format",
- &gst::List::new(&[
- &gst_video::VideoFormat::Bgrx.to_str(),
- &gst_video::VideoFormat::Gray8.to_str(),
- ]),
+ 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),
),
- ("width", &gst::IntRange::<i32>::new(0, i32::MAX)),
- ("height", &gst::IntRange::<i32>::new(0, i32::MAX)),
- (
- "framerate",
- &gst::FractionRange::new(
- gst::Fraction::new(0, 1),
- gst::Fraction::new(i32::MAX, 1),
- ),
- ),
- ],
- );
+ )
+ .build();
// The src pad template must be named "src" for basetransform
// and specific a pad that is always there
let src_pad_template = gst::PadTemplate::new(
@@ -238,21 +235,18 @@ impl ElementImpl for Rgb2Gray {
// On the sink pad, we can accept BGRx of any
// width/height and with any framerate
- let caps = gst::Caps::new_simple(
- "video/x-raw",
- &[
- ("format", &gst_video::VideoFormat::Bgrx.to_str()),
- ("width", &gst::IntRange::<i32>::new(0, i32::MAX)),
- ("height", &gst::IntRange::<i32>::new(0, i32::MAX)),
- (
- "framerate",
- &gst::FractionRange::new(
- gst::Fraction::new(0, 1),
- gst::Fraction::new(i32::MAX, 1),
- ),
+ 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),
),
- ],
- );
+ )
+ .build();
// The sink pad template must be named "sink" for basetransform
// and specific a pad that is always there
let sink_pad_template = gst::PadTemplate::new(
diff --git a/tutorial/src/sinesrc/imp.rs b/tutorial/src/sinesrc/imp.rs
index 938556a7f..4ada4ddd0 100644
--- a/tutorial/src/sinesrc/imp.rs
+++ b/tutorial/src/sinesrc/imp.rs
@@ -360,21 +360,18 @@ 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::new_simple(
- "audio/x-raw",
- &[
- (
- "format",
- &gst::List::new(&[
- &gst_audio::AUDIO_FORMAT_F32.to_str(),
- &gst_audio::AUDIO_FORMAT_F64.to_str(),
- ]),
- ),
- ("layout", &"interleaved"),
- ("rate", &gst::IntRange::<i32>::new(1, i32::MAX)),
- ("channels", &gst::IntRange::<i32>::new(1, i32::MAX)),
- ],
- );
+ 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))
+ .build();
// The src pad template must be named "src" for basesrc
// and specific a pad that is always there
let src_pad_template = gst::PadTemplate::new(
diff --git a/tutorial/tutorial-1.md b/tutorial/tutorial-1.md
index 2e2c3ec00..f1f5688c4 100644
--- a/tutorial/tutorial-1.md
+++ b/tutorial/tutorial-1.md
@@ -340,27 +340,24 @@ To be able to declare what kinds of pads an element can create (they are not nec
In our case we only have always pads, one sink pad called “sink”, on which we can only accept RGB (BGRx to be exact) data with any width/height/framerate and one source pad called “src”, on which we will produce either RGB (BGRx) data or GRAY8 (8-bit grayscale) data. We do this by adding the following code to the class_init function.
```rust
- let caps = gst::Caps::new_simple(
- "video/x-raw",
- &[
- (
- "format",
- &gst::List::new(&[
- &gst_video::VideoFormat::Bgrx.to_str(),
- &gst_video::VideoFormat::Gray8.to_str(),
- ]),
+ 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),
),
- ("width", &gst::IntRange::<i32>::new(0, i32::MAX)),
- ("height", &gst::IntRange::<i32>::new(0, i32::MAX)),
- (
- "framerate",
- &gst::FractionRange::new(
- gst::Fraction::new(0, 1),
- gst::Fraction::new(i32::MAX, 1),
- ),
- ),
- ],
- );
+ )
+ .build();
let src_pad_template = gst::PadTemplate::new(
"src",
gst::PadDirection::Src,
@@ -371,21 +368,18 @@ In our case we only have always pads, one sink pad called “sink”, on which w
klass.add_pad_template(src_pad_template);
- let caps = gst::Caps::new_simple(
- "video/x-raw",
- &[
- ("format", &gst_video::VideoFormat::Bgrx.to_str()),
- ("width", &gst::IntRange::<i32>::new(0, i32::MAX)),
- ("height", &gst::IntRange::<i32>::new(0, i32::MAX)),
- (
- "framerate",
- &gst::FractionRange::new(
- gst::Fraction::new(0, 1),
- gst::Fraction::new(i32::MAX, 1),
- ),
+ 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),
),
- ],
- );
+ )
+ .build();
let sink_pad_template = gst::PadTemplate::new(
"sink",
gst::PadDirection::Sink,
diff --git a/tutorial/tutorial-2.md b/tutorial/tutorial-2.md
index 26d55ef06..acdfcabd2 100644
--- a/tutorial/tutorial-2.md
+++ b/tutorial/tutorial-2.md
@@ -139,21 +139,18 @@ impl ObjectSubclass for SineSrc {
// On the src pad, we can produce F32/F64 with any sample rate
// and any number of channels
- let caps = gst::Caps::new_simple(
- "audio/x-raw",
- &[
- (
- "format",
- &gst::List::new(&[
- &gst_audio::AUDIO_FORMAT_F32.to_str(),
- &gst_audio::AUDIO_FORMAT_F64.to_str(),
- ]),
- ),
- ("layout", &"interleaved"),
- ("rate", &gst::IntRange::<i32>::new(1, i32::MAX)),
- ("channels", &gst::IntRange::<i32>::new(1, i32::MAX)),
- ],
- );
+ 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))
+ .build();
// The src pad template must be named "src" for basesrc
// and specific a pad that is always there
let src_pad_template = gst::PadTemplate::new(