aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSjoerd Simons <sjoerd.simons@collabora.co.uk>2009-03-04 01:34:11 +0800
committerXavier Claessens <xclaesse@src.gnome.org>2009-03-04 01:34:11 +0800
commite4f52b97a4a58fbe747d51f8cb9621242d17969a (patch)
treed1e6a0a228e915523ecd3d4ab39fc7d27641f00f
parent5059be4c25b318924b1f30324bab2cf66c66d407 (diff)
downloadgsoc2013-empathy-e4f52b97a4a58fbe747d51f8cb9621242d17969a.tar
gsoc2013-empathy-e4f52b97a4a58fbe747d51f8cb9621242d17969a.tar.gz
gsoc2013-empathy-e4f52b97a4a58fbe747d51f8cb9621242d17969a.tar.bz2
gsoc2013-empathy-e4f52b97a4a58fbe747d51f8cb9621242d17969a.tar.lz
gsoc2013-empathy-e4f52b97a4a58fbe747d51f8cb9621242d17969a.tar.xz
gsoc2013-empathy-e4f52b97a4a58fbe747d51f8cb9621242d17969a.tar.zst
gsoc2013-empathy-e4f52b97a4a58fbe747d51f8cb9621242d17969a.zip
Add sync and async properties
Signed-off-by: Sjoerd Simons <sjoerd.simons@collabora.co.uk> svn path=/trunk/; revision=2552
-rw-r--r--libempathy-gtk/empathy-video-widget.c88
1 files changed, 80 insertions, 8 deletions
diff --git a/libempathy-gtk/empathy-video-widget.c b/libempathy-gtk/empathy-video-widget.c
index f2465854b..b32e81aef 100644
--- a/libempathy-gtk/empathy-video-widget.c
+++ b/libempathy-gtk/empathy-video-widget.c
@@ -53,6 +53,8 @@ enum {
PROP_GST_BUS,
PROP_MIN_WIDTH,
PROP_MIN_HEIGHT,
+ PROP_SYNC,
+ PROP_ASYNC,
};
/* private structure */
@@ -68,6 +70,10 @@ struct _EmpathyVideoWidgetPriv
FsElementAddedNotifier *notifier;
gint min_width;
gint min_height;
+ gboolean sync;
+ gboolean async;
+
+ GMutex *lock;
};
#define GET_PRIV(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), \
@@ -79,6 +85,8 @@ empathy_video_widget_init (EmpathyVideoWidget *obj)
EmpathyVideoWidgetPriv *priv = GET_PRIV (obj);
GdkColor black;
+ priv->lock = g_mutex_new ();
+
priv->notifier = fs_element_added_notifier_new ();
g_signal_connect (priv->notifier, "element-added",
G_CALLBACK (empathy_video_widget_element_added_cb),
@@ -114,8 +122,11 @@ empathy_video_widget_constructed (GObject *object)
static void empathy_video_widget_dispose (GObject *object);
static void empathy_video_widget_finalize (GObject *object);
+
static gboolean empathy_video_widget_expose_event (GtkWidget *widget,
GdkEventExpose *event);
+static void
+empathy_video_widget_element_set_sink_properties (EmpathyVideoWidget *self);
static void
empathy_video_widget_set_property (GObject *object,
@@ -134,6 +145,16 @@ empathy_video_widget_set_property (GObject *object,
case PROP_MIN_HEIGHT:
priv->min_height = g_value_get_int (value);
break;
+ case PROP_SYNC:
+ priv->sync = g_value_get_boolean (value);
+ empathy_video_widget_element_set_sink_properties (
+ EMPATHY_VIDEO_WIDGET (object));
+ break;
+ case PROP_ASYNC:
+ priv->async = g_value_get_boolean (value);
+ empathy_video_widget_element_set_sink_properties (
+ EMPATHY_VIDEO_WIDGET (object));
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
}
@@ -159,6 +180,12 @@ empathy_video_widget_get_property (GObject *object,
case PROP_MIN_HEIGHT:
g_value_set_int (value, priv->min_height);
break;
+ case PROP_SYNC:
+ g_value_set_boolean (value, priv->sync);
+ break;
+ case PROP_ASYNC:
+ g_value_set_boolean (value, priv->async);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
}
@@ -213,6 +240,19 @@ empathy_video_widget_class_init (
G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
g_object_class_install_property (object_class, PROP_MIN_HEIGHT, param_spec);
+ param_spec = g_param_spec_boolean ("sync",
+ "sync",
+ "Whether the underlying sink should be sync or not",
+ TRUE,
+ G_PARAM_CONSTRUCT | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
+ g_object_class_install_property (object_class, PROP_SYNC, param_spec);
+
+ param_spec = g_param_spec_boolean ("async",
+ "async",
+ "Whether the underlying sink should be async or not",
+ TRUE,
+ G_PARAM_CONSTRUCT | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
+ g_object_class_install_property (object_class, PROP_ASYNC, param_spec);
}
void
@@ -246,31 +286,63 @@ empathy_video_widget_dispose (GObject *object)
void
empathy_video_widget_finalize (GObject *object)
{
- //EmpathyVideoWidget *self = EMPATHY_VIDEO_WIDGET (object);
- //EmpathyVideoWidgetPriv *priv = GET_PRIV (self);
+ EmpathyVideoWidget *self = EMPATHY_VIDEO_WIDGET (object);
+ EmpathyVideoWidgetPriv *priv = GET_PRIV (self);
/* free any data held directly by the object here */
+ g_mutex_free (priv->lock);
G_OBJECT_CLASS (empathy_video_widget_parent_class)->finalize (object);
}
+
+static void
+empathy_video_widget_element_set_sink_properties_unlocked (
+ EmpathyVideoWidget *self)
+{
+ EmpathyVideoWidgetPriv *priv = GET_PRIV (self);
+
+ if (priv->overlay == NULL)
+ return;
+
+ if (g_object_class_find_property (G_OBJECT_GET_CLASS (priv->overlay),
+ "force-aspect-ratio"))
+ g_object_set (G_OBJECT (priv->overlay), "force-aspect-ratio", TRUE, NULL);
+
+ if (g_object_class_find_property (
+ G_OBJECT_GET_CLASS (priv->overlay), "sync"))
+ g_object_set (G_OBJECT (priv->overlay), "sync", priv->sync, NULL);
+
+ if (g_object_class_find_property (G_OBJECT_GET_CLASS (priv->overlay),
+ "async"))
+ g_object_set (G_OBJECT (priv->overlay), "async", priv->async, NULL);
+}
+
+static void
+empathy_video_widget_element_set_sink_properties (EmpathyVideoWidget *self)
+{
+ EmpathyVideoWidgetPriv *priv = GET_PRIV (self);
+
+ g_mutex_lock (priv->lock);
+ empathy_video_widget_element_set_sink_properties_unlocked (self);
+ g_mutex_unlock (priv->lock);
+}
+
static void
empathy_video_widget_element_added_cb (FsElementAddedNotifier *notifier,
GstBin *bin, GstElement *element, EmpathyVideoWidget *self)
{
EmpathyVideoWidgetPriv *priv = GET_PRIV (self);
+ /* We assume the overlay is the sink */
+ g_mutex_lock (priv->lock);
if (priv->overlay == NULL && GST_IS_X_OVERLAY (element))
{
priv->overlay = element;
+ empathy_video_widget_element_set_sink_properties_unlocked (self);
gst_x_overlay_expose (GST_X_OVERLAY (priv->overlay));
}
-
- if (g_object_class_find_property (
- G_OBJECT_GET_CLASS (element), "force-aspect-ratio"))
- {
- g_object_set (G_OBJECT (element), "force-aspect-ratio", TRUE, NULL);
- }
+ g_mutex_unlock (priv->lock);
}
static void