【问题标题】:Using basic auth with gstreamer souphttpsrc将基本身份验证与 gstreamer 汤httpsrc 一起使用
【发布时间】:2019-05-08 08:52:21
【问题描述】:

我们在 gstreamer 管道中使用 gstreamer souphttpsrc 来访问和转发 http 流。要访问 httpstream,我们必须使用 BasicAuth。我们知道如何格式化基本的 auth 标头,但是我们无法通过 souphttpsrc extra-headers 参数将标头作为 GstStructure 传递。

目前我们正在使用下面的命令

gst-launch-1.0 spuphttsrc location="http://streamsource" extra-headers="Authorization: Basic base64hash" ! ...

管道的其余部分已被忽略,因为它之前已经过测试并且正在运行。

我们收到的错误:canot set property extra-headers

gstreamer 的源代码可以在这里找到:https://github.com/GStreamer/gst-plugins-good

GstStructure 文档可以在这里找到:http://web.mit.edu/ghudson/dev/nokrb/third/gstreamer/docs/gst/html/gstreamer-GstStructure.html

任何帮助将不胜感激。

【问题讨论】:

  • 您到底想完成什么?难道你不能以http://username:password@streamsoruce 的形式在uri 中设置你的身份验证就完成了吗?
  • 我们实际上设法解决了这个问题。我会尽快自己发布答案。谢谢。

标签: c gstreamer basic-authentication


【解决方案1】:

我自己已经面对这个问题好几天了,我终于在我开始的时候着陆了。我的错误是我没有正确地转义空格。

错误

gst-launch-1.0 souphttpsrc location="http://streamsource" extra-headers="test,Authorization=Bearer\ eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c"

WARNING: erroneous pipeline: could not set property "extra-headers" in element "souphttpsrc0"

请注意,我确实添加了 \ 以转义 Bearer <Token> 中的空格,但这还不够。

解决方案

gst-launch-1.0

解决方法是将key=valuevalue部分包裹在\"<value>\"中,如下图使用\

gst-launch-1.0 souphttpsrc location="http://streamsource" extra-headers="test,Authorization=(string)\"Bearer\ eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c\""

提示:如果你想明确一点,你可以在value 前面添加它的类型,比如(string)\"value\"

gstreamer-java/gst1-java-core

最初引发我的问题是我无法在 java 绑定中设置 set extra-headers,我想我不妨在这里添加它。

在 Java 中:

String token = "mytoken";
Element httpSrc = ElementFactory.make("souphttpsrc", "test_src");
httpSrc.setAsString("extra-headers", "test, Authorization=Bearer $authToken");

或在 Kotlin 中:

val token: String = "mytoken"
val httpSrc: Element = ElementFactory.make("souphttpsrc", "test_src")
httpSrc.setAsString("extra-headers", "test, Authorization=Bearer $authToken")

对我有帮助的进一步阅读:

【讨论】:

    猜你喜欢
    • 2018-11-10
    • 2014-06-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-10-28
    • 1970-01-01
    • 1970-01-01
    • 2015-12-01
    相关资源
    最近更新 更多