changeset 9746:27fff718ede6

Stream cleanup, don't use blah_on options anymore.
author albeu
date Sun, 30 Mar 2003 17:07:31 +0000
parents c79bcf85f68c
children 264cb5f03131
files libmpdemux/mf.c libmpdemux/mf.h libmpdemux/open.c libmpdemux/stream.h mencoder.c mplayer.h
diffstat 6 files changed, 61 insertions(+), 29 deletions(-) [+]
line wrap: on
line diff
--- a/libmpdemux/mf.c	Sun Mar 30 17:05:58 2003 +0000
+++ b/libmpdemux/mf.c	Sun Mar 30 17:07:31 2003 +0000
@@ -18,7 +18,6 @@
 
 #include "mf.h"
 
-int    mf_support = 0;
 int    mf_w = 0; //352; // let codecs to detect it
 int    mf_h = 0; //288;
 float  mf_fps = 25.0;
--- a/libmpdemux/mf.h	Sun Mar 30 17:05:58 2003 +0000
+++ b/libmpdemux/mf.h	Sun Mar 30 17:07:31 2003 +0000
@@ -2,7 +2,6 @@
 #ifndef _MF_H
 #define _MF_H
 
-extern int    mf_support;
 extern int    mf_w;
 extern int    mf_h;
 extern float  mf_fps;
--- a/libmpdemux/open.c	Sun Mar 30 17:05:58 2003 +0000
+++ b/libmpdemux/open.c	Sun Mar 30 17:07:31 2003 +0000
@@ -5,6 +5,7 @@
 #include <string.h>
 #include <unistd.h>
 #include <fcntl.h>
+#include <string.h>
 
 #include "config.h"
 #include "mp_msg.h"
@@ -32,14 +33,15 @@
 
 int dvbin_param_on=0;
 
+/// We keep these 2 for the gui atm, but they will be removed.
 int dvd_title=0;
+int vcd_track=0;
+
 int dvd_chapter=1;
 int dvd_last_chapter=0;
 int dvd_angle=1;
 char* dvd_device=NULL;
 char* cdrom_device=NULL;
-char* cue_file_name=NULL;
-int dvd_nav=0;                  /* use libdvdnav? */
 
 #ifdef USE_DVDNAV
 #include "dvdnav_stream.h"
@@ -131,30 +133,44 @@
 
 // Open a new stream  (stdin/file/vcd/url)
 
