changeset 5380:8a01cde9cf39

DVDnav support patch by David Holm and Kees Cook <mplayer@outflux.net>
author arpi
date Thu, 28 Mar 2002 20:40:21 +0000
parents 9fc7bcadcc1b
children 9451df83c04b
files cfg-common.h configure input/input.c input/input.h libmpdemux/open.c libmpdemux/stream.c libmpdemux/stream.h mplayer.c
diffstat 8 files changed, 220 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/cfg-common.h	Thu Mar 28 20:22:34 2002 +0000
+++ b/cfg-common.h	Thu Mar 28 20:40:21 2002 +0000
@@ -12,6 +12,9 @@
 #else
 	{"vcd", "VCD support is NOT available on this system!\n", CONF_TYPE_PRINT, CONF_NOCFG, 0, 0, NULL},
 #endif
+#ifdef USE_DVDNAV
+	{"dvdnav", &dvd_nav, CONF_TYPE_FLAG, 0, 0, 1},
+#endif
 #ifdef USE_DVDREAD
 	{"dvd-device", &dvd_device,  CONF_TYPE_STRING, 0, 0, 0, NULL}, 
 	{"dvd", &dvd_title, CONF_TYPE_INT, CONF_RANGE, 1, 99, NULL},
--- a/configure	Thu Mar 28 20:22:34 2002 +0000
+++ b/configure	Thu Mar 28 20:40:21 2002 +0000
@@ -207,6 +207,7 @@
   --with-csslibdir=DIR     libcss in DIR
   --with-madlibdir=DIR     libmad (libmad shared lib.) in DIR
   --with-mlibdir=DIR       libmlib (MLIB support) in DIR (Solaris only)
+  --with-libdvdnav=DIR     libdvdnav in DIR
   --with-win32libdir=DIR   W*ndows DLL files in DIR
   --with-xanimlibdir=DIR   XAnim DLL files in DIR
   --with-xvidcore=PATH     path to XviD libcore.a (e.g: /opt/lib/libcore.a)
@@ -787,6 +788,7 @@
 _vorbis=auto
 _faad=auto
 _css=auto
+_dvdnav=no
 _dvdread=auto
 _xanim=auto
 _xinerama=auto
@@ -970,6 +972,10 @@
   --language=*)
     LINGUAS=`echo $ac_option | cut -d '=' -f 2`
     ;;
+  --with-libdvdnav=*)
+    _dvdnavdir=`echo $ac_option | cut -d '=' -f 2`
+    _dvdnav=yes
+    ;;
 
   --with-win32libdir=*)
     _win32libdir=`echo $ac_option | cut -d '=' -f 2`
@@ -2414,7 +2420,6 @@
   echores "no"
 fi
 
-
 echocheck "DVD support (libdvdread - new style)"
 if test "$_dvdread" = auto ; then
   cat > $TMPC << EOF
@@ -2443,6 +2448,28 @@
   echores "no"
 fi
 
+echocheck "libdvdnav"
+if test "$_dvdnav" = yes ; then
+  cat > $TMPC <<EOF
+#include <dvdnav.h>
+int main(void) { dvdnav_t *dvd=0; return 0; }
+EOF
+  _dvdnav=no
+  cc_check $_inc_extra -I$_dvdnavdir $_ld_css -L$_dvdnavdir/.libs -ldvdnav && _dvdnav=yes
+fi
+if test "$_dvdnav" = yes ; then
+  _largefiles=yes
+  _def_dvdnav='#define USE_DVDNAV 1'
+  _ld_css="$_ld_css -L$_dvdnavdir/.libs -ldvdnav"
+  _inc_extra="$_inc_extra -I$_dvdnavdir"
+  _inputmodules="dvdnav $_inputmodules"
+  echores "yes"
+else
+  _def_dvdnav='#undef USE_DVDNAV'
+  _noinputmodules="dvdnav $_noinputmodules"
+  echores "no"
+fi
+
 echocheck "zlib"
 cat > $TMPC << EOF
 #include <zlib.h>
