diff options
author | 2013-05-03 20:07:04 +0200 | |
---|---|---|
committer | 2013-05-05 18:44:24 +0200 | |
commit | 36444332249e28cc053df83b9a81da492cfca079 (patch) | |
tree | 6a629bc110bd321c1edc340b5037317926a5a8d8 | |
parent | acad31c2d382043f1c43c74a678de659a54a3788 (diff) |
core: move demuxer time reporting to demuxer
-rw-r--r-- | core/mplayer.c | 12 | ||||
-rw-r--r-- | demux/demux.c | 18 | ||||
-rw-r--r-- | demux/demux.h | 3 |
3 files changed, 25 insertions, 8 deletions
diff --git a/core/mplayer.c b/core/mplayer.c index 5a9f45d280..20838b9ff8 100644 --- a/core/mplayer.c +++ b/core/mplayer.c @@ -3000,11 +3000,9 @@ double get_time_length(struct MPContext *mpctx) if (mpctx->timeline) return mpctx->timeline[mpctx->num_timeline_parts].start; - double get_time_ans; - // <= 0 means DEMUXER_CTRL_NOTIMPL or DEMUXER_CTRL_DONTKNOW - if (demux_control(demuxer, DEMUXER_CTRL_GET_TIME_LENGTH, - (void *) &get_time_ans) > 0) - return get_time_ans; + double len = demuxer_get_time_length(demuxer); + if (len >= 0) + return len; struct sh_video *sh_video = mpctx->sh_video; struct sh_audio *sh_audio = mpctx->sh_audio; @@ -3042,9 +3040,7 @@ double get_start_time(struct MPContext *mpctx) struct demuxer *demuxer = mpctx->demuxer; if (!demuxer) return 0; - double time = 0; - demux_control(demuxer, DEMUXER_CTRL_GET_START_TIME, &time); - return time; + return demuxer_get_start_time(demuxer); } // Return playback position in 0.0-1.0 ratio, or -1 if unknown. diff --git a/demux/demux.c b/demux/demux.c index 937c881639..9622c2412a 100644 --- a/demux/demux.c +++ b/demux/demux.c @@ -1382,6 +1382,24 @@ int demuxer_chapter_count(demuxer_t *demuxer) return demuxer->num_chapters; } +double demuxer_get_time_length(struct demuxer *demuxer) +{ + double get_time_ans; + // <= 0 means DEMUXER_CTRL_NOTIMPL or DEMUXER_CTRL_DONTKNOW + if (demux_control(demuxer, DEMUXER_CTRL_GET_TIME_LENGTH, + (void *) &get_time_ans) > 0) + return get_time_ans; + return -1; +} + +double demuxer_get_start_time(struct demuxer *demuxer) +{ + double time; + if (demux_control(demuxer, DEMUXER_CTRL_GET_START_TIME, &time) > 0) + return time; + return 0; +} + int demuxer_angles_count(demuxer_t *demuxer) { int ris, angles = -1; diff --git a/demux/demux.h b/demux/demux.h index 3d66139d69..048ffb3934 100644 --- a/demux/demux.h +++ b/demux/demux.h @@ -401,6 +401,9 @@ int demuxer_seek_chapter(struct demuxer *demuxer, int chapter, double *seek_pts); void demuxer_sort_chapters(demuxer_t *demuxer); +double demuxer_get_time_length(struct demuxer *demuxer); +double demuxer_get_start_time(struct demuxer *demuxer); + /// Get current chapter index if available. int demuxer_get_current_chapter(struct demuxer *demuxer, double time_now); /// Get chapter name by index if available. |