[MPlayer-cvslog] r19484 - in trunk: libmpdemux/demuxer.c libmpdemux/demuxer.h mplayer.c
nicodvb
subversion at mplayerhq.hu
Mon Aug 21 21:19:00 CEST 2006
Author: nicodvb
Date: Mon Aug 21 21:19:00 2006
New Revision: 19484
Modified:
trunk/libmpdemux/demuxer.c
trunk/libmpdemux/demuxer.h
trunk/mplayer.c
Log:
demuxer_seek_chapter() returns informations about chapters count and name
Modified: trunk/libmpdemux/demuxer.c
==============================================================================
--- trunk/libmpdemux/demuxer.c (original)
+++ trunk/libmpdemux/demuxer.c Mon Aug 21 21:19:00 2006
@@ -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;
}
}
Modified: trunk/libmpdemux/demuxer.h
==============================================================================
--- trunk/libmpdemux/demuxer.h (original)
+++ trunk/libmpdemux/demuxer.h Mon Aug 21 21:19:00 2006
@@ -381,5 +381,5 @@
extern int get_demuxer_type_from_name(char *demuxer_name, int *force);
int demuxer_add_chapter(demuxer_t* demuxer, const char* name, uint64_t start, uint64_t end);
-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);
Modified: trunk/mplayer.c
==============================================================================
--- trunk/mplayer.c (original)
+++ trunk/mplayer.c Mon Aug 21 21:19:00 2006
@@ -4822,18 +4822,22 @@
int abs = (cmd->nargs > 1) ? cmd->args[1].v.i : 0;
int chap;
float next_pts = 0;
+ int num_chapters;
+ char *chapter_name;
rel_seek_secs = 0;
abs_seek_pos = 0;
- chap = demuxer_seek_chapter(demuxer, seek, abs, &next_pts);
+ chap = demuxer_seek_chapter(demuxer, seek, abs, &next_pts, &num_chapters, &chapter_name);
if(chap != -1) {
if(next_pts > -1.0) {
abs_seek_pos = 1;
rel_seek_secs = next_pts;
}
- if(demuxer->num_chapters > chap)
+ if(chapter_name) {
set_osd_msg(OSD_MSG_TEXT, 1, osd_duration, MSGTR_OSDChapter,
- chap, demuxer->chapters[chap].name);
+ chap, chapter_name);
+ free(chapter_name);
+ }
} else {
if (seek > 0)
rel_seek_secs = 1000000000.;
More information about the MPlayer-cvslog
mailing list