[MPlayer-cvslog] r22399 - in trunk/stream: tv.c tv.h tvi_bsdbt848.c tvi_def.h tvi_dummy.c tvi_v4l.c tvi_v4l2.c

voroshil subversion at mplayerhq.hu
Thu Mar 1 19:38:00 CET 2007


Author: voroshil
Date: Thu Mar  1 19:38:00 2007
New Revision: 22399

Modified:
   trunk/stream/tv.c
   trunk/stream/tv.h
   trunk/stream/tvi_bsdbt848.c
   trunk/stream/tvi_def.h
   trunk/stream/tvi_dummy.c
   trunk/stream/tvi_v4l.c
   trunk/stream/tvi_v4l2.c

Log:
tv driver loading rework. As a side effect "-tv driver=help" option is
implemented.


Modified: trunk/stream/tv.c
==============================================================================
--- trunk/stream/tv.c	(original)
+++ trunk/stream/tv.c	Thu Mar  1 19:38:00 2007
@@ -71,8 +71,8 @@ int tv_param_quality = 90;
 #if defined(HAVE_ALSA9) || defined(HAVE_ALSA1X)
 int tv_param_alsa = 0;
 #endif
-char* tv_param_adevice = NULL;
 #endif
+char* tv_param_adevice = NULL;
 int tv_param_brightness = 0;
 int tv_param_contrast = 0;
 int tv_param_hue = 0;
@@ -81,6 +81,33 @@ tv_channels_t *tv_channel_list;
 tv_channels_t *tv_channel_current, *tv_channel_last;
 char *tv_channel_last_real;
 
+/* enumerating drivers (like in stream.c) */
+extern tvi_info_t tvi_info_dummy;
+#ifdef HAVE_TV_V4L1
+extern tvi_info_t tvi_info_v4l;
+#endif
+#ifdef HAVE_TV_V4L2
+extern tvi_info_t tvi_info_v4l2;
+#endif
+#ifdef HAVE_TV_BSDBT848
+extern tvi_info_t tvi_info_bsdbt848;
+#endif
+
+static const tvi_info_t* tvi_driver_list[]={
+    &tvi_info_dummy,
+#ifdef HAVE_TV_V4L1
+    &tvi_info_v4l,
+#endif
+#ifdef HAVE_TV_V4L2
+    &tvi_info_v4l2,
+#endif
+#ifdef HAVE_TV_BSDBT848
+    &tvi_info_bsdbt848,
+#endif
+    NULL
+};
+
+
 /* ================== DEMUX_TV ===================== */
 /*
   Return value:
@@ -482,7 +509,7 @@ static demuxer_t* demux_open_tv(demuxer_
     
     demuxer->priv=NULL;
     if(!(tvh=tv_begin())) return NULL;
-    if (!tv_init(tvh)) return NULL;
+    if (!tvh->functions->init(tvh->priv)) return NULL;
     if (!open_tv(tvh)){
 	tv_uninit(tvh);
 	return NULL;
@@ -632,43 +659,41 @@ static void demux_close_tv(demuxer_t *de
 }
 
 /* ================== STREAM_TV ===================== */
