1
0
mirror of https://github.com/mpv-player/mpv synced 2025-01-12 09:59:44 +00:00

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

implemented.


git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@22399 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
voroshil 2007-03-01 18:38:00 +00:00
parent 78d1884e8e
commit e1704a4877
7 changed files with 75 additions and 41 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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());
}

View File

@ -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;

View File

@ -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());
}

View File

@ -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;

View File

@ -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;