extra/vm: Install crtmpserver, an RTMP (Flash video) server, for VidiU

And an example source_pipeline configuration in
~vagrant/.config/stbt/stbt.conf.

Thanks to Aiman Baharna <aiman.baharna@youview.com> for the instructions
and the crtmpserver configuration.
extra/vm: Cosmetic change to ~vagrant/.config/stbt/stbt.conf

`restart_source` is False by default, so this commit doesn't have a
noticeable effect (unless the user changed `restart_source` in
/etc/stbt/stbt.conf, which is unlikely).

I found myself uncommenting the `#restart_source = False` line when I
wanted to use the HDPVR, but forgetting to change the `False` to `True`.
You shouldn't have to change *two* things (remove the comment *and*
change the value).
stbt.py: Handle VidiU H.264 encoder restart

By restarting the source pipeline when it receives an EOS (end of
stream) message. The "--restart-source" mechanism that we use to recover
from HD PVR failures isn't useful here, because after receiving EOS the
GStreamer queue in the source pipeline no longer sends underrun
messages. (The HD PVR's behaviour is that it stops sending frames but it
never sends an EOS.)

The Teradek VidiU is a video-capture device that takes HDMI in, and
streams RTMP out. We use `stbt run --source-pipeline='rtmpsrc ...'`.
When the resolution changes on the VidiU's input signal, *sometimes*
the VidiU goes through the following sequence of events:

        system under test       Vidiu front panel          Vidiu top-right indicator
       ----------------------- -------------------------- --------------------------
    1   Reboot                  Video not detected!        No video
    2   Splash screen appears   Video detected!            Live (briefly)
    3                           H264 blue light goes off   Not ready
    4   ...........................20 seconds.......................................
    5                           H264 blue light goes on    Starting
    6                                                      Live

At point 3 in the above table, the GStreamer rtmpsrc reports EOS (end of
stream).

So far we've only seen this when restarting the system-under-test. The
VidiU doesn't mind losing input video altogether (it just sends a blue
screen). It's when the system-under-test's splash screen appears and
disappears (because it's a different resolution that what came before &
after?) that we see this problem. But only about 50% of the times we
restart the system-under-test.

Test scripts affected by this VidiU behaviour (in our own body of test
scripts, only tests that reboot the system-under-test are affected) will
need to use a `wait_for_match` (or similar) with a timeout longer than
the 20 seconds it takes the VidiU to start streaming again.

Note that the self-test `test_that_frames_raises_NoVideo` would run
indefinitely after this change, because `videotestsrc num-buffers=1`
sends EOS so the source pipeline was continuously restarted. I tried
videotestsrc's `framerate=1/20` property, setting caps
(`! video/x-raw-yuv,framerate=1/20`), and the `videorate` element, but
none of them created the conditions I wanted.
`identity sleep-time=12000000` sleeps for 12 seconds of wall time (not
stream time) so it works even with our default sink-pipeline's
`sync=false`.
README: Virtual remote control's "port" argument is optional
stbt-tv: Stream live video through network

Launching 'stbt tv' with '-l' (for "listen") command line argument
streams video through a TCP socket. Used in conjunction with
'stbt control', it makes remote configuration of the set-top-boxes under
test possible.

The choice of TCP protocol is unusual for this application; the reason
behind is that it is easier to configure both the client and the server
compared to using RTP over UDP. As this tool serves for the convenience
of test system administrators, getting low latency is not critical.

TCP port is read from the new 'tv.port' parameter of the stb-tester
config file, or the hard-coded value 4953 is used if it isn't
specified. 4953 is the default value used by 'tcpclientsrc'.

Video bandwidth is read from the 'tv.bandwidth' parameter in bps,
defaults to 1500000 (1.5 Mbps). This value is a rule of thumb
compromise of video quality and network load; users can fine-tune the
bitrate with tools like tcpperf.

The receiving side can watch the video stream with
* vlc:
    `vlc tcp://<host>:<port>`
* gst-launch:
    `gst-launch tcpclientsrc host=<host> port=<port> ! \
        mpegtsdemux ! decodebin2 ! autovideosink`
stbt tv -l: Error message if gstreamer-ffmpeg isn't installed

3c58225 added the `-l` flag to `stbt tv`. It requires ffenc_mpeg4 from
gstreamer-ffmpeg. On Fedora, gstreamer-ffmpeg isn't available in the
standard repositories; you have to install the rpmfusion repository. So
I don't want to mandate gstreamer-ffmpeg as a requirement in the rpm
spec file; that would force users to install rpmfusion even if they
don't want this feature of `stbt tv`. Instead, `stbt tv` now prints an
informative error message.
stbt tv -l: Print stream URL to stdout

For easy copy-and-paste into VLC.
Merge branch 'stbt-tv-to-provide-streaming-video'

* stbt-tv-to-provide-streaming-video:
  stbt tv -l: Print stream URL to stdout
  stbt tv -l: Error message if gstreamer-ffmpeg isn't installed
  stbt-tv: Stream live video through network
extra/runner/report.py: extra-columns appear in a predictable order

