1
mirror of https://github.com/mpv-player/mpv synced 2024-11-14 22:48:35 +01:00

core: move demuxer time reporting to demuxer

This commit is contained in:
wm4 2013-05-03 20:07:04 +02:00
parent acad31c2d3
commit 3644433224
3 changed files with 25 additions and 8 deletions

View File

@ -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.

View File

@ -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;

View File

@ -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.