From bfddb0aa03a57024070b78c2bb5c4a78d8391f9d Mon Sep 17 00:00:00 2001 From: henry Date: Thu, 19 Dec 2002 10:09:43 +0000 Subject: [PATCH] add a TV_SET_CNANNEL command git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@8495 b3059339-0415-0410-9bf9-f77b7e298cf2 --- input/input.c | 1 + input/input.h | 1 + libmpdemux/tv.c | 21 +++++++++++++++++++++ libmpdemux/tv.h | 2 ++ mplayer.c | 4 ++++ 5 files changed, 29 insertions(+) diff --git a/input/input.c b/input/input.c index 998d7a4d46..3cce4ebf33 100644 --- a/input/input.c +++ b/input/input.c @@ -74,6 +74,7 @@ static mp_cmd_t mp_cmds[] = { { MP_CMD_TV_STEP_CHANNEL, "tv_step_channel", 1, { { MP_CMD_ARG_INT ,{0}}, {-1,{0}} }}, { MP_CMD_TV_STEP_NORM, "tv_step_norm",0, { {-1,{0}} } }, { MP_CMD_TV_STEP_CHANNEL_LIST, "tv_step_chanlist", 0, { {-1,{0}} } }, + { MP_CMD_TV_SET_CHANNEL, "tv_set_channel", 1, { { MP_CMD_ARG_STRING, {0}}, {-1,{0}} }}, #endif { MP_CMD_VO_FULLSCREEN, "vo_fullscreen", 0, { {-1,{0}} } }, { MP_CMD_SCREENSHOT, "screenshot", 0, { {-1,{0}} } }, diff --git a/input/input.h b/input/input.h index c4443fdb81..95b606bc6e 100644 --- a/input/input.h +++ b/input/input.h @@ -19,6 +19,7 @@ #define MP_CMD_TV_STEP_CHANNEL 17 #define MP_CMD_TV_STEP_NORM 18 #define MP_CMD_TV_STEP_CHANNEL_LIST 19 +#define MP_CMD_TV_SET_CHANNEL 37 #define MP_CMD_VO_FULLSCREEN 20 #define MP_CMD_SUB_POS 21 #define MP_CMD_DVDNAV 22 diff --git a/libmpdemux/tv.c b/libmpdemux/tv.c index 5d32e4cfb9..6a90f31ac5 100644 --- a/libmpdemux/tv.c +++ b/libmpdemux/tv.c @@ -554,6 +554,27 @@ int tv_step_channel(tvi_handle_t *tvh, int direction) return(1); } +int tv_set_channel(tvi_handle_t *tvh, char *channel) +{ + int i; + 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, 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; + } + } +} + int tv_step_norm(tvi_handle_t *tvh) { return(1); diff --git a/libmpdemux/tv.h b/libmpdemux/tv.h index 6afaf20a9a..4f2cb9e41c 100644 --- a/libmpdemux/tv.h +++ b/libmpdemux/tv.h @@ -148,6 +148,8 @@ int tv_step_channel(tvi_handle_t *tvh, int direction); #define TV_CHANNEL_LOWER 1 #define TV_CHANNEL_HIGHER 2 +int tv_set_channel(tvi_handle_t *tvh, char *channel); + int tv_step_norm(tvi_handle_t *tvh); int tv_step_chanlist(tvi_handle_t *tvh); diff --git a/mplayer.c b/mplayer.c index e01b951e8f..2e8a02d5a8 100644 --- a/mplayer.c +++ b/mplayer.c @@ -2288,6 +2288,10 @@ if (stream->type==STREAMTYPE_DVDNAV && dvd_nav_still) tv_step_channel((tvi_handle_t*)(demuxer->priv), TV_CHANNEL_LOWER); } } break; + case MP_CMD_TV_SET_CHANNEL : { + if (tv_param_on == 1) + tv_set_channel((tvi_handle_t*)(demuxer->priv), cmd->args[0].v.s); + } break; case MP_CMD_TV_STEP_NORM : { if (tv_param_on == 1) tv_step_norm((tvi_handle_t*)(demuxer->priv));