We are using the gstreamer souphttpsrc in a gstreamer pipeline to access and forward at http stream. To access the httpstream we have to use BasicAuth. We know how to format the basic auth header but we have trouble passing the header via the souphttpsrc extra-headers parameter as a GstStructure.
Currently we are using the command below
gst-launch-1.0 spuphttsrc location="http://streamsource" extra-headers="Authorization: Basic base64hash" ! ...
The rest of the pipeline has been left out as it has been tested previously and is working.
The error we receive: canot set property extra-headers
The source code for gstreamer can be found here: https://github.com/GStreamer/gst-plugins-good
The GstStructure docs can be found here: http://web.mit.edu/ghudson/dev/nokrb/third/gstreamer/docs/gst/html/gstreamer-GstStructure.html
Any help would be appreciated.
Having faced this issue myself for several days I finally landed at exactly the point at which I started. My mistake was that I did not properly escape whitespace.
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"
Notice I did add \
to escape the whitespace in Bearer <Token>
, but its not enough.
The solution is to wrap the value
part of key=value
in \"<value>\"
as shown below to use the \
:
gst-launch-1.0 souphttpsrc location="http://streamsource" extra-headers="test,Authorization=(string)\"Bearer\ eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c\""
Hint: If you want to be explicit you can add its type as well infront of value
like (string)\"value\"
.
What prompted my problem initially was that I was not able to setup set extra-headers
in the java bindings, figured I might as well add it here.
In Java:
String token = "mytoken";
Element httpSrc = ElementFactory.make("souphttpsrc", "test_src");
httpSrc.setAsString("extra-headers", "test, Authorization=Bearer $authToken");
or in Kotlin:
val token: String = "mytoken"
val httpSrc: Element = ElementFactory.make("souphttpsrc", "test_src")
httpSrc.setAsString("extra-headers", "test, Authorization=Bearer $authToken")
Further reading that helped me: