[Goodies-commits] r7862 - in parole/trunk: . parole

Ali Abdallah aliov at xfce.org
Wed Jul 29 17:07:30 CEST 2009


Author: aliov
Date: 2009-07-29 15:07:30 +0000 (Wed, 29 Jul 2009)
New Revision: 7862

Modified:
   parole/trunk/ChangeLog
   parole/trunk/TODO
   parole/trunk/parole/Makefile.am
   parole/trunk/parole/parole-conf.h
   parole/trunk/parole/parole-gst.c
   parole/trunk/parole/parole-player.c
   parole/trunk/parole/parole-stream.c
Log:
	* Added session code for session interaction.
	* Support nice sound fading on exit.
	* Automtically get the preferred video size and resize
	the video output.
	

Modified: parole/trunk/ChangeLog
===================================================================
--- parole/trunk/ChangeLog	2009-07-29 13:46:43 UTC (rev 7861)
+++ parole/trunk/ChangeLog	2009-07-29 15:07:30 UTC (rev 7862)
@@ -1,4 +1,10 @@
 2009-07-29: Ali aliov at xfce.org
+	* Added session code for session interaction.
+	* Support nice sound fading on exit.
+	* Automtically get the preferred video size and resize
+	the video output.
+	
+2009-07-29: 13:00 Ali aliov at xfce.org
 	* Better seeking capabilities with the slider and the buttons.
 	* Added some shortcut keys.
 	* Added volume in the menu bar.

Modified: parole/trunk/TODO
===================================================================
--- parole/trunk/TODO	2009-07-29 13:46:43 UTC (rev 7861)
+++ parole/trunk/TODO	2009-07-29 15:07:30 UTC (rev 7862)
@@ -1,7 +1,8 @@
 === Media player ===
+* Support some aspect ratio view.
+* Support scale ratio view.
 * Complete the shortcut keys.
 * Better support for cdda.
-* Support some aspect ratio view.
 * Handle missing gstreamer plugins.
 * Support some playlist title entity.
 * ...

Modified: parole/trunk/parole/Makefile.am
===================================================================
--- parole/trunk/parole/Makefile.am	2009-07-29 13:46:43 UTC (rev 7861)
+++ parole/trunk/parole/Makefile.am	2009-07-29 15:07:30 UTC (rev 7862)
@@ -78,7 +78,8 @@
 	parole-builder.h			\
 	parole-subtitle-encoding.h		\
 	parole-open-location.h			\
-	parole-disc-menu.h
+	parole-disc-menu.h			\
+	parole-session.h
 
 libparole_headers =				\
 	$(INST_HFILES)
@@ -118,7 +119,8 @@
 	parole-builder.c			\
 	parole-subtitle-encoding.c		\
 	parole-open-location.c			\
-	parole-disc-menu.c
+	parole-disc-menu.c			\
+	parole-session.c
 
 libparole_la_LDFLAGS =				\
 	$(PAROLE_LDFLAGS)

Modified: parole/trunk/parole/parole-conf.h
===================================================================
--- parole/trunk/parole/parole-conf.h	2009-07-29 13:46:43 UTC (rev 7861)
+++ parole/trunk/parole/parole-conf.h	2009-07-29 15:07:30 UTC (rev 7862)
@@ -29,6 +29,16 @@
 #define PAROLE_CONF(o)          (G_TYPE_CHECK_INSTANCE_CAST ((o), PAROLE_TYPE_CONF, ParoleConf))
 #define PAROLE_IS_CONF(o)       (G_TYPE_CHECK_INSTANCE_TYPE ((o), PAROLE_TYPE_CONF))
 
+typedef enum
+{
+    PAROLE_ASPECT_RATIO_AUTO ,
+    PAROLE_ASPECT_RATIO_SQUARE,
+    PAROLE_ASPECT_RATIO_4_3,
+    PAROLE_ASPECT_RATIO_0,
+    PAROLE_ASPECT_RATIO_DVB
+	
+} ParoleAspectRatio;
+    
 typedef struct ParoleConfPrivate ParoleConfPrivate;
 
 typedef struct
@@ -45,6 +55,7 @@
 } ParoleConfClass;
 
 GType        			 parole_conf_get_type        (void) G_GNUC_CONST;
+
 ParoleConf       		*parole_conf_new             (void);
 
 G_END_DECLS

Modified: parole/trunk/parole/parole-gst.c
===================================================================
--- parole/trunk/parole/parole-gst.c	2009-07-29 13:46:43 UTC (rev 7861)
+++ parole/trunk/parole/parole-gst.c	2009-07-29 15:07:30 UTC (rev 7862)
@@ -545,6 +545,59 @@
 }
 
 static void
