]> git.0d.be Git - empathy.git/commitdiff
When no video is received or sent we show contacts' avatars instead of showing
authorJonathan Tellier <jonathan.tellier@gmail.com>
Wed, 20 May 2009 17:49:02 +0000 (13:49 -0400)
committerjtellier <jonathan.tellier@collabora.co.uk>
Fri, 12 Jun 2009 12:59:10 +0000 (08:59 -0400)
black widgets.

libempathy/empathy-call-handler.c
libempathy/empathy-tp-call.c
libempathy/empathy-tp-call.h
src/empathy-call-window.c

index 90df179bc31efe6bbca8a38036486500f65d2d6c..6d7f35102dd0cda31f2818870cc3212dd774b43e 100644 (file)
@@ -43,6 +43,7 @@ enum {
   SINK_PAD_ADDED,
   REQUEST_RESOURCE,
   CLOSED,
+  VIDEO_STREAM_CHANGED,
   LAST_SIGNAL
 };
 
@@ -70,6 +71,13 @@ typedef struct {
 
 #define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyCallHandler)
 
+static void
+empathy_call_handler_call_video_stream_cb (EmpathyTpCall *call,
+    GParamSpec *property, EmpathyCallHandler *self)
+{
+  g_signal_emit (G_OBJECT (self), signals[VIDEO_STREAM_CHANGED], 0);
+}
+
 static void
 empathy_call_handler_dispose (GObject *object)
 {
@@ -93,6 +101,8 @@ empathy_call_handler_dispose (GObject *object)
   if (priv->call != NULL)
     {
       empathy_tp_call_close (priv->call);
+      g_signal_handlers_disconnect_by_func (priv->call,
+          empathy_call_handler_call_video_stream_cb, object);
       g_object_unref (priv->call);
     }
 
@@ -262,6 +272,13 @@ empathy_call_handler_class_init (EmpathyCallHandlerClass *klass)
       g_cclosure_marshal_VOID__VOID,
       G_TYPE_NONE,
       0);
+
+  signals[VIDEO_STREAM_CHANGED] =
+    g_signal_new ("video-stream-changed", G_TYPE_FROM_CLASS (klass),
+      G_SIGNAL_RUN_LAST, 0, NULL, NULL,
+      g_cclosure_marshal_VOID__VOID,
+      G_TYPE_NONE,
+      0);
 }
 
 /**
@@ -514,6 +531,9 @@ empathy_call_handler_request_cb (EmpathyDispatchOperation *operation,
 
   g_object_ref (priv->call);
 
+  g_signal_connect (priv->call, "notify::video-stream",
+      G_CALLBACK (empathy_call_handler_call_video_stream_cb), self);
+
   empathy_call_handler_start_tpfs (self);
 
   empathy_tp_call_to (priv->call, priv->contact,
@@ -536,6 +556,8 @@ empathy_call_handler_start_call (EmpathyCallHandler *handler)
   if (priv->call != NULL)
     {
       empathy_call_handler_start_tpfs (handler);
+      g_signal_connect (priv->call, "notify::video-stream",
+          G_CALLBACK (empathy_call_handler_call_video_stream_cb), handler);
       empathy_tp_call_accept_incoming_call (priv->call);
       return;
     }
index 2971e0ffc09fced718fe655b8767b2c80c986e1e..bf3fe778cbd14322928fe20bb4f9919193ee8940 100644 (file)
@@ -672,3 +672,40 @@ empathy_tp_call_has_dtmf (EmpathyTpCall *call)
       TP_IFACE_QUARK_CHANNEL_INTERFACE_DTMF);
 }
 
+/**
+ * empathy_tp_call_is_receiving_video:
+ * @call: the call
+ *
+ * Indicates if the call is receiving video or not.
+ *
+ * Returns: %TRUE if the call is currently receiving video, %FALSE otherwise.
+ */
+gboolean
+empathy_tp_call_is_receiving_video (EmpathyTpCall *call)
+{
+  EmpathyTpCallPriv *priv = GET_PRIV (call);
+
+  g_return_val_if_fail (EMPATHY_IS_TP_CALL (call), FALSE);
+
+  return priv->video->direction == TP_MEDIA_STREAM_DIRECTION_RECEIVE ||
+            priv->video->direction == TP_MEDIA_STREAM_DIRECTION_BIDIRECTIONAL;
+}
+
+/**
+ * empathy_tp_call_is_sending_video:
+ * @call: the call
+ *
+ * Indicates if the call is sending video or not.
+ *
+ * Returns: %TRUE if the call is currently sending video, %FALSE otherwise.
+ */
+gboolean
+empathy_tp_call_is_sending_video (EmpathyTpCall *call)
+{
+  EmpathyTpCallPriv *priv = GET_PRIV (call);
+
+  g_return_val_if_fail (EMPATHY_IS_TP_CALL (call), FALSE);
+
+  return priv->video->direction == TP_MEDIA_STREAM_DIRECTION_SEND ||
+            priv->video->direction == TP_MEDIA_STREAM_DIRECTION_BIDIRECTIONAL;
+}
index 406ed1c3f6ec18665c0219de7766f2ba318cebf1..a00fe3e40ac290fa13242d5805844e591712f319 100644 (file)
@@ -85,6 +85,8 @@ void empathy_tp_call_request_video_stream_direction (EmpathyTpCall *call,
 void empathy_tp_call_start_tone (EmpathyTpCall *call, TpDTMFEvent event);
 void empathy_tp_call_stop_tone (EmpathyTpCall *call);
 gboolean empathy_tp_call_has_dtmf (EmpathyTpCall *call);
+gboolean empathy_tp_call_is_receiving_video (EmpathyTpCall *call);
+gboolean empathy_tp_call_is_sending_video (EmpathyTpCall *call);
 
 G_END_DECLS
 
index 0ce80c97c88eb80fb4ee9df0ceaf1893ae486195..eec0e5845ff58402ea66669e054e769c38285169 100644 (file)
@@ -229,6 +229,9 @@ static void empathy_call_window_restart_call (EmpathyCallWindow *window);
 static void empathy_call_window_status_message (EmpathyCallWindow *window,
   gchar *message);
 
+static void empathy_call_window_update_avatars_visibility (EmpathyTpCall *call,
+  EmpathyCallWindow *window);
+
 static gboolean empathy_call_window_bus_message (GstBus *bus,
   GstMessage *message, gpointer user_data);
 
@@ -1229,6 +1232,8 @@ empathy_call_window_connected (gpointer user_data)
   gtk_action_set_sensitive (priv->redial, FALSE);
   gtk_widget_set_sensitive (priv->redial_button, FALSE);
 
+  empathy_call_window_update_avatars_visibility (call, self);
+
   g_object_unref (call);
 
   g_mutex_lock (priv->lock);
@@ -1442,6 +1447,48 @@ empathy_call_window_bus_message (GstBus *bus, GstMessage *message,
   return TRUE;
 }
 
+static void
+empathy_call_window_update_avatars_visibility (EmpathyTpCall *call,
+    EmpathyCallWindow *window)
+{
+  EmpathyCallWindowPriv *priv = GET_PRIV (window);
+
+  if (empathy_tp_call_is_receiving_video (call))
+    {
+      gtk_widget_hide (priv->remote_user_avatar_widget);
+      gtk_widget_show (priv->video_output);
+    }
+  else
+    {
+      gtk_widget_hide (priv->video_output);
+      gtk_widget_show (priv->remote_user_avatar_widget);
+    }
+
+  if (empathy_tp_call_is_sending_video (call))
+    {
+      gtk_widget_hide (priv->self_user_avatar_widget);
+      gtk_widget_show (priv->video_preview);
+    }
+  else
+    {
+      gtk_widget_hide (priv->video_preview);
+      gtk_widget_show (priv->self_user_avatar_widget);
+    }
+}
+
+static void
+empathy_call_window_video_stream_changed_cb (EmpathyCallHandler *handler,
+    EmpathyCallWindow *window)
+{
+  EmpathyTpCall *call;
+  EmpathyCallWindowPriv *priv = GET_PRIV (window);
+
+  g_object_get (priv->handler, "tp-call", &call, NULL);
+
+  empathy_call_window_update_avatars_visibility (call, window);
+  g_object_unref (call);
+}
+
 static void
 empathy_call_window_realized_cb (GtkWidget *widget, EmpathyCallWindow *window)
 {
@@ -1457,6 +1504,8 @@ empathy_call_window_realized_cb (GtkWidget *widget, EmpathyCallWindow *window)
     G_CALLBACK (empathy_call_window_src_added_cb), window);
   g_signal_connect (priv->handler, "sink-pad-added",
     G_CALLBACK (empathy_call_window_sink_added_cb), window);
+  g_signal_connect (priv->handler, "video-stream-changed",
+    G_CALLBACK (empathy_call_window_video_stream_changed_cb), window);
 
   empathy_call_window_setup_video_preview (window);