summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--stream/tv.c87
-rw-r--r--stream/tv.h2
-rw-r--r--stream/tvi_bsdbt848.c6
-rw-r--r--stream/tvi_def.h1
-rw-r--r--stream/tvi_dummy.c6
-rw-r--r--stream/tvi_v4l.c7
-rw-r--r--stream/tvi_v4l2.c7
7 files changed, 75 insertions, 41 deletions
diff --git a/stream/tv.c b/stream/tv.c
index 44d16a42fe..1a06cb05bc 100644
--- a/stream/tv.c
+++ b/stream/tv.c
@@ -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_t *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 *demuxer)
}
/* ================== 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;
diff --git a/stream/tv.h b/stream/tv.h
index 3a2d6abfb3..509dfcf9d6 100644
--- a/stream/tv.h
+++ b/stream/tv.h
@@ -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;
diff --git a/stream/tvi_bsdbt848.c b/stream/tvi_bsdbt848.c
index a3aa489db0..cf526823c4 100644
--- a/stream/tvi_bsdbt848.c
+++ b/stream/tvi_bsdbt848.c
@@ -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());
}
diff --git a/stream/tvi_def.h b/stream/tvi_def.h
index 27b797c603..0a5b76e69f 100644
--- a/stream/tvi_def.h
+++ b/stream/tvi_def.h
@@ -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;
diff --git a/stream/tvi_dummy.c b/stream/tvi_dummy.c
index 8dcf7f89c1..e3a922fade 100644
--- a/stream/tvi_dummy.c
+++ b/stream/tvi_dummy.c
@@ -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());
}
diff --git a/stream/tvi_v4l.c b/stream/tvi_v4l.c
index 99d76660e9..8b20149f81 100644
--- a/stream/tvi_v4l.c
+++ b/stream/tvi_v4l.c
@@ -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(priv_t *priv)
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;
diff --git a/stream/tvi_v4l2.c b/stream/tvi_v4l2.c
index bf9ad46cfe..16e775039e 100644
--- a/stream/tvi_v4l2.c
+++ b/stream/tvi_v4l2.c
@@ -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@zpr.uni-koeln.de>",
@@ -814,7 +817,7 @@ static int control(priv_t *priv, int cmd, void *arg)
#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;