-stream_t* open_stream(char* filename,int vcd_track,int* file_format){
+stream_t* open_stream(char* filename,int _remove_me_,int* file_format){
 stream_t* stream=NULL;
 int f=-1;
 off_t len;
 #ifdef __FreeBSD__
 int bsize = VCD_SECTOR_SIZE;
 #endif
+*file_format = DEMUXER_TYPE_UNKNOWN;
+if(!filename) {
+   mp_msg(MSGT_OPEN,MSGL_ERR,"NULL filename, report this bug\n");
+   return NULL;
+}
 
 #ifdef HAVE_CDDA
-if(filename && strncmp("cdda://",filename,7) == 0)
+if(filename && strncmp("cdda://",filename,7) == 0) {
+  *file_format = DEMUXER_TYPE_RAWAUDIO;
   return open_cdda(cdrom_device ? cdrom_device : DEFAULT_CDROM_DEVICE,filename+7);
+}
 #ifdef STREAMING
-if(filename && strncmp("cddb://",filename,7) == 0)
+if(filename && strncmp("cddb://",filename,7) == 0) {
+  *file_format = DEMUXER_TYPE_RAWAUDIO;
   return cddb_open(cdrom_device ? cdrom_device : DEFAULT_CDROM_DEVICE,filename+7);
+}
 #endif
 #endif
 
 //============ Open VideoCD track ==============
 #ifdef HAVE_VCD
-if(vcd_track && !cue_file_name){
+if(strncmp("vcd://",filename,6) == 0){
   int ret,ret2;
   if(!cdrom_device) cdrom_device=strdup(DEFAULT_CDROM_DEVICE);
   f=open(cdrom_device,O_RDONLY);
   if(f<0){ mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_CdDevNotfound,cdrom_device);return NULL; }
+  vcd_track = filename[6] == '\0' ? 1 : strtol(filename+6,NULL,0);
+  if(vcd_track < 1){ 
+    mp_msg(MSGT_OPEN,MSGL_ERR,"Invalid vcd track %s\n",filename+6);
+    return NULL;
+  }
   vcd_read_toc(f);
   ret2=vcd_get_track_end(f,vcd_track);
   if(ret2<0){ mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_ErrTrackSelect " (get)\n");return NULL;}
@@ -175,10 +191,22 @@
 
 
 // for opening of vcds in bincue files
-if(vcd_track && cue_file_name){
+if(strncmp("cue://",filename,6) == 0){
   int ret,ret2;
-  if ((f = cue_read_cue (cue_file_name)) == -1) return NULL;
-
+  char* p = filename + 6;
+  vcd_track = 1;
+  p = strchr(p,':');
+  if(p && p[1] != '\0') {
+    vcd_track = strtol(p+1,NULL,0);
+    if(vcd_track < 1){ 
+      mp_msg(MSGT_OPEN,MSGL_ERR,"Invalid cue track %s\n",p+1);
+      return NULL;
+    }
+    p[0] = '\0';
+  }
+  f = cue_read_cue (filename + 6);
+  if(p && p[1] != '\0') p[0] = ':';
+  if (f == -1) return NULL;
   cue_vcd_read_toc();
   ret2=cue_vcd_get_track_end(vcd_track);
   ret=cue_vcd_seek_to_track(vcd_track);
@@ -195,19 +223,20 @@
 
 //============ Open DVD title ==============
 #ifdef USE_DVDNAV
-if(dvd_nav){
+if(strncmp("dvdnav://",filename,9) == 0){
     dvdnav_priv_t *dvdnav_priv;
     int event,len,tmplen=0;
-
+    char* name = (filename[9] == '\0') ? NULL : filename + 9;
+    
     stream=new_stream(-1,STREAMTYPE_DVDNAV);
     if (!stream) {
         mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_Exit_error);
         return NULL;
     }
 
-    if(!filename) filename=DEFAULT_DVD_DEVICE;
-    if (!(dvdnav_priv=new_dvdnav_stream(filename))) {
-	mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_CantOpenDVD,filename);
+    if(!name) name=DEFAULT_DVD_DEVICE;
+    if (!(dvdnav_priv=new_dvdnav_stream(name))) {
+	mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_CantOpenDVD,name);
         return NULL;
     }
 
@@ -216,7 +245,7 @@
 }
 #endif
 #ifdef USE_DVDREAD
-if(dvd_title){
+if(strncmp("dvd://",filename,6) == 0){
 //  int ret,ret2;
     dvd_priv_t *d;
     int ttn,pgc_id,pgn;
@@ -225,6 +254,7 @@
     ifo_handle_t *vmg_file;
     tt_srpt_t *tt_srpt;
     ifo_handle_t *vts_file;
+    dvd_title = filename[6] == '\0' ? 1 : strtol(filename + 6,NULL,0);
     /**
      * Open the disc.
      */
@@ -487,7 +517,7 @@
 #endif
 
 #ifdef HAS_DVBIN_SUPPORT
-if(dvbin_param_on == 1)
+if(strncmp("dvbin://",filename,8) == 0)
 {
 	stream = new_stream(-1, STREAMTYPE_DVB);
 	if (!stream)
@@ -503,15 +533,22 @@
 
 
 //============ Check for TV-input or multi-file input ====
-  if( (mf_support == 1)
+  if( (strncmp("mf://",filename,5) == 0)
 #ifdef USE_TV
-   || (tv_param_on == 1)
+   || (strncmp("tv://",filename,5) == 0)
 #endif
   ){
     /* create stream */
     stream = new_stream(-1, STREAMTYPE_DUMMY);
     if (!stream) return(NULL);
-    stream->url=filename?strdup(filename):NULL;
+    if(strncmp("mf://",filename,5) == 0) {
+      *file_format =  DEMUXER_TYPE_MF;
+     } else {
+      *file_format =  DEMUXER_TYPE_TV;
+      if(filename[5] != '\0')
+	tv_param_channel = strdup(filename + 5);
+    }
+    stream->url= filename[5] != '\0' ? strdup(filename + 5) : NULL;
     return(stream);
   }
   
--- a/libmpdemux/stream.h	Sun Mar 30 17:05:58 2003 +0000
+++ b/libmpdemux/stream.h	Sun Mar 30 17:07:31 2003 +0000
@@ -195,7 +195,6 @@
 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/mencoder.c	Sun Mar 30 17:05:58 2003 +0000
+++ b/mencoder.c	Sun Mar 30 17:07:31 2003 +0000
@@ -92,7 +92,6 @@
 #define cache_fill_status 0
 #endif
 
-int vcd_track=0;
 int audio_id=-1;
 int video_id=-1;
 int dvdsub_id=-1;
@@ -422,7 +421,7 @@
   }
 #endif
 
-  if(!filename && !vcd_track && !dvd_title && !tv_param_on && !dvbin_param_on){
+  if(!filename){
 	printf(MSGTR_MissingFilename);
 	mencoder_exit(1,NULL);
   }
@@ -448,7 +447,7 @@
 
   vo_init_osd();
 
-  stream=open_stream(filename,vcd_track,&file_format);
+  stream=open_stream(filename,0,&file_format);
 
   if(!stream){
 	printf(MSGTR_CannotOpenFile_Device);
@@ -899,7 +898,7 @@
 	}
 	}
 
-if(tv_param_on == 1) 
+if(file_format == DEMUXER_TYPE_TV) 
 	{
 	fprintf(stderr,"Forcing audio preload to 0, max pts correction to 0\n");
 	audio_preload = 0.0;
@@ -1114,7 +1113,7 @@
 
 if(skip_flag<0){
     // duplicate frame
-	if(!tv_param_on && !verbose) printf(MSGTR_DuplicateFrames,-skip_flag);
+	if(file_format != DEMUXER_TYPE_TV && !verbose) printf(MSGTR_DuplicateFrames,-skip_flag);
     while(skip_flag<0){
 	duplicatedframes++;
 	muxer_write_chunk(mux_v,0,0);
@@ -1123,7 +1122,7 @@
 } else
 if(skip_flag>0){
     // skip frame
-	if(!tv_param_on && !verbose) printf(MSGTR_SkipFrame);
+	if(file_format != DEMUXER_TYPE_TV && !verbose) printf(MSGTR_SkipFrame);
 	skippedframes++;
     --skip_flag;
 }
--- a/mplayer.h	Sun Mar 30 17:05:58 2003 +0000
+++ b/mplayer.h	Sun Mar 30 17:07:31 2003 +0000
@@ -7,7 +7,6 @@
 
 extern int use_gui;
 extern char* current_module;
-extern int vcd_track;
 
 extern char * dvd_device;
 extern char * cdrom_device;