[Mplayer-cvslog] CVS: main/libmpdemux open.c,1.38,1.39 stream.c,1.29,1.30 stream.h,1.37,1.38

Arpi of Ize arpi at mplayer.dev.hu
Thu Mar 28 21:40:08 CET 2002


Update of /cvsroot/mplayer/main/libmpdemux
In directory mplayer:/var/tmp.root/cvs-serv9964

Modified Files:
	open.c stream.c stream.h 
Log Message:
DVDnav support patch by David Holm and Kees Cook <mplayer at outflux.net>

Index: open.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/open.c,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -r1.38 -r1.39
--- open.c	16 Feb 2002 21:48:59 -0000	1.38
+++ open.c	28 Mar 2002 20:40:05 -0000	1.39
@@ -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;

Index: stream.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/stream.c,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -r1.29 -r1.30
--- stream.c	16 Mar 2002 14:32:03 -0000	1.29
+++ stream.c	28 Mar 2002 20:40:05 -0000	1.30
@@ -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);
@@ -58,6 +65,98 @@
 #else
     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: {

Index: stream.h
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/stream.h,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -r1.37 -r1.38
--- stream.h	24 Mar 2002 02:25:41 -0000	1.37
+++ stream.h	28 Mar 2002 20:40:05 -0000	1.38
@@ -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
 




More information about the MPlayer-cvslog mailing list