[MPlayer-dev-eng] [PATCH] Setting TV channels (not stepping)

Stephane Jourdois mplayer-dev-eng at rubis.org
Sun Dec 15 17:42:22 CET 2002


This patch against current cvs adds a new input command :
	tv_set_channel       String

This command takes as argument the channel that have to be set.

This can be used in .lircrc to bind channel buttons as follows :

=====
	begin
		prog   = mplayer
		button = 1
		config = tv_set_channel 25
	end
	begin
		prog   = mplayer
		button = 2
		config = tv_set_channel 22
	end
	begin
		prog   = mplayer
		button = 3
		config = tv_set_channel 28
	end
	begin
		prog   = mplayer
		button = 4
		config = tv_set_channel K06
	end
	begin
		prog   = mplayer
		button = 5
		config = tv_set_channel 30
	end
	begin
		prog   = mplayer
		button = 6
		config = tv_set_channel 33
	end
=====

(Those are French on-air channels)


Patch following :

=====
diff -u -r1.626 mplayer.c
--- mplayer.c	14 Dec 2002 17:12:23 -0000	1.626
+++ mplayer.c	15 Dec 2002 17:07:15 -0000
@@ -2284,6 +2285,10 @@
 	else
 	  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)
diff -u -r1.62 input.c
--- input/input.c	5 Dec 2002 00:15:56 -0000	1.62
+++ input/input.c	15 Dec 2002 17:07:19 -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}} } },
diff -u -r1.26 input.h
--- input/input.h	5 Dec 2002 00:15:56 -0000	1.26
+++ input/input.h	15 Dec 2002 17:07:20 -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
diff -u -r1.40 tv.c
--- libmpdemux/tv.c	23 Nov 2002 10:58:08 -0000	1.40
+++ libmpdemux/tv.c	15 Dec 2002 17:07:22 -0000
@@ -539,6 +539,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);
diff -u -r1.18 tv.h
--- libmpdemux/tv.h	25 Oct 2002 09:42:41 -0000	1.18
+++ libmpdemux/tv.h	15 Dec 2002 17:07:22 -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);
 
=====

Please comment, thanks,
Stéphane (kwisatz) Jourdois.

-- 
 ///  Stephane Jourdois        	/"\  ASCII RIBBON CAMPAIGN \\\
(((    Ingénieur développement 	\ /    AGAINST HTML MAIL    )))
 \\\   6, av. George V	         X                         ///
  \\\  75008  Paris             / \    +33 6 8643 3085    ///





More information about the MPlayer-dev-eng mailing list