[MPlayer-dev-eng] [PATCH] Get Demuxer Time for Proper DVD Time

Paul Huwe reicow at yahoo.com
Thu Jul 15 10:42:18 CEST 2010


Hello,

I've created a small tweak to add a slave command "get_demux_time_pos" to return the present demuxer time as a float (out to 3 digits, aka millisecond accuracy). I was inspired to create this because "get_time_pos" gets reset to zero during the course of playing a DVD and I need the proper DVD time throughout (to sub-second accuracy). Searching on google showed numerous posts where others have a need for a timer that does not reset. 

Please forgive me if I'm doing this in the wrong format, but I've never created a patch and asked for it to be pushed in this format. If there is a FAQ on how to submit patches, I could not find it. 

The patch consists of small tweaks to 5 files:

(diffs to revision 31736.)

diff input/input.h
89a90
>   MP_CMD_GET_DEMUX_TIME_POS,


diff input/input.c
125a126
>   { MP_CMD_GET_DEMUX_TIME_POS, "get_demux_time_pos", 0, { {-1,{0}} } },


diff libmpdemux/demuxer.h
434a435
> double demuxer_get_current_total_time(demuxer_t *demuxer);


diff libmpdemux/demuxer.c
1441a1442,1452
> double demuxer_get_current_total_time(demuxer_t *demuxer)
> {
>     double get_time_ans = 0;
>     sh_video_t *sh_video = demuxer->video->sh;
>     if (demuxer->stream_pts != MP_NOPTS_VALUE)
>         get_time_ans = demuxer->stream_pts;
>     else if (sh_video)
>         get_time_ans = sh_video->pts;
>     return get_time_ans;
> }
> 

diff command.c
>         case MP_CMD_GET_DEMUX_TIME_POS:{
>                 double pos = 0;
>               pos = demuxer_get_current_total_time(mpctx->demuxer);
> 
>                 mp_msg(MSGT_GLOBAL, MSGL_INFO, "ANS_DEMUX_TIME_POSITION=%.3f\n", pos);
>             }
>             break;
> 


That's it. I've tested it out with several DVDs, and it outputs the demux time properly. 

In addition to giving timing information for DVDs and possibly other media, it can help front-end "seekbars" that rely on get_time_pos, and thus get munged during DVD playback.

Please add this function to the mplayer codebase.

Thank You.

Cheers,
Paul










      



More information about the MPlayer-dev-eng mailing list