Date Tags Misc

A really nice feature every video player using GStreamer and playbin2 should have is media on-disk buffering. Even though it is supported only for Quicktime and Flash videos currently it remains one good improvement of the user experience if you are an avid consumer of Apple trailers and flv :)

Under the hood the magic is in queue2 and uridecodebin but you mostly interface with playbin2. Here is the action plan:

  1. Add the "download" flag to the playbin2 flags property
  2. Upon reception of GST_MESSAGE_BUFFERING messages on the bus, add an idle source to the main loop (for instance)
  3. In that source create a gst_query_new_buffering() query with GST_PERCENT_FORMAT format perform the query to playbin2
  4. Use gst_query_parse_buffering_range() to get the stop value and compute the fill_status value
  5. Notify your UI of the fill level

Additionally you can allow the user to save the buffered media for later off-line consumption :) The media is buffered by queue2 in the tmp folder, the exact file location, temp-location queue2 property, can be retrieved by connecting to the "deep-notify::temp-location" signal of playbin2. You also need to make sure that the temporary file is removed when the user exits from your application, GStreamer doesn’t automatically take care of that, as far as I could see.

This is what Totem does, as far as I could understand its code. This is also how I implemented (yet to merge) it in WebKitGTK+:

And to provide a simple example I added this feature to the gst-python example, available in a gist after the break!


comments powered by Disqus