]> git.0d.be Git - empathy.git/commitdiff
Port to gstreamer 1.0
authorSjoerd Simons <sjoerd@luon.net>
Sun, 26 Aug 2012 17:23:06 +0000 (19:23 +0200)
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Mon, 3 Sep 2012 08:15:13 +0000 (10:15 +0200)
configure.ac
src/Makefile.am
src/empathy-audio-sink.c
src/empathy-audio-src.c
src/empathy-call-window.c
src/empathy-video-src.c

index b062303a2b6afb25dc5ca3837355b565a2e245c2..3eea28357cba4dc9aa54e0e1d613ec4d4784e9f9 100644 (file)
@@ -50,7 +50,6 @@ AC_DEFINE(CLUTTER_VERSION_MIN_REQUIRED, CLUTTER_VERSION_1_8, [Ignore post 1.8 de
 AC_DEFINE(CLUTTER_VERSION_MAX_ALLOWED, CLUTTER_VERSION_1_10, [Prevent post 1.10 APIs])
 
 CLUTTER_GTK_REQUIRED=1.1.2
 AC_DEFINE(CLUTTER_VERSION_MAX_ALLOWED, CLUTTER_VERSION_1_10, [Prevent post 1.10 APIs])
 
 CLUTTER_GTK_REQUIRED=1.1.2
-CLUTTER_GST_REQUIRED=1.5.2
 
 TELEPATHY_GLIB_REQUIRED=0.19.6
 AC_DEFINE(TP_VERSION_MIN_REQUIRED, TP_VERSION_0_20, [Ignore post 0.20 deprecations])
 
 TELEPATHY_GLIB_REQUIRED=0.19.6
 AC_DEFINE(TP_VERSION_MIN_REQUIRED, TP_VERSION_0_20, [Ignore post 0.20 deprecations])
@@ -62,7 +61,6 @@ LIBSECRET_REQUIRED=0.5
 GCR_REQUIRED=2.91.4
 LIBCANBERRA_GTK_REQUIRED=0.25
 LIBNOTIFY_REQUIRED=0.7.0
 GCR_REQUIRED=2.91.4
 LIBCANBERRA_GTK_REQUIRED=0.25
 LIBNOTIFY_REQUIRED=0.7.0
-TELEPATHY_FARSTREAM_REQUIRED=0.2.1
 TELEPATHY_LOGGER=0.2.13
 WEBKIT_REQUIRED=1.3.13
 GOA_REQUIRED=3.5.1
 TELEPATHY_LOGGER=0.2.13
 WEBKIT_REQUIRED=1.3.13
 GOA_REQUIRED=3.5.1
@@ -218,16 +216,48 @@ PKG_CHECK_MODULES(EMPATHY,
    gee-1.0
 ])
 
    gee-1.0
 ])
 
-PKG_CHECK_MODULES(EMPATHY_CALL,
-[
-   farstream-0.1
-   telepathy-farstream >= $TELEPATHY_FARSTREAM_REQUIRED
-   clutter-1.0 >= $CLUTTER_REQUIRED
-   clutter-gtk-1.0 >= $CLUTTER_GTK_REQUIRED
-   clutter-gst-1.0 >= $CLUTTER_GST_REQUIRED
-   gstreamer-0.10 >= $GSTREAMER_REQUIRED
-   gstreamer-interfaces-0.10
-])
+# -----------------------------------------------------------
+# GStreamer
+# -----------------------------------------------------------
+AC_ARG_ENABLE(gst-1.0,
+              AS_HELP_STRING([--enable-gst-1.0=@<:@no/yes/auto@:>@],
+                             [build with GStreamer 1.0]), enable_gst1=yes,
+                             enable_gst1=auto)
+
+# Try to use GStreamer 1.à if available
+if test "x$enable_gst1" != "xno"; then
+  PKG_CHECK_MODULES(EMPATHY_CALL,
+  [
+     farstream-0.2
+     telepathy-farstream >= 0.4.999
+     clutter-1.0 >= $CLUTTER_REQUIRED
+     clutter-gtk-1.0 >= $CLUTTER_GTK_REQUIRED
+     clutter-gst-2.0
+  ], have_gst1="yes", have_gst1="no")
+
+  if test "x$have_gst1" = "xyes"; then
+    AC_DEFINE(HAVE_GST1, 1, [Build with GStreamer 1.0])
+  fi
+fi
+
+if test "x$enable_gst1" = "xyes" -a "x$have_gst1" != "xyes"; then
+   AC_MSG_ERROR([Could not find GStreamer 1.0 dependencies:
+
+$EMPATHY_CALL_PKG_ERRORS])
+fi
+
+if test "x$have_gst1" != "xyes"; then
+  PKG_CHECK_MODULES(EMPATHY_CALL,
+  [
+     farstream-0.1
+     telepathy-farstream >= 0.2.1
+     clutter-1.0 >= $CLUTTER_REQUIRED
+     clutter-gtk-1.0 >= $CLUTTER_GTK_REQUIRED
+     clutter-gst-1.0 >= 1.5.2
+     gstreamer-0.10 >= $GSTREAMER_REQUIRED
+     gstreamer-interfaces-0.10
+  ])
+fi
 
 AC_DEFINE(EMPATHY_GOA_PROVIDER, "org.gnome.OnlineAccounts",
    [Name of provider for accounts imported from GOA])
 
 AC_DEFINE(EMPATHY_GOA_PROVIDER, "org.gnome.OnlineAccounts",
    [Name of provider for accounts imported from GOA])
