changeset 8494:47cf94058137

add a TV_SET_CNANNEL command
author henry
date Thu, 19 Dec 2002 10:09:43 +0000
parents dc038bbb36a3
children a23489e72ef0
files input/input.c input/input.h libmpdemux/tv.c libmpdemux/tv.h mplayer.c
diffstat 5 files changed, 29 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/input/input.c	Wed Dec 18 23:49:01 2002 +0000
+++ b/input/input.c	Thu Dec 19 10:09:43 2002 +0000
@@ -74,6 +74,7 @@
   { 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}} } },
--- a/input/input.h	Wed Dec 18 23:49:01 2002 +0000
+++ b/input/input.h	Thu Dec 19 10:09:43 2002 +0000
@@ -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
--- a/libmpdemux/tv.c	Wed Dec 18 23:49:01 2002 +0000
+++ b/libmpdemux/tv.c	Thu Dec 19 10:09:43 2002 +0000
@@ -554,6 +554,27 @@
     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);
--- a/libmpdemux/tv.h	Wed Dec 18 23:49:01 2002 +0000
+++ b/libmpdemux/tv.h	Thu Dec 19 10:09:43 2002 +0000
@@ -148,6 +148,8 @@
 #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);
 
--- a/mplayer.c	Wed Dec 18 23:49:01 2002 +0000
+++ b/mplayer.c	Thu Dec 19 10:09:43 2002 +0000
@@ -2288,6 +2288,10 @@
 	  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));