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:

* For GStreamer 1.0 vp8enc has replaced the property "speed" with
  "cpu-used" where speed=7 is the same as cpu-used=6.  See GStreamer
  BugZilla #684206[1] for more information.
* 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.

[1]: https://bugzilla.gnome.org/show_bug.cgi?id=684206
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.
config: Refactor in preparation for adding set_config

WIP: Talk about uncertainty around `=None` stuff.
WIP: Add _set_config

TODO:

* Decide what to do WRT destroying comments
* Think about making it public or exposing it through the stbt config
  command line interface.
MISC: Add checking to gst_to_opencv
DEBUGGING: Dump internal GStreamer pipeline state on error

GStreamer has a debug feature where it can dump how a pipeline is wired
up as a graph.  This is very useful for debugging problems with the
GStreamer pipeline.  This commit adds the necessary hooks such that this
information may be dumped when an error occurs much like gst-launch-1.0
already behaves

The effect is that if `GST_DEBUG_DUMP_DOT_DIR` is defined in the
environment and an error occurs a GraphViz dot file will be written to that
directory.  You can then use `dot -T png -o image.png graph.dot` to convert
it to a PNG.

See [Running GStreamer Applications][1] in the GStreamer documentation for
more information.

[1]: http://gstreamer.freedesktop.org/data/doc/gstreamer/head/gstreamer/html/gst-running.html
Self-Tests: Improve sandboxing

Take a copy of `stbt.conf` so tests are free to make modifications to it.
Also move `$XDG_CACHE_HOME` into test sandbox dir.  This will be useful
for smart TV support as the calibration and test programs will need to
generate videos for display on the TVs.
OCR: Silence miscellaneous output

Otherwise every time you use OCR you get:

    Tesseract Open Source OCR Engine v3.02.01 with Leptonica

printed in your logs.  With this change logs are clearer and it's easier
to write interactive stbt scripts.  This was required as the future
calibration program stbt camera calibrate is interactive in the terminal
and uses OCR.
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.
Add helper library for generating videos based on stills
Add tv driver
tv_driver: Configure video format with camera.video_format
Add fake TV driver for testing
WIP: fake-video-src: Add overlay
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
Add stbt camera calibrate
WIP: Smart TV Support: Perform geometric correction to reconstruct 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.

`stbt camera calibrate` is enhanced to generate the parameters described
above by displaying an image of a chessboard on the TV and then comparing
the measured values to the expected ones.

In test with real life TVs this calibration/correction achieves pixel
perfect positioning according to `stbt camera validate`.

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
* Add tests for calibration