hlsdemux: Avoid negative sequence numbers
authorEdward Hervey <edward@centricular.com>
Wed, 14 Oct 2015 15:38:39 +0000 (17:38 +0200)
committerEdward Hervey <bilboed@bilboed.com>
Wed, 14 Oct 2015 16:01:04 +0000 (18:01 +0200)
commit8d86a8b75d678eabb4a2124b8473b17674d9e298
tree03446718fbd99514d883aa4464e8a2e0f6e6cc0c
parentf58cd983b6a8460458e6ef406520f2c8e24a1e7b
hlsdemux: Avoid negative sequence numbers

For live streams, we want to make sure there's a certain distance
between the sequence to play and the last (earliest) fragment.

The problem is that it assumes there are at least 3 fragments in
the playlist, which might not always be the case (like in the case
of a server restarting and gradually adding fragments).

In order to avoid ending up with negative sequence numbers (which
will just loop forever), limit the new target sequence number to
the highest of:
* either the first sequence number of the playlist (fallback)
* or 3 fragments from the last one (standard behaviour)
ext/hls/gsthlsdemux.c