maemo-ui/src/mmyth_tvplayer.c
branchtrunk
changeset 237 678cf278c11a
parent 99 404189e73f8e
child 244 c88244670b08
     1.1 --- a/maemo-ui/src/mmyth_tvplayer.c	Wed Nov 22 12:55:16 2006 +0000
     1.2 +++ b/maemo-ui/src/mmyth_tvplayer.c	Wed Dec 20 18:55:48 2006 +0000
     1.3 @@ -30,8 +30,9 @@
     1.4   
     1.5  #include <gdk/gdkx.h>
     1.6  
     1.7 -#include "gmyth_context.h"
     1.8 -#include "gmyth_remote_util.h"
     1.9 +#include <gmyth/gmyth_remote_util.h>
    1.10 +
    1.11 +#define MYTHTV_VERSION_DEFAULT	30
    1.12  
    1.13  typedef struct _GstPlayerWindowStateChange
    1.14  {
    1.15 @@ -73,10 +74,10 @@
    1.16  {
    1.17  	GObjectClass *gobject_class;
    1.18  
    1.19 -    gobject_class = (GObjectClass *) klass;
    1.20 -	
    1.21 -    gobject_class->dispose  = mmyth_tvplayer_dispose;
    1.22 -    gobject_class->finalize = mmyth_tvplayer_finalize;	
    1.23 +	gobject_class = (GObjectClass *) klass;
    1.24 +
    1.25 +	gobject_class->dispose  = mmyth_tvplayer_dispose;
    1.26 +	gobject_class->finalize = mmyth_tvplayer_finalize;	
    1.27  }
    1.28  
    1.29  static void
    1.30 @@ -214,15 +215,16 @@
    1.31   * successfully, FALSE otherwise.
    1.32   */
    1.33  gboolean
    1.34 -mmyth_tvplayer_initialize (MMythTVPlayer *tvplayer)
    1.35 +mmyth_tvplayer_initialize (MMythTVPlayer *tvplayer, GMythBackendInfo *backend_info)
    1.36  {
    1.37 -	
    1.38 -    if (!mmyth_tvplayer_create_pipeline (tvplayer)) {
    1.39 -    	g_warning ("[%s] Error while creating pipeline. TV Player not initialized", __FUNCTION__);
    1.40 +	tvplayer->backend_info = backend_info;
    1.41 +
    1.42 +	if (!mmyth_tvplayer_create_pipeline (tvplayer)) {
    1.43 +		g_warning ("[%s] Error while creating pipeline. TV Player not initialized", __FUNCTION__);
    1.44  		return FALSE;
    1.45  	} else {
    1.46  		g_debug ("[%s] GStreamer pipeline created", __FUNCTION__);	
    1.47 -    }
    1.48 +	}
    1.49  
    1.50  	return TRUE;
    1.51  }
    1.52 @@ -317,7 +319,7 @@
    1.53      g_object_ref (tvplayer->audioqueue1);
    1.54      g_object_ref (tvplayer->audioqueue2);
    1.55    	
    1.56 -    g_object_set (G_OBJECT (videosink), "sync", TRUE, NULL);
    1.57 +    //g_object_set (G_OBJECT (videosink), "sync", TRUE, NULL);
    1.58      g_object_set (G_OBJECT (audiosink), "sync", FALSE, NULL);
    1.59  
    1.60      gst_bus_add_watch (gst_pipeline_get_bus (GST_PIPELINE (tvplayer->gst_pipeline)),
    1.61 @@ -353,14 +355,12 @@
    1.62  gboolean
    1.63  mmyth_tvplayer_record_setup (MMythTVPlayer *tvplayer, gchar *filename)
    1.64  {
    1.65 -	GMythSettings *msettings = gmyth_context_get_settings();
    1.66 -	
    1.67  	// FIXME: we should receive the uri instead of filename
    1.68 -	GString *hostname = gmyth_settings_get_backend_hostname (msettings);
    1.69 -	int port = gmyth_settings_get_backend_port(msettings);
    1.70 +	gchar *hostname = gmyth_backend_info_get_hostname (tvplayer->backend_info);
    1.71 +	gint port = gmyth_backend_info_get_port(tvplayer->backend_info);
    1.72  	
    1.73  	GString *fullpath = g_string_new ("myth://");
    1.74 -	g_string_append_printf (fullpath, "%s:%d/%s", hostname->str, port, filename);
    1.75 +	g_string_append_printf (fullpath, "%s:%d/%s", hostname, port, filename);
    1.76  	
    1.77  	tvplayer->is_livetv = FALSE;
    1.78  
    1.79 @@ -381,90 +381,24 @@
    1.80  gboolean
    1.81  mmyth_tvplayer_livetv_setup (MMythTVPlayer *tvplayer)
    1.82  {
    1.83 -	GMythSettings *msettings = gmyth_context_get_settings ();
    1.84  	gboolean res = TRUE;
    1.85 +	gchar *hostname;
    1.86  
    1.87 -	res = gmyth_context_check_connection();
    1.88 -	if (!res) {
    1.89 -		g_warning ("[%s] LiveTV can not connect to backend", __FUNCTION__);	
    1.90 -		res = FALSE;
    1.91 +	tvplayer->livetv = gmyth_livetv_new ();
    1.92 +
    1.93 +	if ( !gmyth_livetv_setup( tvplayer->livetv, tvplayer->backend_info ) )
    1.94  		goto error;
    1.95 -	}
    1.96 -
    1.97 -	tvplayer->backend_hostname = gmyth_settings_get_backend_hostname(msettings);
    1.98 -	tvplayer->backend_port = gmyth_settings_get_backend_port (msettings);
    1.99 -
   1.100 -	tvplayer->local_hostname  = g_string_new("");    
   1.101 -	gmyth_context_get_local_hostname (tvplayer->local_hostname);
   1.102 -
   1.103 -	if ( tvplayer->local_hostname == NULL ) {
   1.104 -		res = FALSE;
   1.105 -		goto error;
   1.106 -	}
   1.107 -
   1.108 -	// Gets the remote encoder num
   1.109 -	tvplayer->recorder = remote_request_next_free_recorder (-1);
   1.110 -
   1.111 -	if ( tvplayer->recorder == NULL ) {
   1.112 -		g_warning ("[%s] None remote encoder available", __FUNCTION__);
   1.113 -		res = FALSE;
   1.114 -		goto error;
   1.115 -	}
   1.116 -
   1.117 -	// Creates livetv chain handler
   1.118 -	tvplayer->tvchain = GMYTH_TVCHAIN ( g_object_new(GMYTH_TVCHAIN_TYPE, NULL) );
   1.119 -	gmyth_tvchain_initialize ( tvplayer->tvchain, tvplayer->local_hostname );
   1.120 -
   1.121 -	if ( tvplayer->tvchain == NULL || tvplayer->tvchain->tvchain_id == NULL ) {
   1.122 -		res = FALSE;
   1.123 -		goto error;
   1.124 -	}
   1.125 -
   1.126 -	// Init remote encoder. Opens its control socket.
   1.127 -	res = gmyth_recorder_setup(tvplayer->recorder);
   1.128 -	if ( !res ) {
   1.129 -		g_warning ("[%s] Fail while setting remote encoder\n", __FUNCTION__);
   1.130 -		res = FALSE;
   1.131 -		goto error;
   1.132 -	}
   1.133 -	// Spawn live tv. Uses the socket to send mythprotocol data to start livetv in the backend (remotelly)
   1.134 -	res = gmyth_recorder_spawntv ( tvplayer->recorder,
   1.135 -			gmyth_tvchain_get_id(tvplayer->tvchain) );
   1.136 -	if (!res) {
   1.137 -		g_warning ("[%s] Fail while spawn tv\n", __FUNCTION__);
   1.138 -		res = FALSE;
   1.139 -		goto error;
   1.140 -	}
   1.141 -
   1.142 -	// Reload all TV chain from Mysql database.
   1.143 -	gmyth_tvchain_reload_all (tvplayer->tvchain);
   1.144 -
   1.145 -	if ( tvplayer->tvchain == NULL ) {
   1.146 -		res = FALSE;
   1.147 -		goto error;
   1.148 -	}
   1.149 -
   1.150 -	// Get program info from database using chanid and starttime
   1.151 -	tvplayer->proginfo = gmyth_tvchain_get_program_at (tvplayer->tvchain, -1);
   1.152 -	if ( tvplayer->proginfo == NULL ) {
   1.153 -		g_warning ("[%s] LiveTV not successfully started.\n", __FUNCTION__ );
   1.154 -		res = FALSE;
   1.155 -		goto error;
   1.156 -	} else {
   1.157 -		g_debug ("[%s] MythLiveTV: All requests to backend to start TV were OK.\n", __FUNCTION__ );
   1.158 -	}
   1.159 -
   1.160 +	
   1.161  	return res;
   1.162  
   1.163  error:
   1.164 -	if ( tvplayer->backend_hostname != NULL ) {
   1.165 -		g_string_free( tvplayer->backend_hostname, TRUE );
   1.166 -		res = FALSE;
   1.167 +	res = FALSE;
   1.168 +	if ( tvplayer->livetv != NULL ) {
   1.169 +		g_object_unref( tvplayer->livetv );
   1.170  	}
   1.171  
   1.172  	if ( tvplayer->local_hostname != NULL ) {
   1.173  		g_string_free( tvplayer->local_hostname, TRUE );
   1.174 -		res = FALSE;
   1.175  	}
   1.176  
   1.177  	if ( tvplayer->recorder != NULL ) {