[DVDnav-discuss] [Fwd: r856 - in trunk/libdvdnav/src: dvdnav.c dvdnav.h dvdnav_internal.h searching.c]

Nico Sabbi nicola_sabbi at fastwebnet.it
Mon Apr 9 20:30:28 CEST 2007



-------- Original Message --------
Subject: r856 - in trunk/libdvdnav/src: dvdnav.c dvdnav.h 
dvdnav_internal.h searching.c
Date: Sun,  8 Apr 2007 19:45:19 +0200 (CEST)
From: nicodvb <subversion at mplayerhq.hu>
To: nicola_sabbi at fastwebnet.it

Author: nicodvb
Date: Sun Apr  8 19:45:19 2007
New Revision: 856

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

Log:
implemented dvdnav_get_current_time() with obvious meaning

Modified: trunk/libdvdnav/src/dvdnav.c
==============================================================================
--- trunk/libdvdnav/src/dvdnav.c	(original)
+++ trunk/libdvdnav/src/dvdnav.c	Sun Apr  8 19:45:19 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/libdvdnav/src/dvdnav.h
==============================================================================
--- trunk/libdvdnav/src/dvdnav.h	(original)
+++ trunk/libdvdnav/src/dvdnav.h	Sun Apr  8 19:45:19 2007
@@ -361,6 +361,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/libdvdnav/src/dvdnav_internal.h
==============================================================================
--- trunk/libdvdnav/src/dvdnav_internal.h	(original)
+++ trunk/libdvdnav/src/dvdnav_internal.h	Sun Apr  8 19:45:19 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/libdvdnav/src/searching.c
==============================================================================
--- trunk/libdvdnav/src/searching.c	(original)
+++ trunk/libdvdnav/src/searching.c	Sun Apr  8 19:45:19 2007
@@ -122,6 +122,7 @@ dvdnav_status_t dvdnav_time_search(dvdna
    }


+  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 @@ dvdnav_status_t dvdnav_sector_search(dvd
      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 @@ 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
@@ -361,6 +364,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
@@ -404,6 +408,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);
@@ -432,6 +437,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