@@ -3466,6 +3493,9 @@
 /* DeCSS support using libcss */
 $_def_css
 
+/* DVD navigation support using libdvdnav */
+$_def_dvdnav
+
 /* Define this to enable MPEG 1/2 image postprocessing (requires FAST cpu!) */
 #define MPEG12_POSTPROC 1
 
--- a/input/input.c	Thu Mar 28 20:22:34 2002 +0000
+++ b/input/input.c	Thu Mar 28 20:40:21 2002 +0000
@@ -75,6 +75,10 @@
   { MP_CMD_GUI_PREFERENCES, "gui_preferences", 0, { {-1,{0}} } },
   { MP_CMD_GUI_SKINBROWSER, "gui_skinbrowser", 0, { {-1,{0}} } },
 #endif
+
+#ifdef USE_DVDNAV
+  { MP_CMD_DVDNAV, "dvdnav", 1, { {MP_CMD_ARG_INT,{0}}, {-1,{0}} } },
+#endif
   
   { 0, NULL, 0, {} }
 };
@@ -159,6 +163,15 @@
   { {  MOUSE_BTN5, 0 }, "volume 1" },
   { {  MOUSE_BTN6, 0 }, "volume -1" },
   
+#ifdef USE_DVDNAV
+  { { 'K', 0 }, "dvdnav 1" },   // up
+  { { 'J', 0 }, "dvdnav 2" },   // down
+  { { 'H', 0 }, "dvdnav 3" },   // left
+  { { 'L', 0 }, "dvdnav 4" },   // right
+  { { 'M', 0 }, "dvdnav 5" },   // menu
+  { { 'S', 0 }, "dvdnav 6" },   // select
+#endif
+
   { { KEY_RIGHT, 0 }, "seek 10" },
   { {  KEY_LEFT, 0 }, "seek -10" },
   { {  KEY_UP, 0 }, "seek 60" },
--- a/input/input.h	Thu Mar 28 20:22:34 2002 +0000
+++ b/input/input.h	Thu Mar 28 20:40:21 2002 +0000
@@ -24,6 +24,7 @@
 #define MP_CMD_TV_STEP_CHANNEL_LIST 19
 #define MP_CMD_VO_FULLSCREEN 20
 #define MP_CMD_SUB_POS 21
+#define MP_CMD_DVDNAV 22
 
 #define MP_CMD_GUI_EVENTS       5000
 #define MP_CMD_GUI_LOADFILE     5001
@@ -36,6 +37,13 @@
 #define MP_CMD_GUI_FULLSCREEN   5008
 #define MP_CMD_GUI_SKINBROWSER  5009
 
+#define MP_CMD_DVDNAV_UP        1
+#define MP_CMD_DVDNAV_DOWN      2
+#define MP_CMD_DVDNAV_LEFT      3
+#define MP_CMD_DVDNAV_RIGHT     4
+#define MP_CMD_DVDNAV_MENU      5
+#define MP_CMD_DVDNAV_SELECT    6
+
 // The args types
 #define MP_CMD_ARG_INT 0
 #define MP_CMD_ARG_FLOAT 1
--- a/libmpdemux/open.c	Thu Mar 28 20:22:34 2002 +0000
+++ b/libmpdemux/open.c	Thu Mar 28 20:40:21 2002 +0000
@@ -31,6 +31,11 @@
 int dvd_angle=1;
 char* dvd_device=NULL;
 char* cdrom_device=NULL;
+int dvd_nav=0;
+
+#ifdef USE_DVDNAM
+#include <dvdnav.h>
+#endif
 
 #ifdef USE_DVDREAD
 
@@ -110,10 +115,29 @@
 #endif
 
 //============ Open DVD title ==============
