changeset 5472:4bd766a5632b

dvdnav functions moved out to dvdnav_steram.c
author arpi
date Wed, 03 Apr 2002 17:55:31 +0000
parents 348c7d83e710
children 39dae98304af
files libmpdemux/open.c libmpdemux/stream.c
diffstat 2 files changed, 26 insertions(+), 103 deletions(-) [+]
line wrap: on
line diff
--- a/libmpdemux/open.c	Wed Apr 03 17:50:48 2002 +0000
+++ b/libmpdemux/open.c	Wed Apr 03 17:55:31 2002 +0000
@@ -31,10 +31,10 @@
 int dvd_angle=1;
 char* dvd_device=NULL;
 char* cdrom_device=NULL;
-int dvd_nav=0;
+int dvd_nav=0;                  /* use libdvdnav? */
 
 #ifdef USE_DVDNAV
-#include <dvdnav.h>
+#include "dvdnav_stream.h"
 #endif
 
 #ifdef USE_DVDREAD
@@ -117,20 +117,22 @@
 //============ Open DVD title ==============
 #ifdef USE_DVDNAV
 if(dvd_nav){
-    dvdnav_t *dvdnav;
+    dvdnav_priv_t *dvdnav_priv;
     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;
+
+    if(!filename) filename=DEFAULT_DVD_DEVICE;
+    if (!(dvdnav_priv=new_dvdnav_stream(filename))) {
+	mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_CantOpenDVD,filename);
+        return NULL;
+    }
+
+    stream->priv=(void*)dvdnav_priv;
     return stream;
 }
 #endif
--- a/libmpdemux/stream.c	Wed Apr 03 17:50:48 2002 +0000
+++ b/libmpdemux/stream.c	Wed Apr 03 17:55:31 2002 +0000
@@ -28,13 +28,6 @@
 
 #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);
@@ -68,93 +61,8 @@
 #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: {
-          dvdnav_still_event_t *still_event = (dvdnav_still_event_t*)(s->buffer);
-          printf( "Still Frame\n" );
-	  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;
-      }
+    dvdnav_stream_read((dvdnav_priv_t*)s->priv,s->buffer,&len);
+    if (len==0) return 0; // this was an event, so repeat the read
     break;
   }
 #endif
@@ -237,6 +145,19 @@
 #endif
     break;
 #endif
+#ifdef USE_DVDNAV
+  case STREAMTYPE_DVDNAV: {
+    if (newpos==0) {
+      if (dvdnav_stream_reset((dvdnav_priv_t*)s->priv))
+        s->pos=0;
+    }
+    if(newpos!=s->pos){
+      mp_msg(MSGT_STREAM,MSGL_INFO,"Cannot seek in DVDNAV streams yet!\n");
+      return 1;
+    }
+    break;
+  }
+#endif
 #ifdef USE_DVDREAD
   case STREAMTYPE_DVD:
     s->pos=newpos; // real seek