gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r23254 - in Extractor: . src/plugins


From: gnunet
Subject: [GNUnet-SVN] r23254 - in Extractor: . src/plugins
Date: Thu, 16 Aug 2012 11:14:16 +0200

Author: LRN
Date: 2012-08-16 11:14:16 +0200 (Thu, 16 Aug 2012)
New Revision: 23254

Modified:
   Extractor/configure.ac
   Extractor/src/plugins/Makefile.am
   Extractor/src/plugins/gstreamer_extractor.c
Log:
A bunch of gstreamer changes

* Link to libgstapp
* Use gst_app_src_*() functions instead of signals
* Print serialized values that were not sent (for debugging, only makes sense 
in-process)
* Define and use GstExtractor debug category
* Rearrange code in data feeder

Modified: Extractor/configure.ac
===================================================================
--- Extractor/configure.ac      2012-08-16 07:34:35 UTC (rev 23253)
+++ Extractor/configure.ac      2012-08-16 09:14:16 UTC (rev 23254)
@@ -426,13 +426,15 @@
 have_gstreamer=no
 have_gstreamer_pbutils=no
 have_gstreamer_tag=no
+have_gstreamer_app=no
 AS_IF([test "x$with_gstreamer" = "xyes"], [
    PKG_CHECK_MODULES([GSTREAMER], [gstreamer-1.0 >= 0.11.93], 
[have_gstreamer=yes], [have_gstreamer=no])
    PKG_CHECK_MODULES([GSTREAMER_PBUTILS], [gstreamer-pbutils-1.0 >= 0.11.93], 
[have_gstreamer_pbutils=yes], [have_gstreamer_pbutils=no])
    PKG_CHECK_MODULES([GSTREAMER_TAG], [gstreamer-tag-1.0 >= 0.11.93], 
[have_gstreamer_tag=yes], [have_gstreamer_tag=no])
+   PKG_CHECK_MODULES([GSTREAMER_APP], [gstreamer-app-1.0 >= 0.11.93], 
[have_gstreamer_app=yes], [have_gstreamer_app=no])
 ])
 
-AM_CONDITIONAL(HAVE_GSTREAMER, test x$have_gstreamer = xyes -a 
x$have_gstreamer_pbutils = xyes -a x$have_gstreamer_tag = xyes -a ! 
x$without_glib = xtrue)
+AM_CONDITIONAL(HAVE_GSTREAMER, test x$have_gstreamer = xyes -a 
x$have_gstreamer_pbutils = xyes -a x$have_gstreamer_tag = xyes -a 
x$have_gstreamer_app = xyes -a ! x$without_glib = xtrue)
 
 ABI_GSF
 

Modified: Extractor/src/plugins/Makefile.am
===================================================================
--- Extractor/src/plugins/Makefile.am   2012-08-16 07:34:35 UTC (rev 23253)
+++ Extractor/src/plugins/Makefile.am   2012-08-16 09:14:16 UTC (rev 23254)
@@ -448,9 +448,9 @@
 libextractor_gstreamer_la_LDFLAGS = \
   $(PLUGINFLAGS)
 libextractor_gstreamer_la_LIBADD = \
-  $(GSTREAMER_LIBS) $(GSTREAMER_PBUTILS_LIBS) $(GSTREAMER_TAG_LIBS)
+  $(GSTREAMER_LIBS) $(GSTREAMER_PBUTILS_LIBS) $(GSTREAMER_TAG_LIBS) 
$(GSTREAMER_APP_LIBS)
 libextractor_gstreamer_la_CFLAGS = \
-  $(GSTREAMER_CFLAGS) $(GSTREAMER_PBUTILS_CFLAGS) $(GSTREAMER_TAG_CFLAGS)
+  $(GSTREAMER_CFLAGS) $(GSTREAMER_PBUTILS_CFLAGS) $(GSTREAMER_TAG_CFLAGS) 
$(GSTREAMER_APP_CFALGS)
 
 test_gstreamer_SOURCES = \
   test_gstreamer.c

Modified: Extractor/src/plugins/gstreamer_extractor.c
===================================================================
--- Extractor/src/plugins/gstreamer_extractor.c 2012-08-16 07:34:35 UTC (rev 
23253)
+++ Extractor/src/plugins/gstreamer_extractor.c 2012-08-16 09:14:16 UTC (rev 
23254)
@@ -29,7 +29,11 @@
 #include <glib-object.h>
 #include <gst/pbutils/pbutils.h>
 #include <gst/tag/tag.h>
+#include <gst/app/gstappsrc.h>
 
