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:
authorFrançois Laignel <fengalin@free.fr>2021-06-03 21:20:54 +0300
committerFrançois Laignel <fengalin@free.fr>2021-06-03 21:53:16 +0300
commit8dfc872544b26aa5eaf4b12da7d9c5e0361467ca (patch)
treee314ee0cfde5930ac50a5bfd985b34d1129362b0 /tutorial
parent91c8fd146dd477ce744bec944395672719a13ebe (diff)
use gst::glib where applicable
Diffstat (limited to 'tutorial')
-rw-r--r--tutorial/Cargo.toml1
-rw-r--r--tutorial/src/identity/imp.rs2
-rw-r--r--tutorial/src/identity/mod.rs3
-rw-r--r--tutorial/src/lib.rs2
-rw-r--r--tutorial/src/progressbin/imp.rs3
-rw-r--r--tutorial/src/progressbin/mod.rs3
-rw-r--r--tutorial/src/rgb2gray/imp.rs2
-rw-r--r--tutorial/src/rgb2gray/mod.rs3
-rw-r--r--tutorial/src/sinesrc/imp.rs2
-rw-r--r--tutorial/src/sinesrc/mod.rs3
-rw-r--r--tutorial/tutorial-1.md63
-rw-r--r--tutorial/tutorial-2.md18
12 files changed, 56 insertions, 49 deletions
diff --git a/tutorial/Cargo.toml b/tutorial/Cargo.toml
index 63dde7293..551db4cb7 100644
--- a/tutorial/Cargo.toml
+++ b/tutorial/Cargo.toml
@@ -8,7 +8,6 @@ edition = "2018"
description = "Rust Tutorial Plugin"
[dependencies]
-glib = { git = "https://github.com/gtk-rs/gtk-rs-core" }
gst = { package = "gstreamer", git = "https://gitlab.freedesktop.org/gstreamer/gstreamer-rs" }
gst-base = { package = "gstreamer-base", git = "https://gitlab.freedesktop.org/gstreamer/gstreamer-rs" }
gst-video = { package = "gstreamer-video", git = "https://gitlab.freedesktop.org/gstreamer/gstreamer-rs" }
diff --git a/tutorial/src/identity/imp.rs b/tutorial/src/identity/imp.rs
index 6b56e1b53..6f12f6782 100644
--- a/tutorial/src/identity/imp.rs
+++ b/tutorial/src/identity/imp.rs
@@ -6,7 +6,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-use glib::subclass::prelude::*;
+use gst::glib;
use gst::prelude::*;
use gst::subclass::prelude::*;
use gst::{gst_log, gst_trace};
diff --git a/tutorial/src/identity/mod.rs b/tutorial/src/identity/mod.rs
index d7d45183a..15d18158b 100644
--- a/tutorial/src/identity/mod.rs
+++ b/tutorial/src/identity/mod.rs
@@ -6,7 +6,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-use glib::prelude::*;
+use gst::glib;
+use gst::prelude::*;
mod imp;
diff --git a/tutorial/src/lib.rs b/tutorial/src/lib.rs
index f1ce2dd28..bb3ff865e 100644
--- a/tutorial/src/lib.rs
+++ b/tutorial/src/lib.rs
@@ -6,6 +6,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+use gst::glib;
+
mod identity;
mod progressbin;
mod rgb2gray;
diff --git a/tutorial/src/progressbin/imp.rs b/tutorial/src/progressbin/imp.rs
index 94a3909fd..47bab498d 100644
--- a/tutorial/src/progressbin/imp.rs
+++ b/tutorial/src/progressbin/imp.rs
@@ -6,8 +6,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-use glib::prelude::*;
-use glib::subclass::prelude::*;
+use gst::glib;
use gst::gst_info;
use gst::prelude::*;
use gst::subclass::prelude::*;
diff --git a/tutorial/src/progressbin/mod.rs b/tutorial/src/progressbin/mod.rs
index d4f940f76..0e38f75a9 100644
--- a/tutorial/src/progressbin/mod.rs
+++ b/tutorial/src/progressbin/mod.rs
@@ -6,7 +6,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-use glib::prelude::*;
+use gst::glib;
+use gst::prelude::*;
mod imp;
diff --git a/tutorial/src/rgb2gray/imp.rs b/tutorial/src/rgb2gray/imp.rs
index ef76f866b..3f5e724dc 100644
--- a/tutorial/src/rgb2gray/imp.rs
+++ b/tutorial/src/rgb2gray/imp.rs
@@ -6,7 +6,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-use glib::subclass::prelude::*;
+use gst::glib;
use gst::prelude::*;
use gst::subclass::prelude::*;
use gst::{gst_debug, gst_info};
diff --git a/tutorial/src/rgb2gray/mod.rs b/tutorial/src/rgb2gray/mod.rs
index 988904d7d..28faa28d0 100644
--- a/tutorial/src/rgb2gray/mod.rs
+++ b/tutorial/src/rgb2gray/mod.rs
@@ -6,7 +6,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-use glib::prelude::*;
+use gst::glib;
+use gst::prelude::*;
mod imp;
diff --git a/tutorial/src/sinesrc/imp.rs b/tutorial/src/sinesrc/imp.rs
index 7195e550e..b3556a241 100644
--- a/tutorial/src/sinesrc/imp.rs
+++ b/tutorial/src/sinesrc/imp.rs
@@ -6,7 +6,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-use glib::subclass::prelude::*;
+use gst::glib;
use gst::prelude::*;
use gst::subclass::prelude::*;
use gst::{gst_debug, gst_error, gst_info, gst_log};
diff --git a/tutorial/src/sinesrc/mod.rs b/tutorial/src/sinesrc/mod.rs
index 8e3964997..7342f268c 100644
--- a/tutorial/src/sinesrc/mod.rs
+++ b/tutorial/src/sinesrc/mod.rs
@@ -6,7 +6,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-use glib::prelude::*;
+use gst::glib;
+use gst::prelude::*;
mod imp;
diff --git a/tutorial/tutorial-1.md b/tutorial/tutorial-1.md
index 68d95ec1d..2e2c3ec00 100644
--- a/tutorial/tutorial-1.md
+++ b/tutorial/tutorial-1.md
@@ -10,18 +10,17 @@ The final code for this plugin can be found [here](https://gitlab.freedesktop.or
# Table of contents
-1. [Project Structure](#project-structure)
-1. [Plugin Initialization](#plugin-initialization)
-1. [Type Registration](#type-registration)
-1. [Type Class and Instance Initialization](#type-class-and-instance-initialization)
-1. [Caps and Pad Templates](#caps-and-pad-templates)
-1. [Caps Handling Part 1](#caps-handling-part-1)
-1. [Caps Handling Part 2](#caps-handling-part-2)
-1. [Conversion of BGRx Video Frames to Grayscale](#conversion-of-bgrx-video-frames-to-grayscale)
-1. [Testing the new element](#testing-the-new-element)
-1. [Properties](#properties)
-1. [What next](#what-next)
-
+ 1. [Project Structure](#project-structure)
+ 2. [Plugin Initialization](#plugin-initialization)
+ 3. [Type Registration](#type-registration)
+ 4. [Type Class and Instance Initialization](#type-class-and-instance-initialization)
+ 5. [Caps and Pad Templates](#caps-and-pad-templates)
+ 6. [Caps Handling Part 1](#caps-handling-part-1)
+ 7. [Caps Handling Part 2](#caps-handling-part-2)
+ 8. [Conversion of BGRx Video Frames to Grayscale](#conversion-of-bgrx-video-frames-to-grayscale)
+ 9. [Testing the new element](#testing-the-new-element)
+ 10. [Properties](#properties)
+ 11. [What next](#what-next)
## Project Structure
@@ -41,7 +40,6 @@ edition = "2018"
description = "Rust Tutorial Plugin"
[dependencies]
-glib = { git = "https://github.com/gtk-rs/glib" }
gst = { package = "gstreamer", git = "https://gitlab.freedesktop.org/gstreamer/gstreamer-rs" }
gst-base = { package = "gstreamer-base", git = "https://gitlab.freedesktop.org/gstreamer/gstreamer-rs" }
gst-video = { package = "gstreamer-video", git = "https://gitlab.freedesktop.org/gstreamer/gstreamer-rs" }
@@ -91,15 +89,16 @@ gst::plugin_define!(
GStreamer requires this information to be statically available in the shared library, not returned by a function.
The static plugin metadata that we provide here is
-1. name of the plugin
-1. short description for the plugin
-1. name of the plugin entry point function
-1. version number of the plugin
-1. license of the plugin (only a fixed set of licenses is allowed here, [see](https://gstreamer.freedesktop.org/data/doc/gstreamer/head/gstreamer/html/GstPlugin.html#GstPluginDesc))
-1. source package name
-1. binary package name (only really makes sense for e.g. Linux distributions)
-1. origin of the plugin
-1. release date of this version
+
+ 1. name of the plugin
+ 1. short description for the plugin
+ 1. name of the plugin entry point function
+ 1. version number of the plugin
+ 1. license of the plugin (only a fixed set of licenses is allowed here, [see](https://gstreamer.freedesktop.org/data/doc/gstreamer/head/gstreamer/html/GstPlugin.html#GstPluginDesc))
+ 1. source package name
+ 1. binary package name (only really makes sense for e.g. Linux distributions)
+ 1. origin of the plugin
+ 1. release date of this version
Next we create `build.rs` in the project main directory.
@@ -133,6 +132,8 @@ gst-inspect-1.0 target/debug/libgstrstutorial.so
As a next step, we’re going to add another module `rgb2gray` to our project, and call a function called `register` from our `plugin_init` function.
```rust
+use gst::glib;
+
mod rgb2gray;
fn plugin_init(plugin: &gst::Plugin) -> Result<(), glib::BoolError> {
@@ -144,11 +145,7 @@ fn plugin_init(plugin: &gst::Plugin) -> Result<(), glib::BoolError> {
With that our `src/lib.rs` is complete, and all following code is only in `src/rgb2gray/imp.rs`. At the top of the new file we first need to add various `use-directives` to import various types, macros and functions we’re going to use into the current module’s scope.
```rust
-use glib::subclass;
-use glib::subclass::prelude::*;
-
-use gst::prelude::*;
-use gst::subclass::prelude::*;
+use gst::glib;
use gst::{gst_debug, gst_info};
use gst_base::subclass::prelude::*;
@@ -163,6 +160,8 @@ GStreamer is based on the GLib object system ([GObject](https://developer.gnome.
So, as a next step we need to register a new type for our RGB to Grayscale converter GStreamer element with the GObject type system, and then register that type with GStreamer to be able to create new instances of it. We do this with the following code
```rust
+use gst::glib;
+
#[derive(Default)]
pub struct Rgb2Gray {}
@@ -183,11 +182,11 @@ This defines a struct `Rgb2Gray` which is empty for now and an empty implementat
We also add the following code is in `src/rgb2gray/mod.rs`:
```rust
-use glib::prelude::*;
+use gst::glib;
+use gst::prelude::*;
mod imp;
-// The public Rust wrapper type for our element
glib::wrapper! {
pub struct Rgb2Gray(ObjectSubclass<imp::Rgb2Gray>) @extends gst_base::BaseTransform, gst::Element, gst::Object;
}
@@ -220,6 +219,8 @@ In addition, we also define a `register` function (the one that is already calle
As a next step we implement the `new` funtion and `class_init` functions. In the first version, this struct is empty for now but we will later use it to store all state of our element.
```rust
+use gst::glib;
+
#[derive(Default)]
pub struct Rgb2Gray {}
@@ -286,10 +287,12 @@ impl BaseTransformImpl for Rgb2Gray {}
```
```rust
-use glib::prelude::*;
+use gst::glib;
+use gst::prelude::*;
mod imp;
+// The public Rust wrapper type for our element
glib::wrapper! {
pub struct Rgb2Gray(ObjectSubclass<imp::Rgb2Gray>) @extends gst_base::BaseTransform, gst::Element, gst::Object;
}
diff --git a/tutorial/tutorial-2.md b/tutorial/tutorial-2.md
index dfa0e56ba..cc3afac37 100644
--- a/tutorial/tutorial-2.md
+++ b/tutorial/tutorial-2.md
@@ -4,12 +4,12 @@ In this part, a raw audio sine wave source element is going to be written. The f
### Table of Contents
-1. [Boilerplate](#boilerplate)
-2. [Caps Negotiation](#caps-negotiation)
-3. [Buffer Creation](#buffer-creation)
-4. [(Pseudo) Live Mode](#pseudo-live-mode)
-5. [Unlocking](#unlocking)
-6. [Seeking](#seeking)
+ 1. [Boilerplate](#boilerplate)
+ 2. [Caps Negotiation](#caps-negotiation)
+ 3. [Buffer Creation](#buffer-creation)
+ 4. [(Pseudo) Live Mode](#pseudo-live-mode)
+ 5. [Unlocking](#unlocking)
+ 6. [Seeking](#seeking)
### Boilerplate
@@ -22,8 +22,7 @@ So let's get started with all the boilerplate. This time our element will be bas
In `src/sinesrc/imp.rs`:
```rust
-use glib::prelude::*;
-use glib::subclass::prelude::*;
+use gst::glib;
use gst::prelude::*;
use gst::subclass::prelude::*;
use gst::{gst_debug, gst_error, gst_info, gst_log};
@@ -366,7 +365,8 @@ impl BaseSrcImpl for SineSrc {
In `src/sinesrc/mod.rs`:
```rust
-use glib::prelude::*;
+use gst::glib;
+use gst::prelude::*;
mod imp;