gst/typefind/gsttypefindfunctions.c: Don't go into an endless loop if the file starts...
authorTim-Philipp Müller <tim@centricular.net>
Mon, 22 Jan 2007 12:03:27 +0000 (12:03 +0000)
committerTim-Philipp Müller <tim@centricular.net>
Mon, 22 Jan 2007 12:03:27 +0000 (12:03 +0000)
Original commit message from CVS:
* gst/typefind/gsttypefindfunctions.c: (mpeg4_video_type_find):
Don't go into an endless loop if the file starts with 00 00 01 2X,
like quicktime redirect files might. Fixes #396042.
* tests/check/Makefile.am:
* tests/check/gst/.cvsignore:
* tests/check/gst/typefindfunctions.c: (GST_START_TEST),
(typefindfunctions_suite):
Add unit test for the above.

ChangeLog
gst/typefind/gsttypefindfunctions.c
tests/check/Makefile.am
tests/check/gst/.gitignore [new file with mode: 0644]
tests/check/gst/typefindfunctions.c [new file with mode: 0644]

index ac6380d..2803d09 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,17 @@
 2007-01-22  Tim-Philipp Müller  <tim at centricular dot net>
 
+       * gst/typefind/gsttypefindfunctions.c: (mpeg4_video_type_find):
+         Don't go into an endless loop if the file starts with 00 00 01 2X,
+         like quicktime redirect files might. Fixes #396042.
+
+       * tests/check/Makefile.am:
+       * tests/check/gst/.cvsignore:
+       * tests/check/gst/typefindfunctions.c: (GST_START_TEST),
+       (typefindfunctions_suite):
+         Add unit test for the above.
+
+2007-01-22  Tim-Philipp Müller  <tim at centricular dot net>
+
        * gst-libs/gst/riff/riff-media.c: (gst_riff_create_video_caps):
          On second thought, use "depth" field rather than "bpp" field.
 
index fa680c7..e632d8a 100644 (file)
@@ -1363,7 +1363,8 @@ mpeg4_video_type_find (GstTypeFind * tf, gpointer unused)
           gst_type_find_suggest (tf, GST_TYPE_FIND_MAXIMUM - 1, caps);
           gst_caps_unref (caps);
           return;
-        }
+        } else
+          return;
       } else
         return;
     } else
index 43144f3..7e9aba1 100644 (file)
@@ -74,6 +74,7 @@ check_PROGRAMS = \
        elements/volume \
        generic/clock-selection \
        generic/states \
+       gst/typefindfunctions \
        libs/audio \
        libs/cddabasesrc \
        libs/tag \
@@ -198,6 +199,9 @@ elements_vorbistag_CFLAGS = \
        $(VORBIS_CFLAGS) \
        $(CFLAGS) $(AM_CFLAGS)
 
+gst_typefindfunctions_CFLAGS = $(GST_BASE_CFLAGS) $(AM_CFLAGS)
+gst_typefindfunctions_LDADD = $(GST_BASE_LIBS) $(LDADD)
+
 libs_video_CFLAGS = \
        $(GST_PLUGINS_BASE_CFLAGS) \
        $(GST_BASE_CFLAGS) \
