Mercurial > mplayer.hg
changeset 19440:9847a1bd66a0
support for seeking to chapter and getting current playing chapter
author | nicodvb |
---|---|
date | Fri, 18 Aug 2006 19:05:37 +0000 |
parents | 28d2d1fddff4 |
children | b71fd63c06cb |
files | stream/stream_dvd.c |
diffstat | 1 files changed, 38 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/stream/stream_dvd.c Fri Aug 18 19:03:59 2006 +0000 +++ b/stream/stream_dvd.c Fri Aug 18 19:05:37 2006 +0000 @@ -479,16 +479,53 @@ return 1; } +static int seek_to_chapter(stream_t *stream, ifo_handle_t *vts_file, tt_srpt_t *tt_srpt, int title_no, int chapter) +{ + int cell; + ptt_info_t ptt; + pgc_t *pgc; + off_t pos; + + if(!vts_file || !tt_srpt) + return 0; + + if(chapter < 0 || chapter > vts_file->vts_ptt_srpt->title[title_no].nr_of_ptts) //no such chapter + return 0; + + ptt = vts_file->vts_ptt_srpt->title[title_no].ptt[chapter]; + pgc = vts_file->vts_pgcit->pgci_srp[ptt.pgcn-1].pgc; + + cell = pgc->program_map[ptt.pgn - 1] - 1; + pos = (off_t) pgc->cell_playback[cell].first_sector * 2048; + mp_msg(MSGT_OPEN,MSGL_V,"\r\nSTREAM_DVD, seeked to chapter: %d, cell: %u, pos: %"PRIu64"\n", + chapter, pgc->cell_playback[cell].first_sector, pos); + stream_seek(stream, pos); + + return chapter; +} + static int control(stream_t *stream,int cmd,void* arg) { + dvd_priv_t *d = stream->priv; switch(cmd) { case STREAM_CTRL_GET_TIME_LENGTH: { - dvd_priv_t *d = stream->priv; *((unsigned int *)arg) = mp_get_titleset_length(d->vts_file, d->tt_srpt, d->cur_title-1); return 1; } + case STREAM_CTRL_SEEK_TO_CHAPTER: + { + int r = seek_to_chapter(stream, d->vts_file, d->tt_srpt, d->cur_title-1, *((unsigned int *)arg)); + if(! r) return STREAM_UNSUPORTED; + + return 1; + } + case STREAM_CTRL_GET_CURRENT_CHAPTER: + { + *((unsigned int *)arg) = dvd_chapter_from_cell(d, d->cur_title-1, d->cur_cell); + return 1; + } } return STREAM_UNSUPORTED; }