2001-11-09 23:46:06 +00:00
|
|
|
/*
|
2010-01-30 22:26:47 +00:00
|
|
|
* TV Interface for MPlayer
|
|
|
|
*
|
|
|
|
* API idea based on libvo2
|
|
|
|
*
|
|
|
|
* Copyright (C) 2001 Alex Beregszaszi
|
|
|
|
*
|
|
|
|
* Feb 19, 2002: Significant rewrites by Charles R. Henrich (henrich@msu.edu)
|
|
|
|
* to add support for audio, and bktr *BSD support.
|
|
|
|
*
|
|
|
|
* This file is part of MPlayer.
|
|
|
|
*
|
|
|
|
* MPlayer is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* MPlayer is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with MPlayer; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*/
|
2001-11-09 23:46:06 +00:00
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <unistd.h>
|
2001-11-16 21:53:07 +00:00
|
|
|
#include <string.h>
|
2003-06-03 17:43:49 +00:00
|
|
|
#include <ctype.h>
|
2002-03-15 16:07:06 +00:00
|
|
|
#include <sys/time.h>
|
2001-11-09 23:46:06 +00:00
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2001-11-11 03:53:42 +00:00
|
|
|
|
2001-11-09 23:46:06 +00:00
|
|
|
#include "mp_msg.h"
|
|
|
|
|
|
|
|
#include "stream.h"
|
2006-08-04 17:01:29 +00:00
|
|
|
#include "libmpdemux/demuxer.h"
|
|
|
|
#include "libmpdemux/stheader.h"
|
2001-11-11 13:47:42 +00:00
|
|
|
|
2005-11-18 14:39:25 +00:00
|
|
|
#include "libaf/af_format.h"
|
2006-08-18 13:58:03 +00:00
|
|
|
#include "libmpcodecs/img_format.h"
|
2009-10-29 22:13:04 +00:00
|
|
|
#include "libmpcodecs/dec_teletext.h"
|
2007-07-05 22:01:07 +00:00
|
|
|
#include "libavutil/avstring.h"
|
2007-08-23 16:09:30 +00:00
|
|
|
#include "osdep/timer.h"
|
2001-11-11 13:47:42 +00:00
|
|
|
|
2001-11-10 23:32:10 +00:00
|
|
|
#include "tv.h"
|
2001-11-09 23:46:06 +00:00
|
|
|
|
2001-11-17 00:23:48 +00:00
|
|
|
#include "frequencies.h"
|
|
|
|
|
2005-01-29 12:24:43 +00:00
|
|
|
tv_channels_t *tv_channel_list;
|
|
|
|
tv_channels_t *tv_channel_current, *tv_channel_last;
|
|
|
|
char *tv_channel_last_real;
|
2001-11-09 23:46:06 +00:00
|
|
|
|
2007-03-01 18:38:00 +00:00
|
|
|
/* enumerating drivers (like in stream.c) */
|
2008-01-13 12:01:57 +00:00
|
|
|
extern const tvi_info_t tvi_info_dummy;
|
|
|
|
extern const tvi_info_t tvi_info_dshow;
|
|
|
|
extern const tvi_info_t tvi_info_v4l;
|
|
|
|
extern const tvi_info_t tvi_info_v4l2;
|
|
|
|
extern const tvi_info_t tvi_info_bsdbt848;
|
2007-03-01 18:38:00 +00:00
|
|
|
|
2007-09-10 17:09:35 +00:00
|
|
|
/** List of drivers in autodetection order */
|
2007-03-01 18:38:00 +00:00
|
|
|
static const tvi_info_t* tvi_driver_list[]={
|
2008-08-03 15:21:40 +00:00
|
|
|
#ifdef CONFIG_TV_V4L2
|
2007-03-01 18:38:00 +00:00
|
|
|
&tvi_info_v4l2,
|
|
|
|
#endif
|
2008-08-03 15:21:40 +00:00
|
|
|
#ifdef CONFIG_TV_V4L1
|
2007-09-10 17:09:35 +00:00
|
|
|
&tvi_info_v4l,
|
|
|
|
#endif
|
2008-08-03 15:21:40 +00:00
|
|
|
#ifdef CONFIG_TV_BSDBT848
|
2007-03-01 18:38:00 +00:00
|
|
|
&tvi_info_bsdbt848,
|
2007-10-13 17:14:39 +00:00
|
|
|
#endif
|
2008-08-03 15:21:40 +00:00
|
|
|
#ifdef CONFIG_TV_DSHOW
|
2007-10-13 17:14:39 +00:00
|
|
|
&tvi_info_dshow,
|
2007-03-01 18:38:00 +00:00
|
|
|
#endif
|
2007-09-10 17:09:35 +00:00
|
|
|
&tvi_info_dummy,
|
2007-03-01 18:38:00 +00:00
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
2007-08-23 16:09:30 +00:00
|
|
|
void tv_start_scan(tvi_handle_t *tvh, int start)
|
|
|
|
{
|
|
|
|
mp_msg(MSGT_TV,MSGL_INFO,"start scan\n");
|
|
|
|
tvh->tv_param->scan=start?1:0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void tv_scan(tvi_handle_t *tvh)
|
|
|
|
{
|
|
|
|
unsigned int now;
|
|
|
|
struct CHANLIST cl;
|
|
|
|
tv_channels_t *tv_channel_tmp=NULL;
|
|
|
|
tv_channels_t *tv_channel_add=NULL;
|
|
|
|
tv_scan_t* scan;
|
|
|
|
int found=0, index=1;
|
2007-10-14 04:56:01 +00:00
|
|
|
|
2007-10-15 17:46:17 +00:00
|
|
|
//Channel scanner without tuner is useless and causes crash due to uninitialized chanlist_s
|
|
|
|
if (tvh->functions->control(tvh->priv, TVI_CONTROL_IS_TUNER, 0) != TVI_CONTROL_TRUE)
|
|
|
|
{
|
2009-07-06 22:15:02 +00:00
|
|
|
mp_tmsg(MSGT_TV, MSGL_WARN, "Channel scanner is not available without tuner\n");
|
2007-10-15 17:46:17 +00:00
|
|
|
tvh->tv_param->scan=0;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-08-23 16:09:30 +00:00
|
|
|
scan = tvh->scan;
|
|
|
|
now=GetTimer();
|
|
|
|
if (!scan) {
|
|
|
|
scan=calloc(1,sizeof(tv_scan_t));
|
|
|
|
tvh->scan=scan;
|
|
|
|
cl = tvh->chanlist_s[scan->channel_num];
|
|
|
|
tv_set_freq(tvh, (unsigned long)(((float)cl.freq/1000)*16));
|
|
|
|
scan->scan_timer=now+1e6*tvh->tv_param->scan_period;
|
|
|
|
}
|
|
|
|
if(scan->scan_timer>now)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (tv_get_signal(tvh)>tvh->tv_param->scan_threshold) {
|
|
|
|
cl = tvh->chanlist_s[scan->channel_num];
|
|
|
|
tv_channel_tmp=tv_channel_list;
|
|
|
|
while (tv_channel_tmp) {
|
|
|
|
index++;
|
|
|
|
if (cl.freq==tv_channel_tmp->freq){
|
|
|
|
found=1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
tv_channel_add=tv_channel_tmp;
|
|
|
|
tv_channel_tmp=tv_channel_tmp->next;
|
|
|
|
}
|
|
|
|
if (!found) {
|
|
|
|
mp_msg(MSGT_TV, MSGL_INFO, "Found new channel: %s (#%d). \n",cl.name,index);
|
|
|
|
scan->new_channels++;
|
|
|
|
tv_channel_tmp = malloc(sizeof(tv_channels_t));
|
|
|
|
tv_channel_tmp->index=index;
|
|
|
|
tv_channel_tmp->next=NULL;
|
|
|
|
tv_channel_tmp->prev=tv_channel_add;
|
|
|
|
tv_channel_tmp->freq=cl.freq;
|
|
|
|
snprintf(tv_channel_tmp->name,sizeof(tv_channel_tmp->name),"ch%d",index);
|
|
|
|
strncpy(tv_channel_tmp->number, cl.name, 5);
|
|
|
|
tv_channel_tmp->number[4]='\0';
|
|
|
|
if (!tv_channel_list)
|
|
|
|
tv_channel_list=tv_channel_tmp;
|
|
|
|
else {
|
|
|
|
tv_channel_add->next=tv_channel_tmp;
|
|
|
|
tv_channel_list->prev=tv_channel_tmp;
|
|
|
|
}
|
|
|
|
}else
|
|
|
|
mp_msg(MSGT_TV, MSGL_INFO, "Found existing channel: %s-%s.\n",
|
|
|
|
tv_channel_tmp->number,tv_channel_tmp->name);
|
|
|
|
}
|
|
|
|
scan->channel_num++;
|
|
|
|
scan->scan_timer=now+1e6*tvh->tv_param->scan_period;
|
|
|
|
if (scan->channel_num>=chanlists[tvh->chanlist].count) {
|
|
|
|
tvh->tv_param->scan=0;
|
|
|
|
mp_msg(MSGT_TV, MSGL_INFO, "TV scan end. Found %d new channels.\n", scan->new_channels);
|
|
|
|
tv_channel_tmp=tv_channel_list;
|
|
|
|
if(tv_channel_tmp){
|
|
|
|
mp_msg(MSGT_TV,MSGL_INFO,"channels=");
|
|
|
|
while(tv_channel_tmp){
|
|
|
|
mp_msg(MSGT_TV,MSGL_INFO,"%s-%s",tv_channel_tmp->number,tv_channel_tmp->name);
|
|
|
|
if(tv_channel_tmp->next)
|
|
|
|
mp_msg(MSGT_TV,MSGL_INFO,",");
|
|
|
|
tv_channel_tmp=tv_channel_tmp->next;
|
|
|
|
}
|
2007-11-26 10:04:18 +00:00
|
|
|
mp_msg(MSGT_TV, MSGL_INFO, "\n");
|
2007-08-23 16:09:30 +00:00
|
|
|
}
|
|
|
|
if (!tv_channel_current) tv_channel_current=tv_channel_list;
|
|
|
|
if (tv_channel_current)
|
|
|
|
tv_set_freq(tvh, (unsigned long)(((float)tv_channel_current->freq/1000)*16));
|
|
|
|
free(tvh->scan);
|
|
|
|
tvh->scan=NULL;
|
|
|
|
}else{
|
|
|
|
cl = tvh->chanlist_s[scan->channel_num];
|
|
|
|
tv_set_freq(tvh, (unsigned long)(((float)cl.freq/1000)*16));
|
|
|
|
mp_msg(MSGT_TV, MSGL_INFO, "Trying: %s (%.2f). \n",cl.name,1e-3*cl.freq);
|
|
|
|
}
|
|
|
|
}
|
2007-03-01 18:38:00 +00:00
|
|
|
|
2001-11-09 23:46:06 +00:00
|
|
|
/* ================== DEMUX_TV ===================== */
|
|
|
|
/*
|
|
|
|
Return value:
|
|
|
|
0 = EOF(?) or no stream
|
|
|
|
1 = successfully read a packet
|
|
|
|
*/
|
|
|
|
/* fill demux->video and demux->audio */
|
2002-03-15 16:07:06 +00:00
|
|
|
|
2005-08-05 19:57:47 +00:00
|
|
|
static int demux_tv_fill_buffer(demuxer_t *demux, demux_stream_t *ds)
|
2001-11-09 23:46:06 +00:00
|
|
|
{
|
2002-09-15 20:51:55 +00:00
|
|
|
tvi_handle_t *tvh=(tvi_handle_t*)(demux->priv);
|
2001-11-11 02:04:41 +00:00
|
|
|
demux_packet_t* dp;
|
2003-04-18 18:36:22 +00:00
|
|
|
unsigned int len=0;
|
2007-04-13 14:34:38 +00:00
|
|
|
|
2002-03-15 16:07:06 +00:00
|
|
|
/* ================== ADD AUDIO PACKET =================== */
|
2001-11-09 23:46:06 +00:00
|
|
|
|
2007-10-14 04:56:01 +00:00
|
|
|
if (ds==demux->audio && tvh->tv_param->noaudio == 0 &&
|
|
|
|
tvh->functions->control(tvh->priv,
|
2002-03-15 16:07:06 +00:00
|
|
|
TVI_CONTROL_IS_AUDIO, 0) == TVI_CONTROL_TRUE)
|
|
|
|
{
|
|
|
|
len = tvh->functions->get_audio_framesize(tvh->priv);
|
2001-11-10 23:32:10 +00:00
|
|
|
|
2002-04-12 10:40:38 +00:00
|
|
|
dp=new_demux_packet(len);
|
2004-03-17 03:53:02 +00:00
|
|
|
dp->flags|=1; /* Keyframe */
|
2002-04-12 10:40:38 +00:00
|
|
|
dp->pts=tvh->functions->grab_audio_frame(tvh->priv, dp->buffer,len);
|
|
|
|
ds_add_packet(demux->audio,dp);
|
2002-03-15 16:07:06 +00:00
|
|
|
}
|
2001-11-10 23:32:10 +00:00
|
|
|
|
2001-11-09 23:46:06 +00:00
|
|
|
/* ================== ADD VIDEO PACKET =================== */
|
|
|
|
|
2007-10-14 04:56:01 +00:00
|
|
|
if (ds==demux->video && tvh->functions->control(tvh->priv,
|
2002-03-15 16:07:06 +00:00
|
|
|
TVI_CONTROL_IS_VIDEO, 0) == TVI_CONTROL_TRUE)
|
|
|
|
{
|
2002-04-12 10:40:38 +00:00
|
|
|
len = tvh->functions->get_video_framesize(tvh->priv);
|
|
|
|
dp=new_demux_packet(len);
|
2004-03-17 03:53:02 +00:00
|
|
|
dp->flags|=1; /* Keyframe */
|
2002-04-12 10:40:38 +00:00
|
|
|
dp->pts=tvh->functions->grab_video_frame(tvh->priv, dp->buffer, len);
|
|
|
|
ds_add_packet(demux->video,dp);
|
|
|
|
}
|
2001-11-09 23:46:06 +00:00
|
|
|
|
2007-08-23 16:09:30 +00:00
|
|
|
if (tvh->tv_param->scan) tv_scan(tvh);
|
2001-11-09 23:46:06 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2004-11-19 13:04:24 +00:00
|
|
|
static int norm_from_string(tvi_handle_t *tvh, char* norm)
|
2003-08-04 09:13:10 +00:00
|
|
|
{
|
2008-01-13 11:59:50 +00:00
|
|
|
const tvi_functions_t *funcs = tvh->functions;
|
2007-10-14 06:28:51 +00:00
|
|
|
char str[20];
|
2007-10-14 05:18:32 +00:00
|
|
|
int ret;
|
|
|
|
|
|
|
|
strncpy(str, norm, sizeof(str)-1);
|
|
|
|
str[sizeof(str)-1] = '\0';
|
|
|
|
ret=funcs->control(tvh->priv, TVI_CONTROL_SPC_GET_NORMID, str);
|
|
|
|
|
|
|
|
if(ret==TVI_CONTROL_TRUE)
|
|
|
|
return *(int *)str;
|
|
|
|
|
|
|
|
if(ret!=TVI_CONTROL_UNKNOWN)
|
|
|
|
{
|
2009-07-06 22:15:02 +00:00
|
|
|
mp_tmsg(MSGT_TV, MSGL_WARN, "tv.c: norm_from_string(%s): Bogus norm parameter, setting %s.\n", norm,"default");
|
2007-10-14 05:18:32 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2007-10-14 05:15:51 +00:00
|
|
|
|
2003-08-04 09:13:10 +00:00
|
|
|
if (!strcasecmp(norm, "pal"))
|
2007-10-14 05:18:32 +00:00
|
|
|
return TV_NORM_PAL;
|
2003-08-04 09:13:10 +00:00
|
|
|
else if (!strcasecmp(norm, "ntsc"))
|
2007-10-14 05:18:32 +00:00
|
|
|
return TV_NORM_NTSC;
|
2003-08-04 09:13:10 +00:00
|
|
|
else if (!strcasecmp(norm, "secam"))
|
2007-10-14 05:18:32 +00:00
|
|
|
return TV_NORM_SECAM;
|
2003-08-04 09:13:10 +00:00
|
|
|
else if (!strcasecmp(norm, "palnc"))
|
2007-10-14 05:18:32 +00:00
|
|
|
return TV_NORM_PALNC;
|
2003-08-04 09:13:10 +00:00
|
|
|
else if (!strcasecmp(norm, "palm"))
|
2007-10-14 05:18:32 +00:00
|
|
|
return TV_NORM_PALM;
|
2003-08-04 09:13:10 +00:00
|
|
|
else if (!strcasecmp(norm, "paln"))
|
2007-10-14 05:18:32 +00:00
|
|
|
return TV_NORM_PALN;
|
2003-08-04 09:13:10 +00:00
|
|
|
else if (!strcasecmp(norm, "ntscjp"))
|
2007-10-14 05:18:32 +00:00
|
|
|
return TV_NORM_NTSCJP;
|
2003-08-04 09:13:10 +00:00
|
|
|
else {
|
2009-07-06 22:15:02 +00:00
|
|
|
mp_tmsg(MSGT_TV, MSGL_WARN, "tv.c: norm_from_string(%s): Bogus norm parameter, setting %s.\n", norm, "PAL");
|
2007-10-14 05:18:32 +00:00
|
|
|
return TV_NORM_PAL;
|
2003-08-04 09:13:10 +00:00
|
|
|
}
|
|
|
|
}
|
2002-11-06 23:54:29 +00:00
|
|
|
|
2007-08-28 14:36:13 +00:00
|
|
|
static void parse_channels(tvi_handle_t *tvh)
|
|
|
|
{
|
|
|
|
char** channels = tvh->tv_param->channels;
|
|
|
|
|
2009-07-06 22:15:02 +00:00
|
|
|
mp_tmsg(MSGT_TV, MSGL_INFO, "TV channel names detected.\n");
|
2007-08-28 14:36:13 +00:00
|
|
|
tv_channel_list = malloc(sizeof(tv_channels_t));
|
|
|
|
tv_channel_list->index=1;
|
|
|
|
tv_channel_list->next=NULL;
|
|
|
|
tv_channel_list->prev=NULL;
|
|
|
|
tv_channel_current = tv_channel_list;
|
2008-06-14 09:14:16 +00:00
|
|
|
tv_channel_current->norm = tvh->norm;
|
2007-08-28 14:36:13 +00:00
|
|
|
|
|
|
|
while (*channels) {
|
|
|
|
char* tmp = *(channels++);
|
|
|
|
char* sep = strchr(tmp,'-');
|
|
|
|
int i;
|
|
|
|
struct CHANLIST cl;
|
|
|
|
|
|
|
|
if (!sep) continue; // Wrong syntax, but mplayer should not crash
|
|
|
|
|
|
|
|
av_strlcpy(tv_channel_current->name, sep + 1,
|
|
|
|
sizeof(tv_channel_current->name));
|
|
|
|
sep[0] = '\0';
|
|
|
|
strncpy(tv_channel_current->number, tmp, 5);
|
|
|
|
tv_channel_current->number[4]='\0';
|
|
|
|
|
|
|
|
while ((sep=strchr(tv_channel_current->name, '_')))
|
|
|
|
sep[0] = ' ';
|
|
|
|
|
|
|
|
// if channel number is a number and larger than 1000 threat it as frequency
|
|
|
|
// tmp still contain pointer to null-terminated string with channel number here
|
2007-10-14 04:56:01 +00:00
|
|
|
if (atoi(tmp)>1000){
|
2007-08-28 14:36:13 +00:00
|
|
|
tv_channel_current->freq=atoi(tmp);
|
|
|
|
}else{
|
|
|
|
tv_channel_current->freq = 0;
|
|
|
|
for (i = 0; i < chanlists[tvh->chanlist].count; i++) {
|
|
|
|
cl = tvh->chanlist_s[i];
|
|
|
|
if (!strcasecmp(cl.name, tv_channel_current->number)) {
|
|
|
|
tv_channel_current->freq=cl.freq;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (tv_channel_current->freq == 0)
|
2009-07-06 22:15:02 +00:00
|
|
|
mp_tmsg(MSGT_TV, MSGL_ERR, "Couldn't find frequency for channel %s (%s)\n",
|
2007-08-28 14:36:13 +00:00
|
|
|
tv_channel_current->number, tv_channel_current->name);
|
|
|
|
else {
|
|
|
|
sep = strchr(tv_channel_current->name, '-');
|
|
|
|
if ( !sep ) sep = strchr(tv_channel_current->name, '+');
|
|
|
|
|
|
|
|
if ( sep ) {
|
|
|
|
i = atoi (sep+1);
|
|
|
|
if ( sep[0] == '+' ) tv_channel_current->freq += i * 100;
|
|
|
|
if ( sep[0] == '-' ) tv_channel_current->freq -= i * 100;
|
|
|
|
sep[0] = '\0';
|
|
|
|
}
|
2008-06-14 09:14:16 +00:00
|
|
|
|
|
|
|
sep = strchr(tv_channel_current->name, '=');
|
|
|
|
if ( sep ) {
|
|
|
|
tv_channel_current->norm = norm_from_string(tvh, sep+1);
|
|
|
|
sep[0] = '\0';
|
|
|
|
}
|
2007-08-28 14:36:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*mp_msg(MSGT_TV, MSGL_INFO, "-- Detected channel %s - %s (%5.3f)\n",
|
|
|
|
tv_channel_current->number, tv_channel_current->name,
|
|
|
|
(float)tv_channel_current->freq/1000);*/
|
|
|
|
|
|
|
|
tv_channel_current->next = malloc(sizeof(tv_channels_t));
|
|
|
|
tv_channel_current->next->index = tv_channel_current->index + 1;
|
|
|
|
tv_channel_current->next->prev = tv_channel_current;
|
|
|
|
tv_channel_current->next->next = NULL;
|
|
|
|
tv_channel_current = tv_channel_current->next;
|
2008-06-14 09:14:16 +00:00
|
|
|
tv_channel_current->norm = tvh->norm;
|
2007-08-28 14:36:13 +00:00
|
|
|
}
|
|
|
|
if (tv_channel_current->prev)
|
|
|
|
tv_channel_current->prev->next = NULL;
|
|
|
|
free(tv_channel_current);
|
|
|
|
}
|
2008-06-19 07:13:50 +00:00
|
|
|
|
|
|
|
int tv_set_norm(tvi_handle_t *tvh, char* norm)
|
|
|
|
{
|
|
|
|
tvh->norm = norm_from_string(tvh, norm);
|
|
|
|
|
2009-07-06 22:15:02 +00:00
|
|
|
mp_tmsg(MSGT_TV, MSGL_V, "Selected norm : %s\n", norm);
|
2008-06-19 07:13:50 +00:00
|
|
|
if (tvh->functions->control(tvh->priv, TVI_CONTROL_TUN_SET_NORM, &tvh->norm) != TVI_CONTROL_TRUE) {
|
2009-07-06 22:15:02 +00:00
|
|
|
mp_tmsg(MSGT_TV, MSGL_ERR, "Error: Cannot set norm!\n");
|
2008-06-19 07:13:50 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2009-11-07 12:31:05 +00:00
|
|
|
teletext_control(tvh->demuxer->teletext,TV_VBI_CONTROL_RESET,
|
|
|
|
&tvh->tv_param->teletext);
|
2008-06-19 07:13:50 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2008-08-12 10:58:29 +00:00
|
|
|
static int tv_set_norm_i(tvi_handle_t *tvh, int norm)
|
2008-06-19 07:13:50 +00:00
|
|
|
{
|
|
|
|
tvh->norm = norm;
|
|
|
|
|
2009-07-06 22:15:02 +00:00
|
|
|
mp_tmsg(MSGT_TV, MSGL_V, "Selected norm id: %d\n", norm);
|
2008-06-19 07:13:50 +00:00
|
|
|
if (tvh->functions->control(tvh->priv, TVI_CONTROL_TUN_SET_NORM, &tvh->norm) != TVI_CONTROL_TRUE) {
|
2009-07-06 22:15:02 +00:00
|
|
|
mp_tmsg(MSGT_TV, MSGL_ERR, "Error: Cannot set norm!\n");
|
2008-06-19 07:13:50 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-11-07 12:31:05 +00:00
|
|
|
teletext_control(tvh->demuxer->teletext,TV_VBI_CONTROL_RESET,
|
|
|
|
&tvh->tv_param->teletext);
|
2009-10-08 11:25:01 +00:00
|
|
|
return 1;
|
2008-06-19 07:13:50 +00:00
|
|
|
}
|
|
|
|
|
2002-09-15 20:51:55 +00:00
|
|
|
static int open_tv(tvi_handle_t *tvh)
|
2001-11-16 21:30:10 +00:00
|
|
|
{
|
2001-11-17 00:23:48 +00:00
|
|
|
int i;
|
2008-01-13 11:59:50 +00:00
|
|
|
const tvi_functions_t *funcs = tvh->functions;
|
2006-03-14 00:45:06 +00:00
|
|
|
int tv_fmt_list[] = {
|
|
|
|
IMGFMT_YV12,
|
|
|
|
IMGFMT_I420,
|
|
|
|
IMGFMT_UYVY,
|
|
|
|
IMGFMT_YUY2,
|
|
|
|
IMGFMT_RGB32,
|
|
|
|
IMGFMT_RGB24,
|
|
|
|
IMGFMT_RGB16,
|
|
|
|
IMGFMT_RGB15
|
|
|
|
};
|
2001-11-16 21:53:07 +00:00
|
|
|
|
2001-11-10 23:32:10 +00:00
|
|
|
if (funcs->control(tvh->priv, TVI_CONTROL_IS_VIDEO, 0) != TVI_CONTROL_TRUE)
|
|
|
|
{
|
2009-07-06 22:15:02 +00:00
|
|
|
mp_tmsg(MSGT_TV, MSGL_ERR, "Error: No video input present!\n");
|
2001-12-25 11:45:04 +00:00
|
|
|
return 0;
|
2001-11-10 23:32:10 +00:00
|
|
|
}
|
2001-11-09 23:46:06 +00:00
|
|
|
|
2007-07-29 10:22:39 +00:00
|
|
|
if (tvh->tv_param->outfmt == -1)
|
2006-03-14 00:45:06 +00:00
|
|
|
for (i = 0; i < sizeof (tv_fmt_list) / sizeof (*tv_fmt_list); i++)
|
|
|
|
{
|
2007-07-29 10:22:39 +00:00
|
|
|
tvh->tv_param->outfmt = tv_fmt_list[i];
|
2006-03-14 00:45:06 +00:00
|
|
|
if (funcs->control (tvh->priv, TVI_CONTROL_VID_SET_FORMAT,
|
2007-07-29 10:22:39 +00:00
|
|
|
&tvh->tv_param->outfmt) == TVI_CONTROL_TRUE)
|
2006-03-14 00:45:06 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-07-29 10:22:39 +00:00
|
|
|
switch(tvh->tv_param->outfmt)
|
2001-11-11 02:54:50 +00:00
|
|
|
{
|
2003-08-13 18:56:29 +00:00
|
|
|
case IMGFMT_YV12:
|
|
|
|
case IMGFMT_I420:
|
|
|
|
case IMGFMT_UYVY:
|
|
|
|
case IMGFMT_YUY2:
|
|
|
|
case IMGFMT_RGB32:
|
|
|
|
case IMGFMT_RGB24:
|
2005-05-12 15:31:37 +00:00
|
|
|
case IMGFMT_BGR32:
|
|
|
|
case IMGFMT_BGR24:
|
|
|
|
case IMGFMT_BGR16:
|
|
|
|
case IMGFMT_BGR15:
|
2003-08-13 18:56:29 +00:00
|
|
|
break;
|
|
|
|
default:
|
2009-07-06 22:15:02 +00:00
|
|
|
mp_tmsg(MSGT_TV, MSGL_ERR,
|
|
|
|
"==================================================================\n"\
|
|
|
|
" WARNING: UNTESTED OR UNKNOWN OUTPUT IMAGE FORMAT REQUESTED (0x%x)\n"\
|
|
|
|
" This may cause buggy playback or program crash! Bug reports will\n"\
|
|
|
|
" be ignored! You should try again with YV12 (which is the default\n"\
|
|
|
|
" colorspace) and read the documentation!\n"\
|
|
|
|
"==================================================================\n"
|
|
|
|
,tvh->tv_param->outfmt);
|
2001-11-11 02:54:50 +00:00
|
|
|
}
|
2007-07-29 10:22:39 +00:00
|
|
|
funcs->control(tvh->priv, TVI_CONTROL_VID_SET_FORMAT, &tvh->tv_param->outfmt);
|
2006-03-14 00:45:06 +00:00
|
|
|
}
|
2001-11-09 23:46:06 +00:00
|
|
|
|
2002-08-21 21:31:20 +00:00
|
|
|
/* set some params got from cmdline */
|
2007-07-29 10:22:39 +00:00
|
|
|
funcs->control(tvh->priv, TVI_CONTROL_SPC_SET_INPUT, &tvh->tv_param->input);
|
2002-08-21 21:31:20 +00:00
|
|
|
|
2008-08-03 15:21:40 +00:00
|
|
|
#if defined(CONFIG_TV_V4L2) || defined(CONFIG_TV_DSHOW)
|
2007-10-14 04:56:01 +00:00
|
|
|
if (0
|
2008-08-03 15:21:40 +00:00
|
|
|
#ifdef CONFIG_TV_V4L2
|
2007-10-13 17:14:39 +00:00
|
|
|
|| (!strcmp(tvh->tv_param->driver, "v4l2") && tvh->tv_param->normid >= 0)
|
|
|
|
#endif
|
2008-08-03 15:21:40 +00:00
|
|
|
#ifdef CONFIG_TV_DSHOW
|
2007-10-13 17:14:39 +00:00
|
|
|
|| (!strcmp(tvh->tv_param->driver, "dshow") && tvh->tv_param->normid >= 0)
|
|
|
|
#endif
|
2008-06-14 09:14:16 +00:00
|
|
|
)
|
|
|
|
tv_set_norm_i(tvh, tvh->tv_param->normid);
|
|
|
|
else
|
2003-08-07 12:24:35 +00:00
|
|
|
#endif
|
2007-10-14 05:56:17 +00:00
|
|
|
tv_set_norm(tvh,tvh->tv_param->norm);
|
2003-03-19 16:26:58 +00:00
|
|
|
|
2008-08-03 15:21:40 +00:00
|
|
|
#ifdef CONFIG_TV_V4L1
|
2007-07-29 10:22:39 +00:00
|
|
|
if ( tvh->tv_param->mjpeg )
|
2003-03-19 16:26:58 +00:00
|
|
|
{
|
|
|
|
/* set width to expected value */
|
2007-07-29 10:22:39 +00:00
|
|
|
if (tvh->tv_param->width == -1)
|
2003-03-19 16:26:58 +00:00
|
|
|
{
|
2007-07-29 10:22:39 +00:00
|
|
|
tvh->tv_param->width = 704/tvh->tv_param->decimation;
|
2003-03-19 16:26:58 +00:00
|
|
|
}
|
2007-07-29 10:22:39 +00:00
|
|
|
if (tvh->tv_param->height == -1)
|
2003-03-19 16:26:58 +00:00
|
|
|
{
|
|
|
|
if ( tvh->norm != TV_NORM_NTSC )
|
2007-10-14 04:56:01 +00:00
|
|
|
tvh->tv_param->height = 576/tvh->tv_param->decimation;
|
2003-03-19 16:26:58 +00:00
|
|
|
else
|
2007-10-14 04:56:01 +00:00
|
|
|
tvh->tv_param->height = 480/tvh->tv_param->decimation;
|
2003-03-19 16:26:58 +00:00
|
|
|
}
|
2009-07-05 23:41:23 +00:00
|
|
|
mp_tmsg(MSGT_TV, MSGL_INFO,
|
2010-03-07 16:33:01 +00:00
|
|
|
" MJP: width %d height %d\n", tvh->tv_param->width, tvh->tv_param->height);
|
2003-03-19 16:26:58 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2002-08-21 21:31:20 +00:00
|
|
|
/* limits on w&h are norm-dependent -- JM */
|
2009-03-16 17:12:29 +00:00
|
|
|
if (tvh->tv_param->width != -1 && tvh->tv_param->height != -1) {
|
|
|
|
// first tell the driver both width and height, some drivers do not support setting them independently.
|
|
|
|
int dim[2];
|
|
|
|
dim[0] = tvh->tv_param->width; dim[1] = tvh->tv_param->height;
|
|
|
|
funcs->control(tvh->priv, TVI_CONTROL_VID_SET_WIDTH_HEIGHT, dim);
|
|
|
|
}
|
2001-11-09 23:46:06 +00:00
|
|
|
/* set width */
|
2007-07-29 10:22:39 +00:00
|
|
|
if (tvh->tv_param->width != -1)
|
2001-11-09 23:46:06 +00:00
|
|
|
{
|
2007-07-29 10:22:39 +00:00
|
|
|
if (funcs->control(tvh->priv, TVI_CONTROL_VID_CHK_WIDTH, &tvh->tv_param->width) == TVI_CONTROL_TRUE)
|
|
|
|
funcs->control(tvh->priv, TVI_CONTROL_VID_SET_WIDTH, &tvh->tv_param->width);
|
2001-11-09 23:46:06 +00:00
|
|
|
else
|
|
|
|
{
|
2009-07-06 22:15:02 +00:00
|
|
|
mp_tmsg(MSGT_TV, MSGL_ERR, "Unable to set requested width: %d\n", tvh->tv_param->width);
|
2007-07-29 10:22:39 +00:00
|
|
|
funcs->control(tvh->priv, TVI_CONTROL_VID_GET_WIDTH, &tvh->tv_param->width);
|
2007-10-14 04:56:01 +00:00
|
|
|
}
|
2001-11-09 23:46:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* set height */
|
2007-07-29 10:22:39 +00:00
|
|
|
if (tvh->tv_param->height != -1)
|
2001-11-09 23:46:06 +00:00
|
|
|
{
|
2007-07-29 10:22:39 +00:00
|
|
|
if (funcs->control(tvh->priv, TVI_CONTROL_VID_CHK_HEIGHT, &tvh->tv_param->height) == TVI_CONTROL_TRUE)
|
|
|
|
funcs->control(tvh->priv, TVI_CONTROL_VID_SET_HEIGHT, &tvh->tv_param->height);
|
2001-11-09 23:46:06 +00:00
|
|
|
else
|
|
|
|
{
|
2009-07-06 22:15:02 +00:00
|
|
|
mp_tmsg(MSGT_TV, MSGL_ERR, "Unable to set requested height: %d\n", tvh->tv_param->height);
|
2007-07-29 10:22:39 +00:00
|
|
|
funcs->control(tvh->priv, TVI_CONTROL_VID_GET_HEIGHT, &tvh->tv_param->height);
|
2007-10-14 04:56:01 +00:00
|
|
|
}
|
2001-11-09 23:46:06 +00:00
|
|
|
}
|
2001-11-16 21:53:07 +00:00
|
|
|
|
2001-12-03 16:38:40 +00:00
|
|
|
if (funcs->control(tvh->priv, TVI_CONTROL_IS_TUNER, 0) != TVI_CONTROL_TRUE)
|
|
|
|
{
|
2009-07-06 22:15:02 +00:00
|
|
|
mp_tmsg(MSGT_TV, MSGL_WARN, "Selected input hasn't got a tuner!\n");
|
2002-04-12 10:40:38 +00:00
|
|
|
goto done;
|
2001-12-03 16:38:40 +00:00
|
|
|
}
|
|
|
|
|
2001-11-17 00:23:48 +00:00
|
|
|
/* select channel list */
|
|
|
|
for (i = 0; chanlists[i].name != NULL; i++)
|
|
|
|
{
|
2007-07-29 10:22:39 +00:00
|
|
|
if (!strcasecmp(chanlists[i].name, tvh->tv_param->chanlist))
|
2001-11-17 00:23:48 +00:00
|
|
|
{
|
|
|
|
tvh->chanlist = i;
|
|
|
|
tvh->chanlist_s = chanlists[i].list;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (tvh->chanlist == -1)
|
2009-07-06 22:15:02 +00:00
|
|
|
mp_tmsg(MSGT_TV, MSGL_WARN, "Unable to find selected channel list! (%s)\n",
|
2007-07-29 10:22:39 +00:00
|
|
|
tvh->tv_param->chanlist);
|
2001-12-03 16:38:40 +00:00
|
|
|
else
|
2009-07-06 22:15:02 +00:00
|
|
|
mp_tmsg(MSGT_TV, MSGL_V, "Selected channel list: %s (including %d channels)\n",
|
2001-12-03 16:38:40 +00:00
|
|
|
chanlists[tvh->chanlist].name, chanlists[tvh->chanlist].count);
|
2001-11-17 00:23:48 +00:00
|
|
|
|
2007-07-29 10:22:39 +00:00
|
|
|
if (tvh->tv_param->freq && tvh->tv_param->channel)
|
2001-12-03 16:38:40 +00:00
|
|
|
{
|
2009-07-06 22:15:02 +00:00
|
|
|
mp_tmsg(MSGT_TV, MSGL_WARN, "You can't set frequency and channel simultaneously!\n");
|
2002-04-12 10:40:38 +00:00
|
|
|
goto done;
|
2001-12-03 16:38:40 +00:00
|
|
|
}
|
|
|
|
|
2003-09-01 01:21:40 +00:00
|
|
|
/* Handle channel names */
|
2007-07-29 10:22:39 +00:00
|
|
|
if (tvh->tv_param->channels) {
|
2007-08-28 14:36:13 +00:00
|
|
|
parse_channels(tvh);
|
2007-10-14 04:56:01 +00:00
|
|
|
} else
|
2006-05-01 02:04:09 +00:00
|
|
|
tv_channel_last_real = malloc(5);
|
2002-12-28 22:57:39 +00:00
|
|
|
|
|
|
|
if (tv_channel_list) {
|
|
|
|
int i;
|
2003-04-28 16:11:42 +00:00
|
|
|
int channel = 0;
|
2007-07-29 10:22:39 +00:00
|
|
|
if (tvh->tv_param->channel)
|
2003-04-28 16:11:42 +00:00
|
|
|
{
|
2007-07-29 10:22:39 +00:00
|
|
|
if (isdigit(*tvh->tv_param->channel))
|
|
|
|
/* if tvh->tv_param->channel begins with a digit interpret it as a number */
|
|
|
|
channel = atoi(tvh->tv_param->channel);
|
2003-04-28 16:11:42 +00:00
|
|
|
else
|
|
|
|
{
|
2007-10-14 04:56:01 +00:00
|
|
|
/* if tvh->tv_param->channel does not begin with a digit
|
2007-07-29 10:22:39 +00:00
|
|
|
set the first channel that contains tvh->tv_param->channel in its name */
|
2003-04-28 16:11:42 +00:00
|
|
|
|
|
|
|
tv_channel_current = tv_channel_list;
|
|
|
|
while ( tv_channel_current ) {
|
2007-07-29 10:22:39 +00:00
|
|
|
if ( strstr(tv_channel_current->name, tvh->tv_param->channel) )
|
2003-04-28 16:11:42 +00:00
|
|
|
break;
|
|
|
|
tv_channel_current = tv_channel_current->next;
|
|
|
|
}
|
|
|
|
if ( !tv_channel_current ) tv_channel_current = tv_channel_list;
|
|
|
|
}
|
|
|
|
}
|
2002-12-28 22:57:39 +00:00
|
|
|
else
|
|
|
|
channel = 1;
|
|
|
|
|
2003-04-28 16:11:42 +00:00
|
|
|
if ( channel ) {
|
2002-12-28 22:57:39 +00:00
|
|
|
tv_channel_current = tv_channel_list;
|
|
|
|
for (i = 1; i < channel; i++)
|
|
|
|
if (tv_channel_current->next)
|
|
|
|
tv_channel_current = tv_channel_current->next;
|
2003-04-28 16:11:42 +00:00
|
|
|
}
|
|
|
|
|
2009-07-06 22:15:02 +00:00
|
|
|
mp_tmsg(MSGT_TV, MSGL_INFO, "Selected channel: %s - %s (freq: %.3f)\n", tv_channel_current->number,
|
2002-12-28 22:57:39 +00:00
|
|
|
tv_channel_current->name, (float)tv_channel_current->freq/1000);
|
2008-06-14 09:14:16 +00:00
|
|
|
tv_set_norm_i(tvh, tv_channel_current->norm);
|
2002-12-28 22:57:39 +00:00
|
|
|
tv_set_freq(tvh, (unsigned long)(((float)tv_channel_current->freq/1000)*16));
|
|
|
|
tv_channel_last = tv_channel_current;
|
|
|
|
} else {
|
2001-12-03 16:38:40 +00:00
|
|
|
/* we need to set frequency */
|
2007-07-29 10:22:39 +00:00
|
|
|
if (tvh->tv_param->freq)
|
2001-12-03 16:38:40 +00:00
|
|
|
{
|
2007-07-29 10:22:39 +00:00
|
|
|
unsigned long freq = atof(tvh->tv_param->freq)*16;
|
2001-12-03 16:38:40 +00:00
|
|
|
|
|
|
|
/* set freq in MHz */
|
|
|
|
funcs->control(tvh->priv, TVI_CONTROL_TUN_SET_FREQ, &freq);
|
|
|
|
|
|
|
|
funcs->control(tvh->priv, TVI_CONTROL_TUN_GET_FREQ, &freq);
|
2009-07-06 22:15:02 +00:00
|
|
|
mp_tmsg(MSGT_TV, MSGL_V, "Selected frequency: %lu (%.3f)\n",
|
2001-12-03 16:38:40 +00:00
|
|
|
freq, (float)freq/16);
|
|
|
|
}
|
2001-11-17 00:23:48 +00:00
|
|
|
|
2007-07-29 10:22:39 +00:00
|
|
|
if (tvh->tv_param->channel) {
|
2001-11-17 00:23:48 +00:00
|
|
|
struct CHANLIST cl;
|
2001-12-03 16:38:40 +00:00
|
|
|
|
2009-07-06 22:15:02 +00:00
|
|
|
mp_tmsg(MSGT_TV, MSGL_V, "Requested channel: %s\n", tvh->tv_param->channel);
|
2001-11-17 00:23:48 +00:00
|
|
|
for (i = 0; i < chanlists[tvh->chanlist].count; i++)
|
|
|
|
{
|
|
|
|
cl = tvh->chanlist_s[i];
|
2002-12-28 22:57:39 +00:00
|
|
|
// printf("count%d: name: %s, freq: %d\n",
|
|
|
|
// i, cl.name, cl.freq);
|
2007-07-29 10:22:39 +00:00
|
|
|
if (!strcasecmp(cl.name, tvh->tv_param->channel))
|
2001-11-17 00:23:48 +00:00
|
|
|
{
|
2002-12-28 22:57:39 +00:00
|
|
|
strcpy(tv_channel_last_real, cl.name);
|
2001-11-17 00:23:48 +00:00
|
|
|
tvh->channel = i;
|
2009-07-06 22:15:02 +00:00
|
|
|
mp_tmsg(MSGT_TV, MSGL_INFO, "Selected channel: %s (freq: %.3f)\n",
|
2001-11-17 00:23:48 +00:00
|
|
|
cl.name, (float)cl.freq/1000);
|
|
|
|
tv_set_freq(tvh, (unsigned long)(((float)cl.freq/1000)*16));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2002-12-28 22:57:39 +00:00
|
|
|
}
|
2007-10-14 04:56:01 +00:00
|
|
|
|
2002-10-19 20:55:06 +00:00
|
|
|
/* grep frequency in chanlist */
|
|
|
|
{
|
|
|
|
unsigned long i2;
|
|
|
|
int freq;
|
2007-10-14 04:56:01 +00:00
|
|
|
|
2002-10-19 20:55:06 +00:00
|
|
|
tv_get_freq(tvh, &i2);
|
2007-10-14 04:56:01 +00:00
|
|
|
|
2002-10-19 20:55:06 +00:00
|
|
|
freq = (int) (((float)(i2/16))*1000)+250;
|
2007-10-14 04:56:01 +00:00
|
|
|
|
2002-10-19 20:55:06 +00:00
|
|
|
for (i = 0; i < chanlists[tvh->chanlist].count; i++)
|
|
|
|
{
|
|
|
|
if (tvh->chanlist_s[i].freq == freq)
|
|
|
|
{
|
|
|
|
tvh->channel = i+1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2001-12-03 16:38:40 +00:00
|
|
|
|
2007-10-14 04:56:01 +00:00
|
|
|
done:
|
2001-11-16 21:53:07 +00:00
|
|
|
/* also start device! */
|
2002-04-12 10:40:38 +00:00
|
|
|
return 1;
|
2001-11-16 21:53:07 +00:00
|
|
|
}
|
|
|
|
|
2007-07-29 10:18:38 +00:00
|
|
|
static tvi_handle_t *tv_begin(tv_param_t* tv_param)
|
2007-07-29 03:33:39 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
tvi_handle_t* h;
|
2007-09-10 17:09:35 +00:00
|
|
|
if(tv_param->driver && !strcmp(tv_param->driver,"help")){
|
2009-07-06 22:15:02 +00:00
|
|
|
mp_tmsg(MSGT_TV,MSGL_INFO,"Available drivers:\n");
|
2007-07-29 03:33:39 +00:00
|
|
|
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++){
|
2007-09-10 17:09:35 +00:00
|
|
|
if (!tv_param->driver || !strcmp(tvi_driver_list[i]->short_name, tv_param->driver)){
|
2007-07-29 10:18:38 +00:00
|
|
|
h=tvi_driver_list[i]->tvi_init(tv_param);
|
2007-09-10 17:09:35 +00:00
|
|
|
//Requested driver initialization failed
|
|
|
|
if (!h && tv_param->driver)
|
|
|
|
return NULL;
|
|
|
|
//Driver initialization failed during autodetection process.
|
|
|
|
if (!h)
|
|
|
|
continue;
|
2007-07-29 03:33:39 +00:00
|
|
|
|
2007-07-29 10:18:38 +00:00
|
|
|
h->tv_param=tv_param;
|
2009-07-06 22:15:02 +00:00
|
|
|
mp_tmsg(MSGT_TV, MSGL_INFO, "Selected driver: %s\n name: %s\n author: %s\n comment: %s\n", tvi_driver_list[i]->short_name,
|
2007-07-29 03:33:39 +00:00
|
|
|
tvi_driver_list[i]->name,
|
|
|
|
tvi_driver_list[i]->author,
|
|
|
|
tvi_driver_list[i]->comment?tvi_driver_list[i]->comment:"");
|
2007-09-10 17:09:35 +00:00
|
|
|
tv_param->driver=strdup(tvi_driver_list[i]->short_name);
|
2007-07-29 03:33:39 +00:00
|
|
|
return h;
|
|
|
|
}
|
|
|
|
}
|
2007-10-14 04:56:01 +00:00
|
|
|
|
2007-09-10 17:09:35 +00:00
|
|
|
if(tv_param->driver)
|
2009-07-06 22:15:02 +00:00
|
|
|
mp_tmsg(MSGT_TV, MSGL_ERR, "No such driver: %s\n", tv_param->driver);
|
2007-09-10 17:09:35 +00:00
|
|
|
else
|
2009-07-06 22:15:02 +00:00
|
|
|
mp_tmsg(MSGT_TV, MSGL_ERR, "TV driver autodetection failed.\n");
|
2008-05-16 08:43:15 +00:00
|
|
|
return NULL;
|
2007-07-29 03:33:39 +00:00
|
|
|
}
|
|
|
|
|
2007-07-29 03:55:12 +00:00
|
|
|
static int tv_uninit(tvi_handle_t *tvh)
|
2007-07-29 03:38:01 +00:00
|
|
|
{
|
|
|
|
int res;
|
|
|
|
if(!tvh) return 1;
|
|
|
|
if (!tvh->priv) return 1;
|
|
|
|
res=tvh->functions->uninit(tvh->priv);
|
2007-11-05 16:33:29 +00:00
|
|
|
if(res) {
|
|
|
|
free(tvh->priv);
|
|
|
|
tvh->priv=NULL;
|
|
|
|
}
|
2007-07-29 03:38:01 +00:00
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2005-08-05 19:57:47 +00:00
|
|
|
static demuxer_t* demux_open_tv(demuxer_t *demuxer)
|
2001-11-16 21:53:07 +00:00
|
|
|
{
|
2002-09-15 20:51:55 +00:00
|
|
|
tvi_handle_t *tvh;
|
|
|
|
sh_video_t *sh_video;
|
2001-11-16 21:53:07 +00:00
|
|
|
sh_audio_t *sh_audio = NULL;
|
2008-01-13 11:59:50 +00:00
|
|
|
const tvi_functions_t *funcs;
|
2007-10-14 04:56:01 +00:00
|
|
|
|
2007-01-08 05:55:46 +00:00
|
|
|
demuxer->priv=NULL;
|
2007-07-29 10:18:38 +00:00
|
|
|
if(!(tvh=tv_begin(demuxer->stream->priv))) return NULL;
|
2007-03-01 18:38:00 +00:00
|
|
|
if (!tvh->functions->init(tvh->priv)) return NULL;
|
2007-07-29 17:55:28 +00:00
|
|
|
|
2009-11-07 12:31:05 +00:00
|
|
|
tvh->demuxer = demuxer;
|
|
|
|
tvh->functions->control(tvh->priv,TVI_CONTROL_VBI_INIT,
|
|
|
|
&(tvh->tv_param->teletext.device));
|
|
|
|
tvh->functions->control(tvh->priv,TVI_CONTROL_GET_VBI_PTR,
|
|
|
|
&demuxer->teletext);
|
2007-07-29 17:55:28 +00:00
|
|
|
|
2002-09-15 20:51:55 +00:00
|
|
|
if (!open_tv(tvh)){
|
|
|
|
tv_uninit(tvh);
|
2005-08-05 19:57:47 +00:00
|
|
|
return NULL;
|
2002-09-15 20:51:55 +00:00
|
|
|
}
|
|
|
|
funcs = tvh->functions;
|
|
|
|
demuxer->priv=tvh;
|
2007-10-14 04:56:01 +00:00
|
|
|
|
2001-11-16 21:53:07 +00:00
|
|
|
sh_video = new_sh_video(demuxer, 0);
|
|
|
|
|
|
|
|
/* get IMAGE FORMAT */
|
|
|
|
funcs->control(tvh->priv, TVI_CONTROL_VID_GET_FORMAT, &sh_video->format);
|
|
|
|
// if (IMGFMT_IS_RGB(sh_video->format) || IMGFMT_IS_BGR(sh_video->format))
|
2001-12-09 15:39:35 +00:00
|
|
|
// sh_video->format = 0x0;
|
2001-11-16 21:53:07 +00:00
|
|
|
|
|
|
|
/* set FPS and FRAMETIME */
|
2002-03-15 16:07:06 +00:00
|
|
|
|
2001-11-16 21:53:07 +00:00
|
|
|
if(!sh_video->fps)
|
|
|
|
{
|
2003-04-29 02:23:47 +00:00
|
|
|
float tmp;
|
2002-03-15 16:07:06 +00:00
|
|
|
if (funcs->control(tvh->priv, TVI_CONTROL_VID_GET_FPS, &tmp) != TVI_CONTROL_TRUE)
|
|
|
|
sh_video->fps = 25.0f; /* on PAL */
|
|
|
|
else sh_video->fps = tmp;
|
|
|
|
}
|
|
|
|
|
2007-07-29 10:22:39 +00:00
|
|
|
if (tvh->tv_param->fps != -1.0f)
|
|
|
|
sh_video->fps = tvh->tv_param->fps;
|
2002-03-15 16:07:06 +00:00
|
|
|
|
2001-11-16 21:53:07 +00:00
|
|
|
sh_video->frametime = 1.0f/sh_video->fps;
|
|
|
|
|
2002-04-12 10:40:38 +00:00
|
|
|
/* If playback only mode, go to immediate mode, fail silently */
|
2007-07-29 10:22:39 +00:00
|
|
|
if(tvh->tv_param->immediate == 1)
|
2002-04-12 10:40:38 +00:00
|
|
|
{
|
|
|
|
funcs->control(tvh->priv, TVI_CONTROL_IMMEDIATE, 0);
|
2007-10-14 04:56:01 +00:00
|
|
|
tvh->tv_param->noaudio = 1;
|
2002-04-12 10:40:38 +00:00
|
|
|
}
|
|
|
|
|
2003-01-05 14:58:05 +00:00
|
|
|
/* disable TV audio if -nosound is present */
|
|
|
|
if (!demuxer->audio || demuxer->audio->id == -2) {
|
2007-10-14 04:56:01 +00:00
|
|
|
tvh->tv_param->noaudio = 1;
|
2003-01-05 14:58:05 +00:00
|
|
|
}
|
|
|
|
|
2001-11-16 21:53:07 +00:00
|
|
|
/* set width */
|
|
|
|
funcs->control(tvh->priv, TVI_CONTROL_VID_GET_WIDTH, &sh_video->disp_w);
|
|
|
|
|
|
|
|
/* set height */
|
|
|
|
funcs->control(tvh->priv, TVI_CONTROL_VID_GET_HEIGHT, &sh_video->disp_h);
|
2001-11-10 23:32:10 +00:00
|
|
|
|
2001-11-09 23:46:06 +00:00
|
|
|
demuxer->video->sh = sh_video;
|
|
|
|
sh_video->ds = demuxer->video;
|
|
|
|
demuxer->video->id = 0;
|
2003-02-25 08:22:00 +00:00
|
|
|
demuxer->seekable = 0;
|
2001-11-09 23:46:06 +00:00
|
|
|
|
|
|
|
/* here comes audio init */
|
2007-07-29 10:22:39 +00:00
|
|
|
if (tvh->tv_param->noaudio == 0 && funcs->control(tvh->priv, TVI_CONTROL_IS_AUDIO, 0) == TVI_CONTROL_TRUE)
|
2001-11-10 23:32:10 +00:00
|
|
|
{
|
|
|
|
int audio_format;
|
2002-03-15 16:07:06 +00:00
|
|
|
int sh_audio_format;
|
2004-12-27 17:30:15 +00:00
|
|
|
char buf[128];
|
2001-11-10 23:32:10 +00:00
|
|
|
|
|
|
|
/* yeah, audio is present */
|
2002-04-12 10:40:38 +00:00
|
|
|
|
2007-10-14 04:56:01 +00:00
|
|
|
funcs->control(tvh->priv, TVI_CONTROL_AUD_SET_SAMPLERATE,
|
2007-07-29 10:22:39 +00:00
|
|
|
&tvh->tv_param->audiorate);
|
2002-04-12 10:40:38 +00:00
|
|
|
|
2001-11-10 23:32:10 +00:00
|
|
|
if (funcs->control(tvh->priv, TVI_CONTROL_AUD_GET_FORMAT, &audio_format) != TVI_CONTROL_TRUE)
|
|
|
|
goto no_audio;
|
2002-03-15 16:07:06 +00:00
|
|
|
|
2001-11-10 23:32:10 +00:00
|
|
|
switch(audio_format)
|
|
|
|
{
|
2004-12-27 17:30:15 +00:00
|
|
|
case AF_FORMAT_U8:
|
|
|
|
case AF_FORMAT_S8:
|
|
|
|
case AF_FORMAT_U16_LE:
|
|
|
|
case AF_FORMAT_U16_BE:
|
|
|
|
case AF_FORMAT_S16_LE:
|
|
|
|
case AF_FORMAT_S16_BE:
|
|
|
|
case AF_FORMAT_S32_LE:
|
|
|
|
case AF_FORMAT_S32_BE:
|
2002-03-15 16:07:06 +00:00
|
|
|
sh_audio_format = 0x1; /* PCM */
|
2001-11-10 23:32:10 +00:00
|
|
|
break;
|
2004-12-27 17:30:15 +00:00
|
|
|
case AF_FORMAT_IMA_ADPCM:
|
|
|
|
case AF_FORMAT_MU_LAW:
|
|
|
|
case AF_FORMAT_A_LAW:
|
|
|
|
case AF_FORMAT_MPEG2:
|
2001-11-10 23:32:10 +00:00
|
|
|
default:
|
2009-07-06 22:15:02 +00:00
|
|
|
mp_tmsg(MSGT_TV, MSGL_ERR, "Audio type '%s (%x)' unsupported!\n",
|
2004-12-27 19:43:13 +00:00
|
|
|
af_fmt2str(audio_format, buf, 128), audio_format);
|
2001-11-10 23:32:10 +00:00
|
|
|
goto no_audio;
|
|
|
|
}
|
2007-10-14 04:56:01 +00:00
|
|
|
|
2002-03-15 16:07:06 +00:00
|
|
|
sh_audio = new_sh_audio(demuxer, 0);
|
|
|
|
|
2007-10-14 04:56:01 +00:00
|
|
|
funcs->control(tvh->priv, TVI_CONTROL_AUD_GET_SAMPLERATE,
|
2002-03-15 16:07:06 +00:00
|
|
|
&sh_audio->samplerate);
|
2007-10-14 04:56:01 +00:00
|
|
|
funcs->control(tvh->priv, TVI_CONTROL_AUD_GET_SAMPLESIZE,
|
2002-03-15 16:07:06 +00:00
|
|
|
&sh_audio->samplesize);
|
2007-10-14 04:56:01 +00:00
|
|
|
funcs->control(tvh->priv, TVI_CONTROL_AUD_GET_CHANNELS,
|
2002-03-15 16:07:06 +00:00
|
|
|
&sh_audio->channels);
|
|
|
|
|
|
|
|
sh_audio->format = sh_audio_format;
|
|
|
|
sh_audio->sample_format = audio_format;
|
|
|
|
|
|
|
|
sh_audio->i_bps = sh_audio->o_bps =
|
2007-10-14 04:56:01 +00:00
|
|
|
sh_audio->samplerate * sh_audio->samplesize *
|
2002-03-15 16:07:06 +00:00
|
|
|
sh_audio->channels;
|
|
|
|
|
2002-04-12 10:40:38 +00:00
|
|
|
// emulate WF for win32 codecs:
|
2006-07-13 16:41:13 +00:00
|
|
|
sh_audio->wf = malloc(sizeof(WAVEFORMATEX));
|
2002-03-15 16:07:06 +00:00
|
|
|
sh_audio->wf->wFormatTag = sh_audio->format;
|
|
|
|
sh_audio->wf->nChannels = sh_audio->channels;
|
2002-04-12 10:40:38 +00:00
|
|
|
sh_audio->wf->wBitsPerSample = sh_audio->samplesize * 8;
|
2002-03-15 16:07:06 +00:00
|
|
|
sh_audio->wf->nSamplesPerSec = sh_audio->samplerate;
|
2002-04-12 10:40:38 +00:00
|
|
|
sh_audio->wf->nBlockAlign = sh_audio->samplesize * sh_audio->channels;
|
|
|
|
sh_audio->wf->nAvgBytesPerSec = sh_audio->i_bps;
|
|
|
|
|
2010-03-07 16:33:01 +00:00
|
|
|
mp_tmsg(MSGT_DECVIDEO, MSGL_V, " TV audio: %d channels, %d bits, %d Hz\n",
|
2002-04-12 10:40:38 +00:00
|
|
|
sh_audio->wf->nChannels, sh_audio->wf->wBitsPerSample,
|
|
|
|
sh_audio->wf->nSamplesPerSec);
|
2001-11-10 23:32:10 +00:00
|
|
|
|
|
|
|
demuxer->audio->sh = sh_audio;
|
|
|
|
sh_audio->ds = demuxer->audio;
|
|
|
|
demuxer->audio->id = 0;
|
|
|
|
}
|
|
|
|
no_audio:
|
|
|
|
|
2002-09-08 23:00:01 +00:00
|
|
|
if(!(funcs->start(tvh->priv))){
|
|
|
|
// start failed :(
|
|
|
|
tv_uninit(tvh);
|
2005-08-05 19:57:47 +00:00
|
|
|
return NULL;
|
2002-09-08 23:00:01 +00:00
|
|
|
}
|
2003-08-12 13:25:52 +00:00
|
|
|
|
|
|
|
/* set color eq */
|
2007-07-29 10:22:39 +00:00
|
|
|
tv_set_color_options(tvh, TV_COLOR_BRIGHTNESS, tvh->tv_param->brightness);
|
|
|
|
tv_set_color_options(tvh, TV_COLOR_HUE, tvh->tv_param->hue);
|
|
|
|
tv_set_color_options(tvh, TV_COLOR_SATURATION, tvh->tv_param->saturation);
|
|
|
|
tv_set_color_options(tvh, TV_COLOR_CONTRAST, tvh->tv_param->contrast);
|
2003-08-12 13:25:52 +00:00
|
|
|
|
2007-09-18 16:28:39 +00:00
|
|
|
if(tvh->tv_param->gain!=-1)
|
|
|
|
if(funcs->control(tvh->priv,TVI_CONTROL_VID_SET_GAIN,&tvh->tv_param->gain)!=TVI_CONTROL_TRUE)
|
|
|
|
mp_msg(MSGT_TV,MSGL_WARN,"Unable to set gain control!\n");
|
|
|
|
|
2009-11-07 12:31:05 +00:00
|
|
|
teletext_control(demuxer->teletext,TV_VBI_CONTROL_RESET,
|
|
|
|
&tvh->tv_param->teletext);
|
2007-09-13 17:13:27 +00:00
|
|
|
|
2005-08-05 19:57:47 +00:00
|
|
|
return demuxer;
|
2001-11-09 23:46:06 +00:00
|
|
|
}
|
|
|
|
|
2005-12-11 17:21:02 +00:00
|
|
|
static void demux_close_tv(demuxer_t *demuxer)
|
2002-08-21 21:31:20 +00:00
|
|
|
{
|
2002-09-15 20:51:55 +00:00
|
|
|
tvi_handle_t *tvh=(tvi_handle_t*)(demuxer->priv);
|
2007-01-08 05:55:46 +00:00
|
|
|
if (!tvh) return;
|
2007-11-05 16:33:29 +00:00
|
|
|
tv_uninit(tvh);
|
2007-11-05 16:34:15 +00:00
|
|
|
free(tvh);
|
2007-01-08 05:55:46 +00:00
|
|
|
demuxer->priv=NULL;
|
2009-11-10 11:24:29 +00:00
|
|
|
demuxer->teletext=NULL;
|
2002-08-21 21:31:20 +00:00
|
|
|
}
|
|
|
|
|
2001-11-16 22:59:07 +00:00
|
|
|
/* utilities for mplayer (not mencoder!!) */
|
|
|
|
int tv_set_color_options(tvi_handle_t *tvh, int opt, int value)
|
|
|
|
{
|
2008-01-13 11:59:50 +00:00
|
|
|
const tvi_functions_t *funcs = tvh->functions;
|
2001-11-16 22:59:07 +00:00
|
|
|
|
|
|
|
switch(opt)
|
|
|
|
{
|
|
|
|
case TV_COLOR_BRIGHTNESS:
|
2006-04-21 12:45:18 +00:00
|
|
|
return funcs->control(tvh->priv, TVI_CONTROL_VID_SET_BRIGHTNESS, &value);
|
2001-11-16 22:59:07 +00:00
|
|
|
case TV_COLOR_HUE:
|
2006-04-21 12:45:18 +00:00
|
|
|
return funcs->control(tvh->priv, TVI_CONTROL_VID_SET_HUE, &value);
|
2001-11-16 22:59:07 +00:00
|
|
|
case TV_COLOR_SATURATION:
|
2006-04-21 12:45:18 +00:00
|
|
|
return funcs->control(tvh->priv, TVI_CONTROL_VID_SET_SATURATION, &value);
|
2001-11-16 22:59:07 +00:00
|
|
|
case TV_COLOR_CONTRAST:
|
2006-04-21 12:45:18 +00:00
|
|
|
return funcs->control(tvh->priv, TVI_CONTROL_VID_SET_CONTRAST, &value);
|
2001-11-16 22:59:07 +00:00
|
|
|
default:
|
2009-07-06 22:15:02 +00:00
|
|
|
mp_tmsg(MSGT_TV, MSGL_WARN, "Unknown color option (%d) specified!\n", opt);
|
2001-11-16 22:59:07 +00:00
|
|
|
}
|
2007-10-14 04:56:01 +00:00
|
|
|
|
2008-05-16 08:43:15 +00:00
|
|
|
return TVI_CONTROL_UNKNOWN;
|
2006-04-21 12:45:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int tv_get_color_options(tvi_handle_t *tvh, int opt, int* value)
|
|
|
|
{
|
2008-01-13 11:59:50 +00:00
|
|
|
const tvi_functions_t *funcs = tvh->functions;
|
2006-04-21 12:45:18 +00:00
|
|
|
|
|
|
|
switch(opt)
|
|
|
|
{
|
|
|
|
case TV_COLOR_BRIGHTNESS:
|
|
|
|
return funcs->control(tvh->priv, TVI_CONTROL_VID_GET_BRIGHTNESS, value);
|
|
|
|
case TV_COLOR_HUE:
|
|
|
|
return funcs->control(tvh->priv, TVI_CONTROL_VID_GET_HUE, value);
|
|
|
|
case TV_COLOR_SATURATION:
|
|
|
|
return funcs->control(tvh->priv, TVI_CONTROL_VID_GET_SATURATION, value);
|
|
|
|
case TV_COLOR_CONTRAST:
|
|
|
|
return funcs->control(tvh->priv, TVI_CONTROL_VID_GET_CONTRAST, value);
|
|
|
|
default:
|
2009-07-06 22:15:02 +00:00
|
|
|
mp_tmsg(MSGT_TV, MSGL_WARN, "Unknown color option (%d) specified!\n", opt);
|
2006-04-21 12:45:18 +00:00
|
|
|
}
|
2007-10-14 04:56:01 +00:00
|
|
|
|
2008-05-16 08:43:15 +00:00
|
|
|
return TVI_CONTROL_UNKNOWN;
|
2001-11-16 22:59:07 +00:00
|
|
|
}
|
2001-11-17 00:23:48 +00:00
|
|
|
|
2002-10-19 20:55:06 +00:00
|
|
|
int tv_get_freq(tvi_handle_t *tvh, unsigned long *freq)
|
|
|
|
{
|
|
|
|
if (tvh->functions->control(tvh->priv, TVI_CONTROL_IS_TUNER, 0) == TVI_CONTROL_TRUE)
|
|
|
|
{
|
|
|
|
tvh->functions->control(tvh->priv, TVI_CONTROL_TUN_GET_FREQ, freq);
|
2009-07-06 22:15:02 +00:00
|
|
|
mp_tmsg(MSGT_TV, MSGL_V, "Current frequency: %lu (%.3f)\n",
|
2002-10-19 20:55:06 +00:00
|
|
|
*freq, (float)*freq/16);
|
|
|
|
}
|
2008-05-16 08:43:15 +00:00
|
|
|
return 1;
|
2002-10-19 20:55:06 +00:00
|
|
|
}
|
|
|
|
|
2001-11-17 00:23:48 +00:00
|
|
|
int tv_set_freq(tvi_handle_t *tvh, unsigned long freq)
|
|
|
|
{
|
|
|
|
if (tvh->functions->control(tvh->priv, TVI_CONTROL_IS_TUNER, 0) == TVI_CONTROL_TRUE)
|
|
|
|
{
|
2007-07-29 10:22:39 +00:00
|
|
|
// unsigned long freq = atof(tvh->tv_param->freq)*16;
|
2001-11-17 00:23:48 +00:00
|
|
|
|
|
|
|
/* set freq in MHz */
|
|
|
|
tvh->functions->control(tvh->priv, TVI_CONTROL_TUN_SET_FREQ, &freq);
|
|
|
|
|
|
|
|
tvh->functions->control(tvh->priv, TVI_CONTROL_TUN_GET_FREQ, &freq);
|
2009-07-06 22:15:02 +00:00
|
|
|
mp_tmsg(MSGT_TV, MSGL_V, "Current frequency: %lu (%.3f)\n",
|
2001-11-17 00:23:48 +00:00
|
|
|
freq, (float)freq/16);
|
|
|
|
}
|
2009-11-07 12:31:05 +00:00
|
|
|
teletext_control(tvh->demuxer->teletext,TV_VBI_CONTROL_RESET,
|
|
|
|
&tvh->tv_param->teletext);
|
2008-05-16 08:43:15 +00:00
|
|
|
return 1;
|
2001-11-17 00:23:48 +00:00
|
|
|
}
|
|
|
|
|
2007-08-23 16:09:30 +00:00
|
|
|
int tv_get_signal(tvi_handle_t *tvh)
|
|
|
|
{
|
|
|
|
int signal=0;
|
|
|
|
if (tvh->functions->control(tvh->priv, TVI_CONTROL_IS_TUNER, 0) != TVI_CONTROL_TRUE ||
|
|
|
|
tvh->functions->control(tvh->priv, TVI_CONTROL_TUN_GET_SIGNAL, &signal)!=TVI_CONTROL_TRUE)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
return signal;
|
|
|
|
}
|
|
|
|
|
2007-03-17 11:51:17 +00:00
|
|
|
/*****************************************************************
|
|
|
|
* \brief tune current frequency by step_interval value
|
|
|
|
* \parameter step_interval increment value in 1/16 MHz
|
|
|
|
* \note frequency is rounded to 1/16 MHz value
|
|
|
|
* \return 1
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
int tv_step_freq(tvi_handle_t* tvh, float step_interval){
|
|
|
|
unsigned long frequency;
|
|
|
|
|
2007-08-23 16:09:30 +00:00
|
|
|
tvh->tv_param->scan=0;
|
2007-03-17 11:51:17 +00:00
|
|
|
tv_get_freq(tvh,&frequency);
|
|
|
|
frequency+=step_interval;
|
|
|
|
return tv_set_freq(tvh,frequency);
|
|
|
|
}
|
|
|
|
|
2002-12-28 22:57:39 +00:00
|
|
|
int tv_step_channel_real(tvi_handle_t *tvh, int direction)
|
2001-11-17 00:23:48 +00:00
|
|
|
{
|
|
|
|
struct CHANLIST cl;
|
|
|
|
|
2007-08-23 16:09:30 +00:00
|
|
|
tvh->tv_param->scan=0;
|
2001-11-17 00:23:48 +00:00
|
|
|
if (direction == TV_CHANNEL_LOWER)
|
|
|
|
{
|
|
|
|
if (tvh->channel-1 >= 0)
|
|
|
|
{
|
2002-12-28 22:57:39 +00:00
|
|
|
strcpy(tv_channel_last_real, tvh->chanlist_s[tvh->channel].name);
|
2002-05-01 17:07:50 +00:00
|
|
|
cl = tvh->chanlist_s[--tvh->channel];
|
2009-07-06 22:15:02 +00:00
|
|
|
mp_tmsg(MSGT_TV, MSGL_INFO, "Selected channel: %s (freq: %.3f)\n",
|
2001-11-17 00:23:48 +00:00
|
|
|
cl.name, (float)cl.freq/1000);
|
|
|
|
tv_set_freq(tvh, (unsigned long)(((float)cl.freq/1000)*16));
|
2007-10-14 04:56:01 +00:00
|
|
|
}
|
2001-11-17 00:23:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (direction == TV_CHANNEL_HIGHER)
|
|
|
|
{
|
2002-01-18 19:37:12 +00:00
|
|
|
if (tvh->channel+1 < chanlists[tvh->chanlist].count)
|
2001-11-17 00:23:48 +00:00
|
|
|
{
|
2002-12-28 22:57:39 +00:00
|
|
|
strcpy(tv_channel_last_real, tvh->chanlist_s[tvh->channel].name);
|
2002-05-01 17:07:50 +00:00
|
|
|
cl = tvh->chanlist_s[++tvh->channel];
|
2009-07-06 22:15:02 +00:00
|
|
|
mp_tmsg(MSGT_TV, MSGL_INFO, "Selected channel: %s (freq: %.3f)\n",
|
2001-11-17 00:23:48 +00:00
|
|
|
cl.name, (float)cl.freq/1000);
|
|
|
|
tv_set_freq(tvh, (unsigned long)(((float)cl.freq/1000)*16));
|
2007-10-14 04:56:01 +00:00
|
|
|
}
|
2001-11-17 00:23:48 +00:00
|
|
|
}
|
2008-05-16 08:43:15 +00:00
|
|
|
return 1;
|
2001-11-17 00:23:48 +00:00
|
|
|
}
|
|
|
|
|
2002-12-28 22:57:39 +00:00
|
|
|
int tv_step_channel(tvi_handle_t *tvh, int direction) {
|
2007-08-23 16:09:30 +00:00
|
|
|
tvh->tv_param->scan=0;
|
2002-12-28 22:57:39 +00:00
|
|
|
if (tv_channel_list) {
|
|
|
|
if (direction == TV_CHANNEL_HIGHER) {
|
2005-09-12 22:48:14 +00:00
|
|
|
tv_channel_last = tv_channel_current;
|
|
|
|
if (tv_channel_current->next)
|
2002-12-28 22:57:39 +00:00
|
|
|
tv_channel_current = tv_channel_current->next;
|
2005-09-12 22:48:14 +00:00
|
|
|
else
|
|
|
|
tv_channel_current = tv_channel_list;
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2008-06-14 09:14:16 +00:00
|
|
|
tv_set_norm_i(tvh, tv_channel_current->norm);
|
2002-12-28 22:57:39 +00:00
|
|
|
tv_set_freq(tvh, (unsigned long)(((float)tv_channel_current->freq/1000)*16));
|
2009-07-06 22:15:02 +00:00
|
|
|
mp_tmsg(MSGT_TV, MSGL_INFO, "Selected channel: %s - %s (freq: %.3f)\n",
|
2002-12-28 22:57:39 +00:00
|
|
|
tv_channel_current->number, tv_channel_current->name, (float)tv_channel_current->freq/1000);
|
|
|
|
}
|
|
|
|
if (direction == TV_CHANNEL_LOWER) {
|
2005-09-12 22:48:14 +00:00
|
|
|
tv_channel_last = tv_channel_current;
|
|
|
|
if (tv_channel_current->prev)
|
2002-12-28 22:57:39 +00:00
|
|
|
tv_channel_current = tv_channel_current->prev;
|
2005-09-12 22:48:14 +00:00
|
|
|
else
|
|
|
|
while (tv_channel_current->next)
|
|
|
|
tv_channel_current = tv_channel_current->next;
|
2008-06-14 09:14:16 +00:00
|
|
|
tv_set_norm_i(tvh, tv_channel_current->norm);
|
2002-12-28 22:57:39 +00:00
|
|
|
tv_set_freq(tvh, (unsigned long)(((float)tv_channel_current->freq/1000)*16));
|
2009-07-06 22:15:02 +00:00
|
|
|
mp_tmsg(MSGT_TV, MSGL_INFO, "Selected channel: %s - %s (freq: %.3f)\n",
|
2002-12-28 22:57:39 +00:00
|
|
|
tv_channel_current->number, tv_channel_current->name, (float)tv_channel_current->freq/1000);
|
|
|
|
}
|
|
|
|
} else tv_step_channel_real(tvh, direction);
|
2008-05-16 08:43:15 +00:00
|
|
|
return 1;
|
2002-12-28 22:57:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int tv_set_channel_real(tvi_handle_t *tvh, char *channel) {
|
2002-12-19 10:09:43 +00:00
|
|
|
int i;
|
|
|
|
struct CHANLIST cl;
|
|
|
|
|
2007-08-23 16:09:30 +00:00
|
|
|
tvh->tv_param->scan=0;
|
2002-12-28 22:57:39 +00:00
|
|
|
strcpy(tv_channel_last_real, tvh->chanlist_s[tvh->channel].name);
|
2002-12-19 10:09:43 +00:00
|
|
|
for (i = 0; i < chanlists[tvh->chanlist].count; i++)
|
|
|
|
{
|
|
|
|
cl = tvh->chanlist_s[i];
|
|
|
|
// printf("count%d: name: %s, freq: %d\n",
|
|
|
|
// i, cl.name, cl.freq);
|
|
|
|
if (!strcasecmp(cl.name, channel))
|
|
|
|
{
|
|
|
|
tvh->channel = i;
|
2009-07-06 22:15:02 +00:00
|
|
|
mp_tmsg(MSGT_TV, MSGL_INFO, "Selected channel: %s (freq: %.3f)\n",
|
2002-12-19 10:09:43 +00:00
|
|
|
cl.name, (float)cl.freq/1000);
|
|
|
|
tv_set_freq(tvh, (unsigned long)(((float)cl.freq/1000)*16));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2008-05-16 08:43:15 +00:00
|
|
|
return 1;
|
2002-12-28 22:57:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int tv_set_channel(tvi_handle_t *tvh, char *channel) {
|
|
|
|
int i, channel_int;
|
|
|
|
|
2007-08-23 16:09:30 +00:00
|
|
|
tvh->tv_param->scan=0;
|
2002-12-28 22:57:39 +00:00
|
|
|
if (tv_channel_list) {
|
|
|
|
tv_channel_last = tv_channel_current;
|
|
|
|
channel_int = atoi(channel);
|
|
|
|
tv_channel_current = tv_channel_list;
|
|
|
|
for (i = 1; i < channel_int; i++)
|
|
|
|
if (tv_channel_current->next)
|
|
|
|
tv_channel_current = tv_channel_current->next;
|
2009-07-06 22:15:02 +00:00
|
|
|
mp_tmsg(MSGT_TV, MSGL_INFO, "Selected channel: %s - %s (freq: %.3f)\n", tv_channel_current->number,
|
2002-12-28 22:57:39 +00:00
|
|
|
tv_channel_current->name, (float)tv_channel_current->freq/1000);
|
2008-06-14 09:14:16 +00:00
|
|
|
tv_set_norm_i(tvh, tv_channel_current->norm);
|
2002-12-28 22:57:39 +00:00
|
|
|
tv_set_freq(tvh, (unsigned long)(((float)tv_channel_current->freq/1000)*16));
|
|
|
|
} else tv_set_channel_real(tvh, channel);
|
2008-05-16 08:43:15 +00:00
|
|
|
return 1;
|
2002-12-28 22:57:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int tv_last_channel(tvi_handle_t *tvh) {
|
|
|
|
|
2007-08-23 16:09:30 +00:00
|
|
|
tvh->tv_param->scan=0;
|
2002-12-28 22:57:39 +00:00
|
|
|
if (tv_channel_list) {
|
|
|
|
tv_channels_t *tmp;
|
|
|
|
|
|
|
|
tmp = tv_channel_last;
|
|
|
|
tv_channel_last = tv_channel_current;
|
|
|
|
tv_channel_current = tmp;
|
|
|
|
|
2009-07-06 22:15:02 +00:00
|
|
|
mp_tmsg(MSGT_TV, MSGL_INFO, "Selected channel: %s - %s (freq: %.3f)\n", tv_channel_current->number,
|
2002-12-28 22:57:39 +00:00
|
|
|
tv_channel_current->name, (float)tv_channel_current->freq/1000);
|
2008-06-14 09:14:16 +00:00
|
|
|
tv_set_norm_i(tvh, tv_channel_current->norm);
|
2002-12-28 22:57:39 +00:00
|
|
|
tv_set_freq(tvh, (unsigned long)(((float)tv_channel_current->freq/1000)*16));
|
|
|
|
} else {
|
|
|
|
int i;
|
|
|
|
struct CHANLIST cl;
|
|
|
|
|
|
|
|
for (i = 0; i < chanlists[tvh->chanlist].count; i++)
|
|
|
|
{
|
|
|
|
cl = tvh->chanlist_s[i];
|
|
|
|
if (!strcasecmp(cl.name, tv_channel_last_real))
|
|
|
|
{
|
|
|
|
strcpy(tv_channel_last_real, tvh->chanlist_s[tvh->channel].name);
|
|
|
|
tvh->channel = i;
|
2009-07-06 22:15:02 +00:00
|
|
|
mp_tmsg(MSGT_TV, MSGL_INFO, "Selected channel: %s (freq: %.3f)\n",
|
2002-12-28 22:57:39 +00:00
|
|
|
cl.name, (float)cl.freq/1000);
|
|
|
|
tv_set_freq(tvh, (unsigned long)(((float)cl.freq/1000)*16));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2008-05-16 08:43:15 +00:00
|
|
|
return 1;
|
2002-12-19 10:09:43 +00:00
|
|
|
}
|
|
|
|
|
2001-11-17 00:23:48 +00:00
|
|
|
int tv_step_norm(tvi_handle_t *tvh)
|
|
|
|
{
|
2005-11-10 20:31:27 +00:00
|
|
|
tvh->norm++;
|
|
|
|
if (tvh->functions->control(tvh->priv, TVI_CONTROL_TUN_SET_NORM,
|
|
|
|
&tvh->norm) != TVI_CONTROL_TRUE) {
|
|
|
|
tvh->norm = 0;
|
|
|
|
if (tvh->functions->control(tvh->priv, TVI_CONTROL_TUN_SET_NORM,
|
|
|
|
&tvh->norm) != TVI_CONTROL_TRUE) {
|
2009-07-06 22:15:02 +00:00
|
|
|
mp_tmsg(MSGT_TV, MSGL_ERR, "Error: Cannot set norm!\n");
|
2005-11-10 20:31:27 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
2009-11-07 12:31:05 +00:00
|
|
|
teletext_control(tvh->demuxer->teletext,TV_VBI_CONTROL_RESET,
|
|
|
|
&tvh->tv_param->teletext);
|
2008-05-16 08:43:15 +00:00
|
|
|
return 1;
|
2001-11-17 00:23:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int tv_step_chanlist(tvi_handle_t *tvh)
|
|
|
|
{
|
2008-05-16 08:43:15 +00:00
|
|
|
return 1;
|
2001-11-17 00:23:48 +00:00
|
|
|
}
|
2003-08-04 09:13:10 +00:00
|
|
|
|
2005-08-05 19:57:47 +00:00
|
|
|
demuxer_desc_t demuxer_desc_tv = {
|
|
|
|
"Tv card demuxer",
|
|
|
|
"tv",
|
|
|
|
"TV",
|
|
|
|
"Alex Beregszaszi, Charles R. Henrich",
|
|
|
|
"?",
|
|
|
|
DEMUXER_TYPE_TV,
|
|
|
|
0, // no autodetect
|
|
|
|
NULL,
|
|
|
|
demux_tv_fill_buffer,
|
|
|
|
demux_open_tv,
|
|
|
|
demux_close_tv,
|
|
|
|
NULL,
|
|
|
|
NULL
|
|
|
|
};
|