diff --git a/tests/check/gst/.gitignore b/tests/check/gst/.gitignore
new file mode 100644 (file)
index 0000000..67adce0
--- /dev/null
@@ -0,0 +1 @@
+typefindfunctions
diff --git a/tests/check/gst/typefindfunctions.c b/tests/check/gst/typefindfunctions.c
new file mode 100644 (file)
index 0000000..e74aaf3
--- /dev/null
@@ -0,0 +1,96 @@
+/* GStreamer unit tests for the -base typefind functions
+ *
+ * Copyright (C) 2007 Tim-Philipp Müller <tim centricular net>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <gst/check/gstcheck.h>
+#include <gst/base/gsttypefindhelper.h>
+
+GST_START_TEST (test_quicktime_mpeg4video)
+{
+  /* quicktime redirect file which starts with what could also be interpreted
+   * as an MPEG-4 video object layer start code */
+  const guint8 qt_redirect_396042[] =
+      { 0x00, 0x00, 0x01, 0x22, 0x6d, 0x6f, 0x6f, 0x76, 0x00, 0x00, 0x01, 0x1a,
+    0x72, 0x6d, 0x72, 0x61, 0x00, 0x00, 0x00, 0x86, 0x72, 0x6d, 0x64, 0x61,
+    0x00, 0x00, 0x00, 0x54, 0x72, 0x64, 0x72, 0x66, 0x00, 0x00, 0x00, 0x00,
+    0x75, 0x72, 0x6c, 0x20, 0x00, 0x00, 0x00, 0x40, 0x68, 0x74, 0x74, 0x70,
+    0x3a, 0x2f, 0x2f, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x2e, 0x71, 0x74,
+    0x76, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x63, 0x6f, 0x6d, 0x2f,
+    0x65, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x2f, 0x6a, 0x61, 0x6e, 0x2f, 0x6a,
+    0x34, 0x37, 0x64, 0x35, 0x32, 0x6f, 0x6f, 0x2f, 0x71, 0x74, 0x37, 0x72,
+    0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x64, 0x2e, 0x6d, 0x6f, 0x76, 0x00,
+    0x00, 0x00, 0x00, 0x10, 0x72, 0x6d, 0x64, 0x72, 0x00, 0x00, 0x00, 0x00,
+    0x00, 0x00, 0x0a, 0xf0, 0x00, 0x00, 0x00, 0x1a, 0x72, 0x6d, 0x76, 0x63,
+    0x00, 0x00, 0x00, 0x00, 0x71, 0x74, 0x69, 0x6d, 0x06, 0x50, 0x00, 0x00,
+    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x8c, 0x72, 0x6d,
+    0x64, 0x61, 0x00, 0x00, 0x00, 0x5a, 0x72, 0x64, 0x72, 0x66, 0x00, 0x00,
+    0x00, 0x00, 0x75, 0x72, 0x6c, 0x20, 0x00, 0x00, 0x00, 0x46, 0x68, 0x74,
+    0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x2e,
+    0x71, 0x74, 0x76, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x63, 0x6f,
+    0x6d, 0x2f, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x2f, 0x6a, 0x61, 0x6e,
+    0x2f, 0x6a, 0x34, 0x37, 0x64, 0x35, 0x32, 0x6f, 0x6f, 0x2f, 0x38, 0x38,
+    0x34, 0x38, 0x31, 0x32, 0x35, 0x5f, 0x32, 0x5f, 0x33, 0x35, 0x30, 0x5f,
+    0x72, 0x65, 0x66, 0x2e, 0x6d, 0x6f, 0x76, 0x00, 0x00, 0x00, 0x00, 0x10,
+    0x72, 0x6d, 0x64, 0x72, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0xf0,
+    0x00, 0x00, 0x00, 0x1a, 0x72, 0x6d, 0x76, 0x63, 0x00, 0x00, 0x00, 0x00,
+    0x71, 0x74, 0x69, 0x6d, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+    0x00, 0x00
+  };
+  GstTypeFindProbability prob;
+  const gchar *type;
+  GstBuffer *buf;
+  GstCaps *caps = NULL;
+
+  buf = gst_buffer_new ();
+  GST_BUFFER_DATA (buf) = (guint8 *) qt_redirect_396042;
+  GST_BUFFER_SIZE (buf) = sizeof (qt_redirect_396042);
+  GST_BUFFER_OFFSET (buf) = 0;
+
+  caps = gst_type_find_helper_for_buffer (NULL, buf, &prob);
+  fail_unless (caps != NULL);
+  GST_LOG ("Found type: %" GST_PTR_FORMAT, caps);
+
+  type = gst_structure_get_name (gst_caps_get_structure (caps, 0));
+  fail_unless_equals_string (type, "video/quicktime");
+  fail_unless (prob > GST_TYPE_FIND_MINIMUM && prob <= GST_TYPE_FIND_MAXIMUM);
+
+  gst_buffer_unref (buf);
+  gst_caps_unref (caps);
+}
+
+GST_END_TEST;
+
+static Suite *
+typefindfunctions_suite (void)
+{
+  Suite *s = suite_create ("typefindfunctions");
+  TCase *tc_chain = tcase_create ("general");
+
+  suite_add_tcase (s, tc_chain);
+
+  tcase_add_test (tc_chain, test_quicktime_mpeg4video);
+
+  return s;
+}
+
+GST_CHECK_MAIN (typefindfunctions);