From aa234b197bce7c4e7a75f3a8e2ca813df298e499 Mon Sep 17 00:00:00 2001 From: alex Date: Sat, 17 Nov 2001 00:23:48 +0000 Subject: [PATCH] added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@2942 b3059339-0415-0410-9bf9-f77b7e298cf2 --- cfg-common.h | 1 + libmpdemux/Makefile | 2 +- libmpdemux/tv.c | 104 +++++++++++++++++++++++++++++++++++++++++++ libmpdemux/tv.h | 24 +++++++++- libmpdemux/tvi_def.h | 4 ++ mplayer.c | 26 +++++++++++ 6 files changed, 159 insertions(+), 2 deletions(-) diff --git a/cfg-common.h b/cfg-common.h index fe101cf78e..14a7d0bbe7 100644 --- a/cfg-common.h +++ b/cfg-common.h @@ -98,6 +98,7 @@ struct config tvopts_conf[]={ {"device", &tv_param_device, CONF_TYPE_STRING, 0, 0, 0}, {"freq", &tv_param_freq, CONF_TYPE_STRING, 0, 0, 0}, {"channel", &tv_param_channel, CONF_TYPE_STRING, 0, 0, 0}, + {"chanlist", &tv_param_chanlist, CONF_TYPE_STRING, 0, 0, 0}, {"norm", &tv_param_norm, CONF_TYPE_STRING, 0, 0, 0}, {"width", &tv_param_width, CONF_TYPE_INT, 0, 0, 4096}, {"height", &tv_param_height, CONF_TYPE_INT, 0, 0, 4096}, diff --git a/libmpdemux/Makefile b/libmpdemux/Makefile index 9b3f058a59..b39e53b807 100644 --- a/libmpdemux/Makefile +++ b/libmpdemux/Makefile @@ -3,7 +3,7 @@ LIBNAME = libmpdemux.a include ../config.mak -SRCS = mp3_hdr.c video.c mpeg_hdr.c cache2.c asfheader.c aviheader.c aviprint.c aviwrite.c demux_asf.c demux_avi.c demux_mov.c demux_mpg.c demux_viv.c demuxer.c dvdauth.c open.c parse_es.c stream.c tv.c tvi_dummy.c tvi_v4l.c +SRCS = mp3_hdr.c video.c mpeg_hdr.c cache2.c asfheader.c aviheader.c aviprint.c aviwrite.c demux_asf.c demux_avi.c demux_mov.c demux_mpg.c demux_viv.c demuxer.c dvdauth.c open.c parse_es.c stream.c tv.c tvi_dummy.c tvi_v4l.c frequencies.c ifeq ($(STREAMING),yes) SRCS += asf_streaming.c url.c http.c network.c endif diff --git a/libmpdemux/tv.c b/libmpdemux/tv.c index 685b70e01a..b8a7af98c5 100644 --- a/libmpdemux/tv.c +++ b/libmpdemux/tv.c @@ -29,10 +29,13 @@ int tv_param_on = 0; #include "tv.h" +#include "frequencies.h" + /* some default values */ char *tv_param_freq = NULL; char *tv_param_channel = "26"; /* hungarian national tv channel 1 */ char *tv_param_norm = "pal"; +char *tv_param_chanlist = "europe-east"; char *tv_param_device = NULL; char *tv_param_driver = "dummy"; int tv_param_width = -1; @@ -92,6 +95,7 @@ int demux_tv_fill_buffer(demuxer_t *demux, tvi_handle_t *tvh) int stream_open_tv(stream_t *stream, tvi_handle_t *tvh) { + int i; tvi_functions_t *funcs = tvh->functions; int picture_format = 0; @@ -160,6 +164,56 @@ int stream_open_tv(stream_t *stream, tvi_handle_t *tvh) mp_msg(MSGT_TV, MSGL_INFO, "Current frequency: %lu (%.3f)\n", freq, (float)freq/16); } + + /* 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; + + mp_msg(MSGT_TV, MSGL_INFO, "Selected norm: %s\n", tv_param_norm); + + /* 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); + + mp_msg(MSGT_TV, MSGL_INFO, "Selected channel list: %s (including %d channels)\n", + chanlists[tvh->chanlist].name, chanlists[tvh->chanlist].count); + + if (tv_param_freq && tv_param_channel) + mp_msg(MSGT_TV, MSGL_HINT, "You can't set frequency and channel simultanly!\n"); + + if (!tv_param_freq && tv_param_channel) + { + struct CHANLIST cl; + 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, tv_param_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; + } + } + } /* also start device! */ return(funcs->start(tvh->priv)); @@ -366,4 +420,54 @@ int tv_set_color_options(tvi_handle_t *tvh, int opt, int value) return(1); } + +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); + mp_msg(MSGT_TV, MSGL_INFO, "Current frequency: %lu (%.3f)\n", + freq, (float)freq/16); + } +} + +int tv_step_channel(tvi_handle_t *tvh, int direction) +{ + struct CHANLIST cl; + + if (direction == TV_CHANNEL_LOWER) + { + if (tvh->channel-1 >= 0) + { + cl = tvh->chanlist_s[tvh->channel--]; + 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) + { + if (tvh->channel+1 <= chanlists[tvh->chanlist].count) + { + cl = tvh->chanlist_s[tvh->channel++]; + 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)); + } + } +} + +int tv_step_norm(tvi_handle_t *tvh) +{ +} + +int tv_step_chanlist(tvi_handle_t *tvh) +{ +} #endif /* USE_TV */ diff --git a/libmpdemux/tv.h b/libmpdemux/tv.h index 972a790f33..8fa0e596f3 100644 --- a/libmpdemux/tv.h +++ b/libmpdemux/tv.h @@ -1,3 +1,5 @@ +#ifndef TV_H +#define TV_H extern int tv_param_on; @@ -9,6 +11,7 @@ extern int tv_param_on; extern char *tv_param_freq; extern char *tv_param_channel; +extern char *tv_param_chanlist; extern char *tv_param_norm; extern char *tv_param_device; extern char *tv_param_driver; @@ -48,6 +51,12 @@ typedef struct tvi_handle_s { void *priv; tvi_param_t *params; int seq; + + /* specific */ + int norm; + int chanlist; + struct CHANLIST *chanlist_s; + int channel; } tvi_handle_t; @@ -111,10 +120,23 @@ extern tvi_handle_t *tv_begin(void); extern int tv_init(tvi_handle_t *tvh); extern int tv_uninit(tvi_handle_t *tvh); - +int tv_set_color_options(tvi_handle_t *tvh, int opt, int val); #define TV_COLOR_BRIGHTNESS 1 #define TV_COLOR_HUE 2 #define TV_COLOR_SATURATION 3 #define TV_COLOR_CONTRAST 4 +int tv_step_channel(tvi_handle_t *tvh, int direction); +#define TV_CHANNEL_LOWER 1 +#define TV_CHANNEL_HIGHER 2 + +int tv_step_norm(tvi_handle_t *tvh); +int tv_step_chanlist(tvi_handle_t *tvh); + +#define TV_NORM_PAL 1 +#define TV_NORM_NTSC 2 +#define TV_NORM_SECAM 3 + #endif /* USE_TV */ + +#endif /* TV_H */ diff --git a/libmpdemux/tvi_def.h b/libmpdemux/tvi_def.h index 30658f3304..aaca6d5a2f 100644 --- a/libmpdemux/tvi_def.h +++ b/libmpdemux/tvi_def.h @@ -36,6 +36,10 @@ static tvi_handle_t *new_handle() h->functions = &functions; h->params = NULL; h->seq = 0; + h->chanlist = -1; + h->chanlist_s = NULL; + h->norm = -1; + h->channel = -1; return(h); } diff --git a/mplayer.c b/mplayer.c index b616eeeeca..b23d5f52c8 100644 --- a/mplayer.c +++ b/mplayer.c @@ -79,6 +79,13 @@ int quiet=0; #include #endif +#ifdef USE_TV +#include "libmpdemux/tv.h" + +extern int tv_param_on; +extern tvi_handle_t *tv_handler; +#endif + //**************************************************************************// // Config file //**************************************************************************// @@ -1820,6 +1827,25 @@ if(step_sec>0) { frame_dropping=(frame_dropping+1)%3; mp_msg(MSGT_CPLAYER,MSGL_V,"== drop: %d == \n",frame_dropping); break; + +#ifdef USE_TV + case 'h': + if (tv_param_on == 1) + tv_step_channel(tv_handler, TV_CHANNEL_HIGHER); + break; + case 'l': + if (tv_param_on == 1) + tv_step_channel(tv_handler, TV_CHANNEL_LOWER); + break; + case 'n': + if (tv_param_on == 1) + tv_step_norm(tv_handler); + break; + case 'b': + if (tv_param_on == 1) + tv_step_chanlist(tv_handler); + break; +#endif } } // keyboard event handler