Making Rust HTTP source Feature equivalent - Part 1 | GSoC 2019

souphttpsrc is the C version of HTTP source plugin of GStreamer. Making reqwesthttpsrc feature equivalent to that of souphttpsrc is a very important part of the conversion. Although Rust HTTP source is functioning well, it is not fully in to use because it is not equivalent to C HTTP source.

For now there is only one property implemented from C HTTP source apart from the ones which come from base class. That is 'location'. We can set a URL to read using this property. For example

gst-launch-1.0 reqwesthttpsrc location=https://www.google.com ! fakesink dump=true

I introduced two more properties to Rust HTTP source. Let's all give a warm welcome to 'is-live' and 'user-agent'. I had to go through the C code of the plugin to understand about the those properties and see where they've been used in the plugin. 

'is-live' was a easy point to start with because the implementation was straight forward. This is a property which can have Boolean value. If it's set to true then the plugin act as a live source. What is a live source? Yes, I was wondering about that for sometime. Live sources are sources that when paused discard data, such as audio or video capture devices. A typical live source also produces data at a fixed rate and thus provides a clock to publish this rate. A live source does not produce data in the PAUSED state.

Example usage using gst-launch

> gst-launch-1.0 reqwesthttpsrc location=https://www.google.com is-live=true ! fakesink dump=true

'user-agent' is the next property that I added to reqwesthttpsrc. User-Agent is a HTTP request header field. This header is used to identify where the request is being originated from. The User-Agent HTTP request header is set to a custom string using this property. Default value for user-agent header is "GStreamer reqwesthttpsrc".

Example usage

> gst-launch-1.0 reqwesthttpsrc location=https://www.google.com user-agent="Hi, I am new here" ! fakesink dump=true

We can capture the request and check the user-agent header which is going to be "Hi, I am new here". There a few more properties missing in the Rust HTTP source. Below table shows them.


Properties
Description
1
automatic-redirect 
When the status code is 3xx, follow the redirect link. Go to this link for implementing this property using reqwest.
2
compress
Allow compressed content encodings. Go to this link for implementing this property using reqwest.
3
cookies
HTTP request cookies.
4
extra-headers
Extra headers to append to the HTTP request.
5
iradio-mode
Enable internet radio mode (ask server to send shoutcast/ icecast metadata interleaved with the actual stream data)
6
keep-alive
Use HTTP persistent connections.
7
method
Use GET, HEAD requests.
8
proxy
HTTP proxy server related properties.
9
proxy-id
10
proxy-pw
11
retries
Number of retries before giving up.
12
ssl-ca-file
SSL related properties.
13
ssl-strict
14
ssl-use-system-ca-file
15
timeout
Seconds to timeout a blocking I/O. Go to this link for implementing this property using reqwest.
16
user-id
HTTP location URI user id for authentication. Go to this link for implementing this property using reqwest.
17
user-pw
HTTP location URI user password for authentication.

Other than these properties, there are some more features which should be implemented in Rust HTTP source. For example HTTP context sharing feature. Keep in touch for more posts :)

Comments

Popular posts from this blog

Writing tests for Rust HTTP source | GSoC 2019

Making the 'httpsrc' plugin asynchronous | GSoC 2019