maemo-ui/src/mmyth_tvplayer.c
author renatofilho
Tue Mar 27 16:12:15 2007 +0100 (2007-03-27)
branchtrunk
changeset 460 cde4aad8577a
parent 414 0d3d926bc374
child 754 cb885ee44618
permissions -rw-r--r--
[svn r465] removed seek imp.
     1 /**
     2  * GMyth Library
     3  *
     4  * @file gmyth/mmyth_tvplayer.c
     5  * 
     6  * @brief <p> This component provides playback of the remote A/V using
     7  * GStreamer.
     8  * 
     9  * Copyright (C) 2006 INdT - Instituto Nokia de Tecnologia.
    10  * @author Hallyson Luiz de Morais Melo <hallyson.melo@indt.org.br>
    11  *
    12  *//*
    13  * 
    14  * This program is free software; you can redistribute it and/or modify
    15  * it under the terms of the GNU Lesser General Public License as published by
    16  * the Free Software Foundation; either version 2 of the License, or
    17  * (at your option) any later version.
    18  *
    19  * This program is distributed in the hope that it will be useful,
    20  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    22  * GNU General Public License for more details.
    23  *
    24  * You should have received a copy of the GNU Lesser General Public License
    25  * along with this program; if not, write to the Free Software
    26  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    27  */
    28 
    29 #include "mmyth_tvplayer.h"
    30  
    31 #include <gdk/gdkx.h>
    32 
    33 #include <gmyth/gmyth_remote_util.h>
    34 
    35 #define MYTHTV_VERSION_DEFAULT	30
    36 
    37 typedef struct _GstPlayerWindowStateChange
    38 {
    39     GstElement *play;
    40     GstState old_state, new_state;
    41     MMythTVPlayer *tvplayer;
    42 } GstPlayerWindowStateChange;
    43 
    44 typedef struct _GstPlayerWindowTagFound
    45 {
    46     GstElement *play;
    47     GstTagList *taglist;
    48     MMythTVPlayer *tvplayer;
    49 } GstPlayerWindowTagFound;
    50 
    51 /*
    52 static gboolean idle_state (gpointer data);
    53 */
    54 static gboolean bus_call (GstBus * bus, GstMessage * msg, gpointer data);
    55 
    56 static void mmyth_tvplayer_class_init          (MMythTVPlayerClass *klass);
    57 static void mmyth_tvplayer_init                (MMythTVPlayer *object);
    58 
    59 static void mmyth_tvplayer_dispose  (GObject *object);
    60 static void mmyth_tvplayer_finalize (GObject *object);
    61 
    62 G_DEFINE_TYPE(MMythTVPlayer, mmyth_tvplayer, G_TYPE_OBJECT)
    63 
    64 static gboolean mmyth_tvplayer_create_pipeline (MMythTVPlayer* tvplayer);
    65 static void     new_pad_cb (GstElement *element, 
    66                             GstPad *pad, gpointer data);
    67 
    68 static gboolean expose_cb (GtkWidget * widget, 
    69                            GdkEventExpose * event, 
    70                            gpointer user_data);
    71 
    72 static void
    73 mmyth_tvplayer_class_init (MMythTVPlayerClass *klass)
    74 {
    75 	GObjectClass *gobject_class;
    76 
    77 	gobject_class = (GObjectClass *) klass;
    78 
    79 	gobject_class->dispose  = mmyth_tvplayer_dispose;
    80 	gobject_class->finalize = mmyth_tvplayer_finalize;	
    81 }
    82 
    83 static void
    84 new_pad_cb (GstElement *element, GstPad *pad, gpointer data)
    85 {
    86 	MMythTVPlayer *tvplayer = MMYTH_TVPLAYER (data);
    87 	GstPadLinkReturn ret;
    88 	char *s;
    89 	
    90 	s = gst_caps_to_string (pad->caps);
    91 
    92 	if ( s[0] == 'a') {
    93 		ret = gst_pad_link (pad, gst_element_get_pad (tvplayer->audioqueue1, "sink"));
    94 	} else {
    95 		ret = gst_pad_link (pad, gst_element_get_pad (tvplayer->videoqueue1, "sink")); 
    96 	}
    97 	
    98 	g_free(s);
    99 }
   100 
   101 static gboolean
   102 expose_cb (GtkWidget * widget, GdkEventExpose * event, gpointer user_data)
   103 {
   104 	MMythTVPlayer *tvplayer = MMYTH_TVPLAYER (user_data);
   105 
   106 	if (tvplayer && tvplayer->videow) {
   107 		gst_x_overlay_set_xwindow_id (GST_X_OVERLAY (tvplayer->gst_videosink),
   108 				GDK_WINDOW_XWINDOW (widget->window));
   109 		return TRUE;
   110 	}
   111 
   112 	g_warning ("MMythTVPlayer expose called before setting video window\n");
   113 
   114 	return FALSE;
   115 }
   116 
   117 static void
   118 mmyth_tvplayer_init (MMythTVPlayer *tvplayer)
   119 {
   120 	tvplayer->gst_pipeline = NULL;
   121 	tvplayer->gst_source = NULL;
   122 	tvplayer->gst_videodec = NULL;
   123 	tvplayer->gst_videosink = NULL;
   124 	tvplayer->gst_videocolortrs = NULL;
   125 	tvplayer->videoqueue1 = NULL;
   126 	tvplayer->videoqueue2 = NULL;
   127 	tvplayer->audioqueue1 = NULL;
   128 	tvplayer->audioqueue2 = NULL;   
   129 
   130 	/* GTKWidget for rendering the video */
   131 	tvplayer->videow = NULL;
   132 	tvplayer->expose_handler = 0;
   133 
   134 	tvplayer->backend_hostname = NULL;
   135 	tvplayer->backend_port = 0;
   136 	tvplayer->local_hostname = NULL;
   137 
   138 	tvplayer->recorder = NULL;
   139 	tvplayer->tvchain = NULL;
   140 	tvplayer->proginfo = NULL;
   141 }
   142 
   143 static void
   144 mmyth_tvplayer_dispose (GObject *object)
   145 {
   146 
   147 	G_OBJECT_CLASS (mmyth_tvplayer_parent_class)->dispose (object);
   148 }
   149 
   150 static void
   151 mmyth_tvplayer_finalize (GObject *object)
   152 {
   153 	g_signal_handlers_destroy (object);
   154 
   155 	MMythTVPlayer *tvplayer = MMYTH_TVPLAYER (object);
   156 
   157 	g_debug ("[%s] Finalizing tvplayer", __FUNCTION__);
   158 	
   159 	if (tvplayer->videow != NULL) {
   160 		if (g_signal_handler_is_connected (tvplayer->videow, 
   161 						tvplayer->expose_handler)) {
   162 			g_signal_handler_disconnect (tvplayer->videow,
   163 				tvplayer->expose_handler);
   164 		}
   165 		g_object_unref (tvplayer->videow);
   166 	}
   167 	
   168 	if ( tvplayer->recorder != NULL )
   169 		g_object_unref (tvplayer->recorder);
   170 	if ( tvplayer->tvchain != NULL )
   171 		g_object_unref (tvplayer->tvchain);
   172 	if ( tvplayer->proginfo != NULL )
   173 		g_object_unref (tvplayer->proginfo);	
   174 
   175 	// Release Gstreamer elements
   176 	if ( tvplayer->gst_pipeline != NULL )
   177 		g_object_unref (tvplayer->gst_pipeline);	
   178 	if ( tvplayer->gst_source != NULL )
   179 		g_object_unref (tvplayer->gst_source);	
   180 	if ( tvplayer->gst_videodec != NULL )
   181 		g_object_unref (tvplayer->gst_videodec);	
   182 	if ( tvplayer->gst_videocolortrs != NULL )
   183 		g_object_unref (tvplayer->gst_videocolortrs);
   184 	if ( tvplayer->gst_videosink != NULL )
   185 		g_object_unref (tvplayer->gst_videosink);	
   186 	if ( tvplayer->videoqueue1 != NULL )
   187 		g_object_unref (tvplayer->videoqueue1);
   188 	if ( tvplayer->videoqueue2 != NULL )
   189 		g_object_unref (tvplayer->videoqueue2);
   190 	if ( tvplayer->audioqueue1 != NULL )
   191 		g_object_unref (tvplayer->audioqueue1);	
   192 	if ( tvplayer->audioqueue2 != NULL )
   193 		g_object_unref (tvplayer->audioqueue2);	
   194 
   195 	G_OBJECT_CLASS (mmyth_tvplayer_parent_class)->finalize (object);
   196 }
   197 
   198 /** Creates a new instance of MMythTVPlayer. 
   199  * 
   200  * @return a new instance of MMythTVPlayer.
   201  */
   202 MMythTVPlayer *
   203 mmyth_tvplayer_new ()
   204 {
   205     MMythTVPlayer *tvplayer = 
   206         MMYTH_TVPLAYER (g_object_new(MMYTH_TVPLAYER_TYPE, NULL));
   207     
   208     return tvplayer;
   209 }
   210 
   211 /** Initializes the tv player.
   212  *
   213  * @param tvplayer the object instance.
   214  * @return gboolean TRUE if the pipeline was created 
   215  * successfully, FALSE otherwise.
   216  */
   217 gboolean
   218 mmyth_tvplayer_initialize (MMythTVPlayer *tvplayer, GMythBackendInfo *backend_info)
   219 {
   220 	tvplayer->backend_info = backend_info;
   221 
   222 	if (!mmyth_tvplayer_create_pipeline (tvplayer)) {
   223 		g_warning ("[%s] Error while creating pipeline. TV Player not initialized", __FUNCTION__);
   224 		return FALSE;
   225 	} else {
   226 		g_debug ("[%s] GStreamer pipeline created", __FUNCTION__);	
   227 	}
   228 
   229 	return TRUE;
   230 }
   231 
   232 /** Creates the GStreamer pipeline used by the player.
   233  *
   234  * @param tvplayer the object instance.
   235  * @return gboolean TRUE if the pipeline was created 
   236  * successfully, FALSE otherwise.
   237  */
   238 static gboolean
   239 mmyth_tvplayer_create_pipeline (MMythTVPlayer* tvplayer)
   240 {
   241     GstElement *pipeline;
   242     GstElement *source, *parser;
   243     GstElement *videodec, *videosink;
   244     GstElement *videocolortrs;
   245 #ifndef MAEMO_PLATFORM    
   246     GstElement *audiodec, *audioconv, *audioqueue2;
   247 #endif
   248     GstElement *audiosink;
   249     GstElement *videoqueue1, *videoqueue2, *audioqueue1;
   250 
   251     g_debug ("MMythTVPlayer: Setting the Gstreamer pipeline\n");
   252 	
   253     pipeline = gst_pipeline_new ("video-player");
   254     source = gst_element_factory_make ("mythtvsrc", "myth-source");
   255     parser = gst_element_factory_make ("nuvdemux", "nuv-demux");
   256 
   257     /* Gstreamer Video elements */
   258     videoqueue1 = gst_element_factory_make ("queue", "video-queue1");
   259     videodec = gst_element_factory_make ("ffdec_mpeg4", "video-decoder");
   260     videoqueue2 = gst_element_factory_make ("queue", "video-queue2");
   261     videocolortrs = gst_element_factory_make ("ffmpegcolorspace", "image-color-transforms");
   262 
   263 #ifdef MAEMO_PLATFORM
   264     videosink = gst_element_factory_make ("sdlvideosink", "image-output");
   265 #else
   266     videosink = gst_element_factory_make ("xvimagesink", "image-output");
   267 #endif
   268     
   269     /* Gstreamer Audio elements */
   270     audioqueue1 = gst_element_factory_make ("queue", "audio-queue1");
   271 #ifdef MAEMO_PLATFORM    
   272     audiosink = gst_element_factory_make ("dspmp3sink", "audio-output");
   273 #else    
   274 		audioqueue2 = gst_element_factory_make ("queue", "audio-queue2");
   275     audiodec = gst_element_factory_make ("mad", "audio-decoder");
   276     audioconv = gst_element_factory_make ("audioconvert", "audio-converter");
   277     audiosink = gst_element_factory_make ("alsasink", "audio-output");
   278 #endif    
   279     
   280     if (!(pipeline && source && parser && videodec && videosink) ||
   281     	!(videoqueue1 && videoqueue2 && audioqueue1 && audiosink)) {
   282         /* FIXME: hanlde the error correctly */
   283         /* video_alignment is not being created (below) 
   284            and is causing problems to the ui */
   285 
   286 	    tvplayer->gst_pipeline = NULL;
   287 	    tvplayer->gst_videodec = NULL;
   288 	    tvplayer->gst_videosink = NULL;
   289 	    tvplayer->gst_videocolortrs = NULL;
   290            
   291         g_warning ("GstElement creation error!\n");
   292         return FALSE;
   293     }
   294 
   295 #ifndef MAEMO_PLATFORM    
   296     if (!(audiodec && audioconv)) {
   297         g_warning ("GstElement for audio stream creation error!");
   298         return FALSE;
   299     }
   300 #endif    
   301     
   302     tvplayer->gst_pipeline = pipeline;
   303     tvplayer->gst_source = source;
   304     tvplayer->gst_videodec = videodec;
   305     tvplayer->gst_videosink = videosink;
   306     tvplayer->gst_videocolortrs = videocolortrs;
   307     g_object_ref (tvplayer->gst_pipeline);
   308     g_object_ref (tvplayer->gst_source);
   309     g_object_ref (tvplayer->gst_videodec);
   310     g_object_ref (tvplayer->gst_videosink);
   311     g_object_ref (tvplayer->gst_videocolortrs);
   312 
   313     tvplayer->videoqueue1 = videoqueue1;
   314     tvplayer->videoqueue2 = videoqueue2;
   315     tvplayer->audioqueue1 = audioqueue1;
   316     g_object_ref (tvplayer->videoqueue1);
   317     g_object_ref (tvplayer->videoqueue2);
   318     g_object_ref (tvplayer->audioqueue1);
   319     
   320 #ifndef MAEMO_PLATFORM
   321     tvplayer->audioqueue2 = audioqueue2;
   322     g_object_ref (tvplayer->audioqueue2);
   323 #endif
   324   	
   325     //g_object_set (G_OBJECT (videosink), "sync", TRUE, NULL);
   326     g_object_set (G_OBJECT (audiosink), "sync", FALSE, NULL);
   327 
   328     gst_bus_add_watch (gst_pipeline_get_bus (GST_PIPELINE (tvplayer->gst_pipeline)),
   329                        bus_call, tvplayer);
   330 
   331     gst_bin_add_many (GST_BIN (pipeline), source, parser, videoqueue1,
   332     			videodec, videoqueue2, videocolortrs, videosink, NULL );
   333 
   334 #ifndef MAEMO_PLATFORM
   335 			gst_bin_add_many ( GST_BIN(pipeline), audioqueue1, audiodec, audioconv, audioqueue2, audiosink, NULL );
   336 #else
   337 			gst_bin_add_many ( GST_BIN(pipeline), audioqueue1, audiosink, NULL);
   338 #endif
   339 
   340     {
   341 //        GstCaps *rtpcaps = gst_caps_new_simple ("application/x-rtp", NULL);
   342 //        gst_element_link_filtered(source, parser, rtpcaps);
   343     }
   344     
   345     gst_element_link (source, parser);
   346     gst_element_link_many (videoqueue1, videodec, videoqueue2, videocolortrs, videosink, NULL);
   347     
   348 #ifndef MAEMO_PLATFORM
   349     gst_element_link_many (videosink, audioqueue1, audiodec, audioconv, audioqueue2, audiosink, NULL);
   350 #else
   351 		gst_element_link_many (videosink, audioqueue1, audiosink, NULL);
   352 #endif
   353     
   354     g_signal_connect (parser, "pad-added", G_CALLBACK (new_pad_cb), tvplayer);
   355     
   356     return TRUE;
   357 }
   358 
   359 /** Configures the backend and the tv player 
   360  * for playing the recorded content A/V.
   361  *
   362  * FIXME: Change filename to program info or other structure about the recorded
   363  *
   364  * @param tvplayer the object instance.
   365  * @param filename the file uri of the recorded content to be played.
   366  * @return TRUE if successfull, FALSE if any error happens.
   367  */
   368 gboolean
   369 mmyth_tvplayer_record_setup (MMythTVPlayer *tvplayer, const gchar *filename)
   370 {
   371 	// FIXME: we should receive the uri instead of filename
   372 	const gchar *hostname = gmyth_backend_info_get_hostname (tvplayer->backend_info);
   373 	const gint port = gmyth_backend_info_get_port(tvplayer->backend_info);
   374 	
   375 	GString *fullpath = g_string_new ("myth://");
   376 	g_string_append_printf (fullpath, "%s:%d/%s", hostname, port, filename);
   377 	
   378 	tvplayer->is_livetv = FALSE;
   379 
   380 	g_debug ("[%s] Setting record uri to gstreamer pipeline to %s", __FUNCTION__, fullpath->str);
   381 		
   382     g_object_set (G_OBJECT (tvplayer->gst_source), "location",
   383           fullpath->str, NULL);
   384           
   385     return TRUE;
   386 }
   387 
   388 /** Configures the backend and the tv player 
   389  * for playing the live tv.
   390  *
   391  * @param tvplayer the object instance.
   392  * @return TRUE if successfull, FALSE if any error happens.
   393  */
   394 gboolean
   395 mmyth_tvplayer_livetv_setup (MMythTVPlayer *tvplayer)
   396 {
   397 	gboolean res = TRUE;
   398 
   399 	tvplayer->livetv = gmyth_livetv_new ();
   400 
   401 	if ( !gmyth_livetv_setup( tvplayer->livetv, tvplayer->backend_info ) )
   402 		goto error;
   403 	
   404 	return res;
   405 
   406 error:
   407 	res = FALSE;
   408 	if ( tvplayer->livetv != NULL ) {
   409 		g_object_unref( tvplayer->livetv );
   410 	}
   411 
   412 	if ( tvplayer->local_hostname != NULL ) {
   413 		g_string_free( tvplayer->local_hostname, TRUE );
   414 	}
   415 
   416 	if ( tvplayer->recorder != NULL ) {
   417 		g_object_unref (tvplayer->recorder);
   418 		tvplayer->recorder = NULL;
   419 	}
   420 
   421 	if ( tvplayer->tvchain != NULL ) {
   422 		g_object_unref (tvplayer->tvchain);
   423 		tvplayer->tvchain = NULL;
   424 	}
   425 
   426 	if ( tvplayer->proginfo != NULL ) {
   427 		g_object_unref (tvplayer->proginfo);
   428 		tvplayer->proginfo = NULL;
   429 	}
   430 
   431 	return res;
   432 
   433 }
   434 
   435 /** Sets the GTK video widget for the tv player. 
   436  *
   437  * @param tvplayer the object instance.
   438  * @param videow the GTK video window.
   439  * @return TRUE if successfull, FALSE if any error happens.
   440  */
   441 gboolean
   442 mmyth_tvplayer_set_widget (MMythTVPlayer *tvplayer, GtkWidget *videow)
   443 {
   444 	tvplayer->videow = videow;
   445 	g_object_ref (videow);
   446 	
   447 	g_debug ("[%s] Setting widget for tv player render", __FUNCTION__);
   448 	
   449     tvplayer->expose_handler = g_signal_connect (tvplayer->videow, "expose-event", 
   450                                                  G_CALLBACK (expose_cb), tvplayer);
   451 
   452     //g_signal_connect(miptv_ui->videow, "size_request", G_CALLBACK(cb_preferred_video_size), miptv_ui);
   453 
   454     return TRUE;
   455 }
   456 
   457 static gboolean
   458 bus_call (GstBus * bus, GstMessage * msg, gpointer data)
   459 {
   460     //MMythTVPlayer *tvplayer = MMYTH_TVPLAYER ( data );
   461     //GMainLoop *loop = tvplayer->loop;
   462 
   463     switch (GST_MESSAGE_TYPE (msg)) {
   464         case GST_MESSAGE_EOS:
   465 			printf ("End of stream\n");
   466             //g_idle_add ((GSourceFunc) idle_eos, data);
   467             gst_element_set_state ( GST_ELEMENT (GST_MESSAGE_SRC (msg)), GST_STATE_NULL );
   468 	    gst_element_set_locked_state ( GST_ELEMENT (GST_MESSAGE_SRC (msg)), TRUE );
   469             break;
   470         case GST_MESSAGE_ERROR:
   471         {
   472                 gchar *debug;
   473                 GError *err;
   474 
   475                 gst_message_parse_error (msg, &err, &debug);
   476                 g_free (debug);
   477 
   478                 printf ("Error: %s\n", err->message);
   479                 g_error_free (err);
   480 
   481                 //g_main_loop_quit (loop);
   482         }
   483             break;
   484         default:
   485             printf (gst_message_type_get_name (GST_MESSAGE_TYPE (msg)));
   486             printf ("\n");
   487             break;
   488     }
   489 
   490     return TRUE;
   491 }
   492 
   493 
   494 #if 0
   495 static gboolean
   496 idle_state (gpointer data)
   497 {
   498     GstPlayerWindowStateChange *st = data;
   499 
   500     if (st->old_state == GST_STATE_PLAYING) {
   501         if (st->miptv_ui->idle_id != 0) {
   502             g_source_remove (st->miptv_ui->idle_id);
   503             st->miptv_ui->idle_id = 0;
   504         }
   505     }
   506     else if (st->new_state == GST_STATE_PLAYING) {
   507         if (st->miptv_ui->idle_id != 0)
   508             g_source_remove (st->miptv_ui->idle_id);
   509 
   510         st->miptv_ui->idle_id = g_idle_add (cb_iterate, st->miptv_ui);
   511     }
   512 
   513     /* new movie loaded? */
   514     if (st->old_state == GST_STATE_READY && st->new_state > GST_STATE_READY) {
   515 
   516         /* gboolean have_video = FALSE; */
   517 
   518         gtk_widget_show (st->miptv_ui->videow);
   519 
   520         gtk_window_resize (GTK_WINDOW (st->miptv_ui->main_window), 1, 1);
   521 
   522     }
   523 
   524     /* discarded movie? */
   525     if (st->old_state > GST_STATE_READY && st->new_state == GST_STATE_READY) {
   526 
   527         if (st->miptv_ui->tagcache) {
   528             gst_tag_list_free (st->miptv_ui->tagcache);
   529             st->miptv_ui->tagcache = NULL;
   530         }
   531     }
   532 
   533     gst_object_unref (GST_OBJECT (st->play));
   534     //g_object_unref (G_OBJECT (st->win));
   535     g_free (st);
   536 
   537     /* once */
   538     return FALSE;
   539 }
   540 
   541 #endif
   542 
   543 /** Stops playing the current A/V.
   544  *
   545  * FIXME: How to proceed differently between livetv 
   546  * and recorded content?
   547  *
   548  * @param tvplayer the object instance.
   549  * @return void 
   550  */
   551 void
   552 mmyth_tvplayer_stop_playing (MMythTVPlayer *tvplayer) 
   553 {
   554     g_debug ("[%s] Setting gstreamer pipeline state to NULL", __FUNCTION__);
   555 
   556     gst_element_set_state (tvplayer->gst_pipeline, GST_STATE_NULL);
   557     
   558     if (tvplayer->is_livetv) {
   559 	    if (!gmyth_recorder_stop_livetv (tvplayer->recorder)) {
   560 	    	g_warning ("[%s] Error while stoping remote encoder", __FUNCTION__);	
   561 	    }
   562     }
   563 }
   564 
   565 /** Queries if the tvplayer is active playing A/V content.
   566  *
   567  * @param tvplayer the object instance.
   568  * @return TRUE if the tvplayer is active, FALSE otherwise.
   569  */
   570 gboolean
   571 mmyth_tvplayer_is_playing (MMythTVPlayer *tvplayer)
   572 {
   573 	return (GST_STATE (tvplayer->gst_pipeline) == GST_STATE_PLAYING);
   574 }
   575 
   576 /** Static function that sets the tvplayer state to PLAYING.
   577  *
   578  * @param tvplayer the object instance.
   579  * @return TRUE if the tvplayer is active, FALSE otherwise.
   580  */
   581 static gboolean
   582 idle_play (gpointer data)
   583 {
   584     MMythTVPlayer *tvplayer = MMYTH_TVPLAYER (data);
   585 
   586 	g_debug ("MMythTVPlayer: Setting pipeline state to PLAYING\n");
   587 
   588     gst_element_set_state (tvplayer->gst_pipeline, GST_STATE_PLAYING);
   589 
   590     return FALSE;
   591 }
   592 
   593 /** Start playing A/V with the tvplayer attributes.
   594  *
   595  * @param tvplayer the object instance.
   596  */
   597 void
   598 mmyth_tvplayer_start_playing (MMythTVPlayer *tvplayer)
   599 {
   600 
   601 	// FIXME: Move this to livetv_setup??
   602 	if (tvplayer->is_livetv) {
   603 
   604 	#if 0
   605 		if (!tvplayer || !(tvplayer->proginfo) || !(tvplayer->local_hostname)
   606 				|| !(tvplayer->gst_source)) {
   607 			g_warning ("GMythtvPlayer not ready to start playing\n");		
   608 		}
   609 
   610 		if (!(tvplayer->proginfo->pathname)) {
   611 			g_warning ("[%s] Playback url is null, could not play the myth content", __FUNCTION__);
   612 			return;
   613 		}
   614 
   615 		g_debug ("MMythTVPlayer: Start playing %s", tvplayer->proginfo->pathname->str);
   616 #endif
   617 		g_object_set (G_OBJECT (tvplayer->gst_source), "mythtv-live",
   618 				TRUE, NULL);
   619 #if 0
   620 		if ( tvplayer->tvchain != NULL ) {
   621 			GString *str_chainid = gmyth_tvchain_get_id(tvplayer->tvchain);
   622 			g_print( "[%s]\tCHAIN ID: %s\n", __FUNCTION__, str_chainid->str );
   623 
   624 			g_object_set (G_OBJECT (tvplayer->gst_source), "mythtv-live-chainid", 
   625 					g_strdup( str_chainid->str ), NULL);      
   626 			if ( str_chainid!=NULL)
   627 				g_string_free( str_chainid, FALSE );
   628 		}
   629 
   630 		if ( tvplayer->recorder != NULL )	
   631 			g_object_set (G_OBJECT (tvplayer->gst_source), "mythtv-live-id",
   632 					tvplayer->recorder->recorder_num, NULL );
   633 		g_debug ("[%s] Setting location to %s", __FUNCTION__, 
   634 				tvplayer->proginfo->pathname->str);
   635 
   636 		/* Sets the gstreamer properties acording to the service access address */
   637 		g_object_set (G_OBJECT (tvplayer->gst_source), "location",
   638 				tvplayer->proginfo->pathname->str, NULL);              
   639 #endif
   640 	}
   641 
   642 	g_object_set (G_OBJECT (tvplayer->gst_source), "mythtv-version",
   643               MYTHTV_VERSION_DEFAULT, NULL);
   644 
   645     g_object_set (G_OBJECT (tvplayer->gst_source), "mythtv-debug",
   646               TRUE, NULL);
   647 
   648     g_idle_add (idle_play, tvplayer);
   649 
   650 }
   651