@@ -623,6 +653,7 @@ Configure summary:
        Linker Flags................:  ${LDFLAGS}
        Prefix......................:  ${prefix}
        Coding style checks.........:  ${ENABLE_CODING_STYLE_CHECKS}
        Linker Flags................:  ${LDFLAGS}
        Prefix......................:  ${prefix}
        Coding style checks.........:  ${ENABLE_CODING_STYLE_CHECKS}
+       Use GStreamer 1.0...........:  ${have_gst1}
 
     Features:
        Spell checking (enchant)....:  ${have_enchant}
 
     Features:
        Spell checking (enchant)....:  ${have_enchant}
index ed3d8d0db6d63c40b0aeda62bfa09f116c077221..c2cb9f7a0999f6fa650ef2117468cf9689275cf5 100644 (file)
@@ -120,7 +120,7 @@ empathy_call_SOURCES = \
        empathy-mic-monitor.c \
        empathy-mic-monitor.h
 
        empathy-mic-monitor.c \
        empathy-mic-monitor.h
 
-empathy_call_CFLAGS = $(EMPATHY_CALL_CFLAGS)
+empathy_call_CFLAGS = $(EMPATHY_CALL_CFLAGS) -DGST_USE_UNSTABLE_API
 empathy_call_LDFLAGS = $(EMPATHY_CALL_LIBS)
 
 empathy_handwritten_source = \
 empathy_call_LDFLAGS = $(EMPATHY_CALL_LIBS)
 
 empathy_handwritten_source = \
index ba5cab77d32cdc03520bebcf2766b6c64fad0986..94fb95c4d34e49ab2fbfeafce932a0cfad7cb377 100644 (file)
@@ -51,8 +51,12 @@ static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE(
     "sink%d",
     GST_PAD_SINK,
     GST_PAD_REQUEST,
     "sink%d",
     GST_PAD_SINK,
     GST_PAD_REQUEST,
+#ifdef HAVE_GST1
+    GST_STATIC_CAPS ( "audio/x-raw" )
+#else
     GST_STATIC_CAPS ( GST_AUDIO_INT_PAD_TEMPLATE_CAPS " ; "
         GST_AUDIO_FLOAT_PAD_TEMPLATE_CAPS)
     GST_STATIC_CAPS ( GST_AUDIO_INT_PAD_TEMPLATE_CAPS " ; "
         GST_AUDIO_FLOAT_PAD_TEMPLATE_CAPS)
+#endif
 );
 
 enum {
 );
 
 enum {
@@ -80,9 +84,16 @@ empathy_audio_sink_init (EmpathyGstAudioSink *self)
   g_mutex_init (&self->priv->volume_mutex);
 }
 
   g_mutex_init (&self->priv->volume_mutex);
 }
 
+#ifdef HAVE_GST1
+static GstPad * empathy_audio_sink_request_new_pad (GstElement *self,
+  GstPadTemplate *templ,
+  const gchar* name,
+  const GstCaps *caps);
+#else
 static GstPad * empathy_audio_sink_request_new_pad (GstElement *self,
   GstPadTemplate *templ,
   const gchar* name);
 static GstPad * empathy_audio_sink_request_new_pad (GstElement *self,
   GstPadTemplate *templ,
   const gchar* name);
