Mutant Bob
Mutant Bob

Reputation: 3549

What dependencies are needed to write rust/gstreamer plugins for gstreamer crate 0.14?

I am trying to follow the tutorial at https://coaxion.net/blog/2018/01/how-to-write-gstreamer-elements-in-rust-part-1-a-video-filter-for-converting-rgb-to-grayscale/ about writing gstreamer plugins using rust.

If you follow the tutorial to the first point where I have compilable code Cargo.toml is

[package]
name = "gst-plugin-tutorial"
version = "0.1.0"
authors = ["Sebastian Dröge <[email protected]>"]
repository = "https://github.com/sdroege/gst-plugin-rs"
license = "MIT/Apache-2.0"

[dependencies]
glib = "0.4"
gstreamer = "0.10"
gstreamer-base = "0.10"
gstreamer-video = "0.10"
gst-plugin = "0.1"

[lib]
name = "gstrstutorial"
crate-type = ["cdylib"]
path = "src/lib.rs"

and src/lib.rs is

extern crate glib;
#[macro_use]
extern crate gstreamer as gst;
extern crate gstreamer_base as gst_base;
extern crate gstreamer_video as gst_video;
#[macro_use]
extern crate gst_plugin;

plugin_define!(
    b"rstutorial\0",
    b"Rust Tutorial Plugin\0",
    plugin_init,
    b"1.0\0",
    b"MIT/X11\0",
    b"rstutorial\0",
    b"rstutorial\0",
    b"https://github.com/sdroege/gst-plugin-rs\0",
    b"2017-12-30\0"
);

fn plugin_init(plugin: &gst::Plugin) -> bool {
    true
}

This compiles, but the project for which I need to write a plugin uses gstreamer 1.16, so it needs rust crate gstreamer 0.14.

When I alter the Cargo.toml to reference recent versions of the gstreamer crate:

[dependencies]
#glib = "0.4"
gstreamer = "0.14"
gstreamer-base = "0.14"
gstreamer-video = "0.14"
gst-plugin = "0.3.2"

I get errors at build time:

    Updating crates.io index
error: failed to select a version for `glib-sys`.
    ... required by package `gstreamer-base v0.14.0`
    ... which is depended on by `gst-plugin-tutorial v0.1.0 (/home/thoth/src/rust-gst-plugin-exp/coaxion-plugin)`
versions that meet the requirements `^0.9` are: 0.9.0

the package `glib-sys` links to the native library `glib`, but it conflicts with a previous package which links to `glib` as well:
package `glib-sys v0.7.0`
    ... which is depended on by `gst-plugin v0.3.2`
    ... which is depended on by `gst-plugin-tutorial v0.1.0 (/home/thoth/src/rust-gst-plugin-exp/coaxion-plugin)`

failed to select a version for `glib-sys` which could resolve this conflict

What is the proper mix of crate versions to write gstreamer plugins in rust for use with gstreamer 1.16 ?

Upvotes: 1

Views: 1265

Answers (2)

Mutant Bob
Mutant Bob

Reputation: 3549

As a variation on Sebastian's answer, I experimented with a Cargo.toml that doesn't point at git and uses released crates.

glib = "0.8"
gstreamer = "0.14"
gstreamer-base = "0.14"
gstreamer-video = "0.14"
#gst-plugin = "0.3.2"

That failed to provide a definition for gst_plugin_define! . It seems that is part of the subclassing feature. Switching to the following dependencies:

glib = { version = "0.8", features = [ "subclassing"] }
gstreamer = { version = "0.14", features = [ "subclassing"] }
gstreamer-base = { version = "0.14", features = [ "subclassing"] }
gstreamer-video = "0.14"

activated the code defining the gst_plugin_define! macro.

Upvotes: 0

Sebastian Dr&#246;ge
Sebastian Dr&#246;ge

Reputation: 2143

You can find new versions of the tutorials here and the latest version of the code here.

Your problem is that you're still using the gst-plugin crate, but that's obsolete nowadays and everything's part of the glib / gstreamer / gstreamer-base / etc crates now if you enable the subclass feature of them. See the links above for the details.

Depending on the old version of the gst-plugin crate will pull in an older version of the glib-sys (and others) crate, and you can't have two different versions of a -sys crate in the same project.

You'll have the same problem again if you uncomment the glib dependency. Once you update that to the 0.8 version of glib, that error would also go away.

Upvotes: 2

Related Questions