[DVDnav-discuss] r914 - in trunk/libdvdnav2/src: dvdnav.c dvdnav.h dvdnav_internal.h searching.c

nicodvb subversion at mplayerhq.hu
Sun Apr 29 13:31:22 CEST 2007


Author: nicodvb
Date: Sun Apr 29 13:31:22 2007
New Revision: 914

Log:
implemented dvdnav_get_current_time() to return the current time reported in the dsi

Modified:
   trunk/libdvdnav2/src/dvdnav.c
   trunk/libdvdnav2/src/dvdnav.h
   trunk/libdvdnav2/src/dvdnav_internal.h
   trunk/libdvdnav2/src/searching.c

Modified: trunk/libdvdnav2/src/dvdnav.c
==============================================================================
--- trunk/libdvdnav2/src/dvdnav.c	(original)
+++ trunk/libdvdnav2/src/dvdnav.c	Sun Apr 29 13:31:22 2007
@@ -56,6 +56,7 @@ static dvdnav_status_t dvdnav_clear(dvdn
   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 @@ dvdnav_status_t dvdnav_get_next_block(dv
   }
   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; i<state->cellN-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 @@ dvdnav_status_t dvdnav_get_next_cache_bl
     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 @@ dvdnav_status_t dvdnav_get_next_cache_bl
     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;
   }

Modified: trunk/libdvdnav2/src/dvdnav.h
==============================================================================
--- trunk/libdvdnav2/src/dvdnav.h	(original)
+++ trunk/libdvdnav2/src/dvdnav.h	Sun Apr 29 13:31:22 2007
@@ -359,6 +359,12 @@ dvdnav_status_t dvdnav_sector_search(dvd
 				     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.
  *

Modified: trunk/libdvdnav2/src/dvdnav_internal.h
==============================================================================
--- trunk/libdvdnav2/src/dvdnav_internal.h	(original)
+++ trunk/libdvdnav2/src/dvdnav_internal.h	Sun Apr 29 13:31:22 2007
@@ -171,6 +171,7 @@ struct dvdnav_s {
   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;

Modified: trunk/libdvdnav2/src/searching.c
==============================================================================
--- trunk/libdvdnav2/src/searching.c	(original)
+++ trunk/libdvdnav2/src/searching.c	Sun Apr 29 13:31:22 2007
@@ -165,6 +165,8 @@ dvdnav_status_t dvdnav_sector_search(dvd
     return DVDNAV_STATUS_ERR;
   }
   
+  this->cur_cell_time = 0;  
+  this->cur_cell_time = 0;
   if (this->pgc_based) {
     first_cell_nr = 1;
     last_cell_nr = state->pgc->nr_of_cells;
@@ -253,6 +255,7 @@ dvdnav_status_t dvdnav_prev_pg_search(dv
     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
@@ -286,6 +289,7 @@ dvdnav_status_t dvdnav_top_pg_search(dvd
     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
@@ -329,6 +333,7 @@ dvdnav_status_t dvdnav_next_pg_search(dv
       return DVDNAV_STATUS_ERR;
     }
   }
+  this->cur_cell_time = 0;
   /* merge changes on success */
   vm_merge(this->vm, try_vm);
   vm_free_copy(try_vm);
@@ -357,6 +362,7 @@ dvdnav_status_t dvdnav_menu_call(dvdnav_
     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)) {



More information about the DVDnav-discuss mailing list