[vlc-devel] [PATCH] Add HLS output option to write index revisions as different files
Chris Smowton
cs448 at cam.ac.uk
Sat Mar 17 22:17:29 CET 2012
Hi,
I attach a simple patch adding an option to the HTTP live streaming
output module, setting it to record successive revisions of the playlist
like:
/some/path/playlist.m3u8.00000000
/some/path/playlist.m3u8.00000001
etc.
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
because:
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.
--Chris
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Add-facility-for-saving-each-HLS-playlist-update-und.patch
Type: text/x-patch
Size: 3214 bytes
Desc: not available
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20120317/6ac5fad0/attachment.bin>
More information about the vlc-devel
mailing list