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>
|
2014-07-10 06:28:03 +00:00
|
|
|
#include <strings.h>
|
2002-03-15 16:07:06 +00:00
|
|
|
#include <sys/time.h>
|
2014-06-09 21:54:45 +00:00
|
|
|
#include <assert.h>
|
2014-04-19 15:18:10 +00:00
|
|
|
#include <libavutil/avstring.h>
|
2001-11-09 23:46:06 +00:00
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2001-11-11 03:53:42 +00:00
|
|
|
|
2013-12-17 01:39:45 +00:00
|
|
|
#include "common/msg.h"
|
2014-07-01 21:10:38 +00:00
|
|
|
#include "misc/ctype.h"
|
2001-11-09 23:46:06 +00:00
|
|
|
|
2014-06-09 21:54:45 +00:00
|
|
|
#include "options/m_option.h"
|
|
|
|
#include "options/m_config.h"
|
|
|
|
#include "options/options.h"
|
|
|
|
|
2001-11-09 23:46:06 +00:00
|
|
|
#include "stream.h"
|
2001-11-11 13:47:42 +00:00
|
|
|
|
2012-11-09 00:06:43 +00:00
|
|
|
#include "audio/format.h"
|
video: decouple internal pixel formats from FourCCs
mplayer's video chain traditionally used FourCCs for pixel formats. For
example, it used IMGFMT_YV12 for 4:2:0 YUV, which was defined to the
string 'YV12' interpreted as unsigned int. Additionally, it used to
encode information into the numeric values of some formats. The RGB
formats had their bit depth and endian encoded into the least
significant byte. Extended planar formats (420P10 etc.) had chroma
shift, endian, and component bit depth encoded. (This has been removed
in recent commits.)
Replace the FourCC mess with a simple enum. Remove all the redundant
formats like YV12/I420/IYUV. Replace some image format names by
something more intuitive, most importantly IMGFMT_YV12 -> IMGFMT_420P.
Add img_fourcc.h, which contains the old IDs for code that actually uses
FourCCs. Change the way demuxers, that output raw video, identify the
video format: they set either MP_FOURCC_RAWVIDEO or MP_FOURCC_IMGFMT to
request the rawvideo decoder, and sh_video->imgfmt specifies the pixel
format. Like the previous hack, this is supposed to avoid the need for
a complete codecs.cfg entry per format, or other lookup tables. (Note
that the RGB raw video FourCCs mostly rely on ffmpeg's mappings for NUT
raw video, but this is still considered better than adding a raw video
decoder - even if trivial, it would be full of annoying lookup tables.)
The TV code has not been tested.
Some corrective changes regarding endian and other image format flags
creep in.
2012-12-23 19:03:30 +00:00
|
|
|
#include "video/img_fourcc.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"
|
|
|
|
|
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_v4l2;
|
2007-03-01 18:38:00 +00:00
|
|
|
|
2007-09-10 17:09:35 +00:00
|
|
|
/** List of drivers in autodetection order */
|
2014-06-10 21:56:05 +00:00
|
|
|
static const tvi_info_t *const tvi_driver_list[]={
|
2013-07-16 11:28:28 +00:00
|
|
|
#if HAVE_TV_V4L2
|
2007-03-01 18:38:00 +00:00
|
|
|
&tvi_info_v4l2,
|
|
|
|
#endif
|
2007-09-10 17:09:35 +00:00
|
|
|
&tvi_info_dummy,
|
2007-03-01 18:38:00 +00:00
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
2014-06-09 21:54:45 +00:00
|
|
|
#define OPT_BASE_STRUCT tv_param_t
|
|
|
|
const struct m_sub_options tv_params_conf = {
|
|
|
|
.opts = (const m_option_t[]) {
|
|
|
|
OPT_FLAG("immediatemode", immediate, 0),
|
|
|
|
OPT_FLAG("audio", audio, 0),
|
|
|
|
OPT_INT("audiorate", audiorate, 0),
|
|
|
|
OPT_STRING("driver", driver, 0),
|
|
|
|
OPT_STRING("device", device, 0),
|
|
|
|
OPT_STRING("freq", freq, 0),
|
|
|
|
OPT_STRING("channel", channel, 0),
|
|
|
|
OPT_STRING("chanlist", chanlist, 0),
|
|
|
|
OPT_STRING("norm", norm, 0),
|
|
|
|
OPT_INTRANGE("automute", automute, 0, 0, 255),
|
|
|
|
#if HAVE_TV_V4L2
|
|
|
|
OPT_INT("normid", normid, 0),
|
|
|
|
#endif
|
|
|
|
OPT_INTRANGE("width", width, 0, 0, 4096),
|
|
|
|
OPT_INTRANGE("height", height, 0, 0, 4096),
|
|
|
|
OPT_INT("input", input, 0),
|
|
|
|
OPT_GENERAL(int, "outfmt", outfmt, 0, .type = &m_option_type_fourcc),
|
|
|
|
OPT_FLOAT("fps", fps, 0),
|
|
|
|
OPT_STRINGLIST("channels", channels, 0),
|
|
|
|
OPT_INTRANGE("brightness", brightness, 0, -100, 100),
|
|
|
|
OPT_INTRANGE("contrast", contrast, 0, -100, 100),
|
|
|
|
OPT_INTRANGE("hue", hue, 0, -100, 100),
|
|
|
|
OPT_INTRANGE("saturation", saturation, 0, -100, 100),
|
|
|
|
OPT_INTRANGE("gain", gain, 0, -1, 100),
|
|
|
|
#if HAVE_TV_V4L2
|
|
|
|
OPT_INTRANGE("amode", amode, 0, 0, 3),
|
|
|
|
OPT_INTRANGE("volume", volume, 0, 0, 65535),
|
|
|
|
OPT_INTRANGE("bass", bass, 0, 0, 65535),
|
|
|
|
OPT_INTRANGE("treble", treble, 0, 0, 65535),
|
|
|
|
OPT_INTRANGE("balance", balance, 0, 0, 65535),
|
|
|
|
OPT_INTRANGE("forcechan", forcechan, 0, 1, 2),
|
|
|
|
OPT_FLAG("forceaudio", force_audio, 0),
|
|
|
|
OPT_INTRANGE("buffersize", buffer_size, 0, 16, 1024),
|
|
|
|
OPT_FLAG("mjpeg", mjpeg, 0),
|
|
|
|
OPT_INTRANGE("decimation", decimation, 0, 1, 4),
|
|
|
|
OPT_INTRANGE("quality", quality, 0, 0, 100),
|
|
|
|
#if HAVE_ALSA
|
|
|
|
OPT_FLAG("alsa", alsa, 0),
|
|
|
|
#endif /* HAVE_ALSA */
|
|
|
|
#endif /* HAVE_TV_V4L2 */
|
|
|
|
OPT_STRING("adevice", adevice, 0),
|
|
|
|
OPT_INTRANGE("audioid", audio_id, 0, 0, 9),
|
|
|
|
OPT_FLAG("scan-autostart", scan, 0),
|
|
|
|
OPT_INTRANGE("scan-threshold", scan_threshold, 0, 1, 100),
|
|
|
|
OPT_FLOATRANGE("scan-period", scan_period, 0, 0.1, 2.0),
|
|
|
|
{0}
|
|
|
|
},
|
|
|
|
.size = sizeof(tv_param_t),
|
|
|
|
.defaults = &(const tv_param_t){
|
|
|
|
.chanlist = "europe-east",
|
|
|
|
.norm = "pal",
|
|
|
|
.normid = -1,
|
|
|
|
.width = -1,
|
|
|
|
.height = -1,
|
|
|
|
.outfmt = -1,
|
|
|
|
.fps = -1.0,
|
|
|
|
.audio = 1,
|
|
|
|
.immediate = 1,
|
|
|
|
.audiorate = 44100,
|
|
|
|
.amode = -1,
|
|
|
|
.volume = -1,
|
|
|
|
.bass = -1,
|
|
|
|
.treble = -1,
|
|
|
|
.balance = -1,
|
|
|
|
.forcechan = -1,
|
|
|
|
.buffer_size = -1,
|
|
|
|
.decimation = 2,
|
|
|
|
.quality = 90,
|
|
|
|
.gain = -1,
|
|
|
|
.scan_threshold = 50,
|
|
|
|
.scan_period = 0.5,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2013-12-21 19:24:20 +00:00
|
|
|
tvi_handle_t *tv_new_handle(int size, struct mp_log *log, const tvi_functions_t *functions)
|
2010-09-13 18:09:29 +00:00
|
|
|
{
|
|
|
|
tvi_handle_t *h = malloc(sizeof(*h));
|
|
|
|
|
|
|
|
if (!h)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
h->priv = calloc(1, size);
|
|
|
|
|
|
|
|
if (!h->priv) {
|
|
|
|
free(h);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2013-12-21 19:24:20 +00:00
|
|
|
h->log = log;
|
2010-09-13 18:09:29 +00:00
|
|
|
h->functions = functions;
|
|
|
|
h->seq = 0;
|
|
|
|
h->chanlist = -1;
|
|
|
|
h->chanlist_s = NULL;
|
|
|
|
h->norm = -1;
|
|
|
|
h->channel = -1;
|
|
|
|
h->scan = NULL;
|
|
|
|
|
|
|
|
return h;
|
|
|
|
}
|
|
|
|
|
2010-09-11 23:53:15 +00:00
|
|
|
void tv_free_handle(tvi_handle_t *h)
|
|
|
|
{
|
2010-11-07 12:47:40 +00:00
|
|
|
if (!h)
|
|
|
|
return;
|
|
|
|
free(h->priv);
|
|
|
|
free(h->scan);
|
|
|
|
free(h);
|
2010-09-11 23:53:15 +00:00
|
|
|
}
|
|
|
|
|
2007-08-23 16:09:30 +00:00
|
|
|
void tv_start_scan(tvi_handle_t *tvh, int start)
|
|
|
|
{
|
2013-12-21 19:24:20 +00:00
|
|
|
MP_INFO(tvh, "start scan\n");
|
2007-08-23 16:09:30 +00:00
|
|
|
tvh->tv_param->scan=start?1:0;
|
|
|
|
}
|
|
|
|
|
2012-10-30 17:28:34 +00:00
|
|
|
static int tv_set_freq_float(tvi_handle_t *tvh, float freq)
|
|
|
|
{
|
|
|
|
return tv_set_freq(tvh, freq/1000.0*16);
|
|
|
|
}
|
|
|
|
|
2014-07-05 15:00:23 +00:00
|
|
|
void tv_scan(tvi_handle_t *tvh)
|
2007-08-23 16:09:30 +00:00
|
|
|
{
|
|
|
|
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)
|
|
|
|
{
|
2013-12-21 19:24:20 +00:00
|
|
|
MP_WARN(tvh, "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;
|
2013-05-25 16:31:06 +00:00
|
|
|
now=(unsigned int)mp_time_us();
|
2007-08-23 16:09:30 +00:00
|
|
|
if (!scan) {
|
|
|
|
scan=calloc(1,sizeof(tv_scan_t));
|
|
|
|
tvh->scan=scan;
|
|
|
|
cl = tvh->chanlist_s[scan->channel_num];
|
2012-10-30 17:28:34 +00:00
|
|
|
tv_set_freq_float(tvh, cl.freq);
|
2007-08-23 16:09:30 +00:00
|
|
|
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];
|
2014-06-09 21:54:45 +00:00
|
|
|
tv_channel_tmp=tvh->tv_channel_list;
|
2007-08-23 16:09:30 +00:00
|
|
|
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) {
|
2013-12-21 19:24:20 +00:00
|
|
|
MP_INFO(tvh, "Found new channel: %s (#%d). \n",cl.name,index);
|
2007-08-23 16:09:30 +00:00
|
|
|
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';
|
2014-06-09 21:54:45 +00:00
|
|
|
if (!tvh->tv_channel_list)
|
|
|
|
tvh->tv_channel_list=tv_channel_tmp;
|
2007-08-23 16:09:30 +00:00
|
|
|
else {
|
|
|
|
tv_channel_add->next=tv_channel_tmp;
|
2014-06-09 21:54:45 +00:00
|
|
|
tvh->tv_channel_list->prev=tv_channel_tmp;
|
2007-08-23 16:09:30 +00:00
|
|
|
}
|
|
|
|
}else
|
2013-12-21 19:24:20 +00:00
|
|
|
MP_INFO(tvh, "Found existing channel: %s-%s.\n",
|
2007-08-23 16:09:30 +00:00
|
|
|
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;
|
2013-12-21 19:24:20 +00:00
|
|
|
MP_INFO(tvh, "TV scan end. Found %d new channels.\n", scan->new_channels);
|
2014-06-09 21:54:45 +00:00
|
|
|
tv_channel_tmp=tvh->tv_channel_list;
|
2007-08-23 16:09:30 +00:00
|
|
|
if(tv_channel_tmp){
|
2013-12-21 19:24:20 +00:00
|
|
|
MP_INFO(tvh, "channels=");
|
2007-08-23 16:09:30 +00:00
|
|
|
while(tv_channel_tmp){
|
2013-12-21 19:24:20 +00:00
|
|
|
MP_INFO(tvh, "%s-%s",tv_channel_tmp->number,tv_channel_tmp->name);
|
2007-08-23 16:09:30 +00:00
|
|
|
if(tv_channel_tmp->next)
|
2013-12-21 19:24:20 +00:00
|
|
|
MP_INFO(tvh, ",");
|
2007-08-23 16:09:30 +00:00
|
|
|
tv_channel_tmp=tv_channel_tmp->next;
|
|
|
|
}
|
2013-12-21 19:24:20 +00:00
|
|
|
MP_INFO(tvh, "\n");
|
2007-08-23 16:09:30 +00:00
|
|
|
}
|
2014-06-09 21:54:45 +00:00
|
|
|
if (!tvh->tv_channel_current) tvh->tv_channel_current=tvh->tv_channel_list;
|
|
|
|
if (tvh->tv_channel_current)
|
|
|
|
tv_set_freq_float(tvh, tvh->tv_channel_current->freq);
|
2007-08-23 16:09:30 +00:00
|
|
|
free(tvh->scan);
|
|
|
|
tvh->scan=NULL;
|
|
|
|
}else{
|
|
|
|
cl = tvh->chanlist_s[scan->channel_num];
|
2012-10-30 17:28:34 +00:00
|
|
|
tv_set_freq_float(tvh, cl.freq);
|
2013-12-21 19:24:20 +00:00
|
|
|
MP_INFO(tvh, "Trying: %s (%.2f). \n",cl.name,1e-3*cl.freq);
|
2007-08-23 16:09:30 +00:00
|
|
|
}
|
|
|
|
}
|
2007-03-01 18:38:00 +00:00
|
|
|
|
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);
|
|
|
|
|
2011-05-04 20:12:55 +00:00
|
|
|
if (ret == TVI_CONTROL_TRUE) {
|
|
|
|
int *v = (int *)str;
|
|
|
|
return *v;
|
|
|
|
}
|
2007-10-14 05:18:32 +00:00
|
|
|
|
|
|
|
if(ret!=TVI_CONTROL_UNKNOWN)
|
|
|
|
{
|
2013-12-21 19:24:20 +00:00
|
|
|
MP_WARN(tvh, "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 {
|
2013-12-21 19:24:20 +00:00
|
|
|
MP_WARN(tvh, "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;
|
|
|
|
|
2013-12-21 19:24:20 +00:00
|
|
|
MP_INFO(tvh, "TV channel names detected.\n");
|
2014-06-09 21:54:45 +00:00
|
|
|
tvh->tv_channel_list = malloc(sizeof(tv_channels_t));
|
|
|
|
tvh->tv_channel_list->index=1;
|
|
|
|
tvh->tv_channel_list->next=NULL;
|
|
|
|
tvh->tv_channel_list->prev=NULL;
|
|
|
|
tvh->tv_channel_current = tvh->tv_channel_list;
|
|
|
|
tvh->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
|
|
|
|
|
2014-06-09 21:54:45 +00:00
|
|
|
av_strlcpy(tvh->tv_channel_current->name, sep + 1,
|
|
|
|
sizeof(tvh->tv_channel_current->name));
|
2007-08-28 14:36:13 +00:00
|
|
|
sep[0] = '\0';
|
2014-06-09 21:54:45 +00:00
|
|
|
strncpy(tvh->tv_channel_current->number, tmp, 5);
|
|
|
|
tvh->tv_channel_current->number[4]='\0';
|
2007-08-28 14:36:13 +00:00
|
|
|
|
2014-06-09 21:54:45 +00:00
|
|
|
while ((sep=strchr(tvh->tv_channel_current->name, '_')))
|
2007-08-28 14:36:13 +00:00
|
|
|
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){
|
2014-06-09 21:54:45 +00:00
|
|
|
tvh->tv_channel_current->freq=atoi(tmp);
|
2007-08-28 14:36:13 +00:00
|
|
|
}else{
|
2014-06-09 21:54:45 +00:00
|
|
|
tvh->tv_channel_current->freq = 0;
|
2007-08-28 14:36:13 +00:00
|
|
|
for (i = 0; i < chanlists[tvh->chanlist].count; i++) {
|
|
|
|
cl = tvh->chanlist_s[i];
|
2014-06-09 21:54:45 +00:00
|
|
|
if (!strcasecmp(cl.name, tvh->tv_channel_current->number)) {
|
|
|
|
tvh->tv_channel_current->freq=cl.freq;
|
2007-08-28 14:36:13 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-06-09 21:54:45 +00:00
|
|
|
if (tvh->tv_channel_current->freq == 0)
|
2013-12-21 19:24:20 +00:00
|
|
|
MP_ERR(tvh, "Couldn't find frequency for channel %s (%s)\n",
|
2014-06-09 21:54:45 +00:00
|
|
|
tvh->tv_channel_current->number, tvh->tv_channel_current->name);
|
2007-08-28 14:36:13 +00:00
|
|
|
else {
|
2014-06-09 21:54:45 +00:00
|
|
|
sep = strchr(tvh->tv_channel_current->name, '-');
|
|
|
|
if ( !sep ) sep = strchr(tvh->tv_channel_current->name, '+');
|
2007-08-28 14:36:13 +00:00
|
|
|
|
|
|
|
if ( sep ) {
|
|
|
|
i = atoi (sep+1);
|
2014-06-09 21:54:45 +00:00
|
|
|
if ( sep[0] == '+' ) tvh->tv_channel_current->freq += i * 100;
|
|
|
|
if ( sep[0] == '-' ) tvh->tv_channel_current->freq -= i * 100;
|
2007-08-28 14:36:13 +00:00
|
|
|
sep[0] = '\0';
|
|
|
|
}
|
2008-06-14 09:14:16 +00:00
|
|
|
|
2014-06-09 21:54:45 +00:00
|
|
|
sep = strchr(tvh->tv_channel_current->name, '=');
|
2008-06-14 09:14:16 +00:00
|
|
|
if ( sep ) {
|
2014-06-09 21:54:45 +00:00
|
|
|
tvh->tv_channel_current->norm = norm_from_string(tvh, sep+1);
|
2008-06-14 09:14:16 +00:00
|
|
|
sep[0] = '\0';
|
|
|
|
}
|
2007-08-28 14:36:13 +00:00
|
|
|
}
|
|
|
|
|
2013-12-21 19:24:20 +00:00
|
|
|
/*MP_INFO(tvh, "-- Detected channel %s - %s (%5.3f)\n",
|
2014-06-09 21:54:45 +00:00
|
|
|
tvh->tv_channel_current->number, tvh->tv_channel_current->name,
|
|
|
|
(float)tvh->tv_channel_current->freq/1000);*/
|
|
|
|
|
|
|
|
tvh->tv_channel_current->next = malloc(sizeof(tv_channels_t));
|
|
|
|
tvh->tv_channel_current->next->index = tvh->tv_channel_current->index + 1;
|
|
|
|
tvh->tv_channel_current->next->prev = tvh->tv_channel_current;
|
|
|
|
tvh->tv_channel_current->next->next = NULL;
|
|
|
|
tvh->tv_channel_current = tvh->tv_channel_current->next;
|
|
|
|
tvh->tv_channel_current->norm = tvh->norm;
|
2007-08-28 14:36:13 +00:00
|
|
|
}
|
2014-06-09 21:54:45 +00:00
|
|
|
if (tvh->tv_channel_current->prev)
|
|
|
|
tvh->tv_channel_current->prev->next = NULL;
|
|
|
|
free(tvh->tv_channel_current);
|
2007-08-28 14:36:13 +00:00
|
|
|
}
|
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);
|
|
|
|
|
2013-12-21 19:24:20 +00:00
|
|
|
MP_VERBOSE(tvh, "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) {
|
2014-04-13 16:00:51 +00:00
|
|
|
MP_ERR(tvh, "Error: Cannot set norm!\n");
|
|
|
|
return 0;
|
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;
|
|
|
|
|
2013-12-21 19:24:20 +00:00
|
|
|
MP_VERBOSE(tvh, "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) {
|
2013-12-21 19:24:20 +00:00
|
|
|
MP_ERR(tvh, "Error: Cannot set norm!\n");
|
2008-06-19 07:13:50 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-10-08 11:25:01 +00:00
|
|
|
return 1;
|
2008-06-19 07:13:50 +00:00
|
|
|
}
|
|
|
|
|
2012-06-09 11:11:57 +00:00
|
|
|
static void set_norm_and_freq(tvi_handle_t *tvh, tv_channels_t *chan)
|
|
|
|
{
|
2013-12-21 19:24:20 +00:00
|
|
|
MP_INFO(tvh, "Selected channel: %s - %s (freq: %.3f)\n",
|
2012-10-30 17:28:34 +00:00
|
|
|
chan->number, chan->name, chan->freq/1000.0);
|
2012-06-09 11:11:57 +00:00
|
|
|
tv_set_norm_i(tvh, chan->norm);
|
2012-10-30 17:28:34 +00:00
|
|
|
tv_set_freq_float(tvh, chan->freq);
|
2012-06-09 11:11:57 +00:00
|
|
|
}
|
|
|
|
|
2014-07-05 15:00:23 +00:00
|
|
|
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;
|
2012-10-30 17:28:34 +00:00
|
|
|
static const int tv_fmt_list[] = {
|
video: decouple internal pixel formats from FourCCs
mplayer's video chain traditionally used FourCCs for pixel formats. For
example, it used IMGFMT_YV12 for 4:2:0 YUV, which was defined to the
string 'YV12' interpreted as unsigned int. Additionally, it used to
encode information into the numeric values of some formats. The RGB
formats had their bit depth and endian encoded into the least
significant byte. Extended planar formats (420P10 etc.) had chroma
shift, endian, and component bit depth encoded. (This has been removed
in recent commits.)
Replace the FourCC mess with a simple enum. Remove all the redundant
formats like YV12/I420/IYUV. Replace some image format names by
something more intuitive, most importantly IMGFMT_YV12 -> IMGFMT_420P.
Add img_fourcc.h, which contains the old IDs for code that actually uses
FourCCs. Change the way demuxers, that output raw video, identify the
video format: they set either MP_FOURCC_RAWVIDEO or MP_FOURCC_IMGFMT to
request the rawvideo decoder, and sh_video->imgfmt specifies the pixel
format. Like the previous hack, this is supposed to avoid the need for
a complete codecs.cfg entry per format, or other lookup tables. (Note
that the RGB raw video FourCCs mostly rely on ffmpeg's mappings for NUT
raw video, but this is still considered better than adding a raw video
decoder - even if trivial, it would be full of annoying lookup tables.)
The TV code has not been tested.
Some corrective changes regarding endian and other image format flags
creep in.
2012-12-23 19:03:30 +00:00
|
|
|
MP_FOURCC_YV12,
|
|
|
|
MP_FOURCC_I420,
|
|
|
|
MP_FOURCC_UYVY,
|
|
|
|
MP_FOURCC_YUY2,
|
|
|
|
MP_FOURCC_RGB32,
|
|
|
|
MP_FOURCC_RGB24,
|
|
|
|
MP_FOURCC_RGB16,
|
|
|
|
MP_FOURCC_RGB15
|
2006-03-14 00:45:06 +00:00
|
|
|
};
|
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)
|
|
|
|
{
|
2014-04-13 16:00:51 +00:00
|
|
|
MP_ERR(tvh, "Error: No video input present!\n");
|
|
|
|
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
|
|
|
{
|
2014-04-13 16:00:51 +00:00
|
|
|
case MP_FOURCC_YV12:
|
|
|
|
case MP_FOURCC_I420:
|
|
|
|
case MP_FOURCC_UYVY:
|
|
|
|
case MP_FOURCC_YUY2:
|
|
|
|
case MP_FOURCC_RGB32:
|
|
|
|
case MP_FOURCC_RGB24:
|
|
|
|
case MP_FOURCC_BGR32:
|
|
|
|
case MP_FOURCC_BGR24:
|
|
|
|
case MP_FOURCC_BGR16:
|
|
|
|
case MP_FOURCC_BGR15:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
MP_ERR(tvh, "==================================================================\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
|
|
|
|
2013-10-17 21:13:55 +00:00
|
|
|
if ((!strcmp(tvh->tv_param->driver, "v4l2") && tvh->tv_param->normid >= 0))
|
2013-07-16 11:28:28 +00:00
|
|
|
tv_set_norm_i(tvh, tvh->tv_param->normid);
|
2008-06-14 09:14:16 +00:00
|
|
|
else
|
2013-10-17 21:13:55 +00:00
|
|
|
tv_set_norm(tvh,tvh->tv_param->norm);
|
2003-03-19 16:26:58 +00:00
|
|
|
|
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
|
|
|
{
|
2014-04-13 16:00:51 +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);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
MP_ERR(tvh, "Unable to set requested width: %d\n", tvh->tv_param->width);
|
|
|
|
funcs->control(tvh->priv, TVI_CONTROL_VID_GET_WIDTH, &tvh->tv_param->width);
|
|
|
|
}
|
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
|
|
|
{
|
2014-04-13 16:00:51 +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);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
MP_ERR(tvh, "Unable to set requested height: %d\n", tvh->tv_param->height);
|
|
|
|
funcs->control(tvh->priv, TVI_CONTROL_VID_GET_HEIGHT, &tvh->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)
|
|
|
|
{
|
2014-04-13 16:00:51 +00:00
|
|
|
MP_WARN(tvh, "Selected input hasn't got a tuner!\n");
|
|
|
|
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++)
|
|
|
|
{
|
2014-04-13 16:00:51 +00:00
|
|
|
if (!strcasecmp(chanlists[i].name, tvh->tv_param->chanlist))
|
|
|
|
{
|
|
|
|
tvh->chanlist = i;
|
|
|
|
tvh->chanlist_s = chanlists[i].list;
|
|
|
|
break;
|
|
|
|
}
|
2001-11-17 00:23:48 +00:00
|
|
|
}
|
|
|
|
|
2012-10-30 17:28:34 +00:00
|
|
|
if (tvh->chanlist == -1) {
|
2014-04-13 16:00:51 +00:00
|
|
|
MP_WARN(tvh, "Unable to find selected channel list! (%s)\n",
|
|
|
|
tvh->tv_param->chanlist);
|
2012-10-30 17:28:34 +00:00
|
|
|
return 0;
|
|
|
|
} else
|
2014-04-13 16:00:51 +00:00
|
|
|
MP_VERBOSE(tvh, "Selected channel list: %s (including %d channels)\n",
|
|
|
|
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
|
|
|
{
|
2014-04-13 16:00:51 +00:00
|
|
|
MP_WARN(tvh, "You can't set frequency and channel simultaneously!\n");
|
|
|
|
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
|
2014-06-09 21:54:45 +00:00
|
|
|
tvh->tv_channel_last_real = malloc(5);
|
2002-12-28 22:57:39 +00:00
|
|
|
|
2014-06-09 21:54:45 +00:00
|
|
|
if (tvh->tv_channel_list) {
|
2014-04-13 16:00:51 +00:00
|
|
|
int channel = 0;
|
|
|
|
if (tvh->tv_param->channel)
|
|
|
|
{
|
2014-07-01 21:10:38 +00:00
|
|
|
if (mp_isdigit(*tvh->tv_param->channel))
|
2014-04-13 16:00:51 +00:00
|
|
|
/* if tvh->tv_param->channel begins with a digit interpret it as a number */
|
|
|
|
channel = atoi(tvh->tv_param->channel);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* if tvh->tv_param->channel does not begin with a digit
|
|
|
|
set the first channel that contains tvh->tv_param->channel in its name */
|
|
|
|
|
2014-06-09 21:54:45 +00:00
|
|
|
tvh->tv_channel_current = tvh->tv_channel_list;
|
|
|
|
while ( tvh->tv_channel_current ) {
|
|
|
|
if ( strstr(tvh->tv_channel_current->name, tvh->tv_param->channel) )
|
2014-04-13 16:00:51 +00:00
|
|
|
break;
|
2014-06-09 21:54:45 +00:00
|
|
|
tvh->tv_channel_current = tvh->tv_channel_current->next;
|
2014-04-13 16:00:51 +00:00
|
|
|
}
|
2014-06-09 21:54:45 +00:00
|
|
|
if ( !tvh->tv_channel_current ) tvh->tv_channel_current = tvh->tv_channel_list;
|
2014-04-13 16:00:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
channel = 1;
|
|
|
|
|
|
|
|
if ( channel ) {
|
2014-06-09 21:54:45 +00:00
|
|
|
tvh->tv_channel_current = tvh->tv_channel_list;
|
2014-04-13 16:00:51 +00:00
|
|
|
for (int n = 1; n < channel; n++)
|
2014-06-09 21:54:45 +00:00
|
|
|
if (tvh->tv_channel_current->next)
|
|
|
|
tvh->tv_channel_current = tvh->tv_channel_current->next;
|
2014-04-13 16:00:51 +00:00
|
|
|
}
|
|
|
|
|
2014-06-09 21:54:45 +00:00
|
|
|
set_norm_and_freq(tvh, tvh->tv_channel_current);
|
|
|
|
tvh->tv_channel_last = tvh->tv_channel_current;
|
2002-12-28 22:57:39 +00:00
|
|
|
} 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
|
|
|
{
|
2014-04-13 16:00:51 +00:00
|
|
|
unsigned long freq = atof(tvh->tv_param->freq)*16;
|
2001-12-03 16:38:40 +00:00
|
|
|
|
|
|
|
/* set freq in MHz */
|
2014-04-13 16:00:51 +00:00
|
|
|
funcs->control(tvh->priv, TVI_CONTROL_TUN_SET_FREQ, &freq);
|
2001-12-03 16:38:40 +00:00
|
|
|
|
2014-04-13 16:00:51 +00:00
|
|
|
funcs->control(tvh->priv, TVI_CONTROL_TUN_GET_FREQ, &freq);
|
|
|
|
MP_VERBOSE(tvh, "Selected frequency: %lu (%.3f)\n",
|
|
|
|
freq, freq/16.0);
|
2001-12-03 16:38:40 +00:00
|
|
|
}
|
2001-11-17 00:23:48 +00:00
|
|
|
|
2014-04-13 16:00:51 +00:00
|
|
|
if (tvh->tv_param->channel) {
|
|
|
|
struct CHANLIST cl;
|
|
|
|
|
|
|
|
MP_VERBOSE(tvh, "Requested channel: %s\n", tvh->tv_param->channel);
|
|
|
|
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, tvh->tv_param->channel))
|
|
|
|
{
|
2014-06-09 21:54:45 +00:00
|
|
|
strcpy(tvh->tv_channel_last_real, cl.name);
|
2014-04-13 16:00:51 +00:00
|
|
|
tvh->channel = i;
|
|
|
|
MP_INFO(tvh, "Selected channel: %s (freq: %.3f)\n",
|
|
|
|
cl.name, cl.freq/1000.0);
|
|
|
|
tv_set_freq_float(tvh, cl.freq);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2001-11-17 00:23:48 +00:00
|
|
|
}
|
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 */
|
|
|
|
{
|
2014-04-13 16:00:51 +00:00
|
|
|
unsigned long i2;
|
|
|
|
int freq;
|
2007-10-14 04:56:01 +00:00
|
|
|
|
2014-04-13 16:00:51 +00:00
|
|
|
tv_get_freq(tvh, &i2);
|
2007-10-14 04:56:01 +00:00
|
|
|
|
2014-04-13 16:00:51 +00:00
|
|
|
freq = (int) (((float)(i2/16))*1000)+250;
|
2007-10-14 04:56:01 +00:00
|
|
|
|
2014-04-13 16:00:51 +00:00
|
|
|
for (i = 0; i < chanlists[tvh->chanlist].count; i++)
|
|
|
|
{
|
|
|
|
if (tvh->chanlist_s[i].freq == freq)
|
|
|
|
{
|
|
|
|
tvh->channel = i+1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2002-10-19 20:55:06 +00:00
|
|
|
}
|
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! */
|
2014-04-13 16:00:51 +00:00
|
|
|
return 1;
|
2001-11-16 21:53:07 +00:00
|
|
|
}
|
|
|
|
|
2014-07-05 15:00:23 +00:00
|
|
|
tvi_handle_t *tv_begin(tv_param_t* tv_param, struct mp_log *log)
|
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")){
|
2013-12-21 19:24:20 +00:00
|
|
|
mp_info(log, "Available drivers:\n");
|
2007-07-29 03:33:39 +00:00
|
|
|
for(i=0;tvi_driver_list[i];i++){
|
2014-06-09 22:47:10 +00:00
|
|
|
mp_info(log, " %s\t%s\n",tvi_driver_list[i]->short_name,tvi_driver_list[i]->name);
|
2014-04-13 16:00:51 +00:00
|
|
|
}
|
|
|
|
return NULL;
|
2007-07-29 03:33:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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)){
|
2013-12-21 19:24:20 +00:00
|
|
|
h=tvi_driver_list[i]->tvi_init(log, 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;
|
2014-06-09 22:47:10 +00:00
|
|
|
MP_INFO(h, "Selected driver: %s\n name: %s\n", tvi_driver_list[i]->short_name,
|
|
|
|
tvi_driver_list[i]->name);
|
2014-06-09 21:54:45 +00:00
|
|
|
talloc_free(tv_param->driver);
|
|
|
|
tv_param->driver=talloc_strdup(NULL, 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)
|
2013-12-21 19:24:20 +00:00
|
|
|
mp_err(log, "No such driver: %s\n", tv_param->driver);
|
2007-09-10 17:09:35 +00:00
|
|
|
else
|
2013-12-21 19:24:20 +00:00
|
|
|
mp_err(log, "TV driver autodetection failed.\n");
|
2008-05-16 08:43:15 +00:00
|
|
|
return NULL;
|
2007-07-29 03:33:39 +00:00
|
|
|
}
|
|
|
|
|
2014-07-05 15:00:23 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2001-11-16 22:59:07 +00:00
|
|
|
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)
|
|
|
|
{
|
2014-04-13 16:00:51 +00:00
|
|
|
case TV_COLOR_BRIGHTNESS:
|
|
|
|
return funcs->control(tvh->priv, TVI_CONTROL_VID_SET_BRIGHTNESS, &value);
|
|
|
|
case TV_COLOR_HUE:
|
|
|
|
return funcs->control(tvh->priv, TVI_CONTROL_VID_SET_HUE, &value);
|
|
|
|
case TV_COLOR_SATURATION:
|
|
|
|
return funcs->control(tvh->priv, TVI_CONTROL_VID_SET_SATURATION, &value);
|
|
|
|
case TV_COLOR_CONTRAST:
|
|
|
|
return funcs->control(tvh->priv, TVI_CONTROL_VID_SET_CONTRAST, &value);
|
|
|
|
default:
|
|
|
|
MP_WARN(tvh, "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)
|
|
|
|
{
|
2014-04-13 16:00:51 +00:00
|
|
|
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:
|
|
|
|
MP_WARN(tvh, "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)
|
|
|
|
{
|
2014-04-13 16:00:51 +00:00
|
|
|
tvh->functions->control(tvh->priv, TVI_CONTROL_TUN_GET_FREQ, freq);
|
|
|
|
MP_VERBOSE(tvh, "Current frequency: %lu (%.3f)\n",
|
|
|
|
*freq, *freq/16.0);
|
2002-10-19 20:55:06 +00:00
|
|
|
}
|
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)
|
|
|
|
{
|
2014-04-13 16:00:51 +00:00
|
|
|
// unsigned long freq = atof(tvh->tv_param->freq)*16;
|
2001-11-17 00:23:48 +00:00
|
|
|
|
|
|
|
/* set freq in MHz */
|
2014-04-13 16:00:51 +00:00
|
|
|
tvh->functions->control(tvh->priv, TVI_CONTROL_TUN_SET_FREQ, &freq);
|
2001-11-17 00:23:48 +00:00
|
|
|
|
2014-04-13 16:00:51 +00:00
|
|
|
tvh->functions->control(tvh->priv, TVI_CONTROL_TUN_GET_FREQ, &freq);
|
|
|
|
MP_VERBOSE(tvh, "Current frequency: %lu (%.3f)\n",
|
|
|
|
freq, freq/16.0);
|
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
|
|
|
}
|
|
|
|
|
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)
|
|
|
|
{
|
2014-04-13 16:00:51 +00:00
|
|
|
if (tvh->channel-1 >= 0)
|
|
|
|
{
|
2014-06-09 21:54:45 +00:00
|
|
|
strcpy(tvh->tv_channel_last_real, tvh->chanlist_s[tvh->channel].name);
|
2014-04-13 16:00:51 +00:00
|
|
|
cl = tvh->chanlist_s[--tvh->channel];
|
|
|
|
MP_INFO(tvh, "Selected channel: %s (freq: %.3f)\n",
|
|
|
|
cl.name, cl.freq/1000.0);
|
|
|
|
tv_set_freq_float(tvh, cl.freq);
|
|
|
|
}
|
2001-11-17 00:23:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (direction == TV_CHANNEL_HIGHER)
|
|
|
|
{
|
2014-04-13 16:00:51 +00:00
|
|
|
if (tvh->channel+1 < chanlists[tvh->chanlist].count)
|
|
|
|
{
|
2014-06-09 21:54:45 +00:00
|
|
|
strcpy(tvh->tv_channel_last_real, tvh->chanlist_s[tvh->channel].name);
|
2014-04-13 16:00:51 +00:00
|
|
|
cl = tvh->chanlist_s[++tvh->channel];
|
|
|
|
MP_INFO(tvh, "Selected channel: %s (freq: %.3f)\n",
|
|
|
|
cl.name, cl.freq/1000.0);
|
|
|
|
tv_set_freq_float(tvh, cl.freq);
|
|
|
|
}
|
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) {
|
2014-04-13 16:00:51 +00:00
|
|
|
tvh->tv_param->scan=0;
|
2014-06-09 21:54:45 +00:00
|
|
|
if (tvh->tv_channel_list) {
|
2014-04-13 16:00:51 +00:00
|
|
|
if (direction == TV_CHANNEL_HIGHER) {
|
2014-06-09 21:54:45 +00:00
|
|
|
tvh->tv_channel_last = tvh->tv_channel_current;
|
|
|
|
if (tvh->tv_channel_current->next)
|
|
|
|
tvh->tv_channel_current = tvh->tv_channel_current->next;
|
2014-04-13 16:00:51 +00:00
|
|
|
else
|
2014-06-09 21:54:45 +00:00
|
|
|
tvh->tv_channel_current = tvh->tv_channel_list;
|
|
|
|
set_norm_and_freq(tvh, tvh->tv_channel_current);
|
2014-04-13 16:00:51 +00:00
|
|
|
}
|
|
|
|
if (direction == TV_CHANNEL_LOWER) {
|
2014-06-09 21:54:45 +00:00
|
|
|
tvh->tv_channel_last = tvh->tv_channel_current;
|
|
|
|
if (tvh->tv_channel_current->prev)
|
|
|
|
tvh->tv_channel_current = tvh->tv_channel_current->prev;
|
2014-04-13 16:00:51 +00:00
|
|
|
else
|
2014-06-09 21:54:45 +00:00
|
|
|
while (tvh->tv_channel_current->next)
|
|
|
|
tvh->tv_channel_current = tvh->tv_channel_current->next;
|
|
|
|
set_norm_and_freq(tvh, tvh->tv_channel_current);
|
2014-04-13 16:00:51 +00:00
|
|
|
}
|
|
|
|
} else tv_step_channel_real(tvh, direction);
|
|
|
|
return 1;
|
2002-12-28 22:57:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int tv_set_channel_real(tvi_handle_t *tvh, char *channel) {
|
2014-04-13 16:00:51 +00:00
|
|
|
int i;
|
|
|
|
struct CHANLIST cl;
|
2002-12-19 10:09:43 +00:00
|
|
|
|
2007-08-23 16:09:30 +00:00
|
|
|
tvh->tv_param->scan=0;
|
2014-06-09 21:54:45 +00:00
|
|
|
strcpy(tvh->tv_channel_last_real, tvh->chanlist_s[tvh->channel].name);
|
2014-04-13 16:00:51 +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_INFO(tvh, "Selected channel: %s (freq: %.3f)\n",
|
|
|
|
cl.name, cl.freq/1000.0);
|
|
|
|
tv_set_freq_float(tvh, cl.freq);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 1;
|
2002-12-28 22:57:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int tv_set_channel(tvi_handle_t *tvh, char *channel) {
|
2014-04-13 16:00:51 +00:00
|
|
|
int i, channel_int;
|
|
|
|
|
|
|
|
tvh->tv_param->scan=0;
|
2014-06-09 21:54:45 +00:00
|
|
|
if (tvh->tv_channel_list) {
|
|
|
|
tvh->tv_channel_last = tvh->tv_channel_current;
|
2014-04-13 16:00:51 +00:00
|
|
|
channel_int = atoi(channel);
|
2014-06-09 21:54:45 +00:00
|
|
|
tvh->tv_channel_current = tvh->tv_channel_list;
|
2014-04-13 16:00:51 +00:00
|
|
|
for (i = 1; i < channel_int; i++)
|
2014-06-09 21:54:45 +00:00
|
|
|
if (tvh->tv_channel_current->next)
|
|
|
|
tvh->tv_channel_current = tvh->tv_channel_current->next;
|
|
|
|
set_norm_and_freq(tvh, tvh->tv_channel_current);
|
2014-04-13 16:00:51 +00:00
|
|
|
} else tv_set_channel_real(tvh, channel);
|
|
|
|
return 1;
|
2002-12-28 22:57:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int tv_last_channel(tvi_handle_t *tvh) {
|
|
|
|
|
2014-04-13 16:00:51 +00:00
|
|
|
tvh->tv_param->scan=0;
|
2014-06-09 21:54:45 +00:00
|
|
|
if (tvh->tv_channel_list) {
|
2014-04-13 16:00:51 +00:00
|
|
|
tv_channels_t *tmp;
|
|
|
|
|
2014-06-09 21:54:45 +00:00
|
|
|
tmp = tvh->tv_channel_last;
|
|
|
|
tvh->tv_channel_last = tvh->tv_channel_current;
|
|
|
|
tvh->tv_channel_current = tmp;
|
2014-04-13 16:00:51 +00:00
|
|
|
|
2014-06-09 21:54:45 +00:00
|
|
|
set_norm_and_freq(tvh, tvh->tv_channel_current);
|
2014-04-13 16:00:51 +00:00
|
|
|
} else {
|
|
|
|
int i;
|
|
|
|
struct CHANLIST cl;
|
|
|
|
|
|
|
|
for (i = 0; i < chanlists[tvh->chanlist].count; i++)
|
|
|
|
{
|
|
|
|
cl = tvh->chanlist_s[i];
|
2014-06-09 21:54:45 +00:00
|
|
|
if (!strcasecmp(cl.name, tvh->tv_channel_last_real))
|
2014-04-13 16:00:51 +00:00
|
|
|
{
|
2014-06-09 21:54:45 +00:00
|
|
|
strcpy(tvh->tv_channel_last_real, tvh->chanlist_s[tvh->channel].name);
|
2014-04-13 16:00:51 +00:00
|
|
|
tvh->channel = i;
|
|
|
|
MP_INFO(tvh, "Selected channel: %s (freq: %.3f)\n",
|
|
|
|
cl.name, cl.freq/1000.0);
|
|
|
|
tv_set_freq_float(tvh, cl.freq);
|
|
|
|
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)
|
|
|
|
{
|
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) {
|
2013-12-21 19:24:20 +00:00
|
|
|
MP_ERR(tvh, "Error: Cannot set norm!\n");
|
2005-11-10 20:31:27 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
2008-05-16 08:43:15 +00:00
|
|
|
return 1;
|
2001-11-17 00:23:48 +00:00
|
|
|
}
|
|
|
|
|
2014-07-05 15:00:23 +00:00
|
|
|
int tv_stream_control(tvi_handle_t *tvh, int cmd, void *arg)
|
2001-11-17 00:23:48 +00:00
|
|
|
{
|
command: redo ancient TV/DVB/PVR commands
Convert all these commands to properties. (Except tv_last_channel, not
sure what to do with this.) Also, internally, don't access stream
details directly, but dispatch commands with stream ctrls.
Many of the new properties are a bit strange, because they're write-
only. Also remove some OSD output these commands produced, because I
couldn't be bothered to port these.
In general, this makes everything much cleaner, and will also make it
easier to e.g. move the demuxer to its own thread.
Don't bother updating input.conf, but changes.rst documents how old
commands map to the new ones.
Mostly untested, due to lack of hardware.
2014-06-09 21:38:28 +00:00
|
|
|
switch (cmd) {
|
|
|
|
case STREAM_CTRL_TV_SET_SCAN:
|
|
|
|
tv_start_scan(tvh, *(int *)arg);
|
|
|
|
return STREAM_OK;
|
|
|
|
case STREAM_CTRL_SET_TV_FREQ:
|
|
|
|
tv_set_freq(tvh, *(float *)arg * 16.0f);
|
|
|
|
return STREAM_OK;
|
|
|
|
case STREAM_CTRL_GET_TV_FREQ: {
|
|
|
|
unsigned long tmp = 0;
|
|
|
|
tv_get_freq(tvh, &tmp);
|
|
|
|
*(float *)arg = tmp / 16.0f;
|
|
|
|
return STREAM_OK;
|
|
|
|
}
|
|
|
|
case STREAM_CTRL_SET_TV_COLORS:
|
|
|
|
tv_set_color_options(tvh, ((int *)arg)[0], ((int *)arg)[1]);
|
|
|
|
return STREAM_OK;
|
|
|
|
case STREAM_CTRL_GET_TV_COLORS:
|
|
|
|
tv_get_color_options(tvh, ((int *)arg)[0], &((int *)arg)[1]);
|
|
|
|
return STREAM_OK;
|
|
|
|
case STREAM_CTRL_TV_SET_NORM:
|
|
|
|
tv_set_norm(tvh, (char *)arg);
|
|
|
|
return STREAM_OK;
|
|
|
|
case STREAM_CTRL_TV_STEP_NORM:
|
|
|
|
tv_step_norm(tvh);
|
|
|
|
return STREAM_OK;
|
|
|
|
case STREAM_CTRL_TV_SET_CHAN:
|
|
|
|
tv_set_channel(tvh, (char *)arg);
|
|
|
|
return STREAM_OK;
|
|
|
|
case STREAM_CTRL_TV_STEP_CHAN:
|
|
|
|
if (*(int *)arg >= 0) {
|
|
|
|
tv_step_channel(tvh, TV_CHANNEL_HIGHER);
|
|
|
|
} else {
|
|
|
|
tv_step_channel(tvh, TV_CHANNEL_LOWER);
|
|
|
|
}
|
|
|
|
return STREAM_OK;
|
|
|
|
case STREAM_CTRL_TV_LAST_CHAN:
|
|
|
|
tv_last_channel(tvh);
|
|
|
|
return STREAM_OK;
|
|
|
|
}
|
|
|
|
return STREAM_UNSUPPORTED;
|
|
|
|
}
|