Prior to this commit, the order that a user's `extra-columns` appeared
in the html report wasn't consistent (see below for why). This commit
changes this so they appear in the order they appear in the
`extra-columns` file. Although this order is perhaps slightly arbitary,
it is an improvement on having no order at all.

Python dictionaries (which `collections.defaultdict inherits from), don't
have a consistent order (like a list) and so when iterating over different
instances of otherwise identical dictionaries you aren't guarenteed to
access the dictionaries' keys in the same order. See [1].

This commit changes report.py's Run.extra_columns attribute to use an
`OrderedDict`, instead of a `defaultdict`, which guarantees the order of
iteration over a dictionary's contents will always be the order they are
instantiated.

[1] http://www.laurentluce.com/posts/python-dictionary-implementation/
stbt.Display.on_eos: Fix null dereference

...when sink pipeline sends EOS just after source pipeline. The source
pipeline's EOS triggers `restart_source`, which sets the source pipeline
to `None` and waits a few seconds before restarting it; so for a few
seconds, an EOS from the sink pipeline would try to access an invalid
source pipeline.
stbt screenshot: Work around Blackmagic purple tint in first second of video

The first second of video frames delivered by the Blackmagic Intensity
Pro card is brighter than subsequent frames, and with a magenta tint.
Thanks to Aiman Baharna for the bug report & analysis.
test_press_visualisation, test_draw_text: Fix race condition

These tests used to run a stbt script that saved 3 seconds of output to
a video on disk, then ran a second stbt script that analysed that video.
On a heavily loaded system (such as the Travis CI service that runs our
tests in the cloud), the second (verification) script could fail, if
`stbt run` took longer than 3 seconds to reach the `wait_for_match`
call. In that case `wait_for_match` would raise `NoVideo` instead of
finding the match.

Instead, we run 2 `stbt run` instances at the same time, connected via
filesink -> named pipe -> filesrc. The `stbt run` instance providing the
video runs as long as necessary for the other `stbt run` to find the
match; and *only* as long as necessary, so in most cases these tests
run much faster than the previous version.

The `gdppay` and `gdpdepay` payloader elements wrap the raw data with
the "GStreamer Data Protocol". Without this, the filesrc doesn't know
the caps of the video it's receiving.

I cropped the `red-black.png` template tightly around the two lines of
text, because now there may be a third "black" line underneath them from
the previous call to `press_black`.
Fix PEP8 compliance

I don't know why this is working for other people.  I am using pep8 1.2.

[Committer's note: This seems due to pylint more than pep8. I have
tested the change with pylint 0.25 & 0.28, and pep8 0.6.1 & 1.4.6.]
Use fakesink instead of ximagesink during `make check`

Previously `make check` makes a whole bunch of windows appear. This is
really irritating as it interferes with typing on my computer during
`make check`.
Refactor to unify implementations of TCPLircRemote and LircRemote

The difference between TCPLircRemote and LircRemote is that the former
connects to a TCP socket whereas the latter connects to a UNIX domain
socket.  This refactoring unfies the two implementations by introducing
factory functions which inject sockets into the single `LircRemote`
implementation.

This commit saves 5 lines of code but the original motivation was to add
a `hold()` method to the Remote implementations.  Nonetheless I believe
this commit stands on its own.

Neither LircRemote nor TCPLircRemote are intended as public API so this
is not a API break.
.travis.yml: No longer need xvfb

Since cf2b39dc, "make check" uses fakesink instead of ximagesink
so the self-tests don't need an X11 server.
Revert "Remove extra/stbt_checker.py"

This reverts commit 97eada336b11e9730506cef2452d03622f967080.

I had reverted this because it doesn't work with pylint 1.0. However,
not much *does* work with pylint 1.0†, and this tool is still useful
for those of us with pylint 0.x still installed.

† https://bitbucket.org/logilab/pylint/issue/47/
Move extra/stbt_checker.py to stbt_pylint_plugin.py

This is in preparation for creating the "stbt lint" tool.
extra/stb-tester.spec: Cleanup: Sort "Requires" lines alphabetically
stbt lint: Runs pylint (with custom plugin) over stbt scripts

Currently the only additional check done (additional to pylint's
built-in checks) is E7001: Image paths given to
`stbt.wait_for_match` (and similar functions) must exist on disk.

To configure pylint's behaviour:

* Arguments to `stbt lint` will be passed on to pylint.
* Modify ~/.pylintrc, /etc/pylintrc, or set the PYLINTRC environment
  variable, or pass `--rcfile=<file>`.
* In your stbt scripts, inline comments like `# pylint: disable=E7001`
  will disable the specified checker for a single line, function, or
  class.

To use this in `make check` or similar automated checking of your
repository of stbt scripts, use something like this:

    shopt -s globstar
    stbt lint --errors-only **/*.py

Note that (the existing script) extra/pylint.sh is a script used by
stb-tester *developers* to ensure that the core stb-tester code complies
with our coding standards. On the other hand the new `stbt lint` tool is
for stb-tester *users* to run over their test scripts.

`stbt lint` doesn't work with pylint 1.0. See 97eada33 and 65a38380 for
details.