【问题标题】:What dependencies are needed to write rust/gstreamer plugins for gstreamer crate 0.14?为 gstreamer crate 0.14 编写 rust/gstreamer 插件需要哪些依赖项?
【发布时间】:2019-07-17 03:30:20
【问题描述】:

我正在尝试遵循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,因此它需要 rust crate gstreamer 0.14。

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

[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

在 rust 中编写用于 gstreamer 1.16 的 gstreamer 插件的 crate 版本的正确组合是什么?

【问题讨论】:

    标签: rust gstreamer


    【解决方案1】:

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

    您的问题是您仍在使用 gst-plugin 板条箱,但现在已经过时了,如果您启用 subclass 功能,现在所有东西都是 glib / gstreamer / gstreamer-base / 等板条箱的一部分其中。有关详细信息,请参阅上面的链接。

    根据gst-plugin crate 的旧版本,将引入glib-sys(和其他)crate 的旧版本,并且您不能在同一个项目中拥有两个不同版本的-sys crate .

    如果您取消注释 glib 依赖项,您将再次遇到同样的问题。一旦您将其更新为glib0.8 版本,该错误也会消失。

    【讨论】:

    • 当我删除 gst-plugin crate 并将 glib 设置为 0.8 时,我无法找到 plugin_define!gst_plugin_define! 宏的定义。从已发布的 crates 切换到 git repos 确实让我开始编译和开发代码。我预计随着插件 API 的稳定,可以再次创建使用已发布 crate 的插件。
    • 可以使用 crates.io 上发布的版本就好了。你遇到了什么问题?例如。 gst-plugins-rs 存储库的 0.5 branch 正在使用所有内容的已发布版本。检查适用于版本的教程代码。
    【解决方案2】:

    作为 Sebastian 答案的一个变体,我尝试了一个 Cargo.toml,它不指向 git 并使用已发布的 crates。

    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!宏的代码。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-09-28
      • 2018-09-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多