]> git.0d.be Git - empathy.git/commitdiff
Call: Signal content-{added/removed} instead of sink-{added/removed}
authorSjoerd Simons <sjoerd.simons@collabora.co.uk>
Wed, 9 Nov 2011 16:27:51 +0000 (16:27 +0000)
committerSjoerd Simons <sjoerd.simons@collabora.co.uk>
Fri, 11 Nov 2011 14:01:07 +0000 (15:01 +0100)
Tp-Farstream signals contents, not sinks (like tp-farsight did). So lets
mirror that, which allows us to make better decisions about what kind of
contents we are given

https://bugzilla.gnome.org/show_bug.cgi?id=663842

src/empathy-call-handler.c
src/empathy-call-window.c

index ef07c503aa0bab49226d59234a6e00a6ee036bb0..0477cd7c06a3caf36f4d384f3bfcc297fa38f59c 100644 (file)
@@ -47,8 +47,8 @@ enum {
   CONFERENCE_ADDED,
   CONFERENCE_REMOVED,
   SRC_PAD_ADDED,
-  SINK_PAD_ADDED,
-  SINK_PAD_REMOVED,
+  CONTENT_ADDED,
+  CONTENT_REMOVED,
   CLOSED,
   CANDIDATES_CHANGED,
   STATE_CHANGED,
@@ -481,19 +481,19 @@ empathy_call_handler_class_init (EmpathyCallHandlerClass *klass)
       G_TYPE_BOOLEAN,
       2, GST_TYPE_PAD, G_TYPE_UINT);
 
-  signals[SINK_PAD_ADDED] =
-    g_signal_new ("sink-pad-added", G_TYPE_FROM_CLASS (klass),
+  signals[CONTENT_ADDED] =
+    g_signal_new ("content-added", G_TYPE_FROM_CLASS (klass),
       G_SIGNAL_RUN_LAST, 0, NULL, NULL,
       g_cclosure_marshal_generic,
       G_TYPE_BOOLEAN,
-      2, GST_TYPE_PAD, G_TYPE_UINT);
+      1, TF_TYPE_CONTENT);
 
