Implementation of tv:// driver autodetection.

If user did not specify driver directly, all available
drivers will be probed (in order: v4l2,v4l1,bsdbt848,dummy).
In most cases first probed driver will be successfully autodetected
and used.
Autodetection will be disabled if user specified driver directly (in
command line or config).


git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@24423 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
voroshil 2007-09-10 17:09:35 +00:00
parent 36a28b6f50
commit dcc2e2e5ea
4 changed files with 21 additions and 10 deletions

View File

@ -1759,7 +1759,7 @@ In most cases automute=100 will be enough.
Default is 0 (automute disabled).
.IPs driver=<value>
See \-tv driver=help for a list of compiled-in TV input drivers.
available: dummy, v4l, v4l2, bsdbt848
available: dummy, v4l, v4l2, bsdbt848 (default: autodetect)
.IPs device=<value>
Specify TV device (default: /dev/\:video0).
.I NOTE:

View File

@ -2081,6 +2081,7 @@ static char help_text[]=
#define MSGTR_TV_AvailableDrivers "Available drivers:\n"
#define MSGTR_TV_DriverInfo "Selected driver: %s\n name: %s\n author: %s\n comment: %s\n"
#define MSGTR_TV_NoSuchDriver "No such driver: %s\n"
#define MSGTR_TV_DriverAutoDetectionFailed "TV driver autodetection failed.\n"
#define MSGTR_TV_UnknownColorOption "Unknown color option (%d) specified!\n"
#define MSGTR_TV_CurrentFrequency "Current frequency: %lu (%.3f)\n"
#define MSGTR_TV_NoTeletext "No teletext"

View File

@ -40,7 +40,7 @@ tv_param_t stream_tv_defaults = {
-1, //normid
#endif
NULL, //device
"dummy", //driver
NULL, //driver
-1, //width
-1, //height
0, //input, used in v4l and bttv

View File

@ -52,17 +52,18 @@ extern tvi_info_t tvi_info_v4l2;
extern tvi_info_t tvi_info_bsdbt848;
#endif
/** List of drivers in autodetection order */
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_V4L1
&tvi_info_v4l,
#endif
#ifdef HAVE_TV_BSDBT848
&tvi_info_bsdbt848,
#endif
&tvi_info_dummy,
NULL
};
@ -560,7 +561,7 @@ static tvi_handle_t *tv_begin(tv_param_t* tv_param)
{
int i;
tvi_handle_t* h;
if(!strcmp(tv_param->driver,"help")){
if(tv_param->driver && !strcmp(tv_param->driver,"help")){
mp_msg(MSGT_TV,MSGL_INFO,MSGTR_TV_AvailableDrivers);
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);
@ -572,20 +573,29 @@ static tvi_handle_t *tv_begin(tv_param_t* tv_param)
}
for(i=0;tvi_driver_list[i];i++){
if (!strcmp(tvi_driver_list[i]->short_name, tv_param->driver)){
if (!tv_param->driver || !strcmp(tvi_driver_list[i]->short_name, tv_param->driver)){
h=tvi_driver_list[i]->tvi_init(tv_param);
if(!h) return NULL;
//Requested driver initialization failed
if (!h && tv_param->driver)
return NULL;
//Driver initialization failed during autodetection process.
if (!h)
continue;
h->tv_param=tv_param;
mp_msg(MSGT_TV, MSGL_INFO, MSGTR_TV_DriverInfo, tvi_driver_list[i]->short_name,
tvi_driver_list[i]->name,
tvi_driver_list[i]->author,
tvi_driver_list[i]->comment?tvi_driver_list[i]->comment:"");
tv_param->driver=strdup(tvi_driver_list[i]->short_name);
return h;
}
}
mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TV_NoSuchDriver, tv_param->driver);
if(tv_param->driver)
mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TV_NoSuchDriver, tv_param->driver);
else
mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TV_DriverAutoDetectionFailed);
return(NULL);
}