# HG changeset patch # User nicodvb # Date 1176054319 0 # Node ID 77e472cef5f825e12f73137133c561fe983721ec # Parent 5256576e85cd389eeb3a477176b62983dda9da38 implemented dvdnav_get_current_time() with obvious meaning diff -r 5256576e85cd -r 77e472cef5f8 dvdnav.c --- a/dvdnav.c Sun Apr 08 17:41:12 2007 +0000 +++ b/dvdnav.c Sun Apr 08 17:45:19 2007 +0000 @@ -56,6 +56,7 @@ this->sync_wait_skip = 0; this->spu_clut_changed = 0; this->started = 0; + this->cur_cell_time = 0; dvdnav_read_cache_clear(this->cache); @@ -388,6 +389,23 @@ } return status; } + +int64_t dvdnav_get_current_time(dvdnav_t *this) { + int i; + int64_t tm=0; + dvd_state_t *state = &this->vm->state; + + for(i=0; icellN-1; i++) { + if(! + (state->pgc->cell_playback[i].block_type == BLOCK_TYPE_ANGLE_BLOCK && + state->pgc->cell_playback[i].block_mode != BLOCK_MODE_FIRST_CELL) + ) + tm += dvdnav_convert_time(&state->pgc->cell_playback[i].playback_time); + } + tm += this->cur_cell_time; + + return tm; +} dvdnav_status_t dvdnav_get_next_cache_block(dvdnav_t *this, uint8_t **buf, int32_t *event, int32_t *len) { @@ -583,6 +601,7 @@ int32_t first_cell_nr, last_cell_nr, i; dvd_state_t *state = &this->vm->state; + this->cur_cell_time = 0; (*event) = DVDNAV_CELL_CHANGE; #ifdef LOG_DEBUG fprintf(MSG_OUT, "libdvdnav: CELL_CHANGE\n"); @@ -783,6 +802,7 @@ fprintf(MSG_OUT, "libdvdnav: NAV_PACKET\n"); #endif (*len) = 2048; + this->cur_cell_time = dvdnav_convert_time(&this->dsi.dsi_gi.c_eltm); pthread_mutex_unlock(&this->vm_lock); return DVDNAV_STATUS_OK; } diff -r 5256576e85cd -r 77e472cef5f8 dvdnav.h --- a/dvdnav.h Sun Apr 08 17:41:12 2007 +0000 +++ b/dvdnav.h Sun Apr 08 17:45:19 2007 +0000 @@ -361,6 +361,12 @@ uint64_t offset, int32_t origin); /* + returns the current stream time in PTS ticks as reported by the IFO structures + divide it by 90000 to get the current play time in seconds + */ +int64_t dvdnav_get_current_time(dvdnav_t *this); + +/* * Stop playing the current position and start playback of the title * from the specified timecode. * diff -r 5256576e85cd -r 77e472cef5f8 dvdnav_internal.h --- a/dvdnav_internal.h Sun Apr 08 17:41:12 2007 +0000 +++ b/dvdnav_internal.h Sun Apr 08 17:45:19 2007 +0000 @@ -171,6 +171,7 @@ int started; /* vm_start has been called? */ int use_read_ahead; /* 1 - use read-ahead cache, 0 - don't */ int pgc_based; /* positioning works PGC based instead of PG based */ + int cur_cell_time; /* time expired since the beginning of the current cell, read from the dsi */ /* VM */ vm_t *vm; diff -r 5256576e85cd -r 77e472cef5f8 searching.c --- a/searching.c Sun Apr 08 17:41:12 2007 +0000 +++ b/searching.c Sun Apr 08 17:45:19 2007 +0000 @@ -122,6 +122,7 @@ } + this->cur_cell_time = 0; if (this->pgc_based) { first_cell_nr = 1; last_cell_nr = state->pgc->nr_of_cells; @@ -242,6 +243,7 @@ return DVDNAV_STATUS_ERR; } + this->cur_cell_time = 0; if (this->pgc_based) { first_cell_nr = 1; last_cell_nr = state->pgc->nr_of_cells; @@ -328,6 +330,7 @@ pthread_mutex_unlock(&this->vm_lock); return DVDNAV_STATUS_ERR; } + this->cur_cell_time = 0; this->position_current.still = 0; this->vm->hop_channel++; #ifdef LOG_DEBUG @@ -361,6 +364,7 @@ pthread_mutex_unlock(&this->vm_lock); return DVDNAV_STATUS_ERR; } + this->cur_cell_time = 0; this->position_current.still = 0; this->vm->hop_channel++; #ifdef LOG_DEBUG @@ -404,6 +408,7 @@ return DVDNAV_STATUS_ERR; } } + this->cur_cell_time = 0; /* merge changes on success */ vm_merge(this->vm, try_vm); vm_free_copy(try_vm); @@ -432,6 +437,7 @@ return DVDNAV_STATUS_ERR; } + this->cur_cell_time = 0; /* make a copy of current VM and try to navigate the copy to the menu */ try_vm = vm_new_copy(this->vm); if ( (menu == DVD_MENU_Escape) && (this->vm->state.domain != VTS_DOMAIN)) {