[svn r293] Some fixes to the program info. trunk
authorrosfran
Tue Jan 23 22:20:21 2007 +0000 (2007-01-23)
branchtrunk
changeset 292c56122d88430
parent 291 73fa3a0f2f08
child 293 7bf252d4d39f
[svn r293] Some fixes to the program info.
gmyth/src/gmyth_livetv.c
gmyth/src/gmyth_livetv.h
gmyth/src/gmyth_programinfo.c
gmyth/src/gmyth_programinfo.h
gmyth/src/gmyth_recorder.c
gmyth/src/gmyth_recorder.h
gmyth/src/gmyth_uri.c
     1.1 --- a/gmyth/src/gmyth_livetv.c	Tue Jan 23 21:37:27 2007 +0000
     1.2 +++ b/gmyth/src/gmyth_livetv.c	Tue Jan 23 22:20:21 2007 +0000
     1.3 @@ -46,7 +46,7 @@
     1.4  
     1.5  static gint tvchain_curr_index = -1; 
     1.6  
     1.7 -#define GMYTHTV_RECORDER_HEADER         "QUERY_RECORDER"
     1.8 +static GStaticMutex lock = G_STATIC_MUTEX_INIT;
     1.9  
    1.10  #define GMYTHTV_TRANSFER_MAX_WAITS	    100
    1.11  
    1.12 @@ -239,6 +239,8 @@
    1.13  	GMythSocket *socket = gmyth_socket_new ();
    1.14  	
    1.15  	livetv->backend_info = backend_info;
    1.16 +	
    1.17 +	g_static_mutex_lock( &lock );
    1.18  
    1.19  	// FIME: Implement this at gmyth_socket
    1.20  	res = gmyth_socket_connect_to_backend (socket, livetv->backend_info->hostname,
    1.21 @@ -299,11 +301,11 @@
    1.22      gint wait_to_transfer = 0;
    1.23  
    1.24      while (wait_to_transfer++ < GMYTHTV_TRANSFER_MAX_WAITS &&
    1.25 -        (gmyth_livetv_is_recording (livetv) == FALSE))
    1.26 +        (gmyth_recorder_is_recording (livetv->recorder) == FALSE))
    1.27        g_usleep (500);
    1.28  
    1.29      /* IS_RECORDING again, just like the MythTV backend does... */
    1.30 -    gmyth_livetv_is_recording (livetv);
    1.31 +    gmyth_recorder_is_recording (livetv->recorder);
    1.32      
    1.33  		if ( channel != -1 ) 
    1.34  		{
    1.35 @@ -328,7 +330,6 @@
    1.36      sleep (6);                  /* FIXME: this is evil (tpm) */
    1.37    }
    1.38  
    1.39 -
    1.40  	// Reload all TV chain from Mysql database.
    1.41  	gmyth_tvchain_reload_all (livetv->tvchain);
    1.42  
    1.43 @@ -347,6 +348,8 @@
    1.44  		res = TRUE;
    1.45  		gmyth_debug ("GMythLiveTV: All requests to backend to start TV were OK. [%s]\n", livetv->proginfo->pathname->str );
    1.46  	}
    1.47 +	
    1.48 +	g_static_mutex_unlock( &lock );
    1.49  
    1.50  	if ( !gmyth_livetv_monitor_handler_start( livetv ) )
    1.51  	{
    1.52 @@ -483,6 +486,8 @@
    1.53  	}	
    1.54  
    1.55    gmyth_debug( "URI path = %s.\n", livetv->proginfo->pathname->str ); 
    1.56 +  
    1.57 +  g_static_mutex_lock( &lock );
    1.58  
    1.59  	livetv->file_transfer = gmyth_file_transfer_new( livetv->backend_info );
    1.60  
    1.61 @@ -507,6 +512,8 @@
    1.62  		livetv->file_transfer = NULL;
    1.63  		goto done;
    1.64  	}
    1.65 +	
    1.66 +	g_static_mutex_unlock( &lock );
    1.67  
    1.68  done:
    1.69  	if ( uri != NULL )
    1.70 @@ -532,45 +539,6 @@
    1.71  	}
    1.72  }
    1.73  
    1.74 -// FIXME: put here just a wrapper function to call gmyth_recorder_is_recording()...
    1.75 -gboolean
    1.76 -gmyth_livetv_is_recording ( GMythLiveTV *livetv )
    1.77 -{
    1.78 -  gboolean ret = TRUE;
    1.79 -
    1.80 -  GMythStringList *str_list = gmyth_string_list_new ();
    1.81 -  GString *message = g_string_new ("");
    1.82 -
    1.83 -  g_string_printf( message, "%s %d", GMYTHTV_RECORDER_HEADER,
    1.84 -      /* FIXME file_transfer->rec_id >= 0 ? file_transfer->rec_id : file_transfer->card_id );*/
    1.85 -        livetv->recorder->recorder_num);
    1.86 -  gmyth_string_list_append_string (str_list, message);
    1.87 -  gmyth_string_list_append_string (str_list, g_string_new ("IS_RECORDING"));
    1.88 -
    1.89 -  gmyth_socket_sendreceive_stringlist ( livetv->recorder->myth_socket, str_list );
    1.90 -
    1.91 -  if ( str_list != NULL && gmyth_string_list_length(str_list) > 0 )
    1.92 -  {
    1.93 -    GString *str = NULL;
    1.94 -    if ( ( str = gmyth_string_list_get_string( str_list, 0 ) ) != NULL && strcmp( str->str, "bad" )!= 0 ) {
    1.95 -      gint is_rec = gmyth_string_list_get_int( str_list, 0 );
    1.96 -      if ( is_rec != 0 )
    1.97 -        ret = TRUE;
    1.98 -      else
    1.99 -        ret = FALSE;
   1.100 -    }
   1.101 -  }
   1.102 -  g_print( "[%s] %s, stream is %s being recorded!\n", __FUNCTION__, ret ? "YES" : "NO", ret ? "" : "NOT" );
   1.103 -  //g_static_mutex_unlock (&mutex);
   1.104 -
   1.105 -  if ( str_list != NULL )
   1.106 -    g_object_unref (str_list);
   1.107 -
   1.108 -  return ret;
   1.109 -
   1.110 -}
   1.111 -
   1.112 -
   1.113  gboolean
   1.114  gmyth_livetv_is_playing (GMythLiveTV *livetv)
   1.115  {
     2.1 --- a/gmyth/src/gmyth_livetv.h	Tue Jan 23 21:37:27 2007 +0000
     2.2 +++ b/gmyth/src/gmyth_livetv.h	Tue Jan 23 22:20:21 2007 +0000
     2.3 @@ -85,8 +85,6 @@
     2.4  void gmyth_livetv_start_playing (GMythLiveTV *livetv);
     2.5  void gmyth_livetv_stop_playing (GMythLiveTV *livetv);
     2.6  
     2.7 -gboolean gmyth_livetv_is_recording ( GMythLiveTV *livetv );	
     2.8 -
     2.9  gboolean gmyth_livetv_setup (GMythLiveTV *livetv, GMythBackendInfo *backend_info);
    2.10  gboolean gmyth_livetv_channel_setup ( GMythLiveTV *livetv, gint channel, GMythBackendInfo *backend_info );
    2.11  gboolean gmyth_livetv_next_program_chain ( GMythLiveTV *livetv );
     3.1 --- a/gmyth/src/gmyth_programinfo.c	Tue Jan 23 21:37:27 2007 +0000
     3.2 +++ b/gmyth/src/gmyth_programinfo.c	Tue Jan 23 22:20:21 2007 +0000
     3.3 @@ -148,7 +148,7 @@
     3.4  static void
     3.5  gmyth_program_info_dispose  (GObject *object)
     3.6  {
     3.7 -  GMythProgramInfo *gmyth_program_info = GMYTH_PROGRAM_INFO(object);
     3.8 +  //GMythProgramInfo *gmyth_program_info = GMYTH_PROGRAM_INFO(object);
     3.9     
    3.10  	G_OBJECT_CLASS (gmyth_program_info_parent_class)->dispose (object);
    3.11  }
    3.12 @@ -232,47 +232,47 @@
    3.13  
    3.14      g_return_val_if_fail (slist != NULL, NULL);
    3.15  
    3.16 -    prog->title = gmyth_string_list_read_string (slist);
    3.17 -    prog->subtitle = gmyth_string_list_read_string (slist);
    3.18 -    prog->description = gmyth_string_list_read_string (slist);
    3.19 -    prog->category = gmyth_string_list_read_string (slist);
    3.20 -    prog->chanid = gmyth_string_list_read_string (slist);
    3.21 -    prog->chanstr = gmyth_string_list_read_string (slist);
    3.22 -    prog->chansign = gmyth_string_list_read_string (slist);
    3.23 -    prog->channame = gmyth_string_list_read_string (slist);
    3.24 -    prog->pathname = gmyth_string_list_read_string (slist);
    3.25 -    prog->filesize = gmyth_string_list_read_int64 (slist);
    3.26 +    prog->title = gmyth_string_list_get_string (slist, 0);
    3.27 +    prog->subtitle = gmyth_string_list_get_string (slist, 1);
    3.28 +    prog->description = gmyth_string_list_get_string (slist, 2);
    3.29 +    prog->category = gmyth_string_list_get_string (slist, 3);
    3.30 +    prog->chanid = gmyth_string_list_get_string (slist, 4);
    3.31 +    prog->chanstr = gmyth_string_list_get_string (slist, 5);
    3.32 +    prog->chansign = gmyth_string_list_get_string (slist, 6);
    3.33 +    prog->channame = gmyth_string_list_get_string (slist, 7);
    3.34 +    prog->pathname = gmyth_string_list_get_string (slist, 8);
    3.35 +    prog->filesize = gmyth_string_list_get_int64 (slist, 9);
    3.36  
    3.37 -    gmyth_string_list_read_int (slist); //DATETIME_TO_LIST(startts)
    3.38 -    gmyth_string_list_read_int (slist); //DATETIME_TO_LIST(endts)
    3.39 -    prog->duplicate = gmyth_string_list_read_int (slist);
    3.40 -    prog->shareable = gmyth_string_list_read_int (slist);
    3.41 -    prog->findid = gmyth_string_list_read_int (slist);
    3.42 -    prog->hostname = gmyth_string_list_read_string (slist);
    3.43 -    prog->sourceid = gmyth_string_list_read_int (slist);
    3.44 -    prog->cardid = gmyth_string_list_read_int (slist);
    3.45 -    prog->inputid = gmyth_string_list_read_int (slist);
    3.46 -    prog->recpriority = gmyth_string_list_read_int (slist);
    3.47 -    gmyth_string_list_read_int (slist);
    3.48 -    prog->recordid = gmyth_string_list_read_int (slist, prog->recordid);
    3.49 -    gmyth_string_list_read_int (slist);
    3.50 -    gmyth_string_list_read_int (slist);
    3.51 -    gmyth_string_list_read_int (slist);
    3.52 -    gmyth_string_list_read_int (slist); //DATETIME_TO_LIST(recstartts)
    3.53 -    gmyth_string_list_read_int (slist); //DATETIME_TO_LIST(recendts)
    3.54 -    prog->repeat = gmyth_string_list_read_int (slist);
    3.55 -    prog->programflags = gmyth_string_list_read_int (slist);
    3.56 -    prog->recgroup = gmyth_string_list_read_string (slist); //prog->(recgroup != "") ? recgroup : "Default")
    3.57 -    prog->chancommfree = gmyth_string_list_read_int (slist);
    3.58 -    prog->chanOutputFilters = gmyth_string_list_read_string (slist);
    3.59 -    prog->seriesid = gmyth_string_list_read_string (slist);
    3.60 -    prog->programid = gmyth_string_list_read_string (slist);
    3.61 -    gmyth_string_list_read_int (slist); //DATETIME_TO_LIST(lastmodified)
    3.62 -    gmyth_string_list_read_int (slist); //FLOAT_TO_LIST(stars)
    3.63 -    gmyth_string_list_read_int (slist); //DATETIME_TO_LIST(QDateTime(originalAirDate))
    3.64 -    prog->hasAirDate = gmyth_string_list_read_int (slist);
    3.65 -    prog->playgroup = gmyth_string_list_read_char_array (slist); //prog->(playgroup != "") ? playgroup : "Default")
    3.66 -    prog->recpriority2 = gmyth_string_list_read_int (slist);
    3.67 +    gmyth_string_list_get_int (slist, 10); //DATETIME_TO_LIST(startts)
    3.68 +    gmyth_string_list_get_int (slist, 11); //DATETIME_TO_LIST(endts)
    3.69 +    prog->duplicate = gmyth_string_list_get_int (slist, 12);
    3.70 +    prog->shareable = gmyth_string_list_get_int (slist, 13);
    3.71 +    prog->findid = gmyth_string_list_get_int (slist, 14);
    3.72 +    prog->hostname = gmyth_string_list_get_string (slist, 15);
    3.73 +    prog->sourceid = gmyth_string_list_get_int (slist, 16);
    3.74 +    prog->cardid = gmyth_string_list_get_int (slist, 17);
    3.75 +    prog->inputid = gmyth_string_list_get_int (slist, 18);
    3.76 +    prog->recpriority = gmyth_string_list_get_int (slist, 19);
    3.77 +    gmyth_string_list_get_int (slist, 20);
    3.78 +    prog->recordid = gmyth_string_list_get_int (slist, 21);
    3.79 +    gmyth_string_list_get_int (slist, 22);
    3.80 +    gmyth_string_list_get_int (slist, 23);
    3.81 +    gmyth_string_list_get_int (slist, 24);
    3.82 +    gmyth_string_list_get_int (slist, 25); //DATETIME_TO_LIST(recstartts)
    3.83 +    gmyth_string_list_get_int (slist, 26); //DATETIME_TO_LIST(recendts)
    3.84 +    prog->repeat = gmyth_string_list_get_int (slist, 27);
    3.85 +    prog->programflags = gmyth_string_list_get_int (slist, 28);
    3.86 +    prog->recgroup = gmyth_string_list_get_string (slist, 29); //prog->(recgroup != "") ? recgroup : "Default")
    3.87 +    prog->chancommfree = gmyth_string_list_get_int (slist, 30);
    3.88 +    prog->chanOutputFilters = gmyth_string_list_get_string (slist, 31);
    3.89 +    prog->seriesid = gmyth_string_list_get_string (slist, 32);
    3.90 +    prog->programid = gmyth_string_list_get_string (slist, 33);
    3.91 +    gmyth_string_list_get_int (slist, 34); //DATETIME_TO_LIST(lastmodified)
    3.92 +    gmyth_string_list_get_int (slist, 35); //FLOAT_TO_LIST(stars)
    3.93 +    gmyth_string_list_get_int (slist, 36); //DATETIME_TO_LIST(QDateTime(originalAirDate))
    3.94 +    prog->hasAirDate = gmyth_string_list_get_int (slist, 37);
    3.95 +    prog->playgroup = gmyth_string_list_get_string (slist, 38); //prog->(playgroup != "") ? playgroup : "Default")
    3.96 +    prog->recpriority2 = gmyth_string_list_get_int (slist, 39);
    3.97     
    3.98      return prog;
    3.99  }
     4.1 --- a/gmyth/src/gmyth_programinfo.h	Tue Jan 23 21:37:27 2007 +0000
     4.2 +++ b/gmyth/src/gmyth_programinfo.h	Tue Jan 23 22:20:21 2007 +0000
     4.3 @@ -92,9 +92,9 @@
     4.4    GString *seriesid;
     4.5    /** The program unique id. */
     4.6    GString *programid;
     4.7 -  GString * catType;
     4.8 +  GString *catType;
     4.9  
    4.10 -  GString * sortTitle;  
    4.11 +  GString *sortTitle;  
    4.12  
    4.13  	/** A flag informing if the program has video or not. */    
    4.14    gboolean isVideo;
     5.1 --- a/gmyth/src/gmyth_recorder.c	Tue Jan 23 21:37:27 2007 +0000
     5.2 +++ b/gmyth/src/gmyth_recorder.c	Tue Jan 23 22:20:21 2007 +0000
     5.3 @@ -506,3 +506,40 @@
     5.4  
     5.5  }
     5.6  
     5.7 +gboolean
     5.8 +gmyth_recorder_is_recording ( GMythRecorder *recorder )
     5.9 +{
    5.10 +  gboolean ret = TRUE;
    5.11 +  
    5.12 +  g_return_val_if_fail( recorder != NULL, FALSE );
    5.13 +
    5.14 +  GMythStringList *str_list = gmyth_string_list_new ();
    5.15 +  GString *message = g_string_new ("");
    5.16 +
    5.17 +  g_string_printf( message, "%s %d", GMYTHTV_RECORDER_HEADER, recorder->recorder_num);
    5.18 +  gmyth_string_list_append_string (str_list, message);
    5.19 +  gmyth_string_list_append_string (str_list, g_string_new ("IS_RECORDING"));
    5.20 +
    5.21 +  gmyth_socket_sendreceive_stringlist ( recorder->myth_socket, str_list );
    5.22 +
    5.23 +  if ( str_list != NULL && gmyth_string_list_length(str_list) > 0 )
    5.24 +  {
    5.25 +    GString *str = NULL;
    5.26 +    if ( ( str = gmyth_string_list_get_string( str_list, 0 ) ) != NULL && strcmp( str->str, "bad" )!= 0 ) 
    5.27 +    {
    5.28 +      gint is_rec = gmyth_string_list_get_int( str_list, 0 );
    5.29 +      if ( is_rec != 0 )
    5.30 +        ret = TRUE;
    5.31 +      else
    5.32 +        ret = FALSE;
    5.33 +    }
    5.34 +  }
    5.35 +  gmyth_debug( "%s, stream is %s being recorded!\n", ret ? "YES" : "NO", ret ? "" : "NOT" );
    5.36 +  //g_static_mutex_unlock (&mutex);
    5.37 +
    5.38 +  if ( str_list != NULL )
    5.39 +    g_object_unref (str_list);
    5.40 +
    5.41 +  return ret;
    5.42 +
    5.43 +}
     6.1 --- a/gmyth/src/gmyth_recorder.h	Tue Jan 23 21:37:27 2007 +0000
     6.2 +++ b/gmyth/src/gmyth_recorder.h	Tue Jan 23 22:20:21 2007 +0000
     6.3 @@ -101,6 +101,8 @@
     6.4                                           
     6.5  gint64 	 gmyth_recorder_get_file_position ( GMythRecorder *recorder );
     6.6  
     6.7 +gboolean gmyth_recorder_is_recording ( GMythRecorder *recorder );
     6.8 +
     6.9  G_END_DECLS
    6.10  
    6.11  #endif /* __GMYTH_REMOTE_ENCODER_H__ */
     7.1 --- a/gmyth/src/gmyth_uri.c	Tue Jan 23 21:37:27 2007 +0000
     7.2 +++ b/gmyth/src/gmyth_uri.c	Tue Jan 23 22:20:21 2007 +0000
     7.3 @@ -39,7 +39,7 @@
     7.4  
     7.5  #include "gmyth_debug.h"
     7.6  
     7.7 -static void gmyth_string_list_class_init          (GMythURIClass *klass);
     7.8 +static void gmyth_uri_class_init          (GMythURIClass *klass);
     7.9  static void gmyth_uri_init                (GMythURI *object);
    7.10  
    7.11  static void gmyth_uri_dispose  (GObject *object);