+#endif
 
 static void empathy_audio_sink_release_pad (GstElement *self,
   GstPad *pad);
 
 static void empathy_audio_sink_release_pad (GstElement *self,
   GstPad *pad);
@@ -293,10 +304,18 @@ empathy_audio_sink_volume_idle_setup (gpointer user_data)
   return FALSE;
 }
 
   return FALSE;
 }
 
+#ifdef HAVE_GST1
+static GstPad *
+empathy_audio_sink_request_new_pad (GstElement *element,
+  GstPadTemplate *templ,
+  const gchar* name,
+  const GstCaps *caps)
+#else
 static GstPad *
 empathy_audio_sink_request_new_pad (GstElement *element,
   GstPadTemplate *templ,
   const gchar* name)
 static GstPad *
 empathy_audio_sink_request_new_pad (GstElement *element,
   GstPadTemplate *templ,
   const gchar* name)
+#endif
 {
   EmpathyGstAudioSink *self = EMPATHY_GST_AUDIO_SINK (element);
   GstElement *bin, *resample, *audioconvert0, *audioconvert1;
 {
   EmpathyGstAudioSink *self = EMPATHY_GST_AUDIO_SINK (element);
   GstElement *bin, *resample, *audioconvert0, *audioconvert1;
index deff297d07d1b7dfb75df7362ee9ff2ea400b312..c47b8dea760a62fdf333285c11441939f2664de1 100644 (file)
@@ -263,8 +263,6 @@ empathy_audio_src_init (EmpathyGstAudioSrc *obj)
 {
   EmpathyGstAudioSrcPrivate *priv = EMPATHY_GST_AUDIO_SRC_GET_PRIVATE (obj);
   GstPad *ghost, *src;
 {
   EmpathyGstAudioSrcPrivate *priv = EMPATHY_GST_AUDIO_SRC_GET_PRIVATE (obj);
   GstPad *ghost, *src;
-  GstElement *capsfilter;
-  GstCaps *caps;
 
   obj->priv = priv;
   g_mutex_init (&priv->lock);
 
   obj->priv = priv;
   g_mutex_init (&priv->lock);
@@ -309,21 +307,28 @@ empathy_audio_src_init (EmpathyGstAudioSrc *obj)
 
   gst_bin_add (GST_BIN (obj), priv->src);
 
 
   gst_bin_add (GST_BIN (obj), priv->src);
 
-  /* Explicitly state what format we want from pulsesrc. This pushes resampling
-   * and format conversion as early as possible, lowering the amount of data
-   * transferred and thus improving performance. When moving to GStreamer
-   * 0.11/1.0, this should change so that we actually request what the encoder
-   * wants downstream. */
-  caps = gst_caps_new_simple ("audio/x-raw-int",
-      "channels", G_TYPE_INT, 1,
-      "width", G_TYPE_INT, 16,
-      "depth", G_TYPE_INT, 16,
-      "rate", G_TYPE_INT, 32000,
-      NULL);
-  capsfilter = gst_element_factory_make ("capsfilter", NULL);
-  g_object_set (G_OBJECT (capsfilter), "caps", caps, NULL);
-  gst_bin_add (GST_BIN (obj), capsfilter);
-  gst_element_link (priv->src, capsfilter);
+#ifndef HAVE_GST1
+  {
+    GstElement *capsfilter;
+    GstCaps *caps;
+
+    /* Explicitly state what format we want from pulsesrc. This pushes resampling
+     * and format conversion as early as possible, lowering the amount of data
+     * transferred and thus improving performance. When moving to GStreamer
+     * 0.11/1.0, this should change so that we actually request what the encoder
+     * wants downstream. */
+    caps = gst_caps_new_simple ("audio/x-raw-int",
+        "channels", G_TYPE_INT, 1,
+        "width", G_TYPE_INT, 16,
+        "depth", G_TYPE_INT, 16,
+        "rate", G_TYPE_INT, 32000,
+        NULL);
+    capsfilter = gst_element_factory_make ("capsfilter", NULL);
+    g_object_set (G_OBJECT (capsfilter), "caps", caps, NULL);
+    gst_bin_add (GST_BIN (obj), capsfilter);
+    gst_element_link (priv->src, capsfilter);
+  }
+#endif
 
   priv->volume_element = gst_element_factory_make ("volume", NULL);
   gst_bin_add (GST_BIN (obj), priv->volume_element);
 
   priv->volume_element = gst_element_factory_make ("volume", NULL);
   gst_bin_add (GST_BIN (obj), priv->volume_element);
index fca76c3f7ed4bb6d8d5caffaa9cb16bb407180ca..749b4c6f3949876d9a565c22c29ad60e60a66963 100644 (file)
@@ -3255,6 +3255,27 @@ empathy_call_window_check_video_cb (gpointer data)
 }
 
 /* Called from the streaming thread */
 }
 
 /* Called from the streaming thread */
+#ifdef HAVE_GST1
+static GstPadProbeReturn
+empathy_call_window_video_probe_cb (GstPad *pad,
+    GstPadProbeInfo *info,
+    gpointer user_data)
+{
+    EmpathyCallWindow *self = user_data;
+
+  if (G_UNLIKELY (!self->priv->got_video))
+    {
+      /* show the remote video */
+      g_idle_add_full (G_PRIORITY_DEFAULT_IDLE,
+          empathy_call_window_show_video_output_cb,
+          g_object_ref (self), g_object_unref);
+
+      self->priv->got_video = TRUE;
+    }
+
+  return GST_PAD_PROBE_OK;
+}
+#else
 static gboolean
 empathy_call_window_video_probe_cb (GstPad *pad,
     GstMiniObject *mini_obj,
 static gboolean
 empathy_call_window_video_probe_cb (GstPad *pad,
     GstMiniObject *mini_obj,
@@ -3276,6 +3297,7 @@ empathy_call_window_video_probe_cb (GstPad *pad,
 
   return TRUE;
 }
 
   return TRUE;
 }
+#endif
 
 /* Called from the streaming thread */
 static gboolean
 
 /* Called from the streaming thread */
 static gboolean
@@ -3302,8 +3324,14 @@ empathy_call_window_src_added_cb (EmpathyCallHandler *handler,
         g_idle_add (empathy_call_window_show_video_output_cb, self);
         pad = empathy_call_window_get_video_sink_pad (self);
 
         g_idle_add (empathy_call_window_show_video_output_cb, self);
         pad = empathy_call_window_get_video_sink_pad (self);
 
+#ifdef HAVE_GST1
+        gst_pad_add_probe (src,
+            GST_PAD_PROBE_TYPE_BUFFER | GST_PAD_PROBE_TYPE_BUFFER_LIST,
+            empathy_call_window_video_probe_cb, self, NULL);
+#else
         gst_pad_add_data_probe (src,
             G_CALLBACK (empathy_call_window_video_probe_cb), self);
         gst_pad_add_data_probe (src,
             G_CALLBACK (empathy_call_window_video_probe_cb), self);
+#endif
         if (priv->got_video_src > 0)
           g_source_remove (priv->got_video_src);
         priv->got_video_src = g_timeout_add_seconds (1,
         if (priv->got_video_src > 0)
           g_source_remove (priv->got_video_src);
         priv->got_video_src = g_timeout_add_seconds (1,
@@ -3482,7 +3510,11 @@ empathy_call_window_content_added_cb (EmpathyCallHandler *handler,
       case FS_MEDIA_TYPE_VIDEO:
         if (priv->video_tee != NULL)
           {
       case FS_MEDIA_TYPE_VIDEO:
         if (priv->video_tee != NULL)
           {
+#ifdef HAVE_GST1
+            pad = gst_element_get_request_pad (priv->video_tee, "src_%u");
+#else
             pad = gst_element_get_request_pad (priv->video_tee, "src%d");
             pad = gst_element_get_request_pad (priv->video_tee, "src%d");
+#endif
             if (GST_PAD_LINK_FAILED (gst_pad_link (pad, sink)))
               {
                 g_warning ("Could not link video source input pipeline");
             if (GST_PAD_LINK_FAILED (gst_pad_link (pad, sink)))
               {
                 g_warning ("Could not link video source input pipeline");
index 8c9c7501548c6f6182d8845a72981717b58e5998..2fc483567e20b6c21d8ea58b770d9289af28289b 100644 (file)
 #include <stdio.h>
 #include <stdlib.h>
 
 #include <stdio.h>
 #include <stdlib.h>
 
+#ifdef HAVE_GST1
+#include <gst/video/colorbalance.h>
+#else
 #include <gst/interfaces/colorbalance.h>
 #include <gst/interfaces/colorbalance.h>
+#endif
 
 #define DEBUG_FLAG EMPATHY_DEBUG_VOIP
 #include <libempathy/empathy-debug.h>
 
 #define DEBUG_FLAG EMPATHY_DEBUG_VOIP
 #include <libempathy/empathy-debug.h>
@@ -112,11 +116,24 @@ error:
   return NULL;
 }
 
   return NULL;
 }
 
+#ifdef HAVE_GST1
+static GstPadProbeReturn
+empathy_video_src_drop_eos (GstPad *pad,
+  GstPadProbeInfo *info,
+  gpointer user_data)
+{
+  if (GST_EVENT_TYPE (GST_PAD_PROBE_INFO_EVENT (info)) == GST_EVENT_EOS)
+    return GST_PAD_PROBE_DROP;
+
+  return GST_PAD_PROBE_OK;
+}
+#else
 static gboolean
 empathy_video_src_drop_eos (GstPad *pad, GstEvent *event, gpointer user_data)
 {
   return GST_EVENT_TYPE (event) != GST_EVENT_EOS;
 }
 static gboolean
 empathy_video_src_drop_eos (GstPad *pad, GstEvent *event, gpointer user_data)
 {
   return GST_EVENT_TYPE (event) != GST_EVENT_EOS;
 }
+#endif
 
 static void
 empathy_video_src_init (EmpathyGstVideoSrc *obj)
 
 static void
 empathy_video_src_init (EmpathyGstVideoSrc *obj)
@@ -128,7 +145,11 @@ empathy_video_src_init (EmpathyGstVideoSrc *obj)
   gchar *str;
 
   /* allocate caps here, so we can update it by optional elements */
   gchar *str;
 
   /* allocate caps here, so we can update it by optional elements */
+#ifdef HAVE_GST1
+  caps = gst_caps_new_simple ("video/x-raw",
+#else
   caps = gst_caps_new_simple ("video/x-raw-yuv",
   caps = gst_caps_new_simple ("video/x-raw-yuv",
+#endif
     "width", G_TYPE_INT, 320,
     "height", G_TYPE_INT, 240,
     NULL);
     "width", G_TYPE_INT, 320,
     "height", G_TYPE_INT, 240,
     NULL);
@@ -144,7 +165,14 @@ empathy_video_src_init (EmpathyGstVideoSrc *obj)
   /* Drop EOS events, so that our sinks don't get confused when we restart the
    * source (triggering an EOS) */
   src = gst_element_get_static_pad (element, "src");
   /* Drop EOS events, so that our sinks don't get confused when we restart the
    * source (triggering an EOS) */
   src = gst_element_get_static_pad (element, "src");
+
+#ifdef HAVE_GST1
+  gst_pad_add_probe (src, GST_PAD_PROBE_TYPE_EVENT_DOWNSTREAM,
+    empathy_video_src_drop_eos, NULL, NULL);
+#else
   gst_pad_add_event_probe (src, G_CALLBACK (empathy_video_src_drop_eos), NULL);
   gst_pad_add_event_probe (src, G_CALLBACK (empathy_video_src_drop_eos), NULL);
+#endif
+
   gst_object_unref (src);
 
   /* videorate with the required properties optional as it needs a currently
   gst_object_unref (src);
 
   /* videorate with the required properties optional as it needs a currently
@@ -178,9 +206,15 @@ empathy_video_src_init (EmpathyGstVideoSrc *obj)
   DEBUG ("Current video src caps are : %s", str);
   g_free (str);
 
   DEBUG ("Current video src caps are : %s", str);
   g_free (str);
 
+#ifdef HAVE_GST1
+  if ((element = empathy_gst_add_to_bin (GST_BIN (obj),
+      element, "videoconvert")) == NULL)
+    g_error ("Failed to add \"videoconvert\" (gst-plugins-base missing?)");
+#else
   if ((element = empathy_gst_add_to_bin (GST_BIN (obj),
       element, "ffmpegcolorspace")) == NULL)
     g_error ("Failed to add \"ffmpegcolorspace\" (gst-plugins-base missing?)");
   if ((element = empathy_gst_add_to_bin (GST_BIN (obj),
       element, "ffmpegcolorspace")) == NULL)
     g_error ("Failed to add \"ffmpegcolorspace\" (gst-plugins-base missing?)");
+#endif
 
   if ((element = empathy_gst_add_to_bin (GST_BIN (obj),
       element, "videoscale")) == NULL)
 
   if ((element = empathy_gst_add_to_bin (GST_BIN (obj),
       element, "videoscale")) == NULL)