Adaptive Demuxer baseclass

If you haven't read yet, Sebastian has a good overview of adaptive streaming support (client-side) in GStreamer:

Currently, GStreamer works with all 3 adaptive formats out there: HLS with hlsdemux, SmoothStreaming with mssdemux and DASH with dashdemux. And while it all works quite well for the most common scenarios, all 3 elements are very similar and share a lot of code. Large portions of code were actually copy and pasted from one to another while they were being developed and in early stages of stabilization. At the moment it is common to have to fix the same issue or implement the same feature and copy over for the other elements. This is not nice.

The Solution

As most of the code is actually the same, the obvious solution is to write a base class: GstAdaptiveDemux. It will handle the common logic that is now copied on all 3 elements:

  • Receive the manifest from upstream and merge it into a single buffer
  • Start a thread for each stream available in the manifest and create the source element that will fetch the fragments and push downstream
  • Calculate the download rate of fragments to select the