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

nicodvb subversion at mplayerhq.hu
Thu Nov 29 00:19:01 CET 2007


Author: nicodvb
Date: Thu Nov 29 00:19:00 2007
New Revision: 973

Log:
added dvdnav_describe_title_chapters(title)

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

Modified: trunk/libdvdnav/src/dvdnav.h
==============================================================================
--- trunk/libdvdnav/src/dvdnav.h	(original)
+++ trunk/libdvdnav/src/dvdnav.h	Thu Nov 29 00:19:00 2007
@@ -284,6 +284,14 @@ dvdnav_status_t dvdnav_title_play(dvdnav
 dvdnav_status_t dvdnav_part_play(dvdnav_t *self, int32_t title, int32_t part);
 
 /*
+ * Stores in *times an array (that the application *must* free) of
+ * dvdtimes corresponding to the chapter times for the chosen title.
+ * The number of entries in *times is the result of the function.
+ * On error *times is NULL and the output is 0
+ */
+uint32_t dvdnav_describe_title_chapters(dvdnav_t *this, int32_t title, uint64_t **times);
+
+/*
  * Play the specified amount of parts of the specified title of
  * the DVD then STOP.
  *

Modified: trunk/libdvdnav/src/searching.c
==============================================================================
--- trunk/libdvdnav/src/searching.c	(original)
+++ trunk/libdvdnav/src/searching.c	Thu Nov 29 00:19:00 2007
@@ -30,6 +30,7 @@
 #include <limits.h>
 #include <stdio.h>
 #include <string.h>
+#include <stdlib.h>
 #include <sys/time.h>
 #include "dvd_types.h"
 #include "nav_types.h"
@@ -549,3 +550,75 @@ dvdnav_status_t dvdnav_get_position_in_t
   
   return DVDNAV_STATUS_OK;
 }
+
+uint32_t dvdnav_describe_title_chapters(dvdnav_t *this, int32_t title, uint64_t **times) {
+  int32_t retval=0;
+  uint16_t parts, i;
+  title_info_t *ptitle = NULL;
+  ptt_info_t *ptt = NULL;
+  ifo_handle_t *ifo;
+  pgc_t *pgc;
+  cell_playback_t *cell;
+  uint64_t length, *tmp=NULL;
+
+  pthread_mutex_lock(&this->vm_lock);
+  if(!this->vm->vmgi) {
+    printerr("Bad VM state or missing VTSI.");
+    goto fail;
+  }
+  if(!this->started) {
+    /* don't report an error but be nice */
+    vm_start(this->vm);
+    this->started = 1;
+  }
+  ifo = vm_get_title_ifo(this->vm, title);
+  if(!ifo || !ifo->vts_pgcit) {
+    printerr("Couldn't open IFO for chosen title, exit.");
+    goto fail;
+  }
+  
+  ptitle = &this->vm->vmgi->tt_srpt->title[title-1];
+  parts = ptitle->nr_of_ptts;
+  ptt = ifo->vts_ptt_srpt->title[ptitle->vts_ttn-1].ptt;
+  
+  tmp = calloc(1, sizeof(uint64_t)*parts);
+  if(!tmp)
+    goto fail;
+ 
+  length = 0;
+  for(i=0; i<parts; i++) {
+    uint32_t cellnr, endcellnr;
+    pgc = ifo->vts_pgcit->pgci_srp[ptt[i].pgcn-1].pgc;
+    if(ptt[i].pgn > pgc->nr_of_programs) {
+      printerr("WRONG part number.");
+      goto fail;
+    }
+ 
+    cellnr = pgc->program_map[ptt[i].pgn-1];
+    if(ptt[i].pgn < pgc->nr_of_programs)
+      endcellnr = pgc->program_map[ptt[i].pgn];
+    else
+      endcellnr = 0;
+ 
+    do {
+      cell = &pgc->cell_playback[cellnr-1];
+      if(!(cell->block_type == BLOCK_TYPE_ANGLE_BLOCK &&
+           cell->block_mode != BLOCK_MODE_FIRST_CELL
+      ))
+      {
+        tmp[i] = length + dvdnav_convert_time(&cell->playback_time);
+        length = tmp[i];
+      }
+      cellnr++;
+    } while(cellnr < endcellnr);
+  }
+  vm_ifo_close(ifo);
+  retval = parts;
+  *times = tmp;
+
+fail:
+  pthread_mutex_unlock(&this->vm_lock);
+  if(!retval && tmp)
+    free(tmp);
+  return retval;
+}



More information about the DVDnav-discuss mailing list