changeset 7408:0c6948b8100f

stream layer cleanup part 2 STREAMTYPE_TV removed, use STREAMTYPE_DUMMY instead. tv init moved to demux_open
author arpi
date Sun, 15 Sep 2002 20:51:55 +0000
parents 8780415baa87
children 33f2f851d264
files libmpdemux/open.c libmpdemux/stream.c libmpdemux/stream.h libmpdemux/tv.c
diffstat 4 files changed, 22 insertions(+), 48 deletions(-) [+]
line wrap: on
line diff
--- a/libmpdemux/open.c	Sun Sep 15 19:47:49 2002 +0000
+++ b/libmpdemux/open.c	Sun Sep 15 20:51:55 2002 +0000
@@ -390,47 +390,16 @@
 }
 #endif
 
+//============ Check for TV-input or multi-file input ====
+  if( (mf_support == 1)
 #ifdef USE_TV
-//============ Check for TV-input ====
-  if (tv_param_on == 1)
-  {
-    tvi_handle_t *tv_handler;
-
-    /* create stream */
-    stream = new_stream(-1, STREAMTYPE_TV);
-    if (!stream)
-	return(NULL);
-
-    /* create tvi handler */
-    tv_handler = tv_begin();
-    if (!tv_handler)
-	return(NULL);
-
-    /* preinit */
-    if (!tv_init(tv_handler))
-	goto tv_err;
-
-    if (!stream_open_tv(stream, tv_handler))
-	goto tv_err;
-
-    stream->priv=tv_handler;
-    
-    return(stream);
-
-    /* something went wrong - uninit */
-tv_err:
-    tv_uninit(tv_handler);
-    return(NULL);
-  }
+   || (tv_param_on == 1)
 #endif
-
-//============ Check for multi file-input ====
-  if (mf_support == 1)
-  {
+  ){
     /* create stream */
     stream = new_stream(-1, STREAMTYPE_DUMMY);
     if (!stream) return(NULL);
-    stream->url=strdup(filename);
+    stream->url=filename?strdup(filename):NULL;
     return(stream);
   }
   
--- a/libmpdemux/stream.c	Sun Sep 15 19:47:49 2002 +0000
+++ b/libmpdemux/stream.c	Sun Sep 15 20:51:55 2002 +0000
@@ -194,11 +194,8 @@
     }
 #endif
     break;
-#ifdef USE_TV
-  case STREAMTYPE_TV:
-    s->pos=newpos; /* no sense */
-    break;
-#endif
+  default:
+    return 0;
   }
 //   putchar('.');fflush(stdout);
 //} else {
--- a/libmpdemux/stream.h	Sun Sep 15 19:47:49 2002 +0000
+++ b/libmpdemux/stream.h	Sun Sep 15 20:51:55 2002 +0000
@@ -13,7 +13,6 @@
 #define STREAMTYPE_STREAM 2    // same as FILE but no seeking (for net/stdin)
 #define STREAMTYPE_DVD  3      // libdvdread
 #define STREAMTYPE_MEMORY  4   // read data from memory area
-#define STREAMTYPE_TV	5      // FIXME!!! dummy
 #define STREAMTYPE_PLAYLIST 6  // FIXME!!! same as STREAMTYPE_FILE now
 #define STREAMTYPE_DS   8      // read from a demuxer stream
 #define STREAMTYPE_DVDNAV 9    // we cannot safely "seek" in this...
--- a/libmpdemux/tv.c	Sun Sep 15 19:47:49 2002 +0000
+++ b/libmpdemux/tv.c	Sun Sep 15 20:51:55 2002 +0000
@@ -75,7 +75,7 @@
 
 int demux_tv_fill_buffer(demuxer_t *demux, demux_stream_t *ds)
 {
-    tvi_handle_t *tvh=(tvi_handle_t*)(demux->stream->priv);
+    tvi_handle_t *tvh=(tvi_handle_t*)(demux->priv);
     demux_packet_t* dp;
 
     sh_video_t *sh_video = demux->video->sh;
@@ -111,7 +111,7 @@
     return 1;
 }
 
-int stream_open_tv(stream_t *stream, tvi_handle_t *tvh)
+static int open_tv(tvi_handle_t *tvh)
 {
     int i;
     tvi_functions_t *funcs = tvh->functions;
@@ -257,10 +257,19 @@
 
 int demux_open_tv(demuxer_t *demuxer)
 {
-    tvi_handle_t *tvh=(tvi_handle_t*)(demuxer->stream->priv);
-    sh_video_t *sh_video = NULL;
+    tvi_handle_t *tvh;
+    sh_video_t *sh_video;
     sh_audio_t *sh_audio = NULL;
-    tvi_functions_t *funcs = tvh->functions;
+    tvi_functions_t *funcs;
+    
+    if(!(tvh=tv_begin())) return 0;
+    if (!tv_init(tvh)) return 0;
+    if (!open_tv(tvh)){
+	tv_uninit(tvh);
+	return 0;
+    }
+    funcs = tvh->functions;
+    demuxer->priv=tvh;
     
     sh_video = new_sh_video(demuxer, 0);
 
@@ -387,7 +396,7 @@
 #if defined(USE_TV) && defined(HAVE_TV_V4L)
 int demux_close_tv(demuxer_t *demuxer)
 {
-    tvi_handle_t *tvh=(tvi_handle_t*)(demuxer->stream->priv);
+    tvi_handle_t *tvh=(tvi_handle_t*)(demuxer->priv);
     return(tvh->functions->uninit(tvh->priv));
 }
 #endif