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.
RPM spec file: Don't hard code version/paths

Generate RPM spec file with:

    make prefix=/usr extra/stb-tester.spec

This allows installation directories and version to be automatically
substituted into the rpm spec file.  This change was motivated by future
work which will install a GStreamer plugin.  This is required as the
location into which the GStreamer plugin will be installed depends on the
output of

    pkg-config --variable=pluginsdir gstreamer-1.0

which cannot be reliably known ahead-of-time.
WIP: stbt run: Pass all arguments after script name to script

If you passed --hello to stuff it would fail.

TODO:
* Better documentation for release notes: potentially breaks existing
  invocations.
WIP: Allow passing a numpy array as a template to match functions

This allows templates to be generated on-the-fly without having to create
intermediate image files.

TODO:

* Write tests
* Add documentation
stbt tv: Allow complex source pipelines with shell escaping

Previously if you had a stbt.conf like:

    source_pipeline=mysrc property="prop with spaces"

bash would get confused and would pass `property="prop` as `$2` and
separately pass `with` as `$3` and `spaces"` as `$4`.  Using `eval` fixes
this issue although it does make me slightly worried that if some bash
syntax inadvertently ended up in source_pipeline stbt tv could behave
oddly.

This is required for smart-tv support as, due to the complexities of
image processing `source_pipeline`s can require many complex parameters.
Smart TV Support: Add command stbt camera

Entry point for stb-tester support for pointing a camera at a TV.  It is
just a placeholder for now.  Real functionality will be added in later
commits.

Building camera support is optional, as is installing it with rpm as the
RPMs are split into stb-tester and stb-tester-camera.  This will allow
expressing additional dependencies required for camera support but not for
the rest.
WIP: Smart TV Support: Add GStreamer element for reconstructing TV image

Like set-top boxes, Smart TVs run complex software, including software
not provided by the manufacturer (e.g. apps).  Unlike set-top boxes they
provide no digital video output - the only video output they provide is
to screen.  So to support testing software running on TVs we need to
capture the contents of the TV screen.

We plan to do this with a webcam and some image processing to get the
contents of the screen such that we can feed that into GStreamer.  The
image processing will correct for problems with the positioning of the
camera and issues with the lens (which we will call "flattening") as well
as problems with the colours and brighness of the pixels.

This commit adds a GStreamer element `stbtwatchplane` which flattens the
image by first undoing distortions due to the camera lens and then
extracting the region in the undistorted image that corresponds to the
TV (homography) like:

                  |----------------------------|
    1080p         |       stbtwatchplane       |        720p
  Image from  --> |                            | --> Contents of
    Camera        | Undistort  --> Perspective |         TV
                  |----------------------------|

Undistort is parameterised by the properties:

* `camera-matrix` - A 3x3 matrix of the form:

        f_x   0   c_x
         0   f_y  c_y
         0    0    1

* `distortion-coefficients` - 5 values of the form:

        k_1, k_2, p_1, p_2, k_3

The perspective transformation is parameterised by the property:

* `homography-matrix` - A 3x3 matrix.

See the OpenCV documentation for more information[1].

The combined undistort/perspective transformation is actually done in one
operation.  We create a 1280x720 matrix where each "pixel" contains (x, y)
coordinates of where the real pixel value should be taken from in the
source 1080p image.  The OpenCV function `cvRemap` then justs looks
through this matrix to produce a 720p image from the 1080p input.

We generate this remapping matrix by tracing pixel locations from the 720p
image back through to the location on the 1080p image.  This means doing
the reverse perspective transformation on the coordinates and then
distorting the coordinates.

Not included in this commit but coming later:

* A calibration program to generate these properties based on viewing
  calibration patterns with the webcam.
* A validation program to measure the quality of this transformation.

This commit adds an optional build-time/test-time dependency on a C
compiler, OpenCV development headers and GStreamer development headers.
If they are not installed the GStreamer element will not be built.

[1]: http://docs.opencv.org/modules/calib3d/doc/camera_calibration_and_3d_reconstruction.html

TODO:
* Rename stbtwatchplane to stbtgeometriccorrection
WIP: Smart TV support: Add command stbt camera validate

stbt camera validate is intended to measure the quality of video capture
that a camera (plus the software corrections to that camera) provides.  It
does this by displaying images on the TV and then compares the output to
what was expected producing a report.

Currently it defers responsibility for displaying the reference images on
the TV to the user, but support for automatic TV control using DLNA is
coming in the future.

TODO:
* Validate that tests are sufficient?
* Makefile stuff to install validator
* Don't hard-code paths
* Split TV drivers into different python file
WIP: Smart TV Support: Add DLNA TV driver

TODO:
* Add tests
* Add documentation
WIP: Smart TV Support: Add stbtvignettecorrect element

Does location dependent contrast stretching

TODO:
* Add documetation
* Add tests
* Rename stbtcontraststretch?
WIP: Smart TV Support: Add histogram correction

TODO:
* Write tests
* Add documentation