• Anssi Hannula's avatar
    avformat/hls: Fix regression with ranged media segments · 9cb30f7a
    Anssi Hannula authored
    Commit 81306fd4bdf ("hls: eliminate ffurl_* usage", merged in d0fc5de3)
    changed the hls demuxer to use AVIOContext instead of URLContext for its
    HTTP requests.
    
    HLS demuxer uses the "offset" option of the http demuxer, requesting
    the initial file offset for the I/O (http URLProtocol uses the "Range:"
    HTTP header to try to accommodate that).
    
    However, the code in libavformat/aviobuf.c seems to be doing its own
    accounting for the current file offset (AVIOContext.pos), with the
    assumption that the initial offset is always zero.
    
    HLS demuxer does an explicit seek after open_url to account for cases
    where the "offset" was not effective (due to the URL being a local file
    or the HTTP server not obeying it), which should be a no-op in case the
    file offset is already at that position.
    
    However, since aviobuf.c code thinks the starting offset is 0, this
    doesn't work properly.
    
    This breaks retrieval of ranged media segments.
    
    To fix the regression, just drop the seek call from the HLS demuxer when
    the HTTP(S) protocol is used.
    9cb30f7a
hls.c 67.3 KB