oma: refactor seek function

Properly propagate seek errors from avio and the generic pcm seek.
oma: check geob tag boundary

Prevent read after buffer boundary on corrupted tag.

Reported-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
CC: libav-stable@libav.org
oma: correctly mark and decrypt partial packets

Incomplete crypted files would lead to a read after buffer boundary
otherwise.

Reported-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
CC: libav-stable@libav.org
lavf: Don't interpret just slightly broken timestamps as wraparound

This avoids breaking some slightly incorrect (dts > pts) timestamps
in sample HLS streams from Apple.

Signed-off-by: Martin Storsjö <martin@martin.st>
hls: Return all packets from a previous variant before moving on to the next one

This serves as a safeguard; normally we want to use the dts
comparison to interleave packets from all active variants. If that
dts comparison for some reason doesn't work as intended, make sure
that all packets in all variants for a certain sequence number have
been returned before moving on to the next one.

Signed-off-by: Martin Storsjö <martin@martin.st>
hls: Copy the time base from the chained demuxer

When a variant stream isn't mpegts but e.g. raw adts, the
default time base (90k) isn't correct.

Signed-off-by: Martin Storsjö <martin@martin.st>
hls: Don't check discard flags until the parent demuxer's streams actually exist

If passing the end of one segment while initializing the
chained demuxer, the parent demuxer's streams aren't set up
yet, so we can't recheck the discard flags.

Signed-off-by: Martin Storsjö <martin@martin.st>
hls: Set stream offset before opening a chained demuxer

This makes sure we don't accidentally check discard flags
for the wrong stream.

Signed-off-by: Martin Storsjö <martin@martin.st>
hls: Respect the different stream time bases when comparing dts

Also adjust the streams timestamps according to their start
timestamp when comparing. This helps getting correctly interleaved
packets if one stream lacks timestamps (such as a plain ADTS
stream when the other variants are full mpegts) when the others
have timestamps that don't start from zero.

This probably doesn't work properly if such a stream is
temporarily disabled (via the discard flags) and then reenabled,
and such streams are hard to correctly sync against the other
streams as well - but this works better than before at least.

The segment number restriction makes sure all variants advance
roughly at the same pace as well.

Signed-off-by: Martin Storsjö <martin@martin.st>
hls: Create an AVProgram for each variant

Without the information, an application may choose audio from one
variant and video from another variant, which leads to fetching two
variants from the network. This enables av_find_best_stream() to find
matching audio and video streams, so that only one variant is fetched.

Signed-off-by: Martin Storsjö <martin@martin.st>