[PATCH] libmpdemux/demux_ts.c: Add DEMUXER_CTRL_GET_PERCENT_POS command
I've been sitting on this one for years. It will allow mplayer to correctly display the percentage left in a file even as the file is being appended to while being played. This is common when timeshifting programs.
On Mon, Nov 08, 2010 at 08:21:29PM -0800, Scott W. Larson wrote:
I've been sitting on this one for years. It will allow mplayer to correctly display the percentage left in a file even as the file is being appended to while being played. This is common when timeshifting programs.
Index: demux_ts.c =================================================================== --- demux_ts.c (revision 32610) +++ demux_ts.c (working copy) @@ -25,6 +25,7 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <sys/stat.h>
#include "config.h" #include "mp_msg.h" @@ -3341,6 +3342,15 @@
switch(cmd) { + case DEMUXER_CTRL_GET_PERCENT_POS: + { + struct stat stream_stat; + fstat(demuxer->stream->fd, &stream_stat); + + *(int *)arg=(demuxer->filepos*100) / stream_stat.st_size; + return DEMUXER_CTRL_OK; + }
Isn't there a generic fallback function for GET_PERCENT_POS that does something like this, and if so could/should that one be fixed or reused here?
participants (2)
-
Reimar Döffinger -
Scott W. Larson