restreamer: Fix a bug where playlist reports video is finished spuriously

This happens when we are live viewing a stream, and the last available segment
is at the end of an hour.
We generate the end timestamp as being the end of the last available hour,
which might be within the range of the last available segment. When this happens
we stream the last segment then say we reached the requested end point.
This makes the player stop asking for more segments.

The fix is to pad the end time by an extra hour so we're asking for 1 hour more than the
last available hour.
pull/389/head
Mike Lang 7 months ago
parent daf6001402
commit f9ff537b84

@ -265,12 +265,15 @@ def generate_media_playlist(channel, quality):
start = dateutil.parse_utc_only(request.args['start']) if 'start' in request.args else None
end = dateutil.parse_utc_only(request.args['end']) if 'end' in request.args else None
if start is None or end is None:
# If start or end are not given, use the earliest/latest time available
# If start or end are not given, use the earliest/latest time available.
# For end in particular, always pad an extra hour to force a discontinuity at the end
# even if we happen to have a complete hour available. Otherwise when live streaming you
# can get an unexpected "video is complete" even though more segments are about to arrive.
first, last = time_range_for_quality(channel, quality)
if start is None:
start = first
if end is None:
end = last
end = last + datetime.timedelta(hours=1)
# We still allow > 12hr ranges, but only if done explicitly (both start and end are set).
if end - start > datetime.timedelta(hours=12) and ('start' not in request.args or 'end' not in request.args):

Loading…
Cancel
Save