-  signals[SINK_PAD_REMOVED] =
-    g_signal_new ("sink-pad-removed", G_TYPE_FROM_CLASS (klass),
+  signals[CONTENT_REMOVED] =
+    g_signal_new ("content-removed", G_TYPE_FROM_CLASS (klass),
       G_SIGNAL_RUN_LAST, 0, NULL, NULL,
       g_cclosure_marshal_generic,
       G_TYPE_BOOLEAN,
-      2, GST_TYPE_PAD, G_TYPE_UINT);
+      1, TF_TYPE_CONTENT);
 
   signals[CLOSED] =
     g_signal_new ("closed", G_TYPE_FROM_CLASS (klass),
@@ -806,7 +806,6 @@ on_tf_channel_content_added_cb (TfChannel *tfchannel,
   EmpathyCallHandler *handler)
 {
   FsMediaType mtype;
-  GstPad *spad;
   FsSession *session;
 //  FsStream *fs_stream;
   FsCodec *codec;
@@ -822,11 +821,8 @@ on_tf_channel_content_added_cb (TfChannel *tfchannel,
       G_CALLBACK (on_tf_content_stop_sending_cb), handler);
 #endif
 
-  g_object_get (content, "media-type", &mtype,
-    "sink-pad", &spad, NULL);
-
-  g_signal_emit (G_OBJECT (handler), signals[SINK_PAD_ADDED], 0,
-      spad, mtype, &retval);
+  g_signal_emit (G_OBJECT (handler), signals[CONTENT_ADDED], 0,
+    content, &retval);
 
  if (!retval)
       tf_content_error (content, 0 /* FIXME */,
@@ -852,6 +848,8 @@ on_tf_channel_content_added_cb (TfChannel *tfchannel,
  tp_clear_object (&fs_stream);
 */
 
+  g_object_get (content, "media-type", &mtype, NULL);
+
  if (mtype == FS_MEDIA_TYPE_VIDEO)
    {
      guint framerate, width, height;
@@ -878,8 +876,6 @@ on_tf_channel_content_added_cb (TfChannel *tfchannel,
        g_signal_emit (G_OBJECT (handler), signals[RESOLUTION_CHANGED], 0,
            width, height);
    }
-
- gst_object_unref (spad);
 }
 
 static void
@@ -887,17 +883,12 @@ on_tf_channel_content_removed_cb (TfChannel *tfchannel,
   TfContent *content,
   EmpathyCallHandler *handler)
 {
-  FsMediaType mtype;
-  GstPad *spad;
   gboolean retval;
 
   DEBUG ("removing content");
 
-  g_object_get (content, "media-type", &mtype,
-    "sink-pad", &spad, NULL);
-
-  g_signal_emit (G_OBJECT (handler), signals[SINK_PAD_REMOVED], 0,
-      spad, mtype, &retval);
+  g_signal_emit (G_OBJECT (handler), signals[CONTENT_REMOVED], 0,
+      content, &retval);
 
   if (!retval)
     {
index ab7dbeef8ea3cd215d080e947ad305862297029d..8a4a3aa29041ec25f45ed77e9e4f17401d68eacc 100644 (file)
@@ -2691,15 +2691,17 @@ empathy_call_window_channel_closed_cb (EmpathyCallHandler *handler,
 }
 
 static gboolean
-empathy_call_window_sink_removed_cb (EmpathyCallHandler *handler,
-    GstPad *sink,
-    FsMediaType media_type,
+empathy_call_window_content_removed_cb (EmpathyCallHandler *handler,
+    TfContent *content,
     EmpathyCallWindow *self)
 {
   EmpathyCallWindowPriv *priv = GET_PRIV (self);
+  FsMediaType media_type;
 
   DEBUG ("removing content");
 
+  g_object_get (content, "media-type", &media_type, NULL);
+
   /*
    * This assumes that there is only one video stream per channel...
    */
@@ -2718,7 +2720,6 @@ empathy_call_window_sink_removed_cb (EmpathyCallHandler *handler,
           gst_bin_remove (GST_BIN (priv->pipeline), output);
           gst_bin_remove (GST_BIN (priv->pipeline), priv->funnel);
           priv->funnel = NULL;
-          return TRUE;
         }
     }
   else if (media_type == FS_MEDIA_TYPE_AUDIO)
@@ -2729,11 +2730,14 @@ empathy_call_window_sink_removed_cb (EmpathyCallHandler *handler,
 
           gst_bin_remove (GST_BIN (priv->pipeline), priv->audio_output);
           priv->audio_output = NULL;
-          return TRUE;
         }
     }
+  else
+    {
+      g_assert_not_reached ();
+    }
 
-  return FALSE;
+  return TRUE;
 }
 
 static void
@@ -3401,14 +3405,18 @@ empathy_call_window_src_added_cb (EmpathyCallHandler *handler,
 }
 
 static gboolean
-empathy_call_window_sink_added_cb (EmpathyCallHandler *handler,
-  GstPad *sink, FsMediaType media_type, gpointer user_data)
+empathy_call_window_content_added_cb (EmpathyCallHandler *handler,
+  TfContent *content, gpointer user_data)
 {
   EmpathyCallWindow *self = EMPATHY_CALL_WINDOW (user_data);
   EmpathyCallWindowPriv *priv = GET_PRIV (self);
-  GstPad *pad;
+  GstPad *sink, *pad;
+  FsMediaType media_type;
   gboolean retval = FALSE;
 
+  g_object_get (content, "media-type", &media_type, "sink-pad", &sink, NULL);
+  g_assert (sink != NULL);
+
   switch (media_type)
     {
       case FS_MEDIA_TYPE_AUDIO:
@@ -3461,6 +3469,7 @@ empathy_call_window_sink_added_cb (EmpathyCallHandler *handler,
         g_assert_not_reached ();
     }
 
+  gst_object_unref (sink);
   return retval;
 }
 
@@ -3705,10 +3714,10 @@ empathy_call_window_connect_handler (EmpathyCallWindow *self)
     G_CALLBACK (empathy_call_window_channel_closed_cb), self);
   g_signal_connect (priv->handler, "src-pad-added",
     G_CALLBACK (empathy_call_window_src_added_cb), self);
-  g_signal_connect (priv->handler, "sink-pad-added",
-    G_CALLBACK (empathy_call_window_sink_added_cb), self);
-  g_signal_connect (priv->handler, "sink-pad-removed",
-    G_CALLBACK (empathy_call_window_sink_removed_cb), self);
+  g_signal_connect (priv->handler, "content-added",
+    G_CALLBACK (empathy_call_window_content_added_cb), self);
+  g_signal_connect (priv->handler, "content-removed",
+    G_CALLBACK (empathy_call_window_content_removed_cb), self);
 
   /* We connect to ::call-channel unconditionally since we'll
    * get new channels if we hangup and redial or if we reuse the