Commit c28676b1 authored by Ali Abdallah's avatar Ali Abdallah

* Added session code for session interaction.

	* Support nice sound fading on exit.
	* Automtically get the preferred video size and resize
	the video output.
	

(Old svn revision: 7862)
parent 2ca1ba48
2009-07-29: Ali aliov@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@xfce.org
* Better seeking capabilities with the slider and the buttons.
* Added some shortcut keys.
* Added volume in the menu bar.
......
=== 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.
* ...
......
......@@ -78,7 +78,8 @@ NOINST_HFILES = \
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 @@ libparole_la_SOURCES = \
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)
......
......@@ -29,6 +29,16 @@ G_BEGIN_DECLS
#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 @@ typedef struct
} ParoleConfClass;
GType parole_conf_get_type (void) G_GNUC_CONST;
ParoleConf *parole_conf_new (void);
G_END_DECLS
......
......@@ -544,6 +544,59 @@ parole_gst_load_subtitle (ParoleGst *gst)
g_free (uri);
}
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)
{
......@@ -572,6 +625,26 @@ parole_gst_query_info (ParoleGst *gst)
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 @@ parole_gst_construct (GObject *object)
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 @@ parole_gst_new (void)
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 @@ void parole_gst_terminate (ParoleGst *gst)
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);
}
......
......@@ -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 @@ struct ParolePlayerPrivate
ParoleScreenSaver *screen_saver;
ParoleConf *conf;
ParoleDiscMenu *disc_menu;
ParoleSession *session;
GtkWidget *gst;
......@@ -1189,6 +1191,13 @@ parole_player_key_press (GtkWidget *widget, GdkEventKey *ev, ParolePlayer *playe
return ret_val;
}
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)
{
......@@ -1201,6 +1210,10 @@ parole_player_init (ParolePlayer *player)
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 ();
/*
......
......@@ -56,6 +56,8 @@ struct _ParoleStreamPrivate
gboolean seekable;
gboolean tag_available;
gdouble duration;
gint video_w;
gint video_h;
gint64 absolute_duration;
gchar *title;
......@@ -63,6 +65,7 @@ struct _ParoleStreamPrivate
gchar *year;
gchar *album;
gchar *comment;
ParoleMediaType media_type;
};
......@@ -78,6 +81,8 @@ enum
PROP_TAG_AVAILABLE,
PROP_DURATION,
PROP_ABSOLUTE_DURATION,
PROP_VIDEO_WIDTH,
PROP_VIDEO_HEIGHT,
PROP_TITLE,
PROP_ARTIST,
PROP_YEAR,
......@@ -155,6 +160,12 @@ static void parole_stream_set_property (GObject *object,
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 @@ static void parole_stream_get_property (GObject *object,
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;
......@@ -385,6 +402,36 @@ parole_stream_class_init (ParoleStreamClass *klass)
0,
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 @@ void parole_stream_init_properties (ParoleStream *stream)
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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment