将基本身份验证与GStreamer Souphttpsrc配合使用 [英] Using basic auth with gstreamer souphttpsrc
问题描述
我们在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
如有任何帮助,我们将不胜感激。
推荐答案
我自己面对这个问题已经好几天了,我终于回到了我开始的地方。我的错误是我没有正确转义空格。
错误
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=value
的value
部分包装在"<value>"
中,如下所示使用:
gst-launch-1.0 souphttpsrc location="http://streamsource" extra-headers="test,Authorization=(string)"Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c""
提示:如果您想显式,可以在value
Like(string)"value"
前面添加其类型。
GStreamer-Java/gst1-Java-core
最初提示我问题的是,我无法在Java绑定中设置Setextra-headers
,我想我还是在这里添加它吧。
在Java中:
String token = "mytoken";
Element httpSrc = ElementFactory.make("souphttpsrc", "test_src");
httpSrc.setAsString("extra-headers", "test, Authorization=Bearer $authToken");
或科特林语:
val token: String = "mytoken"
val httpSrc: Element = ElementFactory.make("souphttpsrc", "test_src")
httpSrc.setAsString("extra-headers", "test, Authorization=Bearer $authToken")
对我有帮助的进一步阅读:
这篇关于将基本身份验证与GStreamer Souphttpsrc配合使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!