diff options
author | henry <henry@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2004-11-19 13:04:24 +0000 |
---|---|---|
committer | henry <henry@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2004-11-19 13:04:24 +0000 |
commit | dabdcbabbc54cac34924afa4dbab28b19a276a25 (patch) | |
tree | 0f02ec4e762c992d866831affa7f8b02fcec9655 /libmpdemux | |
parent | 26046bd85317ddc731d15ad68b5f7efb586b4389 (diff) | |
download | mpv-dabdcbabbc54cac34924afa4dbab28b19a276a25.tar.bz2 mpv-dabdcbabbc54cac34924afa4dbab28b19a276a25.tar.xz |
setting the norm using text ID instead of numeric
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@13979 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libmpdemux')
-rw-r--r-- | libmpdemux/tv.c | 36 | ||||
-rw-r--r-- | libmpdemux/tv.h | 1 | ||||
-rw-r--r-- | libmpdemux/tvi_v4l2.c | 16 |
3 files changed, 41 insertions, 12 deletions
diff --git a/libmpdemux/tv.c b/libmpdemux/tv.c index c6ae73a514..1bbbf8ca6f 100644 --- a/libmpdemux/tv.c +++ b/libmpdemux/tv.c @@ -123,8 +123,11 @@ int demux_tv_fill_buffer(demuxer_t *demux, demux_stream_t *ds) return 1; } -static int norm_from_string(char* norm) +static int norm_from_string(tvi_handle_t *tvh, char* norm) { +#ifdef HAVE_TV_V4L2 + if (strcmp(tv_param_driver, "v4l2") != 0) { +#endif if (!strcasecmp(norm, "pal")) return TV_NORM_PAL; else if (!strcasecmp(norm, "ntsc")) @@ -143,6 +146,17 @@ static int norm_from_string(char* norm) mp_msg(MSGT_TV, MSGL_V, "tv.c: norm_from_string(%s): Bogus norm parameter, setting PAL.\n", norm); return TV_NORM_PAL; } +#ifdef HAVE_TV_V4L2 + } else { + tvi_functions_t *funcs = tvh->functions; + char str[8]; + strncpy(str, norm, sizeof(str)-1); + str[sizeof(str)-1] = '\0'; + if (funcs->control(tvh->priv, TVI_CONTROL_SPC_GET_NORMID, str) != TVI_CONTROL_TRUE) + return 0; + return *(int *)str; + } +#endif } static int open_tv(tvi_handle_t *tvh) @@ -181,10 +195,16 @@ static int open_tv(tvi_handle_t *tvh) funcs->control(tvh->priv, TVI_CONTROL_SPC_SET_INPUT, &tv_param_input); #ifdef HAVE_TV_V4L2 - if (strcmp(tv_param_driver, "v4l2") != 0) { + if (!strcmp(tv_param_driver, "v4l2") && tv_param_normid >= 0) { + mp_msg(MSGT_TV, MSGL_V, "Selected norm id: %d\n", tv_param_normid); + if (funcs->control(tvh->priv, TVI_CONTROL_TUN_SET_NORM, &tv_param_normid) != TVI_CONTROL_TRUE) { + mp_msg(MSGT_TV, MSGL_ERR, "Error: Cannot set norm!\n"); + return 0; + } + } else { #endif /* select video norm */ - tvh->norm = norm_from_string(tv_param_norm); + tvh->norm = norm_from_string(tvh, 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) { @@ -192,14 +212,6 @@ static int open_tv(tvi_handle_t *tvh) return 0; } #ifdef HAVE_TV_V4L2 - } else { - if (tv_param_normid >= 0) { - mp_msg(MSGT_TV, MSGL_V, "Selected norm id: %d\n", tv_param_normid); - if (funcs->control(tvh->priv, TVI_CONTROL_TUN_SET_NORM, &tv_param_normid) != TVI_CONTROL_TRUE) { - mp_msg(MSGT_TV, MSGL_ERR, "Error: Cannot set norm!\n"); - return 0; - } - } } #endif @@ -826,7 +838,7 @@ int tv_step_chanlist(tvi_handle_t *tvh) int tv_set_norm(tvi_handle_t *tvh, char* norm) { - tvh->norm = norm_from_string(norm); + tvh->norm = norm_from_string(tvh, 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) { diff --git a/libmpdemux/tv.h b/libmpdemux/tv.h index 72aef64b4b..c0ac37cce6 100644 --- a/libmpdemux/tv.h +++ b/libmpdemux/tv.h @@ -156,6 +156,7 @@ char *tv_channel_last_real; /* SPECIFIC controls */ #define TVI_CONTROL_SPC_GET_INPUT 0x401 /* set input channel (tv,s-video,composite..) */ #define TVI_CONTROL_SPC_SET_INPUT 0x402 /* set input channel (tv,s-video,composite..) */ +#define TVI_CONTROL_SPC_GET_NORMID 0x403 /* get normid from norm name */ extern tvi_handle_t *tv_begin(void); extern int tv_init(tvi_handle_t *tvh); diff --git a/libmpdemux/tvi_v4l2.c b/libmpdemux/tvi_v4l2.c index 41b59eaafe..0741b77d0c 100644 --- a/libmpdemux/tvi_v4l2.c +++ b/libmpdemux/tvi_v4l2.c @@ -693,6 +693,22 @@ static int control(priv_t *priv, int cmd, void *arg) return TVI_CONTROL_FALSE; } return TVI_CONTROL_TRUE; + case TVI_CONTROL_SPC_GET_NORMID: + { + int i; + for (i = 0;; i++) { + struct v4l2_standard standard; + memset(&standard, 0, sizeof(standard)); + standard.index = i; + if (-1 == ioctl(priv->video_fd, VIDIOC_ENUMSTD, &standard)) + return TVI_CONTROL_FALSE; + if (!strcasecmp(standard.name, (char *)arg)) { + *(int *)arg = i; + return TVI_CONTROL_TRUE; + } + } + return TVI_CONTROL_FALSE; + } case TVI_CONTROL_SPC_GET_INPUT: if (ioctl(priv->video_fd, VIDIOC_G_INPUT, (int *)arg) < 0) { mp_msg(MSGT_TV, MSGL_ERR, "%s: ioctl get input failed: %s\n", |