diff options
author | LRN <lrn1986@gmail.com> | 2012-08-16 09:14:16 +0000 |
---|---|---|
committer | LRN <lrn1986@gmail.com> | 2012-08-16 09:14:16 +0000 |
commit | d37615ada39c3caa8099787948e01e793e78ed92 (patch) | |
tree | 59a856d1b2b3d5961e05d1c5e25f69ab2e9c59f9 | |
parent | bff8069a458d2817f43b7a946fdbf7acb266ce0a (diff) | |
download | libextractor-d37615ada39c3caa8099787948e01e793e78ed92.tar.gz libextractor-d37615ada39c3caa8099787948e01e793e78ed92.zip |
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
-rw-r--r-- | configure.ac | 4 | ||||
-rw-r--r-- | src/plugins/Makefile.am | 4 | ||||
-rw-r--r-- | src/plugins/gstreamer_extractor.c | 66 |
3 files changed, 39 insertions, 35 deletions
diff --git a/configure.ac b/configure.ac index df05e5a..d0d9f3e 100644 --- a/configure.ac +++ b/configure.ac | |||
@@ -426,13 +426,15 @@ AC_ARG_WITH([gstreamer], AS_HELP_STRING([--with-gstreamer], [Build with the GStr | |||
426 | have_gstreamer=no | 426 | have_gstreamer=no |
427 | have_gstreamer_pbutils=no | 427 | have_gstreamer_pbutils=no |
428 | have_gstreamer_tag=no | 428 | have_gstreamer_tag=no |
429 | have_gstreamer_app=no | ||
429 | AS_IF([test "x$with_gstreamer" = "xyes"], [ | 430 | AS_IF([test "x$with_gstreamer" = "xyes"], [ |
430 | PKG_CHECK_MODULES([GSTREAMER], [gstreamer-1.0 >= 0.11.93], [have_gstreamer=yes], [have_gstreamer=no]) | 431 | PKG_CHECK_MODULES([GSTREAMER], [gstreamer-1.0 >= 0.11.93], [have_gstreamer=yes], [have_gstreamer=no]) |
431 | PKG_CHECK_MODULES([GSTREAMER_PBUTILS], [gstreamer-pbutils-1.0 >= 0.11.93], [have_gstreamer_pbutils=yes], [have_gstreamer_pbutils=no]) | 432 | PKG_CHECK_MODULES([GSTREAMER_PBUTILS], [gstreamer-pbutils-1.0 >= 0.11.93], [have_gstreamer_pbutils=yes], [have_gstreamer_pbutils=no]) |
432 | PKG_CHECK_MODULES([GSTREAMER_TAG], [gstreamer-tag-1.0 >= 0.11.93], [have_gstreamer_tag=yes], [have_gstreamer_tag=no]) | 433 | PKG_CHECK_MODULES([GSTREAMER_TAG], [gstreamer-tag-1.0 >= 0.11.93], [have_gstreamer_tag=yes], [have_gstreamer_tag=no]) |
434 | PKG_CHECK_MODULES([GSTREAMER_APP], [gstreamer-app-1.0 >= 0.11.93], [have_gstreamer_app=yes], [have_gstreamer_app=no]) | ||
433 | ]) | 435 | ]) |
434 | 436 | ||
435 | 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) | 437 | 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) |
436 | 438 | ||
437 | ABI_GSF | 439 | ABI_GSF |
438 | 440 | ||
diff --git a/src/plugins/Makefile.am b/src/plugins/Makefile.am index d12ec57..6e53b2f 100644 --- a/src/plugins/Makefile.am +++ b/src/plugins/Makefile.am | |||
@@ -448,9 +448,9 @@ libextractor_gstreamer_la_SOURCES = \ | |||
448 | libextractor_gstreamer_la_LDFLAGS = \ | 448 | libextractor_gstreamer_la_LDFLAGS = \ |
449 | $(PLUGINFLAGS) | 449 | $(PLUGINFLAGS) |
450 | libextractor_gstreamer_la_LIBADD = \ | 450 | libextractor_gstreamer_la_LIBADD = \ |
451 | $(GSTREAMER_LIBS) $(GSTREAMER_PBUTILS_LIBS) $(GSTREAMER_TAG_LIBS) | 451 | $(GSTREAMER_LIBS) $(GSTREAMER_PBUTILS_LIBS) $(GSTREAMER_TAG_LIBS) $(GSTREAMER_APP_LIBS) |
452 | libextractor_gstreamer_la_CFLAGS = \ | 452 | libextractor_gstreamer_la_CFLAGS = \ |
453 | $(GSTREAMER_CFLAGS) $(GSTREAMER_PBUTILS_CFLAGS) $(GSTREAMER_TAG_CFLAGS) | 453 | $(GSTREAMER_CFLAGS) $(GSTREAMER_PBUTILS_CFLAGS) $(GSTREAMER_TAG_CFLAGS) $(GSTREAMER_APP_CFALGS) |
454 | 454 | ||
455 | test_gstreamer_SOURCES = \ | 455 | test_gstreamer_SOURCES = \ |
456 | test_gstreamer.c | 456 | test_gstreamer.c |
diff --git a/src/plugins/gstreamer_extractor.c b/src/plugins/gstreamer_extractor.c index b67047b..f1f666c 100644 --- a/src/plugins/gstreamer_extractor.c +++ b/src/plugins/gstreamer_extractor.c | |||
@@ -29,6 +29,10 @@ | |||
29 | #include <glib-object.h> | 29 | #include <glib-object.h> |
30 | #include <gst/pbutils/pbutils.h> | 30 | #include <gst/pbutils/pbutils.h> |
31 | #include <gst/tag/tag.h> | 31 | #include <gst/tag/tag.h> |
32 | #include <gst/app/gstappsrc.h> | ||
33 | |||
34 | GST_DEBUG_CATEGORY_STATIC (gstreamer_extractor); | ||
35 | #define GST_CAT_DEFAULT gstreamer_extractor | ||
32 | 36 | ||
33 | struct KnownTag | 37 | struct KnownTag |
34 | { | 38 | { |
@@ -668,6 +672,8 @@ initialize () | |||
668 | 672 | ||
669 | gst_init (NULL, NULL); | 673 | gst_init (NULL, NULL); |
670 | 674 | ||
675 | GST_DEBUG_CATEGORY_INIT (gstreamer_extractor, "GstExtractor", | ||
676 | 0, "GStreamer-based libextractor plugin"); | ||
671 | dc = gst_discoverer_new (timeout * GST_SECOND, &err); | 677 | dc = gst_discoverer_new (timeout * GST_SECOND, &err); |
672 | if (G_UNLIKELY (dc == NULL)) { | 678 | if (G_UNLIKELY (dc == NULL)) { |
673 | g_print ("Error initializing: %s\n", err->message); | 679 | g_print ("Error initializing: %s\n", err->message); |
@@ -719,37 +725,32 @@ _source_setup (GstDiscoverer * dc, GstElement * source, PrivStruct * ps) | |||
719 | static void | 725 | static void |
720 | feed_data (GstElement * appsrc, guint size, PrivStruct * ps) | 726 | feed_data (GstElement * appsrc, guint size, PrivStruct * ps) |
721 | { | 727 | { |
722 | GstBuffer *buffer; | ||
723 | GstFlowReturn ret; | 728 | GstFlowReturn ret; |
724 | GstMemory *data; | ||
725 | GstMapInfo mi; | ||
726 | long data_len; | 729 | long data_len; |
727 | int eos = FALSE; | 730 | uint8_t *le_data; |
728 | 731 | ||
729 | if (ps->length > 0 && ps->offset >= ps->length) { | 732 | if (ps->length > 0 && ps->offset >= ps->length) { |
730 | /* we are at the EOS, send end-of-stream */ | 733 | /* we are at the EOS, send end-of-stream */ |
731 | g_signal_emit_by_name (ps->source, "end-of-stream", &ret); | 734 | ret = gst_app_src_end_of_stream (GST_APP_SRC (ps->source)); |
732 | return; | 735 | return; |
733 | } | 736 | } |
734 | 737 | ||
735 | buffer = gst_buffer_new (); | ||
736 | |||
737 | if (ps->length > 0 && ps->offset + size > ps->length) | 738 | if (ps->length > 0 && ps->offset + size > ps->length) |
738 | size = ps->length - ps->offset; | 739 | size = ps->length - ps->offset; |
739 | 740 | ||
740 | data = gst_allocator_alloc (NULL, size, NULL); | 741 | data_len = ps->ec->read (ps->ec->cls, (void **) &le_data, size); |
741 | eos = TRUE; | 742 | if (data_len > 0) |
742 | if (gst_memory_map (data, &mi, GST_MAP_WRITE | GST_MAP_READ)) | ||
743 | { | 743 | { |
744 | uint8_t *le_data; | 744 | GstMemory *mem; |
745 | data_len = ps->ec->read (ps->ec->cls, (void **) &le_data, size); | 745 | GstMapInfo mi; |
746 | if (data_len > 0) | 746 | mem = gst_allocator_alloc (NULL, data_len, NULL); |
747 | memcpy (mi.data, le_data, data_len); | 747 | if (gst_memory_map (mem, &mi, GST_MAP_WRITE)) |
748 | gst_memory_unmap (data, &mi); | ||
749 | if (data_len > 0) | ||
750 | { | 748 | { |
751 | gst_memory_resize (data, 0, data_len); | 749 | GstBuffer *buffer; |
752 | gst_buffer_append_memory (buffer, data); | 750 | memcpy (mi.data, le_data, data_len); |
751 | gst_memory_unmap (mem, &mi); | ||
752 | buffer = gst_buffer_new (); | ||
753 | gst_buffer_append_memory (buffer, mem); | ||
753 | 754 | ||
754 | /* we need to set an offset for random access */ | 755 | /* we need to set an offset for random access */ |
755 | GST_BUFFER_OFFSET (buffer) = ps->offset; | 756 | GST_BUFFER_OFFSET (buffer) = ps->offset; |
@@ -757,20 +758,17 @@ feed_data (GstElement * appsrc, guint size, PrivStruct * ps) | |||
757 | 758 | ||
758 | GST_DEBUG ("feed buffer %p, offset %" G_GUINT64_FORMAT "-%u", buffer, | 759 | GST_DEBUG ("feed buffer %p, offset %" G_GUINT64_FORMAT "-%u", buffer, |
759 | ps->offset, data_len); | 760 | ps->offset, data_len); |
760 | g_signal_emit_by_name (ps->source, "push-buffer", buffer, &ret); | 761 | ret = gst_app_src_push_buffer (GST_APP_SRC (ps->source), buffer); |
761 | eos = FALSE; | 762 | ps->offset += data_len; |
763 | } | ||
764 | else | ||
765 | { | ||
766 | gst_memory_unref (mem); | ||
767 | ret = gst_app_src_end_of_stream (GST_APP_SRC (ps->source)); | ||
762 | } | 768 | } |
763 | } | 769 | } |
764 | 770 | else | |
765 | if (eos) | 771 | ret = gst_app_src_end_of_stream (GST_APP_SRC (ps->source)); |
766 | { | ||
767 | g_signal_emit_by_name (ps->source, "end-of-stream", &ret); | ||
768 | gst_memory_unref (data); | ||
769 | } | ||
770 | |||
771 | gst_buffer_unref (buffer); | ||
772 | |||
773 | ps->offset += data_len; | ||
774 | 772 | ||
775 | return; | 773 | return; |
776 | } | 774 | } |
@@ -871,8 +869,10 @@ send_structure_foreach (GQuark field_id, const GValue *value, | |||
871 | } | 869 | } |
872 | /* This is a potential source of invalid characters */ | 870 | /* This is a potential source of invalid characters */ |
873 | /* And it also might attempt to serialize binary data - such as images. */ | 871 | /* And it also might attempt to serialize binary data - such as images. */ |
872 | str = gst_value_serialize (value); | ||
873 | g_print ("Will not try to serialize structure field %s (%s) = %s\n", field_name, type_name, str); | ||
874 | g_free (str); | ||
874 | str = NULL; | 875 | str = NULL; |
875 | g_print ("Will not try to serialize structure field %s (%s)\n", field_name, type_name); | ||
876 | break; | 876 | break; |
877 | } | 877 | } |
878 | if (str != NULL) | 878 | if (str != NULL) |
@@ -1361,8 +1361,10 @@ send_toc_tags_foreach (const GstTagList * tags, const gchar * tag, | |||
1361 | } | 1361 | } |
1362 | /* This is a potential source of invalid characters */ | 1362 | /* This is a potential source of invalid characters */ |
1363 | /* And it also might attempt to serialize binary data - such as images. */ | 1363 | /* And it also might attempt to serialize binary data - such as images. */ |
1364 | str = gst_value_serialize (&val); | ||
1365 | g_print ("Will not try to serialize tag %s (%s) = %s\n", tag, type_name, str); | ||
1366 | g_free (str); | ||
1364 | str = NULL; | 1367 | str = NULL; |
1365 | g_print ("Will not try to serialize tag %s (%s)\n", tag, type_name); | ||
1366 | break; | 1368 | break; |
1367 | } | 1369 | } |
1368 | if (str != NULL) | 1370 | if (str != NULL) |