[svn r65] Fixes in some recorder functions, refactoring. trunk
authorrosfran
Mon Nov 06 18:58:26 2006 +0000 (2006-11-06)
branchtrunk
changeset 64f926338c6952
parent 63 957b55b3f630
child 65 dc4814fe4723
[svn r65] Fixes in some recorder functions, refactoring.
maemo-ui/src/mmyth_main.c
maemo-ui/src/mmyth_tvplayer.c
maemo-ui/src/mmyth_tvplayer.h
     1.1 --- a/maemo-ui/src/mmyth_main.c	Mon Oct 30 22:55:19 2006 +0000
     1.2 +++ b/maemo-ui/src/mmyth_main.c	Mon Nov 06 18:58:26 2006 +0000
     1.3 @@ -8,8 +8,7 @@
     1.4  #include "hildon-widgets/hildon-window.h"
     1.5  #endif
     1.6  
     1.7 -
     1.8 -#include "gmyth_remote_encoder.h"
     1.9 +#include "gmyth_recorder.h"
    1.10  #include "gmyth_settings.h"
    1.11  #include "gmyth_context.h"
    1.12  #include "gmyth_tvchain.h"
     2.1 --- a/maemo-ui/src/mmyth_tvplayer.c	Mon Oct 30 22:55:19 2006 +0000
     2.2 +++ b/maemo-ui/src/mmyth_tvplayer.c	Mon Nov 06 18:58:26 2006 +0000
     2.3 @@ -89,9 +89,9 @@
     2.4  	s = gst_caps_to_string (pad->caps);
     2.5  
     2.6  	if ( s[0] == 'a') {
     2.7 -		ret = gst_pad_link (pad, gst_element_get_pad (tvplayer->audioqueue, "sink"));
     2.8 +		ret = gst_pad_link (pad, gst_element_get_pad (tvplayer->audioqueue1, "sink"));
     2.9  	} else {
    2.10 -		ret = gst_pad_link (pad, gst_element_get_pad (tvplayer->videoqueue, "sink")); 
    2.11 +		ret = gst_pad_link (pad, gst_element_get_pad (tvplayer->videoqueue1, "sink")); 
    2.12  	}
    2.13  	
    2.14  	g_free(s);
    2.15 @@ -100,38 +100,41 @@
    2.16  static gboolean
    2.17  expose_cb (GtkWidget * widget, GdkEventExpose * event, gpointer user_data)
    2.18  {
    2.19 -    MMythTVPlayer *tvplayer = MMYTH_TVPLAYER (user_data);
    2.20 +	MMythTVPlayer *tvplayer = MMYTH_TVPLAYER (user_data);
    2.21  
    2.22  	if (tvplayer && tvplayer->videow) {
    2.23 -	    gst_x_overlay_set_xwindow_id (GST_X_OVERLAY (tvplayer->gst_videosink),
    2.24 -                                  GDK_WINDOW_XWINDOW (widget->window));
    2.25 +		gst_x_overlay_set_xwindow_id (GST_X_OVERLAY (tvplayer->gst_videosink),
    2.26 +				GDK_WINDOW_XWINDOW (widget->window));
    2.27  		return TRUE;
    2.28  	}
    2.29 -	
    2.30 +
    2.31  	g_warning ("MMythTVPlayer expose called before setting video window\n");
    2.32 -	
    2.33 -    return FALSE;
    2.34 +
    2.35 +	return FALSE;
    2.36  }
    2.37  
    2.38  static void
    2.39  mmyth_tvplayer_init (MMythTVPlayer *tvplayer)
    2.40  {
    2.41 -    tvplayer->gst_pipeline = NULL;
    2.42 -    tvplayer->gst_source = NULL;
    2.43 -    tvplayer->gst_videodec = NULL;
    2.44 -    tvplayer->gst_videosink = NULL;
    2.45 -    tvplayer->videoqueue = NULL;
    2.46 -    tvplayer->audioqueue = NULL;
    2.47 -    
    2.48 -    /* GTKWidget for rendering the video */
    2.49 -    tvplayer->videow = NULL;
    2.50 +	tvplayer->gst_pipeline = NULL;
    2.51 +	tvplayer->gst_source = NULL;
    2.52 +	tvplayer->gst_videodec = NULL;
    2.53 +	tvplayer->gst_videosink = NULL;
    2.54 +	tvplayer->gst_videocolortrs = NULL;
    2.55 +	tvplayer->videoqueue1 = NULL;
    2.56 +	tvplayer->videoqueue2 = NULL;
    2.57 +	tvplayer->audioqueue1 = NULL;
    2.58 +	tvplayer->audioqueue2 = NULL;   
    2.59 +
    2.60 +	/* GTKWidget for rendering the video */
    2.61 +	tvplayer->videow = NULL;
    2.62  	tvplayer->expose_handler = 0;
    2.63 -	    
    2.64 +
    2.65  	tvplayer->backend_hostname = NULL;
    2.66  	tvplayer->backend_port = 0;
    2.67  	tvplayer->local_hostname = NULL;
    2.68  
    2.69 -	tvplayer->remote_encoder = NULL;
    2.70 +	tvplayer->recorder = NULL;
    2.71  	tvplayer->tvchain = NULL;
    2.72  	tvplayer->proginfo = NULL;
    2.73  }
    2.74 @@ -161,8 +164,8 @@
    2.75  		g_object_unref (tvplayer->videow);
    2.76  	}
    2.77  	
    2.78 -	if ( tvplayer->remote_encoder != NULL )
    2.79 -		g_object_unref (tvplayer->remote_encoder);
    2.80 +	if ( tvplayer->recorder != NULL )
    2.81 +		g_object_unref (tvplayer->recorder);
    2.82  	if ( tvplayer->tvchain != NULL )
    2.83  		g_object_unref (tvplayer->tvchain);
    2.84  	if ( tvplayer->proginfo != NULL )
    2.85 @@ -175,12 +178,18 @@
    2.86  		g_object_unref (tvplayer->gst_source);	
    2.87  	if ( tvplayer->gst_videodec != NULL )
    2.88  		g_object_unref (tvplayer->gst_videodec);	
    2.89 +	if ( tvplayer->gst_videocolortrs != NULL )
    2.90 +		g_object_unref (tvplayer->gst_videocolortrs);
    2.91  	if ( tvplayer->gst_videosink != NULL )
    2.92  		g_object_unref (tvplayer->gst_videosink);	
    2.93 -	if ( tvplayer->videoqueue != NULL )
    2.94 -		g_object_unref (tvplayer->videoqueue);	
    2.95 -	if ( tvplayer->audioqueue != NULL )
    2.96 -		g_object_unref (tvplayer->audioqueue);	
    2.97 +	if ( tvplayer->videoqueue1 != NULL )
    2.98 +		g_object_unref (tvplayer->videoqueue1);
    2.99 +	if ( tvplayer->videoqueue2 != NULL )
   2.100 +		g_object_unref (tvplayer->videoqueue2);
   2.101 +	if ( tvplayer->audioqueue1 != NULL )
   2.102 +		g_object_unref (tvplayer->audioqueue1);	
   2.103 +	if ( tvplayer->audioqueue2 != NULL )
   2.104 +		g_object_unref (tvplayer->audioqueue2);	
   2.105  
   2.106  	G_OBJECT_CLASS (mmyth_tvplayer_parent_class)->finalize (object);
   2.107  }
   2.108 @@ -230,21 +239,25 @@
   2.109      GstElement *pipeline;
   2.110      GstElement *source, *parser;
   2.111      GstElement *videodec, *videosink;
   2.112 +    GstElement *videocolortrs;
   2.113  #ifndef MAEMO_PLATFORM    
   2.114      GstElement *audiodec, *audioconv;
   2.115  #endif
   2.116      GstElement *audiosink;
   2.117 -    GstElement *videoqueue, *audioqueue;
   2.118 +    GstElement *videoqueue1, *videoqueue2, *audioqueue1, *audioqueue2;
   2.119  
   2.120      g_debug ("MMythTVPlayer: Setting the Gstreamer pipeline\n");
   2.121  	
   2.122      pipeline = gst_pipeline_new ("video-player");
   2.123      source = gst_element_factory_make ("mythtvsrc", "myth-source");
   2.124 -    parser = gst_element_factory_make ("ffdemux_nuv", "nuv-demux");
   2.125 +    parser = gst_element_factory_make ("nuvdemux", "nuv-demux");
   2.126  
   2.127      /* Gstreamer Video elements */
   2.128 -    videoqueue = gst_element_factory_make ("queue", "video-queue");
   2.129 -    videodec = gst_element_factory_make ("ffdec_mpeg4", "video-decoder");
   2.130 +    videoqueue1 = gst_element_factory_make ("queue", "video-queue1");
   2.131 +    videodec = gst_element_factory_make ("divxdec", "video-decoder");
   2.132 +    videoqueue2 = gst_element_factory_make ("queue", "video-queue2");
   2.133 +    videocolortrs = gst_element_factory_make ("ffmpegcolorspace", "image-color-transforms");
   2.134 +
   2.135  #ifdef MAEMO_PLATFORM
   2.136      videosink = gst_element_factory_make ("sdlvideosink", "image-output");
   2.137  #else
   2.138 @@ -252,17 +265,18 @@
   2.139  #endif
   2.140      
   2.141      /* Gstreamer Audio elements */
   2.142 -    audioqueue = gst_element_factory_make ("queue", "audio-queue");    
   2.143 +    audioqueue1 = gst_element_factory_make ("queue", "audio-queue1");    
   2.144 +    audioqueue2 = gst_element_factory_make ("queue", "audio-queue2");
   2.145  #ifdef MAEMO_PLATFORM    
   2.146      audiosink = gst_element_factory_make ("dspmp3sink", "audio-output");
   2.147  #else    
   2.148 -    audiodec = gst_element_factory_make ("ffdec_mp3", "audio-decoder");
   2.149 +    audiodec = gst_element_factory_make ("mad", "audio-decoder");
   2.150      audioconv = gst_element_factory_make ("audioconvert", "audio-converter");
   2.151      audiosink = gst_element_factory_make ("alsasink", "audio-output");
   2.152  #endif    
   2.153      
   2.154      if (!(pipeline && source && parser && videodec && videosink) ||
   2.155 -    	!(videoqueue && audioqueue && audiosink)) {
   2.156 +    	!(videoqueue1 && videoqueue2 && audioqueue1 && audioqueue2 && audiosink)) {
   2.157          /* FIXME: hanlde the error correctly */
   2.158          /* video_alignment is not being created (below) 
   2.159             and is causing problems to the ui */
   2.160 @@ -270,6 +284,7 @@
   2.161  	    tvplayer->gst_pipeline = NULL;
   2.162  	    tvplayer->gst_videodec = NULL;
   2.163  	    tvplayer->gst_videosink = NULL;
   2.164 +	    tvplayer->gst_videocolortrs = NULL;
   2.165             
   2.166          g_warning ("GstElement creation error!\n");
   2.167          return FALSE;
   2.168 @@ -282,29 +297,35 @@
   2.169      }
   2.170  #endif    
   2.171      
   2.172 -    
   2.173      tvplayer->gst_pipeline = pipeline;
   2.174      tvplayer->gst_source = source;
   2.175      tvplayer->gst_videodec = videodec;
   2.176      tvplayer->gst_videosink = videosink;
   2.177 +    tvplayer->gst_videocolortrs = videocolortrs;
   2.178      g_object_ref (tvplayer->gst_pipeline);
   2.179      g_object_ref (tvplayer->gst_source);
   2.180      g_object_ref (tvplayer->gst_videodec);
   2.181      g_object_ref (tvplayer->gst_videosink);
   2.182 +    g_object_ref (tvplayer->gst_videocolortrs);
   2.183  
   2.184 -    tvplayer->videoqueue = videoqueue;
   2.185 -    tvplayer->audioqueue = audioqueue;
   2.186 -    g_object_ref (tvplayer->videoqueue);
   2.187 -    g_object_ref (tvplayer->audioqueue);
   2.188 -   	
   2.189 +    tvplayer->videoqueue1 = videoqueue1;
   2.190 +    tvplayer->videoqueue2 = videoqueue2;
   2.191 +    tvplayer->audioqueue1 = audioqueue1;
   2.192 +    tvplayer->audioqueue2 = audioqueue2;
   2.193 +    g_object_ref (tvplayer->videoqueue1);
   2.194 +    g_object_ref (tvplayer->videoqueue2);
   2.195 +    g_object_ref (tvplayer->audioqueue1);
   2.196 +    g_object_ref (tvplayer->audioqueue2);
   2.197 +  	
   2.198      g_object_set (G_OBJECT (videosink), "sync", TRUE, NULL);
   2.199      g_object_set (G_OBJECT (audiosink), "sync", FALSE, NULL);
   2.200  
   2.201      gst_bus_add_watch (gst_pipeline_get_bus (GST_PIPELINE (tvplayer->gst_pipeline)),
   2.202                         bus_call, tvplayer);
   2.203  
   2.204 -    gst_bin_add_many (GST_BIN (pipeline), source, parser, videoqueue,
   2.205 -    			videodec, videosink, audioqueue, audiodec, audioconv, audiosink, NULL);
   2.206 +    gst_bin_add_many (GST_BIN (pipeline), source, parser, videoqueue1,
   2.207 +    			videodec, videoqueue2, videocolortrs, videosink, audioqueue1, 
   2.208 +			audiodec, audioconv, audioqueue2, audiosink, NULL);
   2.209  
   2.210      {
   2.211  //        GstCaps *rtpcaps = gst_caps_new_simple ("application/x-rtp", NULL);
   2.212 @@ -312,8 +333,8 @@
   2.213      }
   2.214      
   2.215      gst_element_link (source, parser);
   2.216 -    gst_element_link_many (videoqueue, videodec, videosink, NULL);
   2.217 -    gst_element_link_many (audioqueue, audiodec, audioconv, audiosink, NULL);
   2.218 +    gst_element_link_many (videoqueue1, videodec, videoqueue2, videocolortrs, videosink, NULL);
   2.219 +    gst_element_link_many (audioqueue1, audiodec, audioconv, audioqueue2, audiosink, NULL);
   2.220      
   2.221      g_signal_connect (parser, "pad-added", G_CALLBACK (new_pad_cb), tvplayer);
   2.222      
   2.223 @@ -382,9 +403,9 @@
   2.224  	}
   2.225  
   2.226  	// Gets the remote encoder num
   2.227 -	tvplayer->remote_encoder = remote_request_next_free_recorder (-1);
   2.228 +	tvplayer->recorder = remote_request_next_free_recorder (-1);
   2.229  
   2.230 -	if ( tvplayer->remote_encoder == NULL ) {
   2.231 +	if ( tvplayer->recorder == NULL ) {
   2.232  		g_warning ("[%s] None remote encoder available", __FUNCTION__);
   2.233  		res = FALSE;
   2.234  		goto error;
   2.235 @@ -400,14 +421,14 @@
   2.236  	}
   2.237  
   2.238  	// Init remote encoder. Opens its control socket.
   2.239 -	res = gmyth_remote_encoder_setup(tvplayer->remote_encoder);
   2.240 +	res = gmyth_recorder_setup(tvplayer->recorder);
   2.241  	if ( !res ) {
   2.242  		g_warning ("[%s] Fail while setting remote encoder\n", __FUNCTION__);
   2.243  		res = FALSE;
   2.244  		goto error;
   2.245  	}
   2.246  	// Spawn live tv. Uses the socket to send mythprotocol data to start livetv in the backend (remotelly)
   2.247 -	res = gmyth_remote_encoder_spawntv ( tvplayer->remote_encoder,
   2.248 +	res = gmyth_recorder_spawntv ( tvplayer->recorder,
   2.249  			gmyth_tvchain_get_id(tvplayer->tvchain) );
   2.250  	if (!res) {
   2.251  		g_warning ("[%s] Fail while spawn tv\n", __FUNCTION__);
   2.252 @@ -446,9 +467,9 @@
   2.253  		res = FALSE;
   2.254  	}
   2.255  
   2.256 -	if ( tvplayer->remote_encoder != NULL ) {
   2.257 -		g_object_unref (tvplayer->remote_encoder);
   2.258 -		tvplayer->remote_encoder = NULL;
   2.259 +	if ( tvplayer->recorder != NULL ) {
   2.260 +		g_object_unref (tvplayer->recorder);
   2.261 +		tvplayer->recorder = NULL;
   2.262  	}
   2.263  
   2.264  	if ( tvplayer->tvchain != NULL ) {
   2.265 @@ -589,7 +610,7 @@
   2.266      gst_element_set_state (tvplayer->gst_pipeline, GST_STATE_NULL);
   2.267      
   2.268      if (tvplayer->is_livetv) {
   2.269 -	    if (!gmyth_remote_encoder_stop_livetv (tvplayer->remote_encoder)) {
   2.270 +	    if (!gmyth_recorder_stop_livetv (tvplayer->recorder)) {
   2.271  	    	g_warning ("[%s] Error while stoping remote encoder", __FUNCTION__);	
   2.272  	    }
   2.273      }
   2.274 @@ -660,9 +681,9 @@
   2.275  				g_string_free( str_chainid, FALSE );
   2.276  		}
   2.277  
   2.278 -		if ( tvplayer->remote_encoder != NULL )	
   2.279 +		if ( tvplayer->recorder != NULL )	
   2.280  			g_object_set (G_OBJECT (tvplayer->gst_source), "mythtv-live-id",
   2.281 -					tvplayer->remote_encoder->recorder_num, NULL );
   2.282 +					tvplayer->recorder->recorder_num, NULL );
   2.283  		g_debug ("[%s] Setting location to %s", __FUNCTION__, 
   2.284  				tvplayer->proginfo->pathname->str);
   2.285  
     3.1 --- a/maemo-ui/src/mmyth_tvplayer.h	Mon Oct 30 22:55:19 2006 +0000
     3.2 +++ b/maemo-ui/src/mmyth_tvplayer.h	Mon Nov 06 18:58:26 2006 +0000
     3.3 @@ -36,7 +36,7 @@
     3.4  #include <gst/gst.h>
     3.5  #include <gst/interfaces/xoverlay.h>
     3.6  
     3.7 -#include "gmyth_remote_encoder.h"
     3.8 +#include "gmyth_recorder.h"
     3.9  #include "gmyth_tvchain.h"
    3.10  #include "gmyth_common.h"
    3.11  
    3.12 @@ -69,9 +69,12 @@
    3.13      GstElement *gst_source;
    3.14      GstElement *gst_videodec;
    3.15      GstElement *gst_videosink;
    3.16 -    GstElement *videoqueue;
    3.17 -    GstElement *audioqueue;
    3.18 -    
    3.19 +    GstElement *gst_videocolortrs; 
    3.20 +    GstElement *videoqueue1;
    3.21 +    GstElement *videoqueue2;
    3.22 +    GstElement *audioqueue1;
    3.23 +    GstElement *audioqueue2;
    3.24 +   
    3.25      gulong expose_handler;
    3.26  //    GMainLoop *loop;
    3.27      
    3.28 @@ -82,7 +85,7 @@
    3.29  	gint backend_port;
    3.30  	GString *local_hostname;
    3.31  
    3.32 -	GMythRemoteEncoder *remote_encoder;
    3.33 +	GMythRecorder *recorder;
    3.34  	GMythTVChain *tvchain;
    3.35  	GMythProgramInfo *proginfo;
    3.36