TV: Quit the TV playback loop when the primary player reports a fatal error

If MythPlayer::OpenFile fails (for instance network congestion) then
TV::StartTV continues by restarting TV instance which then causes problems
for the backend.

Signed-off-by: Lawrence Rust <lvr@softsystem.co.uk>
Signed-off-by: Jean-Yves Avenard <jyavenard@mythtv.org>
(cherry picked from commit faad748af24b9bbbaa894243c9cf52fd841bb8d4)
TV UnpauseLiveTV calls tvchain->SwitchTo opposed to JumpTo to minimise visible disruption

Signed-off-by: Lawrence Rust <lvr@softsystem.co.uk>
Signed-off-by: Jean-Yves Avenard <jyavenard@mythtv.org>
(cherry picked from commit bfc6b9ed58029955d5a4230cad5851ed4848ed20)
mythtranscode: skip audio description streams

A number of recent broadcasts on UK Freeview (BBC & ITV) have an
audio description (AD) stream that is discontiguous.  Mythtranscode attempts
to output all audio streams but if the AD stream is not present for
some time then the output FIFOs overflow.

Signed-off-by: Lawrence Rust <lvr@softsystem.co.uk>
Signed-off-by: Jean-Yves Avenard <jyavenard@mythtv.org>
(cherry picked from commit a1a6502d4529cbe074b587919f05ecbb97ce2c74)
Player: Clear EOF when resuming play

RingBuffer::Read returns 0 (eof) when the buffer is paused.  This causes
ffmpeg to set eof and prevent any further reads by the decoder.

This patch clears the decoder's eof on restarting play which in turn
resets ffmpeg's eof.

Signed-off-by: Lawrence Rust <lvr@softsystem.co.uk>
Signed-off-by: Jean-Yves Avenard <jyavenard@mythtv.org>
(cherry picked from commit 604a9d8db63fababfeb07e1ffc8d45e3f4f2314c)
Player: Enable AVSync to recover quicker after a seek or program change

The a/v timecodes can get out of step by 10's of seconds after a seek
or a livetv program change.  This can cause frames to be doubled or dropped
until the a/v streams get back in step.

This patch checks the a/v timecode difference and if larger than 1 second
disables frame dropping or doubling.

Signed-off-by: Lawrence Rust <lvr@softsystem.co.uk>
Signed-off-by: Jean-Yves Avenard <jyavenard@mythtv.org>
(cherry picked from commit 195eb07fb106fbabf164a1989860adcc132ab9d2)
Player: Finer a/v sync adjustments

Signed-off-by: Lawrence Rust <lvr@softsystem.co.uk>
Signed-off-by: Jean-Yves Avenard <jyavenard@mythtv.org>
(cherry picked from commit f8d72280ccb3ec28391182cf6eaaf20c9c87ae4f)
Player: Improve low bit rate / high latency stream playback

DVB-S radio programs are low bit rate (64Kbps..256Kbps) and suffer
occasional latency.

MHEG interaction streams are internet sourced and often suffer congestion
resulting in high latency for some packets.

- Fix a number of issues to do with changing program to DVB-S radio and
  the lack of video stream causing garbage video display.

Signed-off-by: Lawrence Rust <lvr@softsystem.co.uk>
Signed-off-by: Jean-Yves Avenard <jyavenard@mythtv.org>
(cherry picked from commit 0e0e04ccadfcbeeedbeb5e6286c591caa33d8e62)

Conflicts:
	mythtv/libs/libmythtv/mythplayer.cpp
Player: Amalgamate and simplify SwitchTo and JumpToProgram

1. buffer->UpdateRawBitrate can wait for several 100mS so only call it if absolutely necessary i.e. if stream type hasn't changed.

2. Omit unnecessary call to buffer->IgnoreLiveEOF which also can wait for several 100mS.

3. Omit some lengthy calls to read the deleteMap and bookmarks if liveTV

4. Ensure there are sufficient video frames buffered before starting playback.
   This reduces stutters in the first few seconds on remote frontends.
   Also delays a/v playback start until ringbuffer is ready to read.

5. Reduce interference with RingBuffer readahead.

Signed-off-by: Jean-Yves Avenard <jyavenard@mythtv.org>
(cherry picked from commit cc927f687995a9620de581894a68935b0780b299)
libmythtv: Add a mutex to the ChannelScanSM class

