2001-11-09 23:46:06 +00:00
|
|
|
/*
|
2001-12-03 16:38:40 +00:00
|
|
|
TV Interface for MPlayer
|
2001-11-09 23:46:06 +00:00
|
|
|
|
2001-12-03 16:38:40 +00:00
|
|
|
(C) Alex Beregszaszi <alex@naxine.org>
|
|
|
|
|
|
|
|
API idea based on libvo2
|
2001-11-09 23:46:06 +00:00
|
|
|
|
2002-03-15 16:07:06 +00:00
|
|
|
Feb 19, 2002: Significant rewrites by Charles R. Henrich (henrich@msu.edu)
|
2002-04-12 10:40:38 +00:00
|
|
|
to add support for audio, and bktr *BSD support.
|
2002-03-15 16:07:06 +00:00
|
|
|
|
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>
|
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
|
|
|
int tv_param_on = 0;
|
|
|
|
|
2001-11-09 23:46:06 +00:00
|
|
|
#ifdef USE_TV
|
|
|
|
#include "mp_msg.h"
|
|
|
|
#include "help_mp.h"
|
|
|
|
|
|
|
|
#include "stream.h"
|
|
|
|
#include "demuxer.h"
|
|
|
|
#include "stheader.h"
|
2001-11-11 13:47:42 +00:00
|
|
|
|
|
|
|
#include "../libao2/afmt.h"
|
2002-11-23 10:58:14 +00:00
|
|
|
#include "../libao2/audio_out.h"
|
2001-11-11 13:47:42 +00:00
|
|
|
#include "../libvo/img_format.h"
|
|
|
|
#include "../libvo/fastmemcpy.h"
|
|
|
|
|
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"
|
|
|
|
|
2001-11-09 23:46:06 +00:00
|
|
|
/* some default values */
|
2002-04-12 10:40:38 +00:00
|
|
|
int tv_param_audiorate = 44100;
|
2002-03-15 16:07:06 +00:00
|
|
|
int tv_param_noaudio = 0;
|
2002-04-12 10:40:38 +00:00
|
|
|
int tv_param_immediate = 0;
|
2001-11-11 15:45:23 +00:00
|
|
|
char *tv_param_freq = NULL;
|
2001-12-03 16:38:40 +00:00
|
|
|
char *tv_param_channel = NULL;
|
2001-11-09 23:46:06 +00:00
|
|
|
char *tv_param_norm = "pal";
|
2001-11-17 00:23:48 +00:00
|
|
|
char *tv_param_chanlist = "europe-east";
|
2001-11-09 23:46:06 +00:00
|
|
|
char *tv_param_device = NULL;
|
|
|
|
char *tv_param_driver = "dummy";
|
|
|
|
int tv_param_width = -1;
|
|
|
|
int tv_param_height = -1;
|
2001-11-10 23:32:10 +00:00
|
|
|
int tv_param_input = 0; /* used in v4l and bttv */
|
2001-11-11 02:54:50 +00:00
|
|
|
char *tv_param_outfmt = "yv12";
|
2001-12-03 16:49:55 +00:00
|
|
|
float tv_param_fps = -1.0;
|
2002-12-28 22:57:39 +00:00
|
|
|
char **tv_param_channels = NULL;
|
2002-08-21 21:31:20 +00:00
|
|
|
#ifdef HAVE_TV_V4L
|
2002-08-30 11:37:42 +00:00
|
|
|
int tv_param_amode = -1;
|
2002-08-21 21:31:20 +00:00
|
|
|
int tv_param_audio_id = 0;
|
2002-08-30 11:37:42 +00:00
|
|
|
int tv_param_volume = 60000;
|
|
|
|
int tv_param_bass = -1;
|
|
|
|
int tv_param_treble = -1;
|
|
|
|
int tv_param_balance = -1;
|
|
|
|
int tv_param_forcechan = -1;
|
2002-10-22 07:56:13 +00:00
|
|
|
int tv_param_force_audio = 0;
|
2002-10-25 09:42:41 +00:00
|
|
|
int tv_param_buffer_size = -1;
|
2003-03-19 16:26:58 +00:00
|
|
|
int tv_param_mjpeg = 0;
|
|
|
|
int tv_param_decimation = 2;
|
|
|
|
int tv_param_quality = 90;
|
2002-08-21 21:31:20 +00:00
|
|
|
#ifdef HAVE_ALSA9
|
|
|
|
int tv_param_alsa = 0;
|
|
|
|
#endif
|
|
|
|
char* tv_param_adevice = NULL;
|
|
|
|
#endif
|
2003-03-23 15:05:14 +00:00
|
|
|
int tv_param_brightness = 0;
|
|
|
|
int tv_param_contrast = 0;
|
|
|
|
int tv_param_hue = 0;
|
|
|
|
int tv_param_saturation = 0;
|
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
|
|
|
|
2002-09-08 23:00:01 +00:00
|
|
|
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;
|
2002-03-15 16:07:06 +00:00
|
|
|
|
|
|
|
/* ================== ADD AUDIO PACKET =================== */
|
2001-11-09 23:46:06 +00:00
|
|
|
|
2002-04-12 10:40:38 +00:00
|
|
|
if (ds==demux->audio && tv_param_noaudio == 0 &&
|
2002-03-15 16:07:06 +00:00
|
|
|
tvh->functions->control(tvh->priv,
|
|
|
|
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);
|
|
|
|
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 =================== */
|
|
|
|
|
2002-04-12 10:40:38 +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);
|
|
|
|
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
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2002-11-06 23:54:29 +00:00
|
|
|
/* forward declarations */
|
|
|
|
int tv_set_freq(tvi_handle_t *tvh, unsigned long freq);
|
|
|
|
int tv_get_freq(tvi_handle_t *tvh, unsigned long *freq);
|
|
|
|
|
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;
|
2001-11-09 23:46:06 +00:00
|
|
|
tvi_functions_t *funcs = tvh->functions;
|
2001-11-16 21:53:07 +00:00
|
|
|
int picture_format = 0;
|
|
|
|
|
2001-11-10 23:32:10 +00:00
|
|
|
if (funcs->control(tvh->priv, TVI_CONTROL_IS_VIDEO, 0) != TVI_CONTROL_TRUE)
|
|
|
|
{
|
2001-11-11 03:40:16 +00:00
|
|
|
mp_msg(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
|
|
|
|
2001-11-11 02:54:50 +00:00
|
|
|
if (!strcasecmp(tv_param_outfmt, "yv12"))
|
2001-11-16 21:53:07 +00:00
|
|
|
picture_format = IMGFMT_YV12;
|
2001-12-24 11:01:16 +00:00
|
|
|
else if (!strcasecmp(tv_param_outfmt, "i420"))
|
|
|
|
picture_format = IMGFMT_I420;
|
2001-11-11 02:54:50 +00:00
|
|
|
else if (!strcasecmp(tv_param_outfmt, "uyvy"))
|
2001-11-16 21:53:07 +00:00
|
|
|
picture_format = IMGFMT_UYVY;
|
2002-01-26 15:43:31 +00:00
|
|
|
else if (!strcasecmp(tv_param_outfmt, "yuy2"))
|
|
|
|
picture_format = IMGFMT_YUY2;
|
2001-11-11 02:54:50 +00:00
|
|
|
else if (!strcasecmp(tv_param_outfmt, "rgb32"))
|
2001-11-16 21:53:07 +00:00
|
|
|
picture_format = IMGFMT_RGB32;
|
2001-11-11 02:54:50 +00:00
|
|
|
else if (!strcasecmp(tv_param_outfmt, "rgb24"))
|
2001-11-16 21:53:07 +00:00
|
|
|
picture_format = IMGFMT_RGB24;
|
2001-11-11 02:54:50 +00:00
|
|
|
else if (!strcasecmp(tv_param_outfmt, "rgb16"))
|
2001-11-16 21:53:07 +00:00
|
|
|
picture_format = IMGFMT_RGB16;
|
2001-11-11 02:54:50 +00:00
|
|
|
else if (!strcasecmp(tv_param_outfmt, "rgb15"))
|
2001-11-16 21:53:07 +00:00
|
|
|
picture_format = IMGFMT_RGB15;
|
2001-11-11 02:54:50 +00:00
|
|
|
else
|
|
|
|
{
|
2001-11-11 03:40:16 +00:00
|
|
|
mp_msg(MSGT_TV, MSGL_ERR, "Unknown format given: %s\n", tv_param_outfmt);
|
2002-09-08 16:04:21 +00:00
|
|
|
mp_msg(MSGT_TV, MSGL_V, "Using default: Planar YV12\n");
|
2001-11-16 21:53:07 +00:00
|
|
|
picture_format = IMGFMT_YV12;
|
2001-11-11 02:54:50 +00:00
|
|
|
}
|
2001-11-16 21:53:07 +00:00
|
|
|
funcs->control(tvh->priv, TVI_CONTROL_VID_SET_FORMAT, &picture_format);
|
2001-11-09 23:46:06 +00:00
|
|
|
|
2002-08-21 21:31:20 +00:00
|
|
|
/* set some params got from cmdline */
|
|
|
|
funcs->control(tvh->priv, TVI_CONTROL_SPC_SET_INPUT, &tv_param_input);
|
|
|
|
|
|
|
|
/* select video norm */
|
|
|
|
if (!strcasecmp(tv_param_norm, "pal"))
|
|
|
|
tvh->norm = TV_NORM_PAL;
|
|
|
|
else if (!strcasecmp(tv_param_norm, "ntsc"))
|
|
|
|
tvh->norm = TV_NORM_NTSC;
|
|
|
|
else if (!strcasecmp(tv_param_norm, "secam"))
|
|
|
|
tvh->norm = TV_NORM_SECAM;
|
2002-12-16 23:38:56 +00:00
|
|
|
else if (!strcasecmp(tv_param_norm, "palnc"))
|
|
|
|
tvh->norm = TV_NORM_PALNC;
|
|
|
|
else if (!strcasecmp(tv_param_norm, "palm"))
|
|
|
|
tvh->norm = TV_NORM_PALM;
|
|
|
|
else if (!strcasecmp(tv_param_norm, "paln"))
|
|
|
|
tvh->norm = TV_NORM_PALN;
|
|
|
|
else if (!strcasecmp(tv_param_norm, "ntscjp"))
|
|
|
|
tvh->norm = TV_NORM_NTSCJP;
|
2002-12-16 17:05:49 +00:00
|
|
|
else {
|
|
|
|
mp_msg(MSGT_TV, MSGL_V, "Bogus norm parameter, setting PAL.\n");
|
|
|
|
tvh->norm = TV_NORM_PAL;
|
|
|
|
}
|
2002-08-21 21:31:20 +00:00
|
|
|
|
2002-09-08 16:04:21 +00:00
|
|
|
mp_msg(MSGT_TV, MSGL_V, "Selected norm: %s\n", tv_param_norm);
|
2002-12-16 23:27:39 +00:00
|
|
|
if (funcs->control(tvh->priv, TVI_CONTROL_TUN_SET_NORM, &tvh->norm) != TVI_CONTROL_TRUE) {
|
|
|
|
mp_msg(MSGT_TV, MSGL_ERR, "Error: cannot set norm!\n");
|
|
|
|
return 0;
|
|
|
|
}
|
2002-08-21 21:31:20 +00:00
|
|
|
|
2003-03-19 16:26:58 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_TV_V4L
|
|
|
|
if ( tv_param_mjpeg )
|
|
|
|
{
|
|
|
|
/* set width to expected value */
|
|
|
|
if (tv_param_width == -1)
|
|
|
|
{
|
|
|
|
tv_param_width = 704/tv_param_decimation;
|
|
|
|
}
|
|
|
|
if (tv_param_height == -1)
|
|
|
|
{
|
|
|
|
if ( tvh->norm != TV_NORM_NTSC )
|
|
|
|
tv_param_height = 576/tv_param_decimation;
|
|
|
|
else
|
|
|
|
tv_param_height = 480/tv_param_decimation;
|
|
|
|
}
|
|
|
|
mp_msg(MSGT_TV, MSGL_INFO,
|
|
|
|
" MJP: width %d height %d\n", tv_param_width, tv_param_height);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2002-08-21 21:31:20 +00:00
|
|
|
/* limits on w&h are norm-dependent -- JM */
|
2001-11-09 23:46:06 +00:00
|
|
|
/* set width */
|
|
|
|
if (tv_param_width != -1)
|
|
|
|
{
|
|
|
|
if (funcs->control(tvh->priv, TVI_CONTROL_VID_CHK_WIDTH, &tv_param_width) == TVI_CONTROL_TRUE)
|
|
|
|
funcs->control(tvh->priv, TVI_CONTROL_VID_SET_WIDTH, &tv_param_width);
|
|
|
|
else
|
|
|
|
{
|
2001-11-11 03:40:16 +00:00
|
|
|
mp_msg(MSGT_TV, MSGL_ERR, "Unable set requested width: %d\n", tv_param_width);
|
2001-11-16 21:53:07 +00:00
|
|
|
funcs->control(tvh->priv, TVI_CONTROL_VID_GET_WIDTH, &tv_param_width);
|
2001-11-09 23:46:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* set height */
|
|
|
|
if (tv_param_height != -1)
|
|
|
|
{
|
|
|
|
if (funcs->control(tvh->priv, TVI_CONTROL_VID_CHK_HEIGHT, &tv_param_height) == TVI_CONTROL_TRUE)
|
|
|
|
funcs->control(tvh->priv, TVI_CONTROL_VID_SET_HEIGHT, &tv_param_height);
|
|
|
|
else
|
|
|
|
{
|
2001-11-11 03:40:16 +00:00
|
|
|
mp_msg(MSGT_TV, MSGL_ERR, "Unable set requested height: %d\n", tv_param_height);
|
2001-11-16 21:53:07 +00:00
|
|
|
funcs->control(tvh->priv, TVI_CONTROL_VID_GET_HEIGHT, &tv_param_height);
|
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)
|
|
|
|
{
|
|
|
|
mp_msg(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++)
|
|
|
|
{
|
|
|
|
if (!strcasecmp(chanlists[i].name, tv_param_chanlist))
|
|
|
|
{
|
|
|
|
tvh->chanlist = i;
|
|
|
|
tvh->chanlist_s = chanlists[i].list;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (tvh->chanlist == -1)
|
|
|
|
mp_msg(MSGT_TV, MSGL_WARN, "Unable to find selected channel list! (%s)\n",
|
|
|
|
tv_param_chanlist);
|
2001-12-03 16:38:40 +00:00
|
|
|
else
|
2002-09-08 16:04:21 +00:00
|
|
|
mp_msg(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
|
|
|
|
|
|
|
if (tv_param_freq && tv_param_channel)
|
2001-12-03 16:38:40 +00:00
|
|
|
{
|
|
|
|
mp_msg(MSGT_TV, MSGL_WARN, "You can't set frequency and channel simultanly!\n");
|
2002-04-12 10:40:38 +00:00
|
|
|
goto done;
|
2001-12-03 16:38:40 +00:00
|
|
|
}
|
|
|
|
|
2002-12-28 22:57:39 +00:00
|
|
|
/* Handle channels names */
|
|
|
|
if (tv_param_channels) {
|
2003-03-03 10:59:07 +00:00
|
|
|
char** channels = tv_param_channels;
|
2002-12-28 22:57:39 +00:00
|
|
|
mp_msg(MSGT_TV, MSGL_INFO, "TV Channels names detected.\n");
|
|
|
|
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;
|
|
|
|
|
2003-03-03 10:59:07 +00:00
|
|
|
while (*channels) {
|
|
|
|
char* tmp = *(channels++);
|
2003-01-14 23:15:36 +00:00
|
|
|
char* sep = strchr(tmp,'-');
|
2002-12-28 22:57:39 +00:00
|
|
|
int i;
|
|
|
|
struct CHANLIST cl;
|
|
|
|
|
2003-01-14 23:15:36 +00:00
|
|
|
if (!sep) continue; // Wrong syntax, but mplayer should not crash
|
|
|
|
|
|
|
|
strcpy(tv_channel_current->name, sep + 1);
|
|
|
|
sep[0] = '\0';
|
2003-01-06 13:12:09 +00:00
|
|
|
strncpy(tv_channel_current->number, tmp, 5);
|
2002-12-28 22:57:39 +00:00
|
|
|
|
2003-01-14 23:15:36 +00:00
|
|
|
while ((sep=strchr(tv_channel_current->name, '_')))
|
|
|
|
sep[0] = ' ';
|
2002-12-28 22:57:39 +00:00
|
|
|
|
|
|
|
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)
|
|
|
|
mp_msg(MSGT_TV, MSGL_ERR, "Couldn't find frequency for channel %s (%s)\n",
|
|
|
|
tv_channel_current->number, tv_channel_current->name);
|
2003-04-09 16:07:45 +00:00
|
|
|
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';
|
|
|
|
}
|
|
|
|
}
|
2002-12-28 22:57:39 +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;
|
|
|
|
}
|
2003-01-14 23:15:36 +00:00
|
|
|
if (tv_channel_current->prev)
|
|
|
|
tv_channel_current->prev->next = NULL;
|
2002-12-28 22:57:39 +00:00
|
|
|
free(tv_channel_current);
|
|
|
|
} else
|
|
|
|
tv_channel_last_real = malloc(sizeof(char)*5);
|
|
|
|
|
|
|
|
if (tv_channel_list) {
|
|
|
|
int i;
|
2003-04-28 16:11:42 +00:00
|
|
|
int channel = 0;
|
2002-12-28 22:57:39 +00:00
|
|
|
if (tv_param_channel)
|
2003-04-28 16:11:42 +00:00
|
|
|
{
|
|
|
|
if (isdigit(*tv_param_channel))
|
|
|
|
/* if tv_param_channel begins with a digit interpret it as a number */
|
2002-12-28 22:57:39 +00:00
|
|
|
channel = atoi(tv_param_channel);
|
2003-04-28 16:11:42 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
/* if tv_param_channel does not begin with a digit
|
|
|
|
set the first channel that contains tv_param_channel in its name */
|
|
|
|
|
|
|
|
tv_channel_current = tv_channel_list;
|
|
|
|
while ( tv_channel_current ) {
|
|
|
|
if ( strstr(tv_channel_current->name, tv_param_channel) )
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2002-12-28 22:57:39 +00:00
|
|
|
mp_msg(MSGT_TV, MSGL_INFO, "Selected channel: %s - %s (freq: %.3f)\n", tv_channel_current->number,
|
|
|
|
tv_channel_current->name, (float)tv_channel_current->freq/1000);
|
|
|
|
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 */
|
|
|
|
if (tv_param_freq)
|
|
|
|
{
|
|
|
|
unsigned long freq = atof(tv_param_freq)*16;
|
|
|
|
|
|
|
|
/* set freq in MHz */
|
|
|
|
funcs->control(tvh->priv, TVI_CONTROL_TUN_SET_FREQ, &freq);
|
|
|
|
|
|
|
|
funcs->control(tvh->priv, TVI_CONTROL_TUN_GET_FREQ, &freq);
|
2002-09-08 16:04:21 +00:00
|
|
|
mp_msg(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
|
|
|
|
2002-12-28 22:57:39 +00:00
|
|
|
if (tv_param_channel) {
|
2001-11-17 00:23:48 +00:00
|
|
|
struct CHANLIST cl;
|
2001-12-03 16:38:40 +00:00
|
|
|
|
|
|
|
mp_msg(MSGT_TV, MSGL_V, "Requested channel: %s\n", 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);
|
2001-11-17 00:23:48 +00:00
|
|
|
if (!strcasecmp(cl.name, tv_param_channel))
|
|
|
|
{
|
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;
|
|
|
|
mp_msg(MSGT_TV, MSGL_INFO, "Selected channel: %s (freq: %.3f)\n",
|
|
|
|
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
|
|
|
}
|
2002-10-19 20:55:06 +00:00
|
|
|
|
|
|
|
/* grep frequency in chanlist */
|
|
|
|
{
|
|
|
|
unsigned long i2;
|
|
|
|
int freq;
|
|
|
|
|
|
|
|
tv_get_freq(tvh, &i2);
|
|
|
|
|
|
|
|
freq = (int) (((float)(i2/16))*1000)+250;
|
|
|
|
|
|
|
|
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
|
|
|
|
2002-04-12 10:40:38 +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
|
|
|
}
|
|
|
|
|
2002-09-08 23:00:01 +00:00
|
|
|
int 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;
|
2002-09-15 20:51:55 +00:00
|
|
|
tvi_functions_t *funcs;
|
|
|
|
|
|
|
|
if(!(tvh=tv_begin())) return 0;
|
|
|
|
if (!tv_init(tvh)) return 0;
|
|
|
|
if (!open_tv(tvh)){
|
|
|
|
tv_uninit(tvh);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
funcs = tvh->functions;
|
|
|
|
demuxer->priv=tvh;
|
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)
|
|
|
|
{
|
2002-03-15 16:07:06 +00:00
|
|
|
int tmp;
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2001-12-03 16:49:55 +00:00
|
|
|
if (tv_param_fps != -1.0f)
|
2002-03-15 16:07:06 +00:00
|
|
|
sh_video->fps = tv_param_fps;
|
|
|
|
|
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 */
|
|
|
|
if(tv_param_immediate == 1)
|
|
|
|
{
|
|
|
|
funcs->control(tvh->priv, TVI_CONTROL_IMMEDIATE, 0);
|
|
|
|
tv_param_noaudio = 1;
|
|
|
|
}
|
|
|
|
|
2003-01-05 14:58:05 +00:00
|
|
|
/* disable TV audio if -nosound is present */
|
|
|
|
if (!demuxer->audio || demuxer->audio->id == -2) {
|
|
|
|
tv_param_noaudio = 1;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2003-03-23 15:05:14 +00:00
|
|
|
/* set color eq */
|
|
|
|
tv_set_color_options(tvh, TV_COLOR_BRIGHTNESS, tv_param_brightness);
|
|
|
|
tv_set_color_options(tvh, TV_COLOR_HUE, tv_param_hue);
|
|
|
|
tv_set_color_options(tvh, TV_COLOR_SATURATION, tv_param_saturation);
|
|
|
|
tv_set_color_options(tvh, TV_COLOR_CONTRAST, tv_param_contrast);
|
|
|
|
|
2001-11-09 23:46:06 +00:00
|
|
|
demuxer->video->sh = sh_video;
|
|
|
|
sh_video->ds = demuxer->video;
|
|
|
|
demuxer->video->id = 0;
|
2001-11-16 21:53:07 +00:00
|
|
|
|
2003-02-25 08:22:00 +00:00
|
|
|
demuxer->seekable = 0;
|
2001-11-09 23:46:06 +00:00
|
|
|
|
|
|
|
/* here comes audio init */
|
2002-03-15 16:07:06 +00:00
|
|
|
|
|
|
|
if (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;
|
2001-11-10 23:32:10 +00:00
|
|
|
|
|
|
|
/* yeah, audio is present */
|
2002-04-12 10:40:38 +00:00
|
|
|
|
|
|
|
funcs->control(tvh->priv, TVI_CONTROL_AUD_SET_SAMPLERATE,
|
|
|
|
&tv_param_audiorate);
|
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
case AFMT_U8:
|
|
|
|
case AFMT_S8:
|
|
|
|
case AFMT_U16_LE:
|
|
|
|
case AFMT_U16_BE:
|
|
|
|
case AFMT_S16_LE:
|
|
|
|
case AFMT_S16_BE:
|
|
|
|
case AFMT_S32_LE:
|
|
|
|
case AFMT_S32_BE:
|
2002-03-15 16:07:06 +00:00
|
|
|
sh_audio_format = 0x1; /* PCM */
|
2001-11-10 23:32:10 +00:00
|
|
|
break;
|
|
|
|
case AFMT_IMA_ADPCM:
|
|
|
|
case AFMT_MU_LAW:
|
|
|
|
case AFMT_A_LAW:
|
|
|
|
case AFMT_MPEG:
|
|
|
|
case AFMT_AC3:
|
|
|
|
default:
|
2002-05-23 14:53:11 +00:00
|
|
|
mp_msg(MSGT_TV, MSGL_ERR, "Audio type '%s (%x)' unsupported!\n",
|
|
|
|
audio_out_format_name(audio_format), audio_format);
|
2001-11-10 23:32:10 +00:00
|
|
|
goto no_audio;
|
|
|
|
}
|
|
|
|
|
2002-03-15 16:07:06 +00:00
|
|
|
sh_audio = new_sh_audio(demuxer, 0);
|
|
|
|
|
|
|
|
funcs->control(tvh->priv, TVI_CONTROL_AUD_GET_SAMPLERATE,
|
|
|
|
&sh_audio->samplerate);
|
|
|
|
funcs->control(tvh->priv, TVI_CONTROL_AUD_GET_SAMPLESIZE,
|
|
|
|
&sh_audio->samplesize);
|
|
|
|
funcs->control(tvh->priv, TVI_CONTROL_AUD_GET_CHANNELS,
|
|
|
|
&sh_audio->channels);
|
|
|
|
|
|
|
|
sh_audio->format = sh_audio_format;
|
|
|
|
sh_audio->sample_format = audio_format;
|
|
|
|
|
|
|
|
sh_audio->i_bps = sh_audio->o_bps =
|
2002-04-12 10:40:38 +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:
|
|
|
|
sh_audio->wf = (WAVEFORMATEX *)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;
|
|
|
|
|
|
|
|
mp_msg(MSGT_DECVIDEO, MSGL_V, " TV audio: %d channels, %d bits, %d Hz\n",
|
|
|
|
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);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return 1;
|
2001-11-09 23:46:06 +00:00
|
|
|
}
|
|
|
|
|
2002-09-08 23:00:01 +00:00
|
|
|
int 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);
|
2002-08-21 21:31:20 +00:00
|
|
|
return(tvh->functions->uninit(tvh->priv));
|
|
|
|
}
|
|
|
|
|
2001-11-09 23:46:06 +00:00
|
|
|
/* ================== STREAM_TV ===================== */
|
2002-05-23 14:53:11 +00:00
|
|
|
tvi_handle_t *tvi_init_dummy(char *device);
|
2002-08-21 21:31:20 +00:00
|
|
|
tvi_handle_t *tvi_init_v4l(char *device, char *adevice);
|
2002-05-23 14:53:11 +00:00
|
|
|
tvi_handle_t *tvi_init_bsdbt848(char *device);
|
|
|
|
|
2001-11-10 23:32:10 +00:00
|
|
|
tvi_handle_t *tv_begin(void)
|
2001-11-09 23:46:06 +00:00
|
|
|
{
|
|
|
|
if (!strcmp(tv_param_driver, "dummy"))
|
2002-05-23 14:53:11 +00:00
|
|
|
return tvi_init_dummy(tv_param_device);
|
2001-12-01 17:41:59 +00:00
|
|
|
#ifdef HAVE_TV_V4L
|
2001-11-09 23:46:06 +00:00
|
|
|
if (!strcmp(tv_param_driver, "v4l"))
|
2002-08-21 21:31:20 +00:00
|
|
|
return tvi_init_v4l(tv_param_device, tv_param_adevice);
|
2001-12-01 17:41:59 +00:00
|
|
|
#endif
|
2002-03-15 16:07:06 +00:00
|
|
|
#ifdef HAVE_TV_BSDBT848
|
|
|
|
if (!strcmp(tv_param_driver, "bsdbt848"))
|
2002-05-23 14:53:11 +00:00
|
|
|
return tvi_init_bsdbt848(tv_param_device);
|
2002-03-15 16:07:06 +00:00
|
|
|
#endif
|
2001-11-09 23:46:06 +00:00
|
|
|
|
|
|
|
mp_msg(MSGT_TV, MSGL_ERR, "No such driver: %s\n", tv_param_driver);
|
|
|
|
return(NULL);
|
|
|
|
}
|
|
|
|
|
2001-11-10 23:32:10 +00:00
|
|
|
int tv_init(tvi_handle_t *tvh)
|
2001-11-09 23:46:06 +00:00
|
|
|
{
|
2001-11-11 03:40:16 +00:00
|
|
|
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);
|
2001-11-10 23:32:10 +00:00
|
|
|
if (tvh->info->comment)
|
2001-11-11 03:40:16 +00:00
|
|
|
mp_msg(MSGT_TV, MSGL_INFO, " comment: %s\n", tvh->info->comment);
|
2001-11-10 23:32:10 +00:00
|
|
|
|
2001-12-27 23:52:48 +00:00
|
|
|
return(tvh->functions->init(tvh->priv));
|
2001-11-11 15:45:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int tv_uninit(tvi_handle_t *tvh)
|
|
|
|
{
|
|
|
|
return(tvh->functions->uninit(tvh->priv));
|
2001-11-09 23:46:06 +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)
|
|
|
|
{
|
|
|
|
tvi_functions_t *funcs = tvh->functions;
|
|
|
|
|
|
|
|
switch(opt)
|
|
|
|
{
|
|
|
|
case TV_COLOR_BRIGHTNESS:
|
|
|
|
funcs->control(tvh->priv, TVI_CONTROL_VID_SET_BRIGHTNESS, &value);
|
|
|
|
break;
|
|
|
|
case TV_COLOR_HUE:
|
|
|
|
funcs->control(tvh->priv, TVI_CONTROL_VID_SET_HUE, &value);
|
|
|
|
break;
|
|
|
|
case TV_COLOR_SATURATION:
|
|
|
|
funcs->control(tvh->priv, TVI_CONTROL_VID_SET_SATURATION, &value);
|
|
|
|
break;
|
|
|
|
case TV_COLOR_CONTRAST:
|
|
|
|
funcs->control(tvh->priv, TVI_CONTROL_VID_SET_CONTRAST, &value);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
mp_msg(MSGT_TV, MSGL_WARN, "Unknown color option (%d) specified!\n", opt);
|
|
|
|
}
|
|
|
|
|
|
|
|
return(1);
|
|
|
|
}
|
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);
|
|
|
|
mp_msg(MSGT_TV, MSGL_V, "Current frequency: %lu (%.3f)\n",
|
|
|
|
*freq, (float)*freq/16);
|
|
|
|
}
|
|
|
|
return(1);
|
|
|
|
}
|
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
// unsigned long freq = atof(tv_param_freq)*16;
|
|
|
|
|
|
|
|
/* 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);
|
2002-09-08 16:04:21 +00:00
|
|
|
mp_msg(MSGT_TV, MSGL_V, "Current frequency: %lu (%.3f)\n",
|
2001-11-17 00:23:48 +00:00
|
|
|
freq, (float)freq/16);
|
|
|
|
}
|
2002-09-22 02:33:28 +00:00
|
|
|
return(1);
|
2001-11-17 00:23:48 +00:00
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
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];
|
2001-11-17 00:23:48 +00:00
|
|
|
mp_msg(MSGT_TV, MSGL_INFO, "Selected channel: %s (freq: %.3f)\n",
|
|
|
|
cl.name, (float)cl.freq/1000);
|
|
|
|
tv_set_freq(tvh, (unsigned long)(((float)cl.freq/1000)*16));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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];
|
2001-11-17 00:23:48 +00:00
|
|
|
mp_msg(MSGT_TV, MSGL_INFO, "Selected channel: %s (freq: %.3f)\n",
|
|
|
|
cl.name, (float)cl.freq/1000);
|
|
|
|
tv_set_freq(tvh, (unsigned long)(((float)cl.freq/1000)*16));
|
|
|
|
}
|
|
|
|
}
|
2002-09-22 02:33:28 +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) {
|
|
|
|
if (tv_channel_list) {
|
|
|
|
if (direction == TV_CHANNEL_HIGHER) {
|
|
|
|
if (tv_channel_current->next) {
|
|
|
|
tv_channel_last = tv_channel_current;
|
|
|
|
tv_channel_current = tv_channel_current->next;
|
|
|
|
tv_set_freq(tvh, (unsigned long)(((float)tv_channel_current->freq/1000)*16));
|
|
|
|
mp_msg(MSGT_TV, MSGL_INFO, "Selected channel: %s - %s (freq: %.3f)\n",
|
|
|
|
tv_channel_current->number, tv_channel_current->name, (float)tv_channel_current->freq/1000);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (direction == TV_CHANNEL_LOWER) {
|
|
|
|
if (tv_channel_current->prev) {
|
|
|
|
tv_channel_last = tv_channel_current;
|
|
|
|
tv_channel_current = tv_channel_current->prev;
|
|
|
|
tv_set_freq(tvh, (unsigned long)(((float)tv_channel_current->freq/1000)*16));
|
|
|
|
mp_msg(MSGT_TV, MSGL_INFO, "Selected channel: %s - %s (freq: %.3f)\n",
|
|
|
|
tv_channel_current->number, tv_channel_current->name, (float)tv_channel_current->freq/1000);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else tv_step_channel_real(tvh, direction);
|
|
|
|
return(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
int tv_set_channel_real(tvi_handle_t *tvh, char *channel) {
|
2002-12-19 10:09:43 +00:00
|
|
|
int i;
|
|
|
|
struct CHANLIST cl;
|
|
|
|
|
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;
|
|
|
|
mp_msg(MSGT_TV, MSGL_INFO, "Selected channel: %s (freq: %.3f)\n",
|
|
|
|
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
|
|
|
return(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
int tv_set_channel(tvi_handle_t *tvh, char *channel) {
|
|
|
|
int i, channel_int;
|
|
|
|
|
|
|
|
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;
|
|
|
|
mp_msg(MSGT_TV, MSGL_INFO, "Selected channel: %s - %s (freq: %.3f)\n", tv_channel_current->number,
|
|
|
|
tv_channel_current->name, (float)tv_channel_current->freq/1000);
|
|
|
|
tv_set_freq(tvh, (unsigned long)(((float)tv_channel_current->freq/1000)*16));
|
|
|
|
} else tv_set_channel_real(tvh, channel);
|
|
|
|
return(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
int tv_last_channel(tvi_handle_t *tvh) {
|
|
|
|
|
|
|
|
if (tv_channel_list) {
|
|
|
|
tv_channels_t *tmp;
|
|
|
|
|
|
|
|
tmp = tv_channel_last;
|
|
|
|
tv_channel_last = tv_channel_current;
|
|
|
|
tv_channel_current = tmp;
|
|
|
|
|
|
|
|
mp_msg(MSGT_TV, MSGL_INFO, "Selected channel: %s - %s (freq: %.3f)\n", tv_channel_current->number,
|
|
|
|
tv_channel_current->name, (float)tv_channel_current->freq/1000);
|
|
|
|
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;
|
|
|
|
mp_msg(MSGT_TV, MSGL_INFO, "Selected channel: %s (freq: %.3f)\n",
|
|
|
|
cl.name, (float)cl.freq/1000);
|
|
|
|
tv_set_freq(tvh, (unsigned long)(((float)cl.freq/1000)*16));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
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)
|
|
|
|
{
|
2002-09-22 02:33:28 +00:00
|
|
|
return(1);
|
2001-11-17 00:23:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int tv_step_chanlist(tvi_handle_t *tvh)
|
|
|
|
{
|
2002-09-22 02:33:28 +00:00
|
|
|
return(1);
|
2001-11-17 00:23:48 +00:00
|
|
|
}
|
2001-11-09 23:46:06 +00:00
|
|
|
#endif /* USE_TV */
|