changeset 97:c1dff1899bda src

First patch for personalized dvd viewing. I have not tested it yet.
author jcdutton
date Tue, 17 Sep 2002 11:00:25 +0000
parents 2fcb4f228308
children 457f35f43ba6
files Makefile.am dvdnav.c vm.c vm.h
diffstat 4 files changed, 84 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/Makefile.am	Tue Sep 17 10:47:02 2002 +0000
+++ b/Makefile.am	Tue Sep 17 11:00:25 2002 +0000
@@ -4,13 +4,13 @@
 
 libdvdnav_la_SOURCES = decoder.c dvdnav.c vm.c vmcmd.c \
 		       read_cache.c navigation.c highlight.c \
-		       searching.c settings.c
+		       searching.c settings.c remap.c
 libdvdnav_la_LDFLAGS = $(DVDREAD_LIBS) $(THREAD_LIBS) \
 	-version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE)
 #	-release $(DVDNAV_MAJOR).$(DVDNAV_MINOR).$(DVDNAV_SUB)
 
 include_HEADERS = decoder.h dvdnav.h dvdnav_events.h \
-	dvdnav_internal.h vm.h vmcmd.h read_cache.h dvd_types.h
+	dvdnav_internal.h vm.h vmcmd.h read_cache.h dvd_types.h remap.h
 
 ###
 # Install header files (default=$includedir/xine)
--- a/dvdnav.c	Tue Sep 17 10:47:02 2002 +0000
+++ b/dvdnav.c	Tue Sep 17 11:00:25 2002 +0000
@@ -40,6 +40,8 @@
 #include <stdio.h>
 #include <sys/time.h>
 
+#include "remap.h"
+
 /*
  * NOTE:
  *      All NLCK_*() function are not mutex locked, this made them reusable in
@@ -784,6 +786,14 @@
     /* Perform the jump if necessary (this is always a 
      * VOBU boundary). */
 
+     if (this->vm->map) {
+       this->vobu.vobu_next = remap_block( this->vm->map,
+           this->vm->state.domain, this->vm->state.TTN_REG,
+           this->vm->state.pgN,
+           this->vobu.vobu_start, this->vobu.vobu_next);
+     }
+
+
     //result = DVDReadBlocks(this->file, this->vobu.vobu_start + this->vobu.vobu_next, 1, buf);
     result = dvdnav_read_cache_block(this->cache, this->vobu.vobu_start + this->vobu.vobu_next, 1, buf);
 
@@ -1000,6 +1010,9 @@
 
 /*
  * $Log$
+ * Revision 1.36  2002/09/17 11:00:21  jcdutton
+ * First patch for personalized dvd viewing. I have not tested it yet.
+ *
  * Revision 1.35  2002/09/05 12:55:05  mroi
  * fix memleaks in dvdnav_open
  *
--- a/vm.c	Tue Sep 17 10:47:02 2002 +0000
+++ b/vm.c	Tue Sep 17 11:00:25 2002 +0000
@@ -33,6 +33,9 @@
 #include <unistd.h>
 #include <inttypes.h>
 #include <assert.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
 
 #include <dvdread/ifo_types.h>
 #include <dvdread/ifo_read.h>
@@ -173,6 +176,63 @@
   return vm->dvd;
 }
 
+void dvd_read_name( vm_t *this, char *devname) {
+    int fd, i;
+    off64_t off;
+    uint8_t data[DVD_VIDEO_LB_LEN];
+
+    /* Read DVD name */
+    fd=open(devname, O_RDONLY);
+    if (fd > 0) { 
+      off = lseek64( fd, 32 * (int64_t) DVD_VIDEO_LB_LEN, SEEK_SET );
+      if( off == ( 32 * (int64_t) DVD_VIDEO_LB_LEN ) ) {
+        off = read( fd, data, DVD_VIDEO_LB_LEN ); 
+        close(fd);
+        if (off == ( (int64_t) DVD_VIDEO_LB_LEN )) {
+          fprintf( stderr, "VM DVD Title: ");
+          for(i=25; i < 73; i++ ) {
+            if((data[i] == 0)) break;
+            if((data[i] > 32) && (data[i] < 127)) {
+              fprintf(stderr, "%c", data[i]);
+            } else {
+              fprintf(stderr, " ");
+            }
+          }
+          strncpy(&this->dvd_name[0], &data[25], 48);
+          /* fprintf(stderr, "TITLE:%s\n",&this->dvd_name[0]); */
+          this->dvd_name[48]=0;
+          this->dvd_name_length=strlen(&this->dvd_name[0]);
+          fprintf( stderr, "\nVM DVD Serial Number: ");
+          for(i=73; i < 89; i++ ) {
+            if((data[i] == 0)) break;
+            if((data[i] > 32) && (data[i] < 127)) {
+              fprintf(stderr, "%c", data[i]);
+            } else {
+              fprintf(stderr, " ");
+            } 
+          }
+          fprintf( stderr, "\nVM DVD Title (Alternative): ");
+          for(i=89; i < 128; i++ ) {
+            if((data[i] == 0)) break;
+            if((data[i] > 32) && (data[i] < 127)) {
+              fprintf(stderr, "%c", data[i]);
+            } else {
+              fprintf(stderr, " ");
+            }
+          }
+          fprintf( stderr, "\n");
+        } else {
+          fprintf( stderr, "libdvdread: Can't read name block. Probably not a DVD-ROM device.\n");
+        }
+      } else {
+        fprintf( stderr, "libdvdread: Can't seek to block %u\n", 32 );
+      }
+      close(fd);
+    } else {
+    fprintf(stderr,"NAME OPEN FAILED\n");
+    }
+}
+
 int vm_reset(vm_t *vm, char *dvdroot) /*  , register_t regs) */ { 
   /*  Setup State */
   memset((vm->state).registers.SPRM, 0, sizeof(uint16_t)*24);
@@ -222,6 +282,8 @@
       fprintf(MSG_OUT, "libdvdnav: vm: faild to open/read the DVD\n");
       return -1;
     }
+    dvd_read_name(vm, dvdroot);
+    vm->map = remap_loadmap( vm->dvd_name);
 
     vm->vmgi = ifoOpenVMGI(vm->dvd);
     if(!vm->vmgi) {
@@ -1926,6 +1988,9 @@
 
 /*
  * $Log$
+ * Revision 1.35  2002/09/17 11:00:22  jcdutton
+ * First patch for personalized dvd viewing. I have not tested it yet.
+ *
  * Revision 1.34  2002/09/03 07:50:45  jcdutton
  * Improve chapter selection functions.
  *
--- a/vm.h	Tue Sep 17 10:47:02 2002 +0000
+++ b/vm.h	Tue Sep 17 11:00:25 2002 +0000
@@ -27,6 +27,7 @@
 #define VM_H_INCLUDED
 
 #include "decoder.h"
+#include "remap.h"
 #include <dvd_types.h>
 
 /* DOMAIN enum */
@@ -87,6 +88,9 @@
   dvd_state_t   state;
   int  badness_counter;
   int32_t hop_channel;
+  char dvd_name[50];
+  int dvd_name_length;
+  remap_t *map;
 } vm_t;