# HG changeset patch # User jcdutton # Date 1030936801 0 # Node ID 929f732a0135a5e8d46e606250868df617ffe281 # Parent b1cbe3464fb93de7a69ec1b2a468e9d9f47bd520 Implement proper prev/next chapter/part. I don't know why someone has not noticed the problem until now. diff -r b1cbe3464fb9 -r 929f732a0135 dvdnav.h --- a/dvdnav.h Mon Sep 02 00:27:14 2002 +0000 +++ b/dvdnav.h Mon Sep 02 03:20:01 2002 +0000 @@ -396,6 +396,22 @@ /** * Stop playing the current title and start playback of the title + * from the previous part (chapter). + * + * \param self Pointer to dvdnav_t associated with this operation. + */ +dvdnav_status_t dvdnav_prev_part_search(dvdnav_t *self); + +/** + * Stop playing the current title and start playback of the title + * from the next part (chapter). + * + * \param self Pointer to dvdnav_t associated with this operation. + */ +dvdnav_status_t dvdnav_next_part_search(dvdnav_t *self); + +/** + * Stop playing the current title and start playback of the title * from the previous program (if it exists). * * \param self Pointer to dvdnav_t associated with this operation. diff -r b1cbe3464fb9 -r 929f732a0135 searching.c --- a/searching.c Mon Sep 02 00:27:14 2002 +0000 +++ b/searching.c Mon Sep 02 03:20:01 2002 +0000 @@ -228,6 +228,25 @@ return S_OK; } +dvdnav_status_t dvdnav_prev_part_search(dvdnav_t *this) { + + if((!this) || (!this->vm) ) + return S_ERR; + + vm_prev_part(this->vm); + /* FIXME: handle errors */ + return S_OK; +} + +dvdnav_status_t dvdnav_next_part_search(dvdnav_t *this) { + if((!this) || (!this->vm) ) + return S_ERR; + + vm_next_part(this->vm); + /* FIXME: handle errors */ + return S_OK; +} + dvdnav_status_t dvdnav_prev_pg_search(dvdnav_t *this) { dvd_state_t *state; diff -r b1cbe3464fb9 -r 929f732a0135 vm.c --- a/vm.c Mon Sep 02 00:27:14 2002 +0000 +++ b/vm.c Mon Sep 02 03:20:01 2002 +0000 @@ -438,6 +438,129 @@ return vm_top_pg(vm); } +int vm_prev_part(vm_t *vm) +{ + link_t link_values; + vts_ptt_srpt_t *vts_ptt_srpt; + int title, part=0; + int found = 0; + int16_t pgcN, pgN; + + if((!vm) || (!vm->vtsi) ) + return S_ERR; + + if(!(vm->state.pgc) ) + return S_ERR; + if (vm->state.domain != VTS_DOMAIN) + return S_ERR; + vts_ptt_srpt = vm->vtsi->vts_ptt_srpt; + pgcN = get_PGCN(vm); + pgN = vm->state.pgN; + printf("VTS_PTT_SRPT - PGC: %3i PG: %3i\n", + pgcN, pgN); + for(title=0;( (titlenr_of_srpts) && (found == 0) );title++) { + for(part=0;((part < vts_ptt_srpt->title[title].nr_of_ptts) && (found == 0));part++) { + if ( (vts_ptt_srpt->title[title].ptt[part].pgcn == pgcN) && + (vts_ptt_srpt->title[title].ptt[part].pgn == pgN ) ) { + found = 1; + break; + } + } + if (found != 0) break; + } + title++; + part++; + if (found == 1) { + fprintf(MSG_OUT, "libdvdnav: ************ this chapter FOUND!\n"); + printf("VTS_PTT_SRPT - Title %3i part %3i: PGC: %3i PG: %3i\n", + title, part, + vts_ptt_srpt->title[title-1].ptt[part-1].pgcn , + vts_ptt_srpt->title[title-1].ptt[part-1].pgn ); + } else { + fprintf(MSG_OUT, "libdvdnav: ************ this chapter NOT FOUND!\n"); + return S_ERR; + } + /* Make sure this is not the first chapter */ + if(part <= 1 ) { + fprintf(MSG_OUT, "libdvdnav: at first chapter. prev chapter failed.\n"); + return S_ERR; + } + part--; /* Previous chapter */ + if(set_VTS_PTT(vm,(vm->state).vtsN, title, part) == -1) + assert(0); + link_values = play_PGC_PG( vm, (vm->state).pgN ); + link_values = process_command(vm,link_values); + assert(link_values.command == PlayThis); + (vm->state).blockN = link_values.data1; + assert( (vm->state).blockN == 0 ); + vm->hop_channel++; + + fprintf(MSG_OUT, "libdvdnav: previous chapter done\n"); + + return 1; +} + + +int vm_next_part(vm_t *vm) +{ + link_t link_values; + vts_ptt_srpt_t *vts_ptt_srpt; + int title, part=0; + int found = 0; + int16_t pgcN, pgN; + + if((!vm) || (!vm->vtsi) ) + return S_ERR; + + if(!(vm->state.pgc) ) + return S_ERR; + if (vm->state.domain != VTS_DOMAIN) + return S_ERR; + vts_ptt_srpt = vm->vtsi->vts_ptt_srpt; + pgcN = get_PGCN(vm); + pgN = vm->state.pgN; + printf("VTS_PTT_SRPT - PGC: %3i PG: %3i\n", + pgcN, pgN); + for(title=0;( (titlenr_of_srpts) && (found == 0) );title++) { + for(part=0;((part < vts_ptt_srpt->title[title].nr_of_ptts) && (found == 0));part++) { + if ( (vts_ptt_srpt->title[title].ptt[part].pgcn == pgcN) && + (vts_ptt_srpt->title[title].ptt[part].pgn == pgN ) ) { + found = 1; + break; + } + } + if (found != 0) break; + } + title++; + part++; + if (found == 1) { + fprintf(MSG_OUT, "libdvdnav: ************ this chapter FOUND!\n"); + printf("VTS_PTT_SRPT - Title %3i part %3i: PGC: %3i PG: %3i\n", + title, part, + vts_ptt_srpt->title[title-1].ptt[part-1].pgcn , + vts_ptt_srpt->title[title-1].ptt[part-1].pgn ); + } else { + fprintf(MSG_OUT, "libdvdnav: ************ this chapter NOT FOUND!\n"); + } + /* Make sure this is not the last chapter */ + if(part >= vts_ptt_srpt->title[title-1].nr_of_ptts) { + fprintf(MSG_OUT, "libdvdnav: at last chapter. next chapter failed.\n"); + return S_ERR; + } + part++; /* Next chapter */ + if(set_VTS_PTT(vm,(vm->state).vtsN, title, part) == -1) + assert(0); + link_values = play_PGC_PG( vm, (vm->state).pgN ); + link_values = process_command(vm,link_values); + assert(link_values.command == PlayThis); + (vm->state).blockN = link_values.data1; + assert( (vm->state).blockN == 0 ); + vm->hop_channel++; + + fprintf(MSG_OUT, "libdvdnav: next chapter done\n"); + + return 1; +} static domain_t menuid2domain(DVDMenuID_t menuid) { @@ -1834,6 +1957,10 @@ /* * $Log$ + * Revision 1.33 2002/09/02 03:20:01 jcdutton + * Implement proper prev/next chapter/part. + * I don't know why someone has not noticed the problem until now. + * * Revision 1.32 2002/09/02 00:27:14 jcdutton * Fix bug in JumpVTS_PTT command. * diff -r b1cbe3464fb9 -r 929f732a0135 vm.h --- a/vm.h Mon Sep 02 00:27:14 2002 +0000 +++ b/vm.h Mon Sep 02 03:20:01 2002 +0000 @@ -137,6 +137,8 @@ int vm_top_pg(vm_t *vm); int vm_next_pg(vm_t *vm); int vm_prev_pg(vm_t *vm); +int vm_next_part(vm_t *vm); +int vm_prev_part(vm_t *vm); int vm_get_audio_stream(vm_t *vm, int audioN); int vm_get_audio_active_stream(vm_t *vm); int vm_get_subp_stream(vm_t *vm, int subpN, int mode); @@ -144,6 +146,7 @@ void vm_get_angle_info(vm_t *vm, int *num_avail, int *current); void vm_get_audio_info(vm_t *vm, int *num_avail, int *current); void vm_get_subp_info(vm_t *vm, int *num_avail, int *current); + subp_attr_t vm_get_subp_attr(vm_t *vm, int streamN); audio_attr_t vm_get_audio_attr(vm_t *vm, int streamN); void vm_get_video_res(vm_t *vm, int *width, int *height);