[svn r66] Refactoring some remoce_encoder functions, which actually needs to be just recorder; added channel-related recorder functions. trunk
authorrosfran
Mon Nov 06 19:00:37 2006 +0000 (2006-11-06)
branchtrunk
changeset 65dc4814fe4723
parent 64 f926338c6952
child 66 63854066607a
[svn r66] Refactoring some remoce_encoder functions, which actually needs to be just recorder; added channel-related recorder functions.
gmyth/src/Makefile.am
gmyth/src/gmyth_file_transfer.c
gmyth/src/gmyth_livetv.c
gmyth/src/gmyth_livetv.h
gmyth/src/gmyth_recorder.c
gmyth/src/gmyth_recorder.h
gmyth/src/gmyth_remote_util.c
gmyth/src/gmyth_remote_util.h
     1.1 --- a/gmyth/src/Makefile.am	Mon Nov 06 18:58:26 2006 +0000
     1.2 +++ b/gmyth/src/Makefile.am	Mon Nov 06 19:00:37 2006 +0000
     1.3 @@ -6,7 +6,7 @@
     1.4  	gmyth_common.c				\
     1.5  	gmyth_context.c				\
     1.6  	gmyth_epg.c 				\
     1.7 -	gmyth_remote_encoder.c		\
     1.8 +	gmyth_recorder.c		\
     1.9  	gmyth_remote_util.c			\
    1.10  	gmyth_settings.c			\
    1.11  	gmyth_tvchain.c				\
    1.12 @@ -46,7 +46,7 @@
    1.13  	gmyth_common.h	 			\
    1.14  	gmyth_context.h 			\
    1.15  	gmyth_epg.h 				\
    1.16 -	gmyth_remote_encoder.h 		\
    1.17 +	gmyth_recorder.h 		\
    1.18  	gmyth_scheduler.h 			\
    1.19  	gmyth_settings.h 			\
    1.20  	gmyth_tvchain.h 			\
     2.1 --- a/gmyth/src/gmyth_file_transfer.c	Mon Nov 06 18:58:26 2006 +0000
     2.2 +++ b/gmyth/src/gmyth_file_transfer.c	Mon Nov 06 19:00:37 2006 +0000
     2.3 @@ -845,7 +845,7 @@
     2.4  
     2.5    //g_io_channel_flush( io_channel, NULL );
     2.6  
     2.7 -  g_static_mutex_lock( &mutex );
     2.8 +  //g_static_mutex_lock( &mutex );
     2.9  
    2.10    io_cond = g_io_channel_get_buffer_condition( io_channel );
    2.11  
    2.12 @@ -990,7 +990,7 @@
    2.13    }
    2.14  
    2.15  cleanup:
    2.16 -  g_static_mutex_unlock (&mutex);
    2.17 +  //g_static_mutex_unlock (&mutex);
    2.18    g_io_channel_flush( io_channel_control, NULL );
    2.19  
    2.20    if ( trash != NULL )
     3.1 --- a/gmyth/src/gmyth_livetv.c	Mon Nov 06 18:58:26 2006 +0000
     3.2 +++ b/gmyth/src/gmyth_livetv.c	Mon Nov 06 19:00:37 2006 +0000
     3.3 @@ -34,7 +34,7 @@
     3.4  	livetv->backend_port = 0;
     3.5  	livetv->local_hostname = NULL;
     3.6  
     3.7 -	livetv->remote_encoder = NULL;
     3.8 +	livetv->recorder = NULL;
     3.9  	livetv->tvchain = NULL;
    3.10  	livetv->proginfo = NULL;
    3.11  }
    3.12 @@ -55,9 +55,9 @@
    3.13  
    3.14  	g_debug ("[%s] Finalizing livetv", __FUNCTION__);
    3.15  
    3.16 -	if ( livetv->remote_encoder != NULL ) {
    3.17 -		g_object_unref (livetv->remote_encoder);
    3.18 -		livetv->remote_encoder = NULL;
    3.19 +	if ( livetv->recorder != NULL ) {
    3.20 +		g_object_unref (livetv->recorder);
    3.21 +		livetv->recorder = NULL;
    3.22  	}
    3.23  
    3.24  	if ( livetv->tvchain != NULL ) {
    3.25 @@ -107,10 +107,10 @@
    3.26  		goto error;
    3.27  	}
    3.28  
    3.29 -	// Gets the remote encoder num
    3.30 -	livetv->remote_encoder = remote_request_next_free_recorder (-1);
    3.31 +	// Gets the recorder num
    3.32 +	livetv->recorder = remote_request_next_free_recorder (-1);
    3.33  
    3.34 -	if ( livetv->remote_encoder == NULL ) {
    3.35 +	if ( livetv->recorder == NULL ) {
    3.36  		g_warning ("[%s] None remote encoder available", __FUNCTION__);
    3.37  		res = FALSE;
    3.38  		goto error;
    3.39 @@ -126,14 +126,14 @@
    3.40  	}
    3.41  
    3.42  	// Init remote encoder. Opens its control socket.
    3.43 -	res = gmyth_remote_encoder_setup(livetv->remote_encoder);
    3.44 +	res = gmyth_recorder_setup(livetv->recorder);
    3.45  	if ( !res ) {
    3.46  		g_warning ("[%s] Fail while setting remote encoder\n", __FUNCTION__);
    3.47  		res = FALSE;
    3.48  		goto error;
    3.49  	}
    3.50  	// Spawn live tv. Uses the socket to send mythprotocol data to start livetv in the backend (remotelly)
    3.51 -	res = gmyth_remote_encoder_spawntv ( livetv->remote_encoder,
    3.52 +	res = gmyth_recorder_spawntv ( livetv->recorder,
    3.53  			gmyth_tvchain_get_id(livetv->tvchain) );
    3.54  	if (!res) {
    3.55  		g_warning ("[%s] Fail while spawn tv\n", __FUNCTION__);
    3.56 @@ -173,9 +173,9 @@
    3.57  		res = FALSE;
    3.58  	}
    3.59  
    3.60 -	if ( livetv->remote_encoder != NULL ) {
    3.61 -		g_object_unref (livetv->remote_encoder);
    3.62 -		livetv->remote_encoder = NULL;
    3.63 +	if ( livetv->recorder != NULL ) {
    3.64 +		g_object_unref (livetv->recorder);
    3.65 +		livetv->recorder = NULL;
    3.66  	}
    3.67  
    3.68  	if ( livetv->tvchain != NULL ) {
    3.69 @@ -229,9 +229,9 @@
    3.70  		res = FALSE;
    3.71  	}
    3.72  
    3.73 -	if ( livetv->remote_encoder != NULL ) {
    3.74 -		g_object_unref (livetv->remote_encoder);
    3.75 -		livetv->remote_encoder = NULL;
    3.76 +	if ( livetv->recorder != NULL ) {
    3.77 +		g_object_unref (livetv->recorder);
    3.78 +		livetv->recorder = NULL;
    3.79  	}
    3.80  
    3.81  	if ( livetv->tvchain != NULL ) {
    3.82 @@ -255,7 +255,7 @@
    3.83  	g_debug ("[%s] Stopping the LiveTV...\n", __FUNCTION__);
    3.84  
    3.85  	if (livetv->is_livetv) {
    3.86 -		if (!gmyth_remote_encoder_stop_livetv (livetv->remote_encoder)) {
    3.87 +		if (!gmyth_recorder_stop_livetv (livetv->recorder)) {
    3.88  			g_warning ("[%s] Error while stoping remote encoder", __FUNCTION__);	
    3.89  		}
    3.90  	}
     4.1 --- a/gmyth/src/gmyth_livetv.h	Mon Nov 06 18:58:26 2006 +0000
     4.2 +++ b/gmyth/src/gmyth_livetv.h	Mon Nov 06 19:00:37 2006 +0000
     4.3 @@ -3,7 +3,7 @@
     4.4  
     4.5  #include <glib-object.h>
     4.6  
     4.7 -#include "gmyth_remote_encoder.h"
     4.8 +#include "gmyth_recorder.h"
     4.9  #include "gmyth_tvchain.h"
    4.10  #include "gmyth_common.h"
    4.11  
    4.12 @@ -37,7 +37,7 @@
    4.13  	gint backend_port;
    4.14  	GString *local_hostname;
    4.15  
    4.16 -	GMythRemoteEncoder *remote_encoder;
    4.17 +	GMythRecorder *recorder;
    4.18  	GMythTVChain *tvchain;
    4.19  	GMythProgramInfo *proginfo;
    4.20  
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/gmyth/src/gmyth_recorder.c	Mon Nov 06 19:00:37 2006 +0000
     5.3 @@ -0,0 +1,297 @@
     5.4 +/**
     5.5 + * GMyth Library
     5.6 + *
     5.7 + * @file gmyth/gmyth_remote_encoder.c
     5.8 + * 
     5.9 + * @brief <p> GMythRecorder class defines functions for playing live tv.
    5.10 + *
    5.11 + * The remote encoder is used by gmyth_tvplayer to setup livetv. 
    5.12 + *
    5.13 + * Copyright (C) 2006 INdT - Instituto Nokia de Tecnologia.
    5.14 + * @author Hallyson Luiz de Morais Melo <hallyson.melo@indt.org.br>
    5.15 + *
    5.16 + *//*
    5.17 + * 
    5.18 + * This program is free software; you can redistribute it and/or modify
    5.19 + * it under the terms of the GNU Lesser General Public License as published by
    5.20 + * the Free Software Foundation; either version 2 of the License, or
    5.21 + * (at your option) any later version.
    5.22 + *
    5.23 + * This program is distributed in the hope that it will be useful,
    5.24 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
    5.25 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    5.26 + * GNU General Public License for more details.
    5.27 + *
    5.28 + * You should have received a copy of the GNU Lesser General Public License
    5.29 + * along with this program; if not, write to the Free Software
    5.30 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    5.31 + */
    5.32 +
    5.33 +#include "gmyth_recorder.h"
    5.34 +
    5.35 +#include <assert.h>
    5.36 +
    5.37 +#include "gmyth_stringlist.h"
    5.38 +
    5.39 +static void gmyth_recorder_class_init          (GMythRecorderClass *klass);
    5.40 +static void gmyth_recorder_init                (GMythRecorder *object);
    5.41 +
    5.42 +static void gmyth_recorder_dispose  (GObject *object);
    5.43 +static void gmyth_recorder_finalize (GObject *object);
    5.44 +
    5.45 +G_DEFINE_TYPE(GMythRecorder, gmyth_recorder, G_TYPE_OBJECT)
    5.46 +    
    5.47 +static void
    5.48 +gmyth_recorder_class_init (GMythRecorderClass *klass)
    5.49 +{
    5.50 +    GObjectClass *gobject_class;
    5.51 +
    5.52 +    gobject_class = (GObjectClass *) klass;
    5.53 +	
    5.54 +    gobject_class->dispose  = gmyth_recorder_dispose;
    5.55 +    gobject_class->finalize = gmyth_recorder_finalize;	
    5.56 +}
    5.57 +
    5.58 +static void
    5.59 +gmyth_recorder_init (GMythRecorder *gmyth_remote_encoder)
    5.60 +{
    5.61 +}
    5.62 +
    5.63 +static void
    5.64 +gmyth_recorder_dispose  (GObject *object)
    5.65 +{
    5.66 +    // GMythRecorder *gmyth_remote_encoder = GMYTH_RECORDER(object);
    5.67 +    
    5.68 +	G_OBJECT_CLASS (gmyth_recorder_parent_class)->dispose (object);
    5.69 +}
    5.70 +
    5.71 +
    5.72 +static void
    5.73 +gmyth_recorder_finalize (GObject *object)
    5.74 +{
    5.75 +	g_signal_handlers_destroy (object);
    5.76 +
    5.77 +    GMythRecorder *recorder = GMYTH_RECORDER(object);
    5.78 +
    5.79 +	g_debug ("[%s] Closing control socket", __FUNCTION__);
    5.80 +	gmyth_socket_close_connection(recorder->myth_socket);
    5.81 +	g_object_unref (recorder->myth_socket);
    5.82 +    
    5.83 +    G_OBJECT_CLASS (gmyth_recorder_parent_class)->finalize (object);
    5.84 +}
    5.85 +
    5.86 +/** Creates a new instance of GMythRecorder.
    5.87 + * 
    5.88 + * @return a new instance of GMythRecorder.
    5.89 + */
    5.90 +GMythRecorder*
    5.91 +gmyth_recorder_new (int num, GString *hostname, gshort port)
    5.92 +{
    5.93 +	GMythRecorder *encoder = GMYTH_RECORDER ( g_object_new (
    5.94 +			GMYTH_RECORDER_TYPE, FALSE ));
    5.95 +			
    5.96 +	encoder->recorder_num = num;
    5.97 +	encoder->hostname = g_string_new (hostname->str);
    5.98 +	encoder->port = port;
    5.99 +	
   5.100 +	return encoder;
   5.101 +}
   5.102 +
   5.103 +/** Configures the remote encoder instance connecting it to Mythtv backend.
   5.104 + * 
   5.105 + * @param recorder the GMythRecorder instance.
   5.106 + * @return TRUE if successfull, FALSE if any error happens.
   5.107 + */
   5.108 +gboolean
   5.109 +gmyth_recorder_setup (GMythRecorder *recorder)
   5.110 +{
   5.111 +	assert (recorder);
   5.112 +	g_debug ("[%s] Creating socket and connecting to backend", __FUNCTION__);
   5.113 +
   5.114 +	if (recorder->myth_socket == NULL) {
   5.115 +		
   5.116 +		recorder->myth_socket = gmyth_socket_new ();
   5.117 +		
   5.118 +		if (!gmyth_socket_connect_to_backend (recorder->myth_socket, recorder->hostname->str, 
   5.119 +					recorder->port, TRUE) ) {
   5.120 +			g_warning ("GMythRemoteEncoder: Connection to backend failed");	
   5.121 +			return FALSE;
   5.122 +		}
   5.123 +
   5.124 +	} else {
   5.125 +		g_warning("Remote encoder socket already created\n");
   5.126 +	}
   5.127 +
   5.128 +	return TRUE;
   5.129 +}
   5.130 +
   5.131 +/** Sends the SPAWN_LIVETV command through Mythtv protocol. This command
   5.132 + * requests the backend to start capturing TV content.
   5.133 + * 
   5.134 + * @param recorder The GMythRecorder instance.
   5.135 + * @param tvchain_id The tvchain unique id.
   5.136 + * @return true if success, false if any error happens.
   5.137 + */
   5.138 +gboolean
   5.139 +gmyth_recorder_spawntv (GMythRecorder *recorder, GString *tvchain_id)
   5.140 +{
   5.141 +	GMythStringList *str_list;
   5.142 +	GString *tmp_str;
   5.143 +	
   5.144 +	g_debug ("[%s] Spawntv with tvchain_id = %s", __FUNCTION__, tvchain_id->str);
   5.145 +	
   5.146 +	str_list = gmyth_string_list_new ();
   5.147 +	
   5.148 +	tmp_str = g_string_new ("QUERY_RECORDER ");
   5.149 +	g_string_append_printf (tmp_str, "%d", recorder->recorder_num); 
   5.150 +	
   5.151 +	gmyth_string_list_append_string (str_list, tmp_str);
   5.152 +	gmyth_string_list_append_string (str_list, g_string_new ("SPAWN_LIVETV"));
   5.153 +	gmyth_string_list_append_string (str_list, tvchain_id);
   5.154 +	gmyth_string_list_append_int (str_list, 0); // PIP = FALSE (0)
   5.155 +
   5.156 +	gmyth_socket_sendreceive_stringlist (recorder->myth_socket, str_list);
   5.157 +	
   5.158 +    g_string_free (tmp_str, TRUE);
   5.159 +    
   5.160 +    tmp_str = gmyth_string_list_get_string (str_list, 0);
   5.161 +    if (tmp_str == NULL) {
   5.162 +    	g_warning ("[%s] Spawntv request returned %s", __FUNCTION__, tmp_str->str);
   5.163 +    	return FALSE;
   5.164 +	}
   5.165 +	
   5.166 +    if (g_ascii_strncasecmp (tmp_str->str, "ok", 2)) {
   5.167 +    	g_warning ("[%s] Spawntv request returned %s", __FUNCTION__, tmp_str->str);
   5.168 +	    g_object_unref (str_list);
   5.169 +    	return FALSE;
   5.170 +    }
   5.171 +
   5.172 +    g_object_unref (str_list);
   5.173 +    return TRUE;
   5.174 +
   5.175 +}
   5.176 +
   5.177 +/** Sends the command STOP_LIVETV to Mythtv backend.
   5.178 + * 
   5.179 + * @param recorder the GMythRecorder instance.
   5.180 + * @return true if success, false if any error happens.
   5.181 + */
   5.182 +gboolean
   5.183 +gmyth_recorder_stop_livetv (GMythRecorder *recorder)
   5.184 +{
   5.185 +	GMythStringList *str_list;
   5.186 +	GString *tmp_str;
   5.187 +
   5.188 +	g_debug ("[%s]", __FUNCTION__);
   5.189 +
   5.190 +	str_list = gmyth_string_list_new ();
   5.191 +
   5.192 +	tmp_str = g_string_new ("QUERY_RECORDER ");
   5.193 +	g_string_append_printf (tmp_str, "%d", recorder->recorder_num); 
   5.194 +	gmyth_string_list_append_string (str_list, g_string_new ("STOP_LIVETV"));
   5.195 +
   5.196 +	gmyth_socket_sendreceive_stringlist (recorder->myth_socket, str_list);
   5.197 +
   5.198 +	g_string_free (tmp_str, TRUE);
   5.199 +
   5.200 +	tmp_str = gmyth_string_list_get_string (str_list, 0);
   5.201 +	if (g_ascii_strncasecmp (tmp_str->str, "ok", 2)) {
   5.202 +		g_warning ("[%s] Stop livetv request returned %s", __FUNCTION__, tmp_str->str);
   5.203 +		g_object_unref (str_list);
   5.204 +		return FALSE;
   5.205 +	}
   5.206 +
   5.207 +	g_object_unref (str_list);
   5.208 +	return TRUE;
   5.209 +
   5.210 +}
   5.211 +
   5.212 +/** Send a CHECK_CHANNEL command request to the backend, in order to find if a 
   5.213 + * certain channel actually exists.
   5.214 + * 
   5.215 + * @param recorder The GMythRecorder instance.
   5.216 + * @param channel	 The new channel to be checked.
   5.217 + * @return true if success, false if any error happens.
   5.218 + */
   5.219 +gboolean
   5.220 +gmyth_recorder_check_channel (GMythRecorder *recorder, gint channel)
   5.221 +{
   5.222 +	GMythStringList *str_list;
   5.223 +	GString *tmp_str;
   5.224 +	
   5.225 +	g_debug ("[%s] SET_CHANNEL with channel = %d", __FUNCTION__, channel);
   5.226 +	
   5.227 +	str_list = gmyth_string_list_new ();
   5.228 +	
   5.229 +	tmp_str = g_string_new ("QUERY_RECORDER ");
   5.230 +	g_string_append_printf (tmp_str, "%d", recorder->recorder_num); 
   5.231 +	
   5.232 +	gmyth_string_list_append_string (str_list, tmp_str);
   5.233 +	gmyth_string_list_append_string (str_list, g_string_new ("CHECK_CHANNEL"));
   5.234 +	gmyth_string_list_append_int (str_list, channel);
   5.235 +
   5.236 +	gmyth_socket_sendreceive_stringlist (recorder->myth_socket, str_list);
   5.237 +	
   5.238 +    g_string_free (tmp_str, TRUE);
   5.239 +    
   5.240 +    tmp_str = gmyth_string_list_get_string (str_list, 0);
   5.241 +    if (tmp_str == NULL) {
   5.242 +    	g_warning ("[%s] CHECK_CHANNEL request returned %s", __FUNCTION__, tmp_str->str);
   5.243 +    	return FALSE;
   5.244 +	}
   5.245 +	
   5.246 +    if (g_ascii_strncasecmp (tmp_str->str, "ok", 2) == 0 || g_ascii_strncasecmp (tmp_str->str, "0", 1) == 0 ) {
   5.247 +    	g_warning ("[%s] CHECK_CHANNEL request returned %s", __FUNCTION__, tmp_str->str);
   5.248 +	    g_object_unref (str_list);
   5.249 +    	return FALSE;
   5.250 +    }
   5.251 +
   5.252 +    g_object_unref (str_list);
   5.253 +    return TRUE;
   5.254 +
   5.255 +}
   5.256 +
   5.257 +/** Send a SET_CHANNEL command request to the backend, to start streaming on another 
   5.258 + * TV content channel.
   5.259 + * 
   5.260 + * @param recorder The GMythRecorder instance.
   5.261 + * @param channel	 The new channel to be loaded.
   5.262 + * @return true if success, false if any error happens.
   5.263 + */
   5.264 +gboolean
   5.265 +gmyth_recorder_set_channel (GMythRecorder *recorder, gint channel)
   5.266 +{
   5.267 +	GMythStringList *str_list;
   5.268 +	GString *tmp_str;
   5.269 +	
   5.270 +	g_debug ("[%s] SET_CHANNEL with channel = %d", __FUNCTION__, channel);
   5.271 +	
   5.272 +	str_list = gmyth_string_list_new ();
   5.273 +	
   5.274 +	tmp_str = g_string_new ("QUERY_RECORDER ");
   5.275 +	g_string_append_printf (tmp_str, "%d", recorder->recorder_num); 
   5.276 +	
   5.277 +	gmyth_string_list_append_string (str_list, tmp_str);
   5.278 +	gmyth_string_list_append_string (str_list, g_string_new ("SET_CHANNEL"));
   5.279 +	gmyth_string_list_append_int (str_list, channel);
   5.280 +
   5.281 +	gmyth_socket_sendreceive_stringlist (recorder->myth_socket, str_list);
   5.282 +	
   5.283 +    g_string_free (tmp_str, TRUE);
   5.284 +    
   5.285 +    tmp_str = gmyth_string_list_get_string (str_list, 0);
   5.286 +    if (tmp_str == NULL) {
   5.287 +    	g_warning ("[%s] SET_CHANNEL request returned %s", __FUNCTION__, tmp_str->str);
   5.288 +    	return FALSE;
   5.289 +	}
   5.290 +	
   5.291 +    if (g_ascii_strncasecmp (tmp_str->str, "ok", 2)) {
   5.292 +    	g_warning ("[%s] SET_CHANNEL request returned %s", __FUNCTION__, tmp_str->str);
   5.293 +	    g_object_unref (str_list);
   5.294 +    	return FALSE;
   5.295 +    }
   5.296 +
   5.297 +    g_object_unref (str_list);
   5.298 +    return TRUE;
   5.299 +
   5.300 +}
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/gmyth/src/gmyth_recorder.h	Mon Nov 06 19:00:37 2006 +0000
     6.3 @@ -0,0 +1,94 @@
     6.4 +/**
     6.5 + * GMyth Library
     6.6 + *
     6.7 + * @file gmyth/gmyth_recorder.h
     6.8 + * 
     6.9 + * @brief <p> GMythRecorder class defines functions for playing live tv.
    6.10 + *
    6.11 + * Copyright (C) 2006 INdT - Instituto Nokia de Tecnologia.
    6.12 + * @author Hallyson Luiz de Morais Melo <hallyson.melo@indt.org.br>
    6.13 + *
    6.14 + *//*
    6.15 + * 
    6.16 + * This program is free software; you can redistribute it and/or modify
    6.17 + * it under the terms of the GNU Lesser General Public License as published by
    6.18 + * the Free Software Foundation; either version 2 of the License, or
    6.19 + * (at your option) any later version.
    6.20 + *
    6.21 + * This program is distributed in the hope that it will be useful,
    6.22 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
    6.23 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    6.24 + * GNU General Public License for more details.
    6.25 + *
    6.26 + * You should have received a copy of the GNU Lesser General Public License
    6.27 + * along with this program; if not, write to the Free Software
    6.28 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    6.29 + */
    6.30 +
    6.31 +#ifndef __GMYTH_RECORDER_H__
    6.32 +#define __GMYTH_RECORDER_H__
    6.33 +
    6.34 +#include <glib-object.h>
    6.35 +
    6.36 +#include "gmyth_socket.h"
    6.37 +
    6.38 +#include <stdio.h>
    6.39 +#include <stdlib.h>
    6.40 +#include <string.h>
    6.41 +#include <netdb.h>
    6.42 +#include <sys/socket.h>
    6.43 +#include <unistd.h>
    6.44 +
    6.45 +G_BEGIN_DECLS
    6.46 +
    6.47 +#define GMYTH_RECORDER_TYPE               (gmyth_recorder_get_type ())
    6.48 +#define GMYTH_RECORDER(obj)               (G_TYPE_CHECK_INSTANCE_CAST ((obj), GMYTH_RECORDER_TYPE, GMythRecorder))
    6.49 +#define GMYTH_RECORDER_CLASS(klass)       (G_TYPE_CHECK_CLASS_CAST ((klass), GMYTH_RECORDER_TYPE, GMythRecorderClass))
    6.50 +#define IS_GMYTH_RECORDER(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GMYTH_RECORDER_TYPE))
    6.51 +#define IS_GMYTH_RECORDER_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), GMYTH_RECORDER_TYPE))
    6.52 +#define GMYTH_RECORDER_GET_CLASS(obj)     (G_TYPE_INSTANCE_GET_CLASS ((obj), GMYTH_RECORDER_TYPE, GMythRecorderClass))
    6.53 +
    6.54 +
    6.55 +typedef struct _GMythRecorder         GMythRecorder;
    6.56 +typedef struct _GMythRecorderClass    GMythRecorderClass;
    6.57 +
    6.58 +struct _GMythRecorderClass
    6.59 +{
    6.60 +  GObjectClass parent_class;
    6.61 +
    6.62 +  /* callbacks */
    6.63 +  /* no one for now */
    6.64 +};
    6.65 +
    6.66 +struct _GMythRecorder
    6.67 +{
    6.68 +    GObject parent;
    6.69 +
    6.70 +    /* socket descriptor */
    6.71 +    GMythSocket *myth_socket;
    6.72 +    
    6.73 +    int recorder_num;
    6.74 +    GString *hostname;
    6.75 +    int port;
    6.76 +};
    6.77 +
    6.78 +
    6.79 +GType   gmyth_recorder_get_type   (void);
    6.80 +
    6.81 +GMythRecorder* gmyth_recorder_new    (int num,
    6.82 +	                                     GString *hostname,
    6.83 +	                                     gshort port);
    6.84 +
    6.85 +gboolean gmyth_recorder_setup     (GMythRecorder *recorder);
    6.86 +gboolean gmyth_recorder_spawntv   (GMythRecorder *recorder,
    6.87 +                                         GString *tvchain_id);
    6.88 +gboolean gmyth_recorder_stop_livetv (GMythRecorder *recorder);
    6.89 +
    6.90 +gboolean gmyth_recorder_check_channel (GMythRecorder *recorder, gint channel);
    6.91 +
    6.92 +gboolean gmyth_recorder_set_channel   (GMythRecorder *recorder,
    6.93 +                                         gint channel);
    6.94 +
    6.95 +G_END_DECLS
    6.96 +
    6.97 +#endif /* __GMYTH_REMOTE_ENCODER_H__ */
     7.1 --- a/gmyth/src/gmyth_remote_util.c	Mon Nov 06 18:58:26 2006 +0000
     7.2 +++ b/gmyth/src/gmyth_remote_util.c	Mon Nov 06 19:00:37 2006 +0000
     7.3 @@ -28,7 +28,7 @@
     7.4  #include "gmyth_remote_util.h"
     7.5   
     7.6  #include "gmyth_context.h"
     7.7 -#include "gmyth_remote_encoder.h"
     7.8 +#include "gmyth_recorder.h"
     7.9  #include "gmyth_stringlist.h"
    7.10  
    7.11  /** Requests the Mythtv backend for a free remote recorder.
    7.12 @@ -36,10 +36,10 @@
    7.13   * @param curr The recorder index, or -1 to consider the first one.
    7.14   * @return the remote encoder instance available, or NULL if any error happens.
    7.15   */
    7.16 -GMythRemoteEncoder*
    7.17 +GMythRecorder*
    7.18  remote_request_next_free_recorder (int curr)
    7.19  {
    7.20 -	GMythRemoteEncoder *encoder;
    7.21 +	GMythRecorder *recorder = NULL;
    7.22  	GString *hostname;
    7.23  	int num, port;
    7.24  	
    7.25 @@ -58,13 +58,18 @@
    7.26      num = gmyth_string_list_get_int (strlist, 0);
    7.27      hostname = gmyth_string_list_get_string (strlist, 1);
    7.28      port = gmyth_string_list_get_int (strlist, 2);
    7.29 +    
    7.30 +    if ( num < 0 || port < 0 )
    7.31 +    	goto clean_up;
    7.32  
    7.33  	g_debug ("[%s] Free recorder info received: num: %d, hostname: %s, port: %d", 
    7.34  				__FUNCTION__, num, hostname->str, port);
    7.35  	
    7.36 -	encoder = gmyth_remote_encoder_new (num, hostname, port);
    7.37 +	recorder = gmyth_recorder_new (num, hostname, port);
    7.38 +
    7.39 +clean_up:
    7.40  	
    7.41  	g_object_unref (strlist);
    7.42  	
    7.43 -	return encoder;
    7.44 +	return recorder;
    7.45  }
     8.1 --- a/gmyth/src/gmyth_remote_util.h	Mon Nov 06 18:58:26 2006 +0000
     8.2 +++ b/gmyth/src/gmyth_remote_util.h	Mon Nov 06 19:00:37 2006 +0000
     8.3 @@ -29,11 +29,11 @@
     8.4  #define __REMOTE_UTIL_H__
     8.5  
     8.6  #include <glib.h>
     8.7 -#include "gmyth_remote_encoder.h"
     8.8 +#include "gmyth_recorder.h"
     8.9  
    8.10  G_BEGIN_DECLS
    8.11  
    8.12 -GMythRemoteEncoder* remote_request_next_free_recorder (int curr);
    8.13 +GMythRecorder* remote_request_next_free_recorder (int curr);
    8.14  
    8.15  G_END_DECLS
    8.16