# HG changeset patch # User richwareham # Date 1018188611 0 # Node ID 66708b4a1b5e5e3b6e923e0d98a9d027c08b3dcd # Parent 7fdefafa624f5aa2e4f58ce68bd64801254395c8 Stop C++ bitching about some things and extend the menus example diff -r 7fdefafa624f -r 66708b4a1b5e dvdnav.c --- a/dvdnav.c Sat Apr 06 18:42:05 2002 +0000 +++ b/dvdnav.c Sun Apr 07 14:10:11 2002 +0000 @@ -82,7 +82,7 @@ return S_OK; } -dvdnav_status_t dvdnav_open(dvdnav_t** dest, char *path) { +dvdnav_status_t dvdnav_open(dvdnav_t** dest, const char *path) { dvdnav_t *self; /* Create a new structure */ @@ -988,6 +988,9 @@ /* * $Log$ + * Revision 1.6 2002/04/07 14:10:11 richwareham + * Stop C++ bitching about some things and extend the menus example + * * Revision 1.5 2002/04/06 18:42:05 jcdutton * Slight correction to handle quicker menu transitions. * diff -r 7fdefafa624f -r 66708b4a1b5e dvdnav.h --- a/dvdnav.h Sat Apr 06 18:42:05 2002 +0000 +++ b/dvdnav.h Sun Apr 07 14:10:11 2002 +0000 @@ -61,7 +61,7 @@ * dest -- Pointer to a dvdnav_t pointer to fill in. * path -- Any libdvdread acceptable path */ -dvdnav_status_t dvdnav_open(dvdnav_t** dest, char *path); +dvdnav_status_t dvdnav_open(dvdnav_t** dest, const char *path); /** * Closes a dvdnav_t previously opened with dvdnav_open(), freeing any @@ -286,7 +286,15 @@ * part and the length (in blocks) of said part. */ dvdnav_status_t dvdnav_get_position(dvdnav_t *self, unsigned int* pos, - unsigned int *len); + unsigned int *len); + +/** + * Return the current position (in blocks) within the current + * title and the length (in blocks) of said title. + */ +dvdnav_status_t dvdnav_get_position_in_title(dvdnav_t *self, + unsigned int* pos, + unsigned int *len); /** Highlights **/ diff -r 7fdefafa624f -r 66708b4a1b5e searching.c --- a/searching.c Sat Apr 06 18:42:05 2002 +0000 +++ b/searching.c Sun Apr 07 14:10:11 2002 +0000 @@ -318,3 +318,40 @@ return S_OK; } +dvdnav_status_t dvdnav_get_position_in_title(dvdnav_t *self, + unsigned int *pos, + unsigned int *len) { + uint32_t cur_sector; + uint32_t first_cell_nr; + uint32_t last_cell_nr; + cell_playback_t *first_cell; + cell_playback_t *last_cell; + dvd_state_t *state; + if((!self) || (!self->vm) ) + return S_ERR; + + state = &(self->vm->state); + if((!state) || (!state->pgc) ) + return S_ERR; + + /* Sanity check */ + if(state->pgN > state->pgc->nr_of_programs) { + return S_ERR; + } + + /* Get current sector */ + cur_sector = self->vobu_start + self->blockN; + + /* Now find first and last cells in title. */ + first_cell_nr = state->pgc->program_map[0]; + first_cell = &(state->pgc->cell_playback[first_cell_nr-1]); + last_cell_nr = state->pgc->nr_of_cells; + last_cell = &(state->pgc->cell_playback[last_cell_nr-1]); + + *pos = cur_sector - first_cell->first_sector; + *len = last_cell->last_sector - first_cell->first_sector; + + return S_OK; +} + +