Page 1 of 1

cache_block, cache_read, prefetch, record plugins?

Posted: 31 Mar 2019 21:47
by oviano
More of a general Q - I am trying to understand what each of these do and how they fit in with using the imem callback input.

If I remove these plugins then my code still works, so what is their precise purpose, as I cannot find any high level documentation.

I observe:

- that it tries to use “prefetch, cache_read” preferring the prefetch.
- it always tries to include “record” in the chain.
- it doesn’t seem to use “cache_block”.

My guess:

prefetch - gather enough data first before allowing the demuxer to parse it or something? What might go wrong if this isn’t used?
cache_read - gets used if I remove prefetch. How does it differ from prefetch?
record - some sort of hook to be able grab the bytestream and write it out again or something?

I’m using imem with my data coming across the Internet. Like I say if I remove these plugins my app seems to work but of course I don’t want to then have issues with sone edge cases or something.

I realise this is a bit of a vague request, just trying to understand what is needed for a minimal libvlc-based application.

Re: cache_block, cache_read, prefetch, record plugins?

Posted: 01 Apr 2019 10:30
by unidan
Hi, VLC is pipelined with different modules. When you have started the pipeline (after the Open() sequence of every module), the pipeline is fixed and can't be modified as it is autoconfigured and adding/removing a module might need a configuration change or new module load. So a pipeline change is a pipeline reconfiguration/creation. If you want to be able to record the stream, it means that you need a bypassed module ready to be enabled in the pipeline. Thus the record module which is idle if you don't use it.

Then, prefetch is what you think of, and if you don't have this but your access is slow, you can have stuttering (it acts like the beginning of a playback on youtube or other streaming services). So it's mostly to have a smooth startup of the playback.

cache_read/cache_block are there to compensate jitter in the playback, for example on youtube, it would be the grey bar indicating how much have been buffered. I'm not too knowledgeable on this so I can't really enter into the details. Both prefetch and cache modules are loaded at the beginning of a stream, see stream_AccessNew function for details. ;)

> I realise this is a bit of a vague request, just trying to understand what is needed for a minimal libvlc-based application.

For a minimal libvlc-based application, you might not even need to go this low level.

Re: cache_block, cache_read, prefetch, record plugins?

Posted: 01 Apr 2019 12:48
by oviano
Thank you very much for that!

Re: cache_block, cache_read, prefetch, record plugins?

Posted: 01 Apr 2019 17:21
by Rémi Denis-Courmont
It depends on the type of stream which one is used. They all do the same thing - caching, just different strategies.

Re: cache_block, cache_read, prefetch, record plugins?

Posted: 01 Apr 2019 21:24
by oviano
In my case it’s a stream received over the internet using a custom protocol but much like HLS in that it sends chunks. I then pass this data into libvlc using imem, although with certain settings of my player app it may buffer a number of chunks before passing them to libvlc.

Trying to figure out if there is any point in using the libvlc caching plug-ins.