gmyth/src/gmyth_recorder.c
author rosfran
Mon Jan 29 14:14:26 2007 +0000 (2007-01-29)
branchtrunk
changeset 309 311da9c88a53
parent 307 0a8fe4427e41
child 310 0638b71f9293
permissions -rw-r--r--
[svn r310] Added new function to recorder: CHANGE_CHANNEL, which try to move to the next valid channel, instead of passing a valid channel name.
     1 /**
     2  * GMyth Library
     3  *
     4  * @file gmyth/gmyth_remote_encoder.c
     5  * 
     6  * @brief <p> GMythRecorder class defines functions for playing live tv.
     7  *
     8  * The remote encoder is used by gmyth_tvplayer to setup livetv. 
     9  *
    10  * Copyright (C) 2006 INdT - Instituto Nokia de Tecnologia.
    11  * @author Hallyson Luiz de Morais Melo <hallyson.melo@indt.org.br>
    12  *
    13  *//*
    14  * 
    15  * This program is free software; you can redistribute it and/or modify
    16  * it under the terms of the GNU Lesser General Public License as published by
    17  * the Free Software Foundation; either version 2 of the License, or
    18  * (at your option) any later version.
    19  *
    20  * This program is distributed in the hope that it will be useful,
    21  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    22  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    23  * GNU General Public License for more details.
    24  *
    25  * You should have received a copy of the GNU Lesser General Public License
    26  * along with this program; if not, write to the Free Software
    27  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    28  */
    29  
    30 #ifdef HAVE_CONFIG_H
    31 #include "config.h"
    32 #endif
    33 
    34 #include "gmyth_recorder.h"
    35 
    36 #include <assert.h>
    37 
    38 #include "gmyth_stringlist.h"
    39 #include "gmyth_util.h"
    40 #include "gmyth_debug.h"
    41 
    42 #define	 GMYTHTV_RECORDER_HEADER			"QUERY_RECORDER"
    43 
    44 static void gmyth_recorder_class_init          (GMythRecorderClass *klass);
    45 static void gmyth_recorder_init                (GMythRecorder *object);
    46 
    47 static void gmyth_recorder_dispose  (GObject *object);
    48 static void gmyth_recorder_finalize (GObject *object);
    49 
    50 G_DEFINE_TYPE(GMythRecorder, gmyth_recorder, G_TYPE_OBJECT)
    51     
    52 static void
    53 gmyth_recorder_class_init (GMythRecorderClass *klass)
    54 {
    55     GObjectClass *gobject_class;
    56 
    57     gobject_class = (GObjectClass *) klass;
    58 	
    59     gobject_class->dispose  = gmyth_recorder_dispose;
    60     gobject_class->finalize = gmyth_recorder_finalize;	
    61 }
    62 
    63 static void
    64 gmyth_recorder_init (GMythRecorder *gmyth_remote_encoder)
    65 {
    66 }
    67 
    68 static void
    69 gmyth_recorder_dispose  (GObject *object)
    70 {
    71     // GMythRecorder *gmyth_remote_encoder = GMYTH_RECORDER(object);
    72     
    73 	G_OBJECT_CLASS (gmyth_recorder_parent_class)->dispose (object);
    74 }
    75 
    76 
    77 static void
    78 gmyth_recorder_finalize (GObject *object)
    79 {
    80 	g_signal_handlers_destroy (object);
    81 
    82   GMythRecorder *recorder = GMYTH_RECORDER(object);
    83 
    84 	gmyth_debug ("[%s] Closing control socket", __FUNCTION__);
    85 	gmyth_socket_close_connection(recorder->myth_socket);
    86 	g_object_unref (recorder->myth_socket);
    87     
    88   G_OBJECT_CLASS (gmyth_recorder_parent_class)->finalize (object);
    89 }
    90 
    91 /** Creates a new instance of GMythRecorder.
    92  * 
    93  * @return a new instance of GMythRecorder.
    94  */
    95 GMythRecorder*
    96 gmyth_recorder_new (int num, GString *hostname, gshort port)
    97 {
    98 	GMythRecorder *encoder = GMYTH_RECORDER ( g_object_new (
    99 			GMYTH_RECORDER_TYPE, FALSE ));
   100 			
   101 	encoder->recorder_num = num;
   102 	encoder->hostname = g_string_new (hostname->str);
   103 	encoder->port = port;
   104 	
   105 	return encoder;
   106 }
   107 
   108 /** Configures the remote encoder instance connecting it to Mythtv backend.
   109  * 
   110  * @param recorder the GMythRecorder instance.
   111  * @return TRUE if successfull, FALSE if any error happens.
   112  */
   113 gboolean
   114 gmyth_recorder_setup (GMythRecorder *recorder)
   115 {
   116 	assert (recorder);
   117 	gmyth_debug ("[%s] Creating socket and connecting to backend", __FUNCTION__);
   118 
   119 	if (recorder->myth_socket == NULL) {
   120 		
   121 		recorder->myth_socket = gmyth_socket_new ();
   122 		
   123 		if (!gmyth_socket_connect_to_backend ( recorder->myth_socket, recorder->hostname->str, 
   124 					recorder->port, TRUE ) ) {
   125 			g_warning ("GMythRemoteEncoder: Connection to backend failed");	
   126 			return FALSE;
   127 		}
   128 		
   129 	} else {
   130 		g_warning("Remote encoder socket already created\n");
   131 	}
   132 
   133 	return TRUE;
   134 }
   135 
   136 /** Sends the SPAWN_LIVETV command through Mythtv protocol. This command
   137  * requests the backend to start capturing TV content.
   138  * 
   139  * @param recorder The GMythRecorder instance.
   140  * @param tvchain_id The tvchain unique id.
   141  * @return true if success, false if any error happens.
   142  */
   143 gboolean
   144 gmyth_recorder_spawntv (GMythRecorder *recorder, GString *tvchain_id)
   145 {
   146 	GMythStringList *str_list;
   147 	GString *tmp_str = g_string_new( GMYTHTV_RECORDER_HEADER );
   148 	
   149 	gmyth_debug ("[%s] Spawntv with tvchain_id = %s", __FUNCTION__, tvchain_id->str);
   150 	
   151 	str_list = gmyth_string_list_new ();
   152 	
   153 	g_string_append_printf ( tmp_str, " %d", recorder->recorder_num ); 
   154 	
   155 	gmyth_string_list_append_string (str_list, tmp_str);
   156 	gmyth_string_list_append_string (str_list, g_string_new ("SPAWN_LIVETV"));
   157 	gmyth_string_list_append_string (str_list, tvchain_id);
   158 	gmyth_string_list_append_int (str_list, 0); // PIP = FALSE (0)
   159 
   160 	gmyth_socket_sendreceive_stringlist (recorder->myth_socket, str_list);
   161 	
   162     g_string_free (tmp_str, TRUE);
   163     
   164     tmp_str = gmyth_string_list_get_string (str_list, 0);
   165     if (tmp_str == NULL) {
   166     	g_warning ("[%s] Spawntv request returned %s", __FUNCTION__, tmp_str->str);
   167     	return FALSE;
   168 	}
   169 	
   170     if (g_ascii_strncasecmp (tmp_str->str, "ok", 2)) {
   171     	g_warning ("[%s] Spawntv request returned %s", __FUNCTION__, tmp_str->str);
   172 	    g_object_unref (str_list);
   173     	return FALSE;
   174     }
   175 
   176     g_object_unref (str_list);
   177     return TRUE;
   178 
   179 }
   180 
   181 /** Sends the command STOP_LIVETV to Mythtv backend.
   182  * 
   183  * @param recorder the GMythRecorder instance.
   184  * @return true if success, false if any error happens.
   185  */
   186 gboolean
   187 gmyth_recorder_stop_livetv (GMythRecorder *recorder)
   188 {
   189 	GMythStringList *str_list;
   190 	GString *tmp_str = g_string_new( GMYTHTV_RECORDER_HEADER );
   191 
   192 	gmyth_debug ("[%s]", __FUNCTION__);
   193 
   194 	str_list = gmyth_string_list_new ();
   195 
   196 	g_string_append_printf ( tmp_str, " %d", recorder->recorder_num ); 
   197 	gmyth_string_list_append_char_array( str_list, "STOP_LIVETV" );
   198 
   199 	gmyth_socket_sendreceive_stringlist (recorder->myth_socket, str_list);
   200 
   201 	g_string_free (tmp_str, TRUE);
   202 
   203 	tmp_str = gmyth_string_list_get_string (str_list, 0);
   204 	if (g_ascii_strncasecmp (tmp_str->str, "ok", 2)) {
   205 		g_warning ("[%s] Stop livetv request returned %s", __FUNCTION__, tmp_str->str);
   206 		g_object_unref (str_list);
   207 		return FALSE;
   208 	}
   209 
   210 	g_object_unref (str_list);
   211 	return TRUE;
   212 
   213 }
   214 
   215 /** Sends the FRONTEND_READY command through Mythtv protocol. This command
   216  * advertises the backend to start capturing TV content.
   217  * 
   218  * @param recorder The GMythRecorder instance.
   219  * @return TRUE if success, FALSE if any error happens.
   220  */
   221 gboolean
   222 gmyth_recorder_send_frontend_ready_command (GMythRecorder *recorder)
   223 {
   224 	GMythStringList *str_list;
   225 	GString *tmp_str = g_string_new( GMYTHTV_RECORDER_HEADER );
   226 	
   227 	gmyth_debug ( "[%s] FRONTEND_READY with recorder id = %d", __FUNCTION__, recorder->recorder_num );
   228 	
   229 	str_list = gmyth_string_list_new ();
   230 	
   231 	g_string_append_printf ( tmp_str, " %d", recorder->recorder_num ); 
   232 	
   233 	gmyth_string_list_append_string (str_list, tmp_str);
   234 	gmyth_string_list_append_string (str_list, g_string_new ("FRONTEND_READY"));
   235 
   236 	gmyth_socket_sendreceive_stringlist (recorder->myth_socket, str_list);
   237 	
   238   g_string_free (tmp_str, TRUE);
   239     
   240   tmp_str = gmyth_string_list_get_string (str_list, 0);
   241   if (tmp_str == NULL) {
   242   	g_warning ("[%s] FRONTEND_READY command request couldn't returns, reason: %s", __FUNCTION__, tmp_str->str);
   243   	return FALSE;
   244 	}
   245 	
   246   if (g_ascii_strncasecmp (tmp_str->str, "ok", 2)) {
   247   	g_warning ("[%s] FRONTEND_READY request returned %s", __FUNCTION__, tmp_str->str);
   248     g_object_unref (str_list);
   249   	return FALSE;
   250   }
   251 
   252   g_object_unref (str_list);
   253   return TRUE;
   254 
   255 }
   256 
   257 /** Send a CHECK_CHANNEL command request to the backend, in order to find if a 
   258  * certain channel actually exists.
   259  * 
   260  * @param recorder The GMythRecorder instance.
   261  * @param channel	 The new channel to be checked (string format).
   262  * @return true if success, false if any error happens.
   263  */
   264 gboolean
   265 gmyth_recorder_check_channel_name (GMythRecorder *recorder, gchar* channel)
   266 {
   267 	GMythStringList *str_list;
   268 	GString *tmp_str = g_string_new( GMYTHTV_RECORDER_HEADER );
   269 	
   270 	gmyth_debug ("[%s] CHECK_CHANNEL with channel = %s", __FUNCTION__, channel);
   271 	
   272 	str_list = gmyth_string_list_new ();
   273 	
   274 	g_string_append_printf ( tmp_str, " %d", recorder->recorder_num ); 
   275 	
   276 	gmyth_string_list_append_string (str_list, tmp_str);
   277 	gmyth_string_list_append_string (str_list, g_string_new ("CHECK_CHANNEL"));
   278 	gmyth_string_list_append_char_array (str_list, channel);
   279 
   280 	gmyth_socket_sendreceive_stringlist (recorder->myth_socket, str_list);
   281 	
   282     g_string_free (tmp_str, TRUE);
   283     
   284     tmp_str = gmyth_string_list_get_string (str_list, 0);
   285     if (tmp_str == NULL) {
   286     	g_warning ("[%s] CHECK_CHANNEL request returned %s", __FUNCTION__, tmp_str->str);
   287     	return FALSE;
   288 	}
   289 	
   290     if (g_ascii_strncasecmp (tmp_str->str, "ok", 2) == 0 || g_ascii_strncasecmp (tmp_str->str, "0", 1) == 0 ) {
   291     	g_warning ("[%s] CHECK_CHANNEL request returned %s", __FUNCTION__, tmp_str->str);
   292 	    g_object_unref (str_list);
   293     	return FALSE;
   294     }
   295 
   296     g_object_unref (str_list);
   297     return TRUE;
   298 
   299 }
   300 
   301 /** Send a CHECK_CHANNEL command request to the backend, in order to find if a 
   302  * certain channel actually exists.
   303  * 
   304  * @param recorder The GMythRecorder instance.
   305  * @param channel	 The new channel to be checked (decimal integer value).
   306  * @return true if success, false if any error happens.
   307  */
   308 gboolean
   309 gmyth_recorder_check_channel (GMythRecorder *recorder, gint channel)
   310 {
   311 	return gmyth_recorder_check_channel_name( recorder, g_strdup_printf( "%d", channel ) );
   312 }
   313 
   314 /** Send a SET_CHANNEL command request to the backend, to start streaming on another 
   315  * TV content channel.
   316  * 
   317  * @param recorder The GMythRecorder instance.
   318  * @param channel	 The new channel to be loaded.
   319  * @return true if success, false if any error happens.
   320  */
   321 gboolean
   322 gmyth_recorder_set_channel (GMythRecorder *recorder, gint channel)
   323 {
   324 	GMythStringList *str_list;
   325 	GString *tmp_str = g_string_new( GMYTHTV_RECORDER_HEADER );
   326 	
   327 	gmyth_debug ("[%s] SET_CHANNEL with channel = %d", __FUNCTION__, channel);
   328 	
   329 	str_list = gmyth_string_list_new ();
   330 	
   331 	g_string_append_printf ( tmp_str, " %d", recorder->recorder_num ); 
   332 	
   333 	gmyth_string_list_append_string (str_list, tmp_str);
   334 	gmyth_string_list_append_string (str_list, g_string_new ("SET_CHANNEL"));
   335 	gmyth_string_list_append_int (str_list, channel);
   336 
   337 	gmyth_socket_sendreceive_stringlist (recorder->myth_socket, str_list);
   338 	
   339     g_string_free (tmp_str, TRUE);
   340     
   341     tmp_str = gmyth_string_list_get_string (str_list, 0);
   342     if (tmp_str == NULL) {
   343     	g_warning ("[%s] SET_CHANNEL request returned %s", __FUNCTION__, tmp_str->str);
   344     	return FALSE;
   345 	}
   346 	
   347     if (g_ascii_strncasecmp (tmp_str->str, "ok", 2)) {
   348     	g_warning ("[%s] SET_CHANNEL request returned %s", __FUNCTION__, tmp_str->str);
   349 	    g_object_unref (str_list);
   350     	return FALSE;
   351     }
   352 
   353     g_object_unref (str_list);
   354     return TRUE;
   355 
   356 }
   357 
   358 /** Send a SET_CHANNEL command request to the backend, to start streaming on another 
   359  * TV content channel.
   360  * 
   361  * @param recorder The GMythRecorder instance.
   362  * @param channel	 The new channel to be loaded.
   363  * @return true if success, false if any error happens.
   364  */
   365 gboolean
   366 gmyth_recorder_set_channel_name (GMythRecorder *recorder, const gchar* channel)
   367 {
   368 	GMythStringList *str_list;
   369 	GString *tmp_str = g_string_new( GMYTHTV_RECORDER_HEADER );
   370 	
   371 	gmyth_debug ("[%s] SET_CHANNEL with channel name = %s", __FUNCTION__, channel);
   372 	
   373 	str_list = gmyth_string_list_new ();
   374 	
   375 	g_string_append_printf ( tmp_str, " %d", recorder->recorder_num ); 
   376 	
   377 	gmyth_string_list_append_string (str_list, tmp_str);
   378 	gmyth_string_list_append_string (str_list, g_string_new ("SET_CHANNEL"));
   379 	gmyth_string_list_append_char_array (str_list, channel);
   380 
   381 	gmyth_socket_sendreceive_stringlist (recorder->myth_socket, str_list);
   382 	
   383     g_string_free (tmp_str, TRUE);
   384     
   385     tmp_str = gmyth_string_list_get_string (str_list, 0);
   386     if (tmp_str == NULL) {
   387     	g_warning ("[%s] SET_CHANNEL name request returned %s", __FUNCTION__, tmp_str->str );
   388     	return FALSE;
   389 	}
   390 	
   391     if (g_ascii_strncasecmp (tmp_str->str, "ok", 2) || g_ascii_strtoull( tmp_str->str, NULL, 10 ) == 0 ) {
   392     	g_warning ("[%s] SET_CHANNEL name request returned %s", __FUNCTION__, tmp_str->str);
   393 	    g_object_unref (str_list);
   394     	return FALSE;
   395     }
   396 
   397     g_object_unref (str_list);
   398     return TRUE;
   399 
   400 }
   401 
   402 /**
   403  * Changes the channel of the actual Recorder.
   404  * 
   405  * CHANNEL_DIRECTION_UP       - Go up one channel in the listing
   406  *
   407  * CHANNEL_DIRECTION_DOWN     - Go down one channel in the listing
   408  *
   409  * CHANNEL_DIRECTION_FAVORITE - Go to the next favorite channel
   410  *
   411  * CHANNEL_DIRECTION_SAME     - Stay
   412  * 
   413  * @param recorder 	 The GMythRecorder instance.
   414  * @param direction	 The new channel direction where to move to.
   415  * @return true if success, false if any error happens.
   416  */
   417 gboolean
   418 gmyth_recorder_change_channel (GMythRecorder *recorder, const GMythRecorderChannelChangeDirection direction)
   419 {
   420 	GMythStringList *str_list;
   421 	GString *tmp_str = g_string_new( GMYTHTV_RECORDER_HEADER );
   422 	
   423 	gmyth_debug ("[%s] CHANGE_CHANNEL to the channel direction = %u", __FUNCTION__, direction);
   424 	
   425 	str_list = gmyth_string_list_new ();
   426 	
   427 	g_string_append_printf ( tmp_str, " %d", recorder->recorder_num ); 
   428 	
   429 	gmyth_string_list_append_string (str_list, tmp_str);
   430 	gmyth_string_list_append_string (str_list, g_string_new ("CHANGE_CHANNEL"));
   431 	gmyth_string_list_append_int (str_list, direction);
   432 
   433 	gmyth_socket_sendreceive_stringlist (recorder->myth_socket, str_list);
   434 	
   435     g_string_free (tmp_str, TRUE);
   436     
   437     tmp_str = gmyth_string_list_get_string (str_list, 0);
   438     if (tmp_str == NULL) {
   439     	g_warning ("[%s] CHANGE_CHANNEL name request returned %s", __FUNCTION__, tmp_str->str );
   440     	return FALSE;
   441 	}
   442 	
   443     if (g_ascii_strncasecmp (tmp_str->str, "ok", 2) || g_ascii_strtoull( tmp_str->str, NULL, 10 ) == 0 ) {
   444     	g_warning ("[%s] CHANGE_CHANNEL name request returned %s", __FUNCTION__, tmp_str->str);
   445 	    g_object_unref (str_list);
   446     	return FALSE;
   447     }
   448 
   449     g_object_unref (str_list);
   450     return TRUE;
   451 
   452 }
   453 
   454 /** Send a PAUSE command request to the backend, to pause streaming on another 
   455  * TV content channel.
   456  * 
   457  * @param recorder The GMythRecorder instance.
   458  * @return true if success, false if any error happens.
   459  */
   460 gboolean
   461 gmyth_recorder_pause_recording ( GMythRecorder *recorder )
   462 {
   463 	GMythStringList *str_list;
   464 	GString *tmp_str = g_string_new( GMYTHTV_RECORDER_HEADER );
   465 	
   466 	gmyth_debug ("[%s] PAUSE", __FUNCTION__);
   467 	
   468 	str_list = gmyth_string_list_new ();
   469 	
   470 	g_string_append_printf ( tmp_str, " %d", recorder->recorder_num ); 
   471 	
   472 	gmyth_string_list_append_string (str_list, tmp_str);
   473 	gmyth_string_list_append_string (str_list, g_string_new ("PAUSE"));
   474 
   475 	gmyth_socket_sendreceive_stringlist (recorder->myth_socket, str_list);
   476 	
   477     g_string_free (tmp_str, TRUE);
   478     
   479     tmp_str = gmyth_string_list_get_string (str_list, 0);
   480     if (tmp_str == NULL) {
   481     	g_warning ("[%s] PAUSE name request returned %s", __FUNCTION__, tmp_str->str);
   482     	return FALSE;
   483 	}
   484 	
   485     if (g_ascii_strncasecmp (tmp_str->str, "ok", 2)) {
   486     	g_warning ("[%s] PAUSE name request returned %s", __FUNCTION__, tmp_str->str);
   487 	    g_object_unref (str_list);
   488     	return FALSE;
   489     }
   490 
   491     g_object_unref (str_list);
   492     return TRUE;
   493 
   494 }
   495 
   496 /**
   497  * Requests the actual program info from the MythTV backend server.
   498  * 
   499  * @param recorder The GMythRecorder instance.
   500  * @return The actual program info.
   501  */
   502 GMythProgramInfo *
   503 gmyth_recorder_get_current_program_info ( GMythRecorder *recorder )
   504 {
   505 	GMythStringList *str_list;
   506 	GMythProgramInfo *program_info = gmyth_program_info_new();
   507 	GString *tmp_str = g_string_new( GMYTHTV_RECORDER_HEADER );
   508 	
   509 	str_list = gmyth_string_list_new ();
   510 	
   511 	g_string_append_printf ( tmp_str, " %d", recorder->recorder_num ); 
   512 	
   513 	gmyth_string_list_append_string (str_list, tmp_str);
   514 	
   515 	if ( recorder->myth_socket->mythtv_version >= 26 )
   516 		gmyth_string_list_append_string (str_list, g_string_new ("GET_CURRENT_RECORDING"));
   517 	else
   518 		gmyth_string_list_append_string (str_list, g_string_new ("GET_PROGRAM_INFO"));
   519 
   520 	gmyth_socket_sendreceive_stringlist (recorder->myth_socket, str_list);
   521 
   522   g_string_free (tmp_str, TRUE);
   523 
   524   if (str_list == NULL) {
   525   	g_warning ("[%s] GET_PROGRAM_INFO request returned. Error getting program info, string list equals to NULL!", __FUNCTION__);
   526   	return FALSE;
   527 	}
   528   
   529   program_info = gmyth_program_info_from_string_list( str_list );
   530 
   531   if ( NULL == program_info ) {
   532   	g_warning ("[%s] GET_PROGRAM_INFO request returned. Error getting program info, it is equals to NULL!!!", __FUNCTION__);
   533     g_object_unref (program_info);
   534   	return NULL;
   535   }
   536 
   537   g_object_unref (str_list);
   538   return program_info;
   539 
   540 }
   541 
   542 gint64
   543 gmyth_recorder_get_file_position ( GMythRecorder *recorder )
   544 {
   545   gint64 pos = 0;
   546   GString *query = g_string_new( GMYTHTV_RECORDER_HEADER );
   547 
   548   GMythStringList *str_list = gmyth_string_list_new ();
   549 
   550   g_string_append_printf( query, " %d", recorder->recorder_num );
   551 
   552   gmyth_string_list_append_string (str_list, query);
   553   gmyth_string_list_append_char_array( str_list, "GET_FILE_POSITION" );
   554 
   555   gmyth_socket_sendreceive_stringlist ( recorder->myth_socket, str_list );
   556 
   557   if ( str_list != NULL && gmyth_string_list_length(str_list) > 0 ) 
   558   {
   559     GString *str = NULL;
   560     if ( ( str = gmyth_string_list_get_string( str_list, 0 ) ) != NULL && strstr ( str->str, "bad" ) == NULL )
   561       pos = gmyth_util_decode_long_long( str_list, 0 );
   562   } 
   563 
   564 #ifndef GMYTHTV_ENABLE_DEBUG
   565   g_print( "[%s] Got file position = %lld\n", __FUNCTION__, pos );
   566 #endif
   567   if (str_list!=NULL)
   568     g_object_unref (str_list);
   569 
   570   return pos;
   571 
   572 }
   573 
   574 gboolean
   575 gmyth_recorder_is_recording ( GMythRecorder *recorder )
   576 {
   577   gboolean ret = TRUE;
   578   
   579   g_return_val_if_fail( recorder != NULL, FALSE );
   580 
   581   GMythStringList *str_list = gmyth_string_list_new ();
   582   GString *message = g_string_new ("");
   583 
   584   g_string_printf( message, "%s %d", GMYTHTV_RECORDER_HEADER, recorder->recorder_num);
   585   gmyth_string_list_append_string (str_list, message);
   586   gmyth_string_list_append_string (str_list, g_string_new ("IS_RECORDING"));
   587 
   588   gmyth_socket_sendreceive_stringlist ( recorder->myth_socket, str_list );
   589 
   590   if ( str_list != NULL && gmyth_string_list_length(str_list) > 0 )
   591   {
   592     GString *str = NULL;
   593     if ( ( str = gmyth_string_list_get_string( str_list, 0 ) ) != NULL && strcmp( str->str, "bad" )!= 0 ) 
   594     {
   595       gint is_rec = gmyth_string_list_get_int( str_list, 0 );
   596       if ( is_rec != 0 )
   597         ret = TRUE;
   598       else
   599         ret = FALSE;
   600     }
   601   }
   602   gmyth_debug( "%s, stream is %s being recorded!\n", ret ? "YES" : "NO", ret ? "" : "NOT" );
   603   //g_static_mutex_unlock (&mutex);
   604 
   605   if ( str_list != NULL )
   606     g_object_unref (str_list);
   607 
   608   return ret;
   609 
   610 }