+GST_DEBUG_CATEGORY_STATIC (gstreamer_extractor);
+#define GST_CAT_DEFAULT gstreamer_extractor
+
 struct KnownTag
 {
   const char *gst_tag_id;
@@ -668,6 +672,8 @@
 
   gst_init (NULL, NULL);
 
+  GST_DEBUG_CATEGORY_INIT (gstreamer_extractor, "GstExtractor",
+                         0, "GStreamer-based libextractor plugin");
   dc = gst_discoverer_new (timeout * GST_SECOND, &err);
   if (G_UNLIKELY (dc == NULL)) {
     g_print ("Error initializing: %s\n", err->message);
@@ -719,37 +725,32 @@
 static void
 feed_data (GstElement * appsrc, guint size, PrivStruct * ps)
 {
-  GstBuffer *buffer;
   GstFlowReturn ret;
-  GstMemory *data;
-  GstMapInfo mi;
   long data_len;
-  int eos = FALSE;
+  uint8_t *le_data;
 
   if (ps->length > 0 && ps->offset >= ps->length) {
     /* we are at the EOS, send end-of-stream */
-    g_signal_emit_by_name (ps->source, "end-of-stream", &ret);
+    ret = gst_app_src_end_of_stream (GST_APP_SRC (ps->source));
     return;
   }
 
-  buffer = gst_buffer_new ();
-  
   if (ps->length > 0 && ps->offset + size > ps->length)
     size = ps->length - ps->offset;
 
-  data = gst_allocator_alloc (NULL, size, NULL);
-  eos = TRUE;
-  if (gst_memory_map (data, &mi, GST_MAP_WRITE | GST_MAP_READ))
+  data_len = ps->ec->read (ps->ec->cls, (void **) &le_data, size);
+  if (data_len > 0)
   {
-    uint8_t *le_data;
-    data_len = ps->ec->read (ps->ec->cls, (void **) &le_data, size);
-    if (data_len > 0)
+    GstMemory *mem;
+    GstMapInfo mi;
+    mem = gst_allocator_alloc (NULL, data_len, NULL);
+    if (gst_memory_map (mem, &mi, GST_MAP_WRITE))
+    {
+      GstBuffer *buffer;
       memcpy (mi.data, le_data, data_len);
-    gst_memory_unmap (data, &mi);
-    if (data_len > 0)
-    {
-      gst_memory_resize (data, 0, data_len);
-      gst_buffer_append_memory (buffer, data);
+      gst_memory_unmap (mem, &mi);
+      buffer = gst_buffer_new ();
+      gst_buffer_append_memory (buffer, mem);
 
       /* we need to set an offset for random access */
       GST_BUFFER_OFFSET (buffer) = ps->offset;
@@ -757,21 +758,18 @@
 
       GST_DEBUG ("feed buffer %p, offset %" G_GUINT64_FORMAT "-%u", buffer,
           ps->offset, data_len);
-      g_signal_emit_by_name (ps->source, "push-buffer", buffer, &ret);
-      eos = FALSE;
+      ret = gst_app_src_push_buffer (GST_APP_SRC (ps->source), buffer);
+      ps->offset += data_len;
     }
+    else
+    {
+      gst_memory_unref (mem);
+      ret = gst_app_src_end_of_stream (GST_APP_SRC (ps->source));
+    }
   }
+  else
+    ret = gst_app_src_end_of_stream (GST_APP_SRC (ps->source));
 
-  if (eos)
-  {
-    g_signal_emit_by_name (ps->source, "end-of-stream", &ret);
-    gst_memory_unref (data);
-  }
-
-  gst_buffer_unref (buffer);
-
-  ps->offset += data_len;
-
   return;
 }
 
@@ -871,8 +869,10 @@
     }
     /* This is a potential source of invalid characters */
     /* And it also might attempt to serialize binary data - such as images. */
+    str = gst_value_serialize (value);
+    g_print ("Will not try to serialize structure field %s (%s) = %s\n", 
field_name, type_name, str);
+    g_free (str);
     str = NULL;
-    g_print ("Will not try to serialize structure field %s (%s)\n", 
field_name, type_name);
     break;
   }
   if (str != NULL)
@@ -1361,8 +1361,10 @@
     }
     /* This is a potential source of invalid characters */
     /* And it also might attempt to serialize binary data - such as images. */
+    str = gst_value_serialize (&val);
+    g_print ("Will not try to serialize tag %s (%s) = %s\n", tag, type_name, 
str);
+    g_free (str);
     str = NULL;
-    g_print ("Will not try to serialize tag %s (%s)\n", tag, type_name);
     break;
   }
   if (str != NULL)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]