Llink:unrar: Difference between revisions
No edit summary |
No edit summary |
||
(One intermediate revision by the same user not shown) | |||
Line 1: | Line 1: | ||
== unrar in llink == | |||
'''unrar''' supports the '''p''' flag, to print a file to stdout, and using -inul to not corrupt it, should work to spawn it to '''unrar''' something on the fly. | |||
Since '''seek()''' is currently not an option, and not possible for compressed archives, we have to simulate '''seek()''' by discarding data we do not need. | |||
The pseudo code could be something like: | |||
GET file.rar/video.avi | |||
Content-Range: bytes '''BytesA'''-'''BytesB'''. | |||
# Check if a process is running, if so, make sure it hasn't already past where we want to start. | |||
if (running-process()) | |||
if (sent-data() > '''BytesA''') | |||
kill-process(); | |||
# Spawn process if needed (including if just killed above) | |||
if ( ! running-process()) | |||
spawn ('''unrar''' p -inul file.rar video.rar); | |||
while ( get-data() < '''BytesA''' do-nothing; | |||
while ( get-data() < '''BytesB''') { | |||
send-data(); | |||
} | |||
pause-process(); | |||
The biggest complication lie in controlling the block reads, and pausing. For example, if | |||
we only have another 200 bytes to read to satisfy the '''Content-Range''', it would be nice if we could tell lion to only send maximum 200 bytes. But we currently can not. It will send '''buffer-size''' which is set globally. (Update lion maybe). | |||
We can buffer the remaining data in llink until we are ready to search for the next read request. | |||
I am fairly sure that '''lion_disable_read''' will honour the pause requirement. Even if the buffer is full, it should stop sending us events and resume said events when we later call '''lion_enable_read'''. |
Latest revision as of 08:33, 4 December 2007
unrar in llink
unrar supports the p flag, to print a file to stdout, and using -inul to not corrupt it, should work to spawn it to unrar something on the fly.
Since seek() is currently not an option, and not possible for compressed archives, we have to simulate seek() by discarding data we do not need.
The pseudo code could be something like:
GET file.rar/video.avi Content-Range: bytes BytesA-BytesB. # Check if a process is running, if so, make sure it hasn't already past where we want to start. if (running-process()) if (sent-data() > BytesA) kill-process(); # Spawn process if needed (including if just killed above) if ( ! running-process()) spawn (unrar p -inul file.rar video.rar); while ( get-data() < BytesA do-nothing; while ( get-data() < BytesB) { send-data(); } pause-process();
The biggest complication lie in controlling the block reads, and pausing. For example, if we only have another 200 bytes to read to satisfy the Content-Range, it would be nice if we could tell lion to only send maximum 200 bytes. But we currently can not. It will send buffer-size which is set globally. (Update lion maybe).
We can buffer the remaining data in llink until we are ready to search for the next read request.
I am fairly sure that lion_disable_read will honour the pause requirement. Even if the buffer is full, it should stop sending us events and resume said events when we later call lion_enable_read.