+parole_gst_set_size (GtkWidget *widget, gint w, gint h)
+{
+    GdkScreen *screen;
+    GtkWidget *toplevel;
+    gint monitor;
+    
+    toplevel = gtk_widget_get_toplevel (widget);
+    
+    gtk_widget_set_size_request (GTK_WIDGET (widget), w, h);
+    
+    screen = gtk_window_get_screen (GTK_WINDOW (toplevel));
+    
+    monitor = gdk_screen_get_monitor_at_window (screen, toplevel->window),
+    
+    xfce_gtk_window_center_on_monitor (GTK_WINDOW (toplevel), screen, monitor);
+}
+
+static void
+parole_gst_get_pad_capabilities (GObject *object, GParamSpec *pspec, ParoleGst *gst)
+{
+    GstPad *pad;
+    GstStructure *st;
+    gint width;
+    gint height;
+    gint num;
+    gint den;
+    const GValue *value;
+    
+    pad = GST_PAD (object);
+    
+    st = gst_caps_get_structure (GST_PAD_CAPS (pad), 0);
+    
+    if ( st )
+    {
+	gst_structure_get_int (st, "width", &width);
+	gst_structure_get_int (st, "height", &height);
+	TRACE ("Caps width=%d height=%d\n", width, height);
+	
+	g_object_set (G_OBJECT (gst->priv->stream),
+		      "video-width", width,
+		      "video-height", height,
+		      NULL);
+	parole_gst_set_size (GTK_WIDGET (gst), width, height);
+	if ( ( value = gst_structure_get_value (st, "pixel-aspect-ratio")) )
+	{
+	    num = gst_value_get_fraction_numerator (value),
+	    den = gst_value_get_fraction_denominator (value);
+	    TRACE ("FIXME: Use these value num=%d den=%d \n", num, den);
+	}
+    }
+}
+
+static void
 parole_gst_query_info (ParoleGst *gst)
 {
     const GList *info = NULL;
@@ -572,6 +625,26 @@
 	if ( g_ascii_strcasecmp (val->value_name, "video") == 0 ||
 	     g_ascii_strcasecmp (val->value_nick, "video") == 0)
 	{
+	    GstPad *pad = NULL;
+	    
+	    g_object_get (G_OBJECT (obj), 
+			  "object", &pad, 
+			  NULL);
+	    
+	    if ( pad )
+	    {
+		if ( GST_PAD_CAPS (pad) )
+		{
+		    parole_gst_get_pad_capabilities (G_OBJECT (pad), NULL, gst);
+		}
+		else
+		{
+		    g_signal_connect (pad, "notify::caps",
+				      G_CALLBACK (parole_gst_get_pad_capabilities),
+				      gst);
+		}
+		g_object_unref (pad);
+	    }
 	    TRACE ("Stream has video");
 	    g_object_set (G_OBJECT (gst->priv->stream),
 			  "has-video", TRUE,
@@ -1013,8 +1086,10 @@
     g_signal_connect (gst->priv->bus, "message",
 		      G_CALLBACK (parole_gst_bus_event), gst);
 		      
-    /* Handling 'prepare-xwindow-id' message async causes XSync error in some occasions
-     * So we handle this message synchronously*/
+    /* 
+     * Handling 'prepare-xwindow-id' message async causes XSync 
+     * error in some occasions So we handle this message synchronously
+     */
     gst_bus_set_sync_handler (gst->priv->bus, gst_bus_sync_signal_handler, gst);
     g_signal_connect (gst->priv->bus, "sync-message::element",
 		      G_CALLBACK (parole_gst_element_message_sync), gst);
@@ -1257,6 +1332,11 @@
     
     if ( G_LIKELY (parole_gst_object != NULL ) )
     {
+	/* 
+	 * Don't increase the reference count of this object as 
+	 * we need it to be destroyed immediately when the main 
+	 * window is destroyed.
+	 */
 	//g_object_ref (parole_gst_object);
     }
     else
@@ -1339,6 +1419,26 @@
 
     parole_window_busy_cursor (GTK_WIDGET (gst)->window);
     
+    if ( gst->priv->state == GST_STATE_PLAYING )
+    {
+	gdouble volume;
+	gdouble step;
+	volume = parole_gst_get_volume (gst);
+	/*
+	 * Like amarok, reduce the sound slowley then exit.
+	 */
+	if ( volume != 0 )
+	{
+	    while ( volume > 0 )
+	    {
+		step = volume - volume / 10;
+		parole_gst_set_volume (gst, step < 0.01 ? 0 : step);
+		volume = parole_gst_get_volume (gst);
+		g_usleep (30000);
+	    }
+	}
+    }
+    
     parole_gst_change_state (gst, GST_STATE_NULL);
 }
 

Modified: parole/trunk/parole/parole-player.c
===================================================================
--- parole/trunk/parole/parole-player.c	2009-07-29 13:46:43 UTC (rev 7861)
+++ parole/trunk/parole/parole-player.c	2009-07-29 15:07:30 UTC (rev 7862)
@@ -47,6 +47,7 @@
 #include "parole-conf.h"
 #include "parole-rc-utils.h"
 #include "parole-utils.h"
+#include "parole-session.h"
 #include "enum-gtypes.h"
 #include "parole-debug.h"
 
@@ -146,6 +147,7 @@
     ParoleScreenSaver   *screen_saver;
     ParoleConf          *conf;
     ParoleDiscMenu      *disc_menu;
+    ParoleSession       *session;
 
     GtkWidget 		*gst;
 
@@ -1190,6 +1192,13 @@
 }
 
 static void
+parole_player_session_die_cb (ParolePlayer *player)
+{
+    player->priv->exit = TRUE;
+    parole_gst_terminate (PAROLE_GST (player->priv->gst));
+}
+
+static void
 parole_player_init (ParolePlayer *player)
 {
     GtkBuilder *builder;
@@ -1201,7 +1210,11 @@
     builder = parole_builder_get_main_interface ();
     
     player->priv->conf = parole_conf_new ();
+    player->priv->session = parole_session_get ();
     
+    g_signal_connect_swapped (player->priv->session, "die",
+			      G_CALLBACK (parole_player_session_die_cb), player);
+    
     player->priv->gst = parole_gst_new ();
     /*
      * Since ParoleGst is derived from GtkWidget and packed in the media output

Modified: parole/trunk/parole/parole-stream.c
===================================================================
--- parole/trunk/parole/parole-stream.c	2009-07-29 13:46:43 UTC (rev 7861)
+++ parole/trunk/parole/parole-stream.c	2009-07-29 15:07:30 UTC (rev 7862)
@@ -56,6 +56,8 @@
     gboolean 	seekable;
     gboolean 	tag_available;
     gdouble   	duration;
+    gint        video_w;
+    gint        video_h;
     gint64  	absolute_duration;
     
     gchar      *title;
@@ -63,6 +65,7 @@
     gchar      *year;
     gchar      *album;
     gchar      *comment;
+    
     ParoleMediaType media_type; 
 };
 
@@ -78,6 +81,8 @@
     PROP_TAG_AVAILABLE,
     PROP_DURATION,
     PROP_ABSOLUTE_DURATION,
+    PROP_VIDEO_WIDTH,
+    PROP_VIDEO_HEIGHT,
     PROP_TITLE,
     PROP_ARTIST,
     PROP_YEAR,
@@ -155,6 +160,12 @@
 	case PROP_ABSOLUTE_DURATION:
 	    PAROLE_STREAM_GET_PRIVATE (stream)->absolute_duration = g_value_get_int64 (value);
 	    break;
+	case PROP_VIDEO_HEIGHT:
+	    PAROLE_STREAM_GET_PRIVATE (stream)->video_h = g_value_get_int (value);
+	    break;
+	case PROP_VIDEO_WIDTH:
+	    PAROLE_STREAM_GET_PRIVATE (stream)->video_w = g_value_get_int (value);
+	    break;
 	case PROP_TITLE:
 	    PAROLE_STREAM_DUP_GVALUE_STRING (PAROLE_STREAM_GET_PRIVATE (stream)->title, value);
 	    break;
@@ -213,6 +224,12 @@
 	case PROP_ABSOLUTE_DURATION:
 	    g_value_set_int64 (value, PAROLE_STREAM_GET_PRIVATE (stream)->absolute_duration);
 	    break;
+	case PROP_VIDEO_HEIGHT:
+	    g_value_set_int (value, PAROLE_STREAM_GET_PRIVATE (stream)->video_h);
+	    break;
+	case PROP_VIDEO_WIDTH:
+	    g_value_set_int (value, PAROLE_STREAM_GET_PRIVATE (stream)->video_w);
+	    break;
 	case PROP_TITLE:
 	    g_value_set_string (value, PAROLE_STREAM_GET_PRIVATE (stream)->title);
 	    break;
@@ -386,6 +403,36 @@
 							  G_PARAM_READWRITE));
 
     /**
+     * ParoleStream:video-width:
+     * 
+     * 
+     * 
+     * Since: 0.1 
+     **/
+    g_object_class_install_property (object_class,
+				     PROP_VIDEO_WIDTH,
+				     g_param_spec_int    ("video-width",
+							  NULL, NULL,
+							  0, G_MAXINT,
+							  0,
+							  G_PARAM_READWRITE));
+							  
+    /**
+     * ParoleStream:video-height:
+     * 
+     * 
+     * 
+     * Since: 0.1 
+     **/
+    g_object_class_install_property (object_class,
+				     PROP_VIDEO_HEIGHT,
+				     g_param_spec_int    ("video-height",
+							  NULL, NULL,
+							  0, G_MAXINT,
+							  0,
+							  G_PARAM_READWRITE));
+							  
+    /**
      * ParoleStream:title:
      * 
      * 
@@ -487,6 +534,8 @@
     priv->duration = 0;
     priv->tag_available = FALSE;
     priv->media_type = PAROLE_MEDIA_TYPE_UNKNOWN;
+    priv->video_h = 0;
+    priv->video_w = 0;
     
     PAROLE_STREAM_FREE_STR_PROP (priv->title);
     PAROLE_STREAM_FREE_STR_PROP (priv->uri);




More information about the Goodies-commits mailing list