为gstreamer crate 0.14编写rust / gstreamer插件需要什么依赖关系?

时间:2019-07-16 14:37:05

标签: rust gstreamer

我正在尝试遵循https://coaxion.net/blog/2018/01/how-to-write-gstreamer-elements-in-rust-part-1-a-video-filter-for-converting-rgb-to-grayscale/上有关使用rust编写gstreamer插件的教程。

如果您按照本教程进行操作,那么我拥有可编译代码Cargo.toml的第一点就是

[package]
name = "gst-plugin-tutorial"
version = "0.1.0"
authors = ["Sebastian Dröge <sebastian@centricular.com>"]
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"

和src / lib.rs是

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
}

这可以编译,但是我需要为其编写插件的项目使用gstreamer 1.16,因此它需要防锈板条箱gstreamer 0.14。

当我更改Cargo.toml以引用gstreamer板条箱的最新版本时:

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

在构建时出现错误:

    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

使用grateer 1.16在rust中编写gstreamer插件的板条箱版本的正确组合是什么?

2 个答案:

答案 0 :(得分:1)

您可以找到教程here的新版本和代码here的最新版本。

您的问题是您仍在使用gst-plugin板条箱,但如今已过时,而glib / gstreamer / gstreamer-base /等板条箱中的所有内容现在都已使用如果启用了它们的subclass功能。有关详细信息,请参见上面的链接。

取决于旧版本的gst-plugin板条箱将引入旧版本的glib-sys(及其他)板条箱,并且您不能有{{1}的两个不同版本}放在同一项目中。

如果取消注释-sys依赖项,则会再次遇到相同的问题。将其更新为glib的{​​{1}}版本后,该错误也将消失。

答案 1 :(得分:0)

作为塞巴斯蒂安回答的一种变体,我尝试了一个Cargo.toml,它不指向git并使用已释放的板条箱。

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

未能为gst_plugin_define!提供定义。看来这是子分类功能的一部分。切换到以下依赖项:

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

激活了定义gst_plugin_define!宏的代码。