-tvi_handle_t *tvi_init_dummy(char *device);
-tvi_handle_t *tvi_init_v4l(char *device, char *adevice);
-tvi_handle_t *tvi_init_v4l2(char *device, char *adevice);
-tvi_handle_t *tvi_init_bsdbt848(char *device);
 
 tvi_handle_t *tv_begin(void)
 {
-    if (!strcmp(tv_param_driver, "dummy"))
-	return tvi_init_dummy(tv_param_device);
-#ifdef HAVE_TV_V4L1
-    if (!strcmp(tv_param_driver, "v4l"))
-	return tvi_init_v4l(tv_param_device, tv_param_adevice);
-#endif
-#ifdef HAVE_TV_V4L2
-    if (!strcmp(tv_param_driver, "v4l2"))
-	return tvi_init_v4l2(tv_param_device, tv_param_adevice);
-#endif
-#ifdef HAVE_TV_BSDBT848
-    if (!strcmp(tv_param_driver, "bsdbt848"))
-	return tvi_init_bsdbt848(tv_param_device);
-#endif
+    int i;
+    tvi_info_t* info;
+    tvi_handle_t* h;
+    if(!strcmp(tv_param_driver,"help")){
+        mp_msg(MSGT_TV,MSGL_INFO,"Available drivers:\n");
+        for(i=0;tvi_driver_list[i];i++){
+	    mp_msg(MSGT_TV,MSGL_INFO," %s\t%s",tvi_driver_list[i]->short_name,tvi_driver_list[i]->name);
+	    if(tvi_driver_list[i]->comment)
+	        mp_msg(MSGT_TV,MSGL_INFO," (%s)",tvi_driver_list[i]->comment);
+	    mp_msg(MSGT_TV,MSGL_INFO,"\n");
+	}
+	return NULL;
+    }
 
+    for(i=0;tvi_driver_list[i];i++){
+        if (!strcmp(tvi_driver_list[i]->short_name, tv_param_driver)){
+            h=tvi_driver_list[i]->tvi_init(tv_param_device,tv_param_adevice);
+            if(!h) return NULL;
+
+            mp_msg(MSGT_TV, MSGL_INFO, "Selected driver: %s\n", tvi_driver_list[i]->short_name);
+            mp_msg(MSGT_TV, MSGL_INFO, " name: %s\n", tvi_driver_list[i]->name);
+            mp_msg(MSGT_TV, MSGL_INFO, " author: %s\n", tvi_driver_list[i]->author);
+            if (tvi_driver_list[i]->comment)
+                mp_msg(MSGT_TV, MSGL_INFO, " comment: %s\n", tvi_driver_list[i]->comment);
+            return h;
+        }
+    }
+    
     mp_msg(MSGT_TV, MSGL_ERR, "No such driver: %s\n", tv_param_driver); 
     return(NULL);
 }
 
