drothlis/stb-tester — pull request #71 by wmanley (2013-11-29 10:36:09+00:00)
Title: Port to Gstreamer 1.0

Gstreamer 1.0 has been out for more than a year now and is where the majority of the upstream development is going nowadays. This change will make it easier to develop further more advanced features such as sound analysis and new UIs for stbt.

Using GStreamer 1.0 from Python is incompatible with Gstreamer 0.10 in that Gstreamer 1.0:

1. Gstreamer 1.0 has a different C API to 0.10
2. Some of the elements and properties have been renamed in Gstreamer 1.0.
3. Gstreamer 1.0 uses GObject introspection for automatically generating
Python bindings from the C API

This was mostly straightforward, but the changes to the appsink/appsrc were quite tricky. Because caps information is no longer attached to buffers appsink now produces `GstSample`s rather than `GstBuffers` which includes caps information. Getting this right so the caps can get through to the appsrc was a little tricky. Also caps are now set as a property on appsrc.

Notes:

* vp8enc has lost the "speed" property so this has been removed. It
should probably be replaced with the "cpu-used" property but I don't
know what value should be used (range -16 - +16)
* sink pipeline used in tests now uses xvimagesink. This needs testing
on machines which don't have Xv support such as in a VM(?)
* gst_to_opencv now copies the data contained in the array. It may be
possible to further optimise this but that will require greater
understanding on the relationship between Python and GObject lifetimes.
* on_new_sample is called as a GObject callback and should never throw.
This was noticed as with Gstreamer 1.0 it requires a return value. We
should probably catch all exceptions thrown in any callback and work out
how to signal errors some other way.
* pylint 0.25.1 which I have on my Debian testing machine doesn't
understand gobject introspection imports so I've had to add a pylint
disable to the import. Upgrading to pylint 1.0.0 fixes this but finds
other issues with the code. This can be resolved in a seperate commit.
* I've had to increase the threshold in the black screen test as it seems,
possibly with the move from video/x-raw-yuv to video/x-raw,format=I420
that blacks aren't as black anymore, possibly as a result of GStreamer
1.0 choosing a different type of yuv in 0.10.
* I've **not yet tested this with any real hardware** but I'm opening this pull
request anyway so there is a place to collect discussion