Making the 'httpsrc' plugin asynchronous | GSoC 2019

GStreamer plugins are the building units of any GStreamer application. The plugins can be linked and arranged in a pipeline. This pipeline defines the flow of the data. 'souphttpsrc', aka HTTP source is a plugin which reads data from a remote location specified by a URI and the supported protocols are 'http', 'https'. This plugin is written in C. 'rshttpsrc' is the Rust version of the above said plugin. 



Although the Rust version of the plugin is working, it is not feature complete. So my task here is to finish 'rshttpsrc' plugin completely. Let me break the task into smaller branches.
  1. Switching to async IO (Currently it is making request synchronously). 
  2. Support for cookie/HTTP connection sharing between multiple instances. 
  3. Making 'rshttpsrc' feature equivalent to 'souphttpsrc' (the C version of the same plugin). There are properties missing in 'rshttpsrc' which are implemented in C version of the plugin. Here is the list of properties in C version of the plugin.
This is the Gitlab link to this issue. Let me dig in detail into the first part of the problem. 

'rshttpsrc' is using 'reqwest' for making HTTP/HTTPS request. Our plugin was using the synchronous Client of the 'reqwest' crate which pretty much explain why the requests were synchronous. All I had to do to make it asynchronous was introducing async Client of the reqwest. But when doing this conversion I had to change the code that is wrapped around the method which makes the call to the specified URI and modify the methods which handle the request. 

Basically 'do_request()' method makes the call specified by the URI and gets the response asynchronously while 'create()' method is called by Gstreamer when data is needed. So 'create()' is invoked with the data from the response. These were some of the places in the code that I had to modify.

'wait()' is an interesting function introduced newly to cater asynchronous feature. It was previously implemented in 's3' plugin. This is what the function does. It gets a input of a Future (something that take time to resolve) which resolves either into an error or an item. Basically this gives you an API that allows to run some operation that takes time, but allows to cancel it at any time without having to wait until it finishes.


Switching to async IO for 'rshttpsrc' is done. Let's discuss the next part of the problem in the upcoming blogs :)

Comments

Popular posts from this blog

The Journey Begins | Google Summer of Code

I was there at GNOME.Asia Summit 2019

Review | GSoC 2019