The attached patch adds a function to dvdnav to obtain the dvd serial
number externally.

This is used in mythtv to generate a unique id for the disc for it's
bookmarking code.

This is my first patch to dvdnav to please tell me if I'm doing things
wrong etc.

Cheers,
Matthew
Index: src/dvdnav/dvdnav.h
===================================================================
--- src/dvdnav/dvdnav.h	(révision 1166)
+++ src/dvdnav/dvdnav.h	(copie de travail)
@@ -537,6 +537,13 @@
 dvdnav_status_t dvdnav_get_title_string(dvdnav_t *self, const char **title_str);
 
 /*
+ * Returns a string containing the serial number of the DVD.
+ * This has a max of 15 characters and should be more unique than the
+ * title string.
+ */
+dvdnav_status_t dvdnav_get_serial_string(dvdnav_t *self, const char **serial_str);
+
+/*
  * Get video aspect code.
  * The aspect code does only change on VTS boundaries.
  * See the DVDNAV_VTS_CHANGE event.
Index: src/vm/vm.c
===================================================================
--- src/vm/vm.c	(révision 1166)
+++ src/vm/vm.c	(copie de travail)
@@ -156,7 +156,7 @@
 }
 #endif
 
-static void dvd_read_name(char *name, const char *device) {
+static void dvd_read_name(char *name, char *serial, const char *device) {
     /* Because we are compiling with _FILE_OFFSET_BITS=64
      * all off_t are 64bit.
      */
@@ -192,6 +192,8 @@
               fprintf(MSG_OUT, " ");
             }
           }
+          strncpy(serial, (char*) &data[73], (i-73));
+          serial[15] = 0;
           fprintf(MSG_OUT, "\nlibdvdnav: DVD Title (Alternative): ");
           for(i=89; i < 128; i++ ) {
             if((data[i] == 0)) break;
@@ -352,7 +354,7 @@
       fprintf(MSG_OUT, "libdvdnav: vm: failed to open/read the DVD\n");
       return 0;
     }
-    dvd_read_name(vm->dvd_name, dvdroot);
+    dvd_read_name(vm->dvd_name, vm->dvd_serial, dvdroot);
     vm->map  = remap_loadmap(vm->dvd_name);
     vm->vmgi = ifoOpenVMGI(vm->dvd);
     if(!vm->vmgi) {
Index: src/vm/vm.h
===================================================================
--- src/vm/vm.h	(révision 1166)
+++ src/vm/vm.h	(copie de travail)
@@ -82,6 +82,7 @@
   dvd_state_t   state;
   int32_t       hop_channel;
   char          dvd_name[50];
+  char          dvd_serial[15];
   remap_t      *map;
   int           stopped;
 } vm_t;
Index: src/dvdnav.c
===================================================================
--- src/dvdnav.c	(révision 1166)
+++ src/dvdnav.c	(copie de travail)
@@ -825,6 +825,11 @@
   return DVDNAV_STATUS_OK;
 }
 
+dvdnav_status_t dvdnav_get_serial_string(dvdnav_t *this, const char **serial_str) {
+  (*serial_str) = this->vm->dvd_serial;
+  return DVDNAV_STATUS_OK;
+}
+
 uint8_t dvdnav_get_video_aspect(dvdnav_t *this) {
   uint8_t         retval;
 
_______________________________________________
DVDnav-discuss mailing list
[email protected]
https://lists.mplayerhq.hu/mailman/listinfo/dvdnav-discuss

Reply via email to