tests: fix some more tests

This commit is contained in:
Wim Taymans 2012-02-03 16:13:51 +01:00
parent 3a095a26b2
commit 56eb65babc
8 changed files with 101 additions and 44 deletions

View file

@ -48,7 +48,7 @@ test_taglib_apev2mux_create_tags (guint32 mask)
{ {
GstTagList *tags; GstTagList *tags;
tags = gst_tag_list_new (); tags = gst_tag_list_new_empty ();
if (mask & (1 << 0)) { if (mask & (1 << 0)) {
gst_tag_list_add (tags, GST_TAG_MERGE_KEEP, gst_tag_list_add (tags, GST_TAG_MERGE_KEEP,
@ -175,21 +175,27 @@ static void
fill_mp3_buffer (GstElement * fakesrc, GstBuffer * buf, GstPad * pad, fill_mp3_buffer (GstElement * fakesrc, GstBuffer * buf, GstPad * pad,
guint64 * p_offset) guint64 * p_offset)
{ {
fail_unless (GST_BUFFER_SIZE (buf) == MP3_FRAME_SIZE); gsize size;
size = gst_buffer_get_size (buf);
fail_unless (size == MP3_FRAME_SIZE);
GST_LOG ("filling buffer with fake mp3 data, offset = %" G_GUINT64_FORMAT, GST_LOG ("filling buffer with fake mp3 data, offset = %" G_GUINT64_FORMAT,
*p_offset); *p_offset);
memcpy (GST_BUFFER_DATA (buf), mp3_dummyhdr, sizeof (mp3_dummyhdr)); gst_buffer_fill (buf, 0, mp3_dummyhdr, sizeof (mp3_dummyhdr));
#if 0
/* can't use gst_buffer_set_caps() here because the metadata isn't writable /* can't use gst_buffer_set_caps() here because the metadata isn't writable
* because of the extra refcounts taken by the signal emission mechanism; * because of the extra refcounts taken by the signal emission mechanism;
* we know it's fine to use GST_BUFFER_CAPS() here though */ * we know it's fine to use GST_BUFFER_CAPS() here though */
GST_BUFFER_CAPS (buf) = gst_caps_new_simple ("audio/mpeg", "mpegversion", GST_BUFFER_CAPS (buf) = gst_caps_new_simple ("audio/mpeg", "mpegversion",
G_TYPE_INT, 1, "layer", G_TYPE_INT, 3, NULL); G_TYPE_INT, 1, "layer", G_TYPE_INT, 3, NULL);
#endif
GST_BUFFER_OFFSET (buf) = *p_offset; GST_BUFFER_OFFSET (buf) = *p_offset;
*p_offset += GST_BUFFER_SIZE (buf); *p_offset += size;
} }
static void static void
@ -197,40 +203,47 @@ got_buffer (GstElement * fakesink, GstBuffer * buf, GstPad * pad,
GstBuffer ** p_buf) GstBuffer ** p_buf)
{ {
gint64 off; gint64 off;
guint size; GstMapInfo map;
off = GST_BUFFER_OFFSET (buf); off = GST_BUFFER_OFFSET (buf);
size = GST_BUFFER_SIZE (buf);
GST_LOG ("got buffer, size=%u, offset=%" G_GINT64_FORMAT, size, off); gst_buffer_map (buf, &map, GST_MAP_READ);
GST_LOG ("got buffer, size=%u, offset=%" G_GINT64_FORMAT, map.size, off);
fail_unless (GST_BUFFER_OFFSET_IS_VALID (buf)); fail_unless (GST_BUFFER_OFFSET_IS_VALID (buf));
if (*p_buf == NULL || (off + size) > GST_BUFFER_SIZE (*p_buf)) { if (*p_buf == NULL || (off + map.size) > gst_buffer_get_size (*p_buf)) {
GstBuffer *newbuf; GstBuffer *newbuf;
/* not very elegant, but who cares */ /* not very elegant, but who cares */
newbuf = gst_buffer_new_and_alloc (off + size); newbuf = gst_buffer_new_and_alloc (off + map.size);
if (*p_buf) { if (*p_buf) {
memcpy (GST_BUFFER_DATA (newbuf), GST_BUFFER_DATA (*p_buf), GstMapInfo pmap;
GST_BUFFER_SIZE (*p_buf));
gst_buffer_map (*p_buf, &pmap, GST_MAP_READ);
gst_buffer_fill (newbuf, 0, pmap.data, pmap.size);
gst_buffer_unmap (*p_buf, &pmap);
} }
memcpy (GST_BUFFER_DATA (newbuf) + off, GST_BUFFER_DATA (buf), size); gst_buffer_fill (newbuf, off, map.data, map.size);
if (*p_buf) if (*p_buf)
gst_buffer_unref (*p_buf); gst_buffer_unref (*p_buf);
*p_buf = newbuf; *p_buf = newbuf;
} else { } else {
memcpy (GST_BUFFER_DATA (*p_buf) + off, GST_BUFFER_DATA (buf), size); gst_buffer_fill (*p_buf, off, map.data, map.size);
} }
gst_buffer_unmap (buf, &map);
} }
static void static void
demux_pad_added (GstElement * apedemux, GstPad * srcpad, GstBuffer ** p_outbuf) demux_pad_added (GstElement * apedemux, GstPad * srcpad, GstBuffer ** p_outbuf)
{ {
GstElement *fakesink, *pipeline; GstElement *fakesink, *pipeline;
GstCaps *caps;
GST_LOG ("apedemux added source pad with caps %" GST_PTR_FORMAT, caps = gst_pad_get_current_caps (srcpad);
GST_PAD_CAPS (srcpad)); GST_LOG ("apedemux added source pad with caps %" GST_PTR_FORMAT, caps);
gst_caps_unref (caps);
pipeline = apedemux; pipeline = apedemux;
while (GST_OBJECT_PARENT (pipeline) != NULL) while (GST_OBJECT_PARENT (pipeline) != NULL)
@ -252,15 +265,17 @@ demux_pad_added (GstElement * apedemux, GstPad * srcpad, GstBuffer ** p_outbuf)
static void static void
test_taglib_apev2mux_check_output_buffer (GstBuffer * buf) test_taglib_apev2mux_check_output_buffer (GstBuffer * buf)
{ {
guint8 *data = GST_BUFFER_DATA (buf); GstMapInfo map;
guint size = GST_BUFFER_SIZE (buf);
guint off; guint off;
g_assert (size % MP3_FRAME_SIZE == 0); gst_buffer_map (buf, &map, GST_MAP_READ);
g_assert (map.size % MP3_FRAME_SIZE == 0);
for (off = 0; off < size; off += MP3_FRAME_SIZE) { for (off = 0; off < map.size; off += MP3_FRAME_SIZE) {
fail_unless (memcmp (data + off, mp3_dummyhdr, sizeof (mp3_dummyhdr)) == 0); fail_unless (memcmp (map.data + off, mp3_dummyhdr,
sizeof (mp3_dummyhdr)) == 0);
} }
gst_buffer_unmap (buf, &map);
} }
static void static void

View file

@ -18,6 +18,10 @@
* 02110-1301 USA * 02110-1301 USA
*/ */
/* FIXME 0.11: suppress warnings for deprecated API such as GValueArray
* with newer GLib versions (>= 2.31.0) */
#define GLIB_DISABLE_DEPRECATION_WARNINGS
#include <gst/gst.h> #include <gst/gst.h>
#include <gst/check/gstcheck.h> #include <gst/check/gstcheck.h>

View file

@ -18,6 +18,10 @@
* 02110-1301 USA * 02110-1301 USA
*/ */
/* FIXME 0.11: suppress warnings for deprecated API such as GValueArray
* with newer GLib versions (>= 2.31.0) */
#define GLIB_DISABLE_DEPRECATION_WARNINGS
#include <gst/gst.h> #include <gst/gst.h>
#include <gst/check/gstcheck.h> #include <gst/check/gstcheck.h>

View file

@ -21,6 +21,10 @@
* Boston, MA 02111-1307, USA. * Boston, MA 02111-1307, USA.
*/ */
/* FIXME 0.11: suppress warnings for deprecated API such as GValueArray
* with newer GLib versions (>= 2.31.0) */
#define GLIB_DISABLE_DEPRECATION_WARNINGS
#include <gst/check/gstcheck.h> #include <gst/check/gstcheck.h>
#include <gst/tag/tag.h> #include <gst/tag/tag.h>

View file

@ -64,7 +64,7 @@ test_taglib_id3mux_create_tags (guint32 mask)
{ {
GstTagList *tags; GstTagList *tags;
tags = gst_tag_list_new (); tags = gst_tag_list_new_empty ();
if (mask & (1 << 0)) { if (mask & (1 << 0)) {
gst_tag_list_add (tags, GST_TAG_MERGE_KEEP, gst_tag_list_add (tags, GST_TAG_MERGE_KEEP,
@ -130,13 +130,17 @@ static gboolean
utf8_string_in_buf (GstBuffer * buf, const gchar * s) utf8_string_in_buf (GstBuffer * buf, const gchar * s)
{ {
gint i, len; gint i, len;
GstMapInfo map;
len = strlen (s); len = strlen (s);
for (i = 0; i < (GST_BUFFER_SIZE (buf) - len); ++i) { gst_buffer_map (buf, &map, GST_MAP_READ);
if (memcmp (GST_BUFFER_DATA (buf) + i, s, len) == 0) { for (i = 0; i < (map.size - len); ++i) {
if (memcmp (map.data + i, s, len) == 0) {
gst_buffer_unmap (buf, &map);
return TRUE; return TRUE;
} }
} }
gst_buffer_unmap (buf, &map);
return FALSE; return FALSE;
} }
@ -256,21 +260,27 @@ static void
fill_mp3_buffer (GstElement * fakesrc, GstBuffer * buf, GstPad * pad, fill_mp3_buffer (GstElement * fakesrc, GstBuffer * buf, GstPad * pad,
guint64 * p_offset) guint64 * p_offset)
{ {
fail_unless (GST_BUFFER_SIZE (buf) == MP3_FRAME_SIZE); gsize size;
size = gst_buffer_get_size (buf);
fail_unless (size == MP3_FRAME_SIZE);
GST_LOG ("filling buffer with fake mp3 data, offset = %" G_GUINT64_FORMAT, GST_LOG ("filling buffer with fake mp3 data, offset = %" G_GUINT64_FORMAT,
*p_offset); *p_offset);
memcpy (GST_BUFFER_DATA (buf), mp3_dummyhdr, sizeof (mp3_dummyhdr)); gst_buffer_fill (buf, 0, mp3_dummyhdr, sizeof (mp3_dummyhdr));
#if 0
/* can't use gst_buffer_set_caps() here because the metadata isn't writable /* can't use gst_buffer_set_caps() here because the metadata isn't writable
* because of the extra refcounts taken by the signal emission mechanism; * because of the extra refcounts taken by the signal emission mechanism;
* we know it's fine to use GST_BUFFER_CAPS() here though */ * we know it's fine to use GST_BUFFER_CAPS() here though */
GST_BUFFER_CAPS (buf) = gst_caps_new_simple ("audio/mpeg", "mpegversion", GST_BUFFER_CAPS (buf) = gst_caps_new_simple ("audio/mpeg", "mpegversion",
G_TYPE_INT, 1, "layer", G_TYPE_INT, 3, NULL); G_TYPE_INT, 1, "layer", G_TYPE_INT, 3, NULL);
#endif
GST_BUFFER_OFFSET (buf) = *p_offset; GST_BUFFER_OFFSET (buf) = *p_offset;
*p_offset += GST_BUFFER_SIZE (buf); *p_offset += size;
} }
static void static void
@ -278,40 +288,48 @@ got_buffer (GstElement * fakesink, GstBuffer * buf, GstPad * pad,
GstBuffer ** p_buf) GstBuffer ** p_buf)
{ {
gint64 off; gint64 off;
guint size; GstMapInfo map;
off = GST_BUFFER_OFFSET (buf); off = GST_BUFFER_OFFSET (buf);
size = GST_BUFFER_SIZE (buf);
GST_LOG ("got buffer, size=%u, offset=%" G_GINT64_FORMAT, size, off); gst_buffer_map (buf, &map, GST_MAP_READ);
GST_LOG ("got buffer, size=%u, offset=%" G_GINT64_FORMAT, map.size, off);
fail_unless (GST_BUFFER_OFFSET_IS_VALID (buf)); fail_unless (GST_BUFFER_OFFSET_IS_VALID (buf));
if (*p_buf == NULL || (off + size) > GST_BUFFER_SIZE (*p_buf)) { if (*p_buf == NULL || (off + map.size) > gst_buffer_get_size (*p_buf)) {
GstBuffer *newbuf; GstBuffer *newbuf;
/* not very elegant, but who cares */ /* not very elegant, but who cares */
newbuf = gst_buffer_new_and_alloc (off + size); newbuf = gst_buffer_new_and_alloc (off + map.size);
if (*p_buf) { if (*p_buf) {
memcpy (GST_BUFFER_DATA (newbuf), GST_BUFFER_DATA (*p_buf), GstMapInfo pmap;
GST_BUFFER_SIZE (*p_buf));
gst_buffer_map (*p_buf, &pmap, GST_MAP_READ);
gst_buffer_fill (newbuf, 0, pmap.data, pmap.size);
gst_buffer_unmap (*p_buf, &pmap);
} }
memcpy (GST_BUFFER_DATA (newbuf) + off, GST_BUFFER_DATA (buf), size); gst_buffer_fill (newbuf, off, map.data, map.size);
if (*p_buf) if (*p_buf)
gst_buffer_unref (*p_buf); gst_buffer_unref (*p_buf);
*p_buf = newbuf; *p_buf = newbuf;
} else { } else {
memcpy (GST_BUFFER_DATA (*p_buf) + off, GST_BUFFER_DATA (buf), size); gst_buffer_fill (*p_buf, off, map.data, map.size);
} }
gst_buffer_unmap (buf, &map);
} }
static void static void
demux_pad_added (GstElement * id3demux, GstPad * srcpad, GstBuffer ** p_outbuf) demux_pad_added (GstElement * id3demux, GstPad * srcpad, GstBuffer ** p_outbuf)
{ {
GstElement *fakesink, *pipeline; GstElement *fakesink, *pipeline;
GstCaps *caps;
GST_LOG ("id3demux added source pad with caps %" GST_PTR_FORMAT, caps = gst_pad_get_current_caps (srcpad);
GST_PAD_CAPS (srcpad)); GST_LOG ("id3demux added source pad with caps %" GST_PTR_FORMAT, caps);
gst_caps_unref (caps);
pipeline = id3demux; pipeline = id3demux;
while (GST_OBJECT_PARENT (pipeline) != NULL) while (GST_OBJECT_PARENT (pipeline) != NULL)
@ -333,15 +351,17 @@ demux_pad_added (GstElement * id3demux, GstPad * srcpad, GstBuffer ** p_outbuf)
static void static void
test_taglib_id3mux_check_output_buffer (GstBuffer * buf) test_taglib_id3mux_check_output_buffer (GstBuffer * buf)
{ {
guint8 *data = GST_BUFFER_DATA (buf); GstMapInfo map;
guint size = GST_BUFFER_SIZE (buf);
guint off; guint off;
g_assert (size % MP3_FRAME_SIZE == 0); gst_buffer_map (buf, &map, GST_MAP_READ);
g_assert (map.size % MP3_FRAME_SIZE == 0);
for (off = 0; off < size; off += MP3_FRAME_SIZE) { for (off = 0; off < map.size; off += MP3_FRAME_SIZE) {
fail_unless (memcmp (data + off, mp3_dummyhdr, sizeof (mp3_dummyhdr)) == 0); fail_unless (memcmp (map.data + off, mp3_dummyhdr,
sizeof (mp3_dummyhdr)) == 0);
} }
gst_buffer_unmap (buf, &map);
} }
static void static void

View file

@ -18,6 +18,10 @@
* Boston, MA 02111-1307, USA. * Boston, MA 02111-1307, USA.
*/ */
/* FIXME 0.11: suppress warnings for deprecated API such as GValueArray
* with newer GLib versions (>= 2.31.0) */
#define GLIB_DISABLE_DEPRECATION_WARNINGS
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
# include "config.h" # include "config.h"
#endif #endif

View file

@ -153,7 +153,9 @@ setup_element (const gchar * factory, GstStaticPadTemplate * sink_template,
sinkpad = gst_check_setup_sink_pad (element, sink_template); sinkpad = gst_check_setup_sink_pad (element, sink_template);
gst_pad_set_active (srcpad, TRUE); gst_pad_set_active (srcpad, TRUE);
gst_pad_set_active (sinkpad, TRUE); gst_pad_set_active (sinkpad, TRUE);
if (src_caps)
fail_unless (gst_pad_set_caps (srcpad, src_caps)); fail_unless (gst_pad_set_caps (srcpad, src_caps));
if (sink_caps)
fail_unless (gst_pad_set_caps (sinkpad, sink_caps)); fail_unless (gst_pad_set_caps (sinkpad, sink_caps));
bus = gst_bus_new (); bus = gst_bus_new ();

View file

@ -20,6 +20,10 @@
* Boston, MA 02111-1307, USA. * Boston, MA 02111-1307, USA.
*/ */
/* FIXME 0.11: suppress warnings for deprecated API such as GValueArray
* with newer GLib versions (>= 2.31.0) */
#define GLIB_DISABLE_DEPRECATION_WARNINGS
#include <gst/check/gstcheck.h> #include <gst/check/gstcheck.h>
#include <gst/audio/audio.h> #include <gst/audio/audio.h>
#include <gst/audio/audio-enumtypes.h> #include <gst/audio/audio-enumtypes.h>