diff -r 404189e73f8e -r 00b55a87f1ba maemo-ui/src/mmyth_tvplayer.c --- a/maemo-ui/src/mmyth_tvplayer.c Wed Nov 22 12:55:16 2006 +0000 +++ b/maemo-ui/src/mmyth_tvplayer.c Tue Dec 19 23:28:32 2006 +0000 @@ -30,8 +30,9 @@ #include -#include "gmyth_context.h" -#include "gmyth_remote_util.h" +#include + +#define MYTHTV_VERSION_DEFAULT 30 typedef struct _GstPlayerWindowStateChange { @@ -73,10 +74,10 @@ { GObjectClass *gobject_class; - gobject_class = (GObjectClass *) klass; - - gobject_class->dispose = mmyth_tvplayer_dispose; - gobject_class->finalize = mmyth_tvplayer_finalize; + gobject_class = (GObjectClass *) klass; + + gobject_class->dispose = mmyth_tvplayer_dispose; + gobject_class->finalize = mmyth_tvplayer_finalize; } static void @@ -214,15 +215,16 @@ * successfully, FALSE otherwise. */ gboolean -mmyth_tvplayer_initialize (MMythTVPlayer *tvplayer) +mmyth_tvplayer_initialize (MMythTVPlayer *tvplayer, GMythBackendInfo *backend_info) { - - if (!mmyth_tvplayer_create_pipeline (tvplayer)) { - g_warning ("[%s] Error while creating pipeline. TV Player not initialized", __FUNCTION__); + tvplayer->backend_info = backend_info; + + if (!mmyth_tvplayer_create_pipeline (tvplayer)) { + g_warning ("[%s] Error while creating pipeline. TV Player not initialized", __FUNCTION__); return FALSE; } else { g_debug ("[%s] GStreamer pipeline created", __FUNCTION__); - } + } return TRUE; } @@ -317,7 +319,7 @@ g_object_ref (tvplayer->audioqueue1); g_object_ref (tvplayer->audioqueue2); - g_object_set (G_OBJECT (videosink), "sync", TRUE, NULL); + //g_object_set (G_OBJECT (videosink), "sync", TRUE, NULL); g_object_set (G_OBJECT (audiosink), "sync", FALSE, NULL); gst_bus_add_watch (gst_pipeline_get_bus (GST_PIPELINE (tvplayer->gst_pipeline)), @@ -353,14 +355,12 @@ gboolean mmyth_tvplayer_record_setup (MMythTVPlayer *tvplayer, gchar *filename) { - GMythSettings *msettings = gmyth_context_get_settings(); - // FIXME: we should receive the uri instead of filename - GString *hostname = gmyth_settings_get_backend_hostname (msettings); - int port = gmyth_settings_get_backend_port(msettings); + gchar *hostname = gmyth_backend_info_get_hostname (tvplayer->backend_info); + gint port = gmyth_backend_info_get_port(tvplayer->backend_info); GString *fullpath = g_string_new ("myth://"); - g_string_append_printf (fullpath, "%s:%d/%s", hostname->str, port, filename); + g_string_append_printf (fullpath, "%s:%d/%s", hostname, port, filename); tvplayer->is_livetv = FALSE; @@ -381,90 +381,24 @@ gboolean mmyth_tvplayer_livetv_setup (MMythTVPlayer *tvplayer) { - GMythSettings *msettings = gmyth_context_get_settings (); gboolean res = TRUE; + gchar *hostname; - res = gmyth_context_check_connection(); - if (!res) { - g_warning ("[%s] LiveTV can not connect to backend", __FUNCTION__); - res = FALSE; + tvplayer->livetv = gmyth_livetv_new (); + + if ( !gmyth_livetv_setup( tvplayer->livetv, tvplayer->backend_info ) ) goto error; - } - - tvplayer->backend_hostname = gmyth_settings_get_backend_hostname(msettings); - tvplayer->backend_port = gmyth_settings_get_backend_port (msettings); - - tvplayer->local_hostname = g_string_new(""); - gmyth_context_get_local_hostname (tvplayer->local_hostname); - - if ( tvplayer->local_hostname == NULL ) { - res = FALSE; - goto error; - } - - // Gets the remote encoder num - tvplayer->recorder = remote_request_next_free_recorder (-1); - - if ( tvplayer->recorder == NULL ) { - g_warning ("[%s] None remote encoder available", __FUNCTION__); - res = FALSE; - goto error; - } - - // Creates livetv chain handler - tvplayer->tvchain = GMYTH_TVCHAIN ( g_object_new(GMYTH_TVCHAIN_TYPE, NULL) ); - gmyth_tvchain_initialize ( tvplayer->tvchain, tvplayer->local_hostname ); - - if ( tvplayer->tvchain == NULL || tvplayer->tvchain->tvchain_id == NULL ) { - res = FALSE; - goto error; - } - - // Init remote encoder. Opens its control socket. - res = gmyth_recorder_setup(tvplayer->recorder); - if ( !res ) { - g_warning ("[%s] Fail while setting remote encoder\n", __FUNCTION__); - res = FALSE; - goto error; - } - // Spawn live tv. Uses the socket to send mythprotocol data to start livetv in the backend (remotelly) - res = gmyth_recorder_spawntv ( tvplayer->recorder, - gmyth_tvchain_get_id(tvplayer->tvchain) ); - if (!res) { - g_warning ("[%s] Fail while spawn tv\n", __FUNCTION__); - res = FALSE; - goto error; - } - - // Reload all TV chain from Mysql database. - gmyth_tvchain_reload_all (tvplayer->tvchain); - - if ( tvplayer->tvchain == NULL ) { - res = FALSE; - goto error; - } - - // Get program info from database using chanid and starttime - tvplayer->proginfo = gmyth_tvchain_get_program_at (tvplayer->tvchain, -1); - if ( tvplayer->proginfo == NULL ) { - g_warning ("[%s] LiveTV not successfully started.\n", __FUNCTION__ ); - res = FALSE; - goto error; - } else { - g_debug ("[%s] MythLiveTV: All requests to backend to start TV were OK.\n", __FUNCTION__ ); - } - + return res; error: - if ( tvplayer->backend_hostname != NULL ) { - g_string_free( tvplayer->backend_hostname, TRUE ); - res = FALSE; + res = FALSE; + if ( tvplayer->livetv != NULL ) { + g_object_unref( tvplayer->livetv ); } if ( tvplayer->local_hostname != NULL ) { g_string_free( tvplayer->local_hostname, TRUE ); - res = FALSE; } if ( tvplayer->recorder != NULL ) {