This class is accessed by two threads, the signal monitor and the
thread that drives the scan.

A segv can occur if one thread deletes the currentInfo member
while it is being used by the other.

Signed-off-by: Lawrence Rust <lvr@softsystem.co.uk>
Signed-off-by: Jean-Yves Avenard <jyavenard@mythtv.org>
(cherry picked from commit 738114f03f392ed882847e29eeb1462b028a0f3c)
TV: Avoid a SEGV when switching from PiP to PbP

If a PiP reaches EOF then it's still possible to select the menu item
to switch from PiP to PbP.  Then TV::PxPToggleType calls
GetPlayer(mctx, 1)->SetPIPState(kPBPRight) but GetPlayer(mctx, 1)
returns NULL.

    0  SetPIPState (change=<optimised out>, this=<optimised out>)
        at playercontext.h:107
    1  TV::PxPToggleType (this=0xa9d39f8, mctx=0xae006c8, wantPBP=true)
        at tv_play.cpp:5881
    2  0xb7029da6 in TV::HandlePxPTimerEvent (this=0xa9d39f8)
        at tv_play.cpp:3191
    3  0xb705b3da in TV::timerEvent (this=0xa9d39f8, te=0x0)
        at tv_play.cpp:2796
    4  0xb5379ee7 in QObject::event (this=0xa9d39f8, e=0xbfee4fbc)
        at kernel/qobject.cpp:1157

This fix checks that the PiP is valid before changing state.

Signed-off-by: Lawrence Rust <lvr@softsystem.co.uk>
Signed-off-by: Jean-Yves Avenard <jyavenard@mythtv.org>
(cherry picked from commit d2a785b79196fb8194e60628b756ffc66d79db6c)
Player: Allow seeking upto last frame when paused

Signed-off-by: Lawrence Rust <lvr@softsystem.co.uk>
Signed-off-by: Jean-Yves Avenard <jyavenard@mythtv.org>
(cherry picked from commit c63a09c92b4ee2d82c104cd358a31b8464ca3e23)
Transcode: Fix a race condition in VideoDecodeBuffer when EOF encountered

Signed-off-by: Lawrence Rust <lvr@softsystem.co.uk>
Signed-off-by: Jean-Yves Avenard <jyavenard@mythtv.org>
(cherry picked from commit 0937dac17f362ca28ff8e627d58d6b32eecad02f)
Flush buffers prior to closing the codec.

Avoid random crashes seen with HLS streams

(cherry picked from commit af6f82616a970d9b5e292ae4cffc25c1878d0405)
Limit bitrate to 100Mbit/s and fill_min to half the size of the ringbuffer

Under some circumstances, FFmpeg can returns rubbish bitrates, set a maximum value of 100Mbit. This is almost twice the maximum bitrate permissible on a bluray.

Fixes #12196

(cherry picked from commit 83050ac67d40a449bc5433e0edda2c41d75eb45f)
Obey useonairguide and enable it for ERT

Ignore the SDT in the EIT scanner, thus obeying useonairguide.
Add quirk for ONID 65330 (ERT) to the channel scanner.

Refs #9592

(cherry picked from commit 7af260e6ff315fd511477e3cd1efb2e0b5cd0a67)
metadata: do not unnecessarily query the database if there’s no chance that it will yield a result

(cherry picked from commit 2d6eef6ecf0062f503b2188220eb8db9092cc6d6)
metadata: fix incorrect tests

would always return false

similar to a50a24b0f408957885ff928569a061df07e5e993

(cherry picked from commit 5d3d319936513cac22557f9a3969f7210b8ac049)

Conflicts:
	mythtv/programs/mythmetadatalookup/lookup.cpp
Revert "metadata: properly handle media search type if we already have an extended inetref."

This reverts commit 30b03cc2b86e949b434b7afc207f12d35e6c6d87.

(cherry picked from commit 1abcb6f6a6785d834e9ba95d5ef963ab67fceaf1)
metadata: create Set/GetIsCollection

Will be used to propagate the information that the metadata came from a collection rather than a given season/episode.
That information is only necessary during the lifetime of the Metadatalookup object, so no need to change other classes

(cherry picked from commit 7407adf97fe10485a7afce561eb425d26f210ca8)
add GuessLookupType for VideoMetadata to match other content

Refactor the lookup so its easier to compare the guessing.

(cherry picked from commit 80c5e450b651732c476fbf8f1c47ba71a036f040)