From bff4b3ee5eda10ba77f968015e9bcc7585a793e9 Mon Sep 17 00:00:00 2001 From: gabucino Date: Mon, 4 Aug 2003 09:13:10 +0000 Subject: I'd like to change tv tuner frequency in the slave mode. So this patch helps me. Patch by Kir Kostuchenko git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@10522 b3059339-0415-0410-9bf9-f77b7e298cf2 --- DOCS/tech/slave.txt | 4 ++++ input/input.c | 2 ++ input/input.h | 2 ++ libmpdemux/tv.c | 56 +++++++++++++++++++++++++++++++++-------------------- libmpdemux/tv.h | 5 +++++ mplayer.c | 8 ++++++++ 6 files changed, 56 insertions(+), 21 deletions(-) diff --git a/DOCS/tech/slave.txt b/DOCS/tech/slave.txt index b344217790..1a708d4324 100644 --- a/DOCS/tech/slave.txt +++ b/DOCS/tech/slave.txt @@ -76,5 +76,9 @@ tv_set_channel channel Set the current TV channel. tv_last_channel Set the current TV channel to the last one. +tv_set_freq + Set the tv tuner frequency. +tv_set_norm + Set the tv tuner norm. PAL, SECAM, NTSC and so on.. gui_[loadsubtitle|about|play|stop] GUI actions diff --git a/input/input.c b/input/input.c index bcac10be80..29949c2782 100644 --- a/input/input.c +++ b/input/input.c @@ -85,6 +85,8 @@ static mp_cmd_t mp_cmds[] = { { 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}} }}, { MP_CMD_TV_LAST_CHANNEL, "tv_last_channel", 0, { {-1,{0}} } }, + { MP_CMD_TV_SET_FREQ, "tv_set_freq", 1, { {MP_CMD_ARG_FLOAT,{0}}, {-1,{0}} } }, + { MP_CMD_TV_SET_NORM, "tv_set_norm", 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 34ff50067d..1e6392d612 100644 --- a/input/input.h +++ b/input/input.h @@ -43,6 +43,8 @@ #define MP_CMD_SUB_ALIGNMENT 39 #define MP_CMD_TV_LAST_CHANNEL 40 #define MP_CMD_OSD_SHOW_TEXT 41 +#define MP_CMD_TV_SET_FREQ 42 +#define MP_CMD_TV_SET_NORM 43 #define MP_CMD_GUI_EVENTS 5000 #define MP_CMD_GUI_LOADFILE 5001 diff --git a/libmpdemux/tv.c b/libmpdemux/tv.c index 3268623436..f212252581 100644 --- a/libmpdemux/tv.c +++ b/libmpdemux/tv.c @@ -118,9 +118,27 @@ int demux_tv_fill_buffer(demuxer_t *demux, demux_stream_t *ds) return 1; } - /* forward declarations */ -int tv_set_freq(tvi_handle_t *tvh, unsigned long freq); -int tv_get_freq(tvi_handle_t *tvh, unsigned long *freq); +static int norm_from_string(char* norm) +{ + if (!strcasecmp(norm, "pal")) + return TV_NORM_PAL; + else if (!strcasecmp(norm, "ntsc")) + return TV_NORM_NTSC; + else if (!strcasecmp(norm, "secam")) + return TV_NORM_SECAM; + else if (!strcasecmp(norm, "palnc")) + return TV_NORM_PALNC; + else if (!strcasecmp(norm, "palm")) + return TV_NORM_PALM; + else if (!strcasecmp(norm, "paln")) + return TV_NORM_PALN; + else if (!strcasecmp(norm, "ntscjp")) + return TV_NORM_NTSCJP; + else { + mp_msg(MSGT_TV, MSGL_V, "tv.c : norm_from_string(%s): Bogus norm parameter, setting PAL.\n", norm); + return TV_NORM_PAL; + } +} static int open_tv(tvi_handle_t *tvh) { @@ -162,24 +180,7 @@ static int open_tv(tvi_handle_t *tvh) 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; - 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; - else { - mp_msg(MSGT_TV, MSGL_V, "Bogus norm parameter, setting PAL.\n"); - tvh->norm = TV_NORM_PAL; - } + tvh->norm = norm_from_string(tv_param_norm); mp_msg(MSGT_TV, MSGL_V, "Selected norm: %s\n", tv_param_norm); if (funcs->control(tvh->priv, TVI_CONTROL_TUN_SET_NORM, &tvh->norm) != TVI_CONTROL_TRUE) { @@ -804,4 +805,17 @@ int tv_step_chanlist(tvi_handle_t *tvh) { return(1); } + +int tv_set_norm(tvi_handle_t *tvh, char* norm) +{ + tvh->norm = norm_from_string(norm); + + mp_msg(MSGT_TV, MSGL_V, "Selected norm: %s\n", tv_param_norm); + if (tvh->functions->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; + } + return(1); +} + #endif /* USE_TV */ diff --git a/libmpdemux/tv.h b/libmpdemux/tv.h index 18ef4c52e6..fcacf3adb3 100644 --- a/libmpdemux/tv.h +++ b/libmpdemux/tv.h @@ -177,6 +177,11 @@ 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); +int tv_set_freq(tvi_handle_t *tvh, unsigned long freq); +int tv_get_freq(tvi_handle_t *tvh, unsigned long *freq); + +int tv_set_norm(tvi_handle_t *tvh, char* norm); + #define TV_NORM_PAL 1 #define TV_NORM_NTSC 2 #define TV_NORM_SECAM 3 diff --git a/mplayer.c b/mplayer.c index b903043ab7..4a8278ffe3 100644 --- a/mplayer.c +++ b/mplayer.c @@ -2777,6 +2777,14 @@ if (stream->type==STREAMTYPE_DVDNAV && dvd_nav_still) frame_dropping = v > 2 ? 2 : v; } break; #ifdef USE_TV + case MP_CMD_TV_SET_FREQ : { + if (file_format == DEMUXER_TYPE_TV) + tv_set_freq((tvi_handle_t*)(demuxer->priv), cmd->args[0].v.f * 16.0); + } break; + case MP_CMD_TV_SET_NORM : { + if (file_format == DEMUXER_TYPE_TV) + tv_set_norm((tvi_handle_t*)(demuxer->priv), cmd->args[0].v.s); + } break; case MP_CMD_TV_STEP_CHANNEL : { if (file_format == DEMUXER_TYPE_TV) { int v = cmd->args[0].v.i; -- cgit v1.2.3