-int tv_init(tvi_handle_t *tvh)
-{
-    mp_msg(MSGT_TV, MSGL_INFO, "Selected driver: %s\n", tvh->info->short_name);
-    mp_msg(MSGT_TV, MSGL_INFO, " name: %s\n", tvh->info->name);
-    mp_msg(MSGT_TV, MSGL_INFO, " author: %s\n", tvh->info->author);
-    if (tvh->info->comment)
-	mp_msg(MSGT_TV, MSGL_INFO, " comment: %s\n", tvh->info->comment);
-
-    return(tvh->functions->init(tvh->priv));
-}
-
 int tv_uninit(tvi_handle_t *tvh)
 {
     int res;

Modified: trunk/stream/tv.h
==============================================================================
--- trunk/stream/tv.h	(original)
+++ trunk/stream/tv.h	Thu Mar  1 19:38:00 2007
@@ -52,6 +52,7 @@ extern int tv_param_saturation;
 
 typedef struct tvi_info_s
 {
+    struct tvi_handle_s * (*tvi_init)(char *device,char *adevice);
     const char *name;
     const char *short_name;
     const char *author;
@@ -74,7 +75,6 @@ typedef struct tvi_functions_s
 } tvi_functions_t;
 
 typedef struct tvi_handle_s {
-    tvi_info_t		*info;
     tvi_functions_t	*functions;
     void		*priv;
     int 		seq;

Modified: trunk/stream/tvi_bsdbt848.c
==============================================================================
--- trunk/stream/tvi_bsdbt848.c	(original)
+++ trunk/stream/tvi_bsdbt848.c	Thu Mar  1 19:38:00 2007
@@ -66,8 +66,10 @@
 #include "libmpcodecs/img_format.h"
 #include "tv.h"
 
+static tvi_handle_t *tvi_init_bsdbt848(char *device, char *adevice);
 /* information about this file */
-static tvi_info_t info = {
+tvi_info_t tvi_info_bsdbt848 = {
+    tvi_init_bsdbt848,
     "Brooktree848 Support",
     "bsdbt848",
     "Charles Henrich",
@@ -169,7 +171,7 @@ return;
 }
 
 /* handler creator - entry point ! */
-tvi_handle_t *tvi_init_bsdbt848(char *device)
+static tvi_handle_t *tvi_init_bsdbt848(char *device,char* adevice)
 {
     return(new_handle());
 }

Modified: trunk/stream/tvi_def.h
==============================================================================
--- trunk/stream/tvi_def.h	(original)
+++ trunk/stream/tvi_def.h	Thu Mar  1 19:38:00 2007
@@ -41,7 +41,6 @@ static tvi_handle_t *new_handle(void)
 	return(NULL);
     }
     memset(h->priv, 0, sizeof(priv_t));
-    h->info = &info;
     h->functions = &functions;
     h->seq = 0;
     h->chanlist = -1;

Modified: trunk/stream/tvi_dummy.c
==============================================================================
--- trunk/stream/tvi_dummy.c	(original)
+++ trunk/stream/tvi_dummy.c	Thu Mar  1 19:38:00 2007
@@ -8,8 +8,10 @@
 #include "libmpcodecs/img_format.h"
 #include "tv.h"
 
+static tvi_handle_t *tvi_init_dummy(char *device,char *adevice);
 /* information about this file */
-static tvi_info_t info = {
+tvi_info_t tvi_info_dummy = {
+	tvi_init_dummy,
 	"NULL-TV",
 	"dummy",
 	"alex",
@@ -25,7 +27,7 @@ typedef struct {
 #include "tvi_def.h"
 
 /* handler creator - entry point ! */
-tvi_handle_t *tvi_init_dummy(char *device)
+static tvi_handle_t *tvi_init_dummy(char *device,char *adevice)
 {
     return(new_handle());
 }

Modified: trunk/stream/tvi_v4l.c
==============================================================================
--- trunk/stream/tvi_v4l.c	(original)
+++ trunk/stream/tvi_v4l.c	Thu Mar  1 19:38:00 2007
@@ -48,7 +48,10 @@
 
 #include "audio_in.h"
 
-static tvi_info_t info = {
+static tvi_handle_t *tvi_init_v4l(char *device, char *adevice);
+
+tvi_info_t tvi_info_v4l = {
+	tvi_init_v4l,
 	"Video 4 Linux input",
 	"v4l",
 	"Alex Beregszaszi",
@@ -266,7 +269,7 @@ static void setup_audio_buffer_sizes(pri
 	   priv->audio_buffer_size, priv->audio_in.blocksize, priv->aud_skew_cnt);
 }
 
-tvi_handle_t *tvi_init_v4l(char *device, char *adevice)
+static tvi_handle_t *tvi_init_v4l(char *device, char *adevice)
 {
     tvi_handle_t *h;
     priv_t *priv;

Modified: trunk/stream/tvi_v4l2.c
==============================================================================
--- trunk/stream/tvi_v4l2.c	(original)
+++ trunk/stream/tvi_v4l2.c	Thu Mar  1 19:38:00 2007
@@ -46,8 +46,11 @@ known issues:
 #include "tv.h"
 #include "audio_in.h"
 
+#define info tvi_info_v4l2
+static tvi_handle_t *tvi_init_v4l2(char *video_dev, char *audio_dev);
 /* information about this file */
-static tvi_info_t info = {
+tvi_info_t tvi_info_v4l2 = {
+    tvi_init_v4l2,
     "Video 4 Linux 2 input",
     "v4l2",
     "Martin Olschewski <olschewski at zpr.uni-koeln.de>",
@@ -814,7 +817,7 @@ static int control(priv_t *priv, int cmd
 #define PRIV ((priv_t *) (tvi_handle->priv))
 
 /* handler creator - entry point ! */
-tvi_handle_t *tvi_init_v4l2(char *video_dev, char *audio_dev)
+static tvi_handle_t *tvi_init_v4l2(char *video_dev, char *audio_dev)
 {
     tvi_handle_t *tvi_handle;
 



More information about the MPlayer-cvslog mailing list