On Thu, Mar 3, 2016 at 11:59 AM, Adrien Destugues <pulkomandy@xxxxxxxxxxxxx>
wrote:
This is what I would have thought without having thought it through:sniffing)
Preconditions:
1) We should avoid refetching data whenever possible (for example, while
2) Many streams are actually positionable to allow for seeking (HTTP isusually positionable).
3) Therefore, we need to differentiate between streams that are trulynon seekable, and those that
are.
There are a few more caveats:
a) Currently our API for seekable streams (BPositionIO) assume they have a
(fixed) size. This is not the case if you listen to a web radio, for
example, which is an endless stream of data.
b) In the case of ffmpeg, in some cases it will try to seek to the end of
a file to sniff data there and detect the format. This is not possible on
such infinite streams, of course.
c) Adding a seekable overlay onto a mostly streamed media is easy: you can
just download it all and let it sit in memory (or in a seekable file). The
real problem is knowing when data is not needed anymore and can be dropped.
For c) at a minimum we need to know if we are in the sniffing state (data
can be read multiple times, possibly by different plugins), or in "runtime"
(ffmpeg has started decoding the stream, now there should be mostly no
seeks). Once in runtime we can decide to allow only pause and fast-forward
for really streamed data, or we can decide to keep some megabytes behind
the current play time buffered to allow some seeking a few minutes back.