[vlc-devel] [PATCH] Add HLS output option to write index revisions as different files
cs448 at cam.ac.uk
Sat Mar 17 22:17:29 CET 2012
I attach a simple patch adding an option to the HTTP live streaming
output module, setting it to record successive revisions of the playlist
As opposed to the existing (and still default) behaviour of overwriting
a single file.
I made this change for my own use when writing HLS streams under Win32.
This is because of two weaknesses of Win32's filesystem semantics:
1. vlc_rename is not atomic under Win32. Atomic replacement of a file is
possible under Windows Vista and 7 using MoveFileTransacted, but not
under earlier versions and possibly not under later versions (Microsoft
are deprecating transactional NTFS for being too difficult to maintain).
This non-atomic replacement of the m3u8 means that the file so produced
is not suitable for serving directly with a web server on Win32, as
users will occasionally fall into the gap between versions and get a
404. Many clients will call that a fatal error.
Therefore my first plan was to serve the m3u8 under Win32 using a simple
server-side wrapper script, which would retry reading as necessary to
work around the lack of atomicity. However, this too causes problems
2. Under Win32, a file which still has open handles may not be deleted
immediately after DeleteFile (or vlc_unlink here) is called. This means
that if the webserver has an open handle against the m3u8 file (as it
will if it's popular), the file will not disappear immediately and a
subsequent rename operation will fail.
Therefore I wrote the attached patch; I have my server watch the
directory for newer versions of the m3u8 file and serve the most recent
version. No risk of a client 404, and each name is fresh so there's no
risk of VLC stumbling over its own previous version of the playlist.
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 3214 bytes
Desc: not available
More information about the vlc-devel