+#ifdef USE_DVDNAV
+if(dvd_nav){
+    dvdnav_t *dvdnav;
+    int event,len,tmplen=0;
+    if(!filename) filename=DEFAULT_DVD_DEVICE;
+    if(dvdnav_open(&dvdnav,filename)!=DVDNAV_STATUS_OK) {
+	mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_CantOpenDVD,filename);
+        return NULL;
+    }
+
+    stream=new_stream(-1,STREAMTYPE_DVDNAV);
+    if (!stream) {
+        mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_Exit_error);
+        return NULL;
+    }
+    stream->priv=(void*)dvdnav;
+    return stream;
+}
+#endif
 #ifdef USE_DVDREAD
 if(dvd_title){
 //  int ret,ret2;
-  dvd_priv_t *d;
+    dvd_priv_t *d;
     int ttn,pgc_id,pgn;
     dvd_reader_t *dvd;
     dvd_file_t *title;
--- a/libmpdemux/stream.c	Thu Mar 28 20:22:34 2002 +0000
+++ b/libmpdemux/stream.c	Thu Mar 28 20:40:21 2002 +0000
@@ -28,6 +28,13 @@
 
 #endif
 
+#ifdef USE_DVDNAV
+#include <dvdnav.h>
+#include <../linux/timer.h>
+static int still_sleep_until;
+static int sleeping=0;
+static int stillen=0;
+#endif
 #ifdef USE_DVDREAD
 int dvd_read_sector(void* d,void* p2);
 void dvd_seek(void* d,off_t pos);
@@ -59,6 +66,98 @@
     len=vcd_read(s->fd,s->buffer);break;
 #endif
 #endif
+#ifdef USE_DVDNAV
+  case STREAMTYPE_DVDNAV: {
+    int event = DVDNAV_NOP;
+    if(sleeping)
+    {
+      dvdnav_still_skip(s->priv);
+      if(sleeping==1) if(GetTimer()>=still_sleep_until) sleeping = 0;
+      len = stillen;
+    }
+    if(dvdnav_get_next_block(s->priv,s->buffer,&event,&len)!=DVDNAV_STATUS_OK)
+      printf( "Error getting next block from DVD (%s)\n",dvdnav_err_to_string(s->priv) );
+    else switch(event) {
+      case DVDNAV_BLOCK_OK: {
+          /* be silent about this one */
+                break;
+          }
+      case DVDNAV_HIGHLIGHT: {
+          dvdnav_highlight_event_t *hevent = (dvdnav_highlight_event_t*)(s->buffer);
+          if (!hevent) {
+                printf("Highlight event broken\n");
+                break;
+          }
+
+          if (hevent->display)
+          {
+    	        printf( "Highlight (%u,%u)-(%u,%u) (button %d)\n",
+                     hevent->sx,hevent->sy,
+                     hevent->ex,hevent->ey,
+                     hevent->buttonN );
+          }
+          else {
+                  printf("Highlight Hide\n");
+          }
+        break;
+        }
+      case DVDNAV_STILL_FRAME: {
+          printf( "Still Frame\n" );
+          dvdnav_still_event_t *still_event = (dvdnav_still_event_t*)(s->buffer);
+	  if(still_event->length==0xff) { printf( "Sleeping indefinately\n" ); sleeping=2; }
+	  else  {
+	    InitTimer();
+	    still_sleep_until = GetTimer() + still_event->length*1000000;
+	    printf( "Sleeping %d sec(s)\n", still_event->length );
+	    sleeping=1;
+	  }
+          stillen = len;          
+	break;
+        }
+      case DVDNAV_STOP: {
+          printf( "Nav Stop\n" );
+          len=0;
+	break;
+        }
+      case DVDNAV_NOP: {
+        printf("Nav NOP\n");
+	break;
+        }
+      case DVDNAV_SPU_STREAM_CHANGE: {
+        printf("Nav SPU Stream Change\n");
+	break;
+        }
+      case DVDNAV_AUDIO_STREAM_CHANGE: {
+        printf("Nav Audio Stream Change\n");
+	break;
+        }
+      case DVDNAV_VTS_CHANGE: {
+        printf("Nav VTS Change\n");
+	break;
+        }
+      case DVDNAV_CELL_CHANGE: {
+        printf("Nav Cell Change\n");
+	break;
+        }
+      case DVDNAV_NAV_PACKET: {
+        // printf("Nav Packet\n");
+	break;
+        }
+      case DVDNAV_SPU_CLUT_CHANGE: {
+        printf("Nav SPU CLUT Change\n");
+	break;
+        }
+      case DVDNAV_SEEK_DONE: {
+        printf("Nav Seek Done\n");
+	break;
+        }
+      default:
+        printf("Weird nav event %d\n",event);
+        break;
+      }
+    break;
+  }
+#endif
 #ifdef USE_DVDREAD
   case STREAMTYPE_DVD: {
     off_t pos=dvd_read_sector(s->priv,s->buffer);
--- a/libmpdemux/stream.h	Thu Mar 28 20:22:34 2002 +0000
+++ b/libmpdemux/stream.h	Thu Mar 28 20:40:21 2002 +0000
@@ -16,6 +16,7 @@
 #define STREAMTYPE_PLAYLIST 6
 #define STREAMTYPE_MF   7
 #define STREAMTYPE_DS   8
+#define STREAMTYPE_DVDNAV 9
 
 #define VCD_SECTOR_SIZE 2352
 #define VCD_SECTOR_OFFS 24
@@ -197,6 +198,7 @@
 extern int dvd_chapter;
 extern int dvd_last_chapter;
 extern int dvd_angle;
+extern int dvd_nav;
 int dvd_parse_chapter_range(struct config*, const char*);
 //#endif
 
--- a/mplayer.c	Thu Mar 28 20:22:34 2002 +0000
+++ b/mplayer.c	Thu Mar 28 20:40:21 2002 +0000
@@ -48,6 +48,9 @@
 #include "codec-cfg.h"
 
 #include "dvdauth.h"
+#ifdef USE_DVDNAV
+#include <dvdnav.h>
+#endif
 #ifdef USE_DVDREAD
 #include "spudec.h"
 #endif
@@ -627,7 +630,7 @@
     }
 
 
-    if(!filename && !vcd_track && !dvd_title && !tv_param_on){
+    if(!filename && !vcd_track && !dvd_title && !dvd_nav && !tv_param_on){
       if(!use_gui){
 	// no file/vcd/dvd -> show HELP:
 	mp_msg(MSGT_CPLAYER, MSGL_INFO, help_text);
@@ -1962,6 +1965,13 @@
       break;
     // quit
     case KEY_ESC: // ESC
+#ifdef USE_DVDNAV
+      if(dvd_nav) {
+              printf("menu\n");
+        dvdnav_menu_call(stream->priv,DVD_MENU_Root);
+        break;
+      }
+#endif
     case 'q': 
       exit_player(MSGTR_Exit_quit);
     case KEY_ENTER: // ESC
@@ -2437,6 +2447,34 @@
 	if(sub_pos >100) sub_pos=100;
 	if(sub_pos <0) sub_pos=0;
     }	break;
+#ifdef USE_DVDNAV
+    case MP_CMD_DVDNAV: {
+      switch (cmd->args[0].v.i) {
+        case MP_CMD_DVDNAV_UP:
+          dvdnav_upper_button_select(stream->priv);
+          break;
+        case MP_CMD_DVDNAV_DOWN:
+          dvdnav_lower_button_select(stream->priv);
+          break;
+        case MP_CMD_DVDNAV_LEFT:
+          dvdnav_left_button_select(stream->priv);
+          break;
+        case MP_CMD_DVDNAV_RIGHT:
+          dvdnav_right_button_select(stream->priv);
+          break;
+        case MP_CMD_DVDNAV_MENU:
+          dvdnav_menu_call(stream->priv,DVD_MENU_Root);
+          break;
+        case MP_CMD_DVDNAV_SELECT:
+          dvdnav_button_activate(stream->priv);
+          break;
+        default:
+          mp_msg(MSGT_CPLAYER, MSGL_V, "Weird DVD Nav cmd %d\n",cmd->args[0].v.i);
+          break;
+      }
+      break;
+    }
+#endif
     default : {
 #ifdef HAVE_NEW_GUI
       if ( ( use_gui )&&( cmd->id > MP_CMD_GUI_EVENTS ) ) guiGetEvent( guiIEvent,(char *)cmd->id );