Mercurial > mplayer.hg
diff libmpdemux/demuxer.c @ 19478:bab82c53e433
demuxer_seek_chapter() returns informations about chapters count and name
author | nicodvb |
---|---|
date | Mon, 21 Aug 2006 19:19:00 +0000 |
parents | 28d2d1fddff4 |
children | 8dd04ec733f5 |
line wrap: on
line diff
--- a/libmpdemux/demuxer.c Mon Aug 21 19:16:39 2006 +0000 +++ b/libmpdemux/demuxer.c Mon Aug 21 19:19:00 2006 +0000 @@ -1053,10 +1053,12 @@ * \param chapter - chapter number wished - 0-based * \param mode 0: relative to current main pts, 1: absolute * \param seek_pts set by the function to the pts to seek to (if demuxer->chapters is set) + * \param num_chapters number of chapters present (set by this function is param is not null) + * \param chapter_name name of chapter found (set by this function is param is not null) * \return -1 on error, current chapter if successful */ -int demuxer_seek_chapter(demuxer_t *demuxer, int chapter, int mode, float *seek_pts) { +int demuxer_seek_chapter(demuxer_t *demuxer, int chapter, int mode, float *seek_pts, int *num_chapters, char **chapter_name) { int ris; int current, total; sh_video_t *sh_video = demuxer->video->sh; @@ -1091,6 +1093,21 @@ //exit status may be ok, but main() doesn't have to seek itself (because e.g. dvds depend on sectors, not on pts) *seek_pts = -1.0; + + if(num_chapters) { + if(stream_control(demuxer->stream, STREAM_CTRL_GET_NUM_CHAPTERS, num_chapters) == STREAM_UNSUPORTED) + *num_chapters = 0; + } + + if(chapter_name) { + char *tmp = malloc(16); + *chapter_name = NULL; + if(num_chapters && *num_chapters && tmp) { + sprintf(tmp, " of %3d", *num_chapters); + *chapter_name = tmp; + } + } + return (ris != STREAM_UNSUPORTED ? chapter : -1); } else { //chapters structure is set in the demuxer total = demuxer->num_chapters; @@ -1115,6 +1132,12 @@ *seek_pts = demuxer->chapters[current].start / 1000.0; + if(num_chapters) + *num_chapters = demuxer->num_chapters; + + if(chapter_name) + *chapter_name = demuxer->chapters[current].name; + return current; } }