mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 12:11:13 +00:00
tests: fix some more tests
This commit is contained in:
parent
3a095a26b2
commit
56eb65babc
8 changed files with 101 additions and 44 deletions
|
@ -48,7 +48,7 @@ test_taglib_apev2mux_create_tags (guint32 mask)
|
|||
{
|
||||
GstTagList *tags;
|
||||
|
||||
tags = gst_tag_list_new ();
|
||||
tags = gst_tag_list_new_empty ();
|
||||
|
||||
if (mask & (1 << 0)) {
|
||||
gst_tag_list_add (tags, GST_TAG_MERGE_KEEP,
|
||||
|
@ -175,21 +175,27 @@ static void
|
|||
fill_mp3_buffer (GstElement * fakesrc, GstBuffer * buf, GstPad * pad,
|
||||
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,
|
||||
*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
|
||||
* because of the extra refcounts taken by the signal emission mechanism;
|
||||
* we know it's fine to use GST_BUFFER_CAPS() here though */
|
||||
GST_BUFFER_CAPS (buf) = gst_caps_new_simple ("audio/mpeg", "mpegversion",
|
||||
G_TYPE_INT, 1, "layer", G_TYPE_INT, 3, NULL);
|
||||
#endif
|
||||
|
||||
GST_BUFFER_OFFSET (buf) = *p_offset;
|
||||
*p_offset += GST_BUFFER_SIZE (buf);
|
||||
*p_offset += size;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -197,40 +203,47 @@ got_buffer (GstElement * fakesink, GstBuffer * buf, GstPad * pad,
|
|||
GstBuffer ** p_buf)
|
||||
{
|
||||
gint64 off;
|
||||
guint size;
|
||||
GstMapInfo map;
|
||||
|
||||
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));
|
||||
|
||||
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;
|
||||
|
||||
/* 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) {
|
||||
memcpy (GST_BUFFER_DATA (newbuf), GST_BUFFER_DATA (*p_buf),
|
||||
GST_BUFFER_SIZE (*p_buf));
|
||||
GstMapInfo pmap;
|
||||
|
||||
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)
|
||||
gst_buffer_unref (*p_buf);
|
||||
*p_buf = newbuf;
|
||||
} 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
|
||||
demux_pad_added (GstElement * apedemux, GstPad * srcpad, GstBuffer ** p_outbuf)
|
||||
{
|
||||
GstElement *fakesink, *pipeline;
|
||||
GstCaps *caps;
|
||||
|
||||
GST_LOG ("apedemux added source pad with caps %" GST_PTR_FORMAT,
|
||||
GST_PAD_CAPS (srcpad));
|
||||
caps = gst_pad_get_current_caps (srcpad);
|
||||
GST_LOG ("apedemux added source pad with caps %" GST_PTR_FORMAT, caps);
|
||||
gst_caps_unref (caps);
|
||||
|
||||
pipeline = apedemux;
|
||||
while (GST_OBJECT_PARENT (pipeline) != NULL)
|
||||
|
@ -252,15 +265,17 @@ demux_pad_added (GstElement * apedemux, GstPad * srcpad, GstBuffer ** p_outbuf)
|
|||
static void
|
||||
test_taglib_apev2mux_check_output_buffer (GstBuffer * buf)
|
||||
{
|
||||
guint8 *data = GST_BUFFER_DATA (buf);
|
||||
guint size = GST_BUFFER_SIZE (buf);
|
||||
GstMapInfo map;
|
||||
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) {
|
||||
fail_unless (memcmp (data + off, mp3_dummyhdr, sizeof (mp3_dummyhdr)) == 0);
|
||||
for (off = 0; off < map.size; off += MP3_FRAME_SIZE) {
|
||||
fail_unless (memcmp (map.data + off, mp3_dummyhdr,
|
||||
sizeof (mp3_dummyhdr)) == 0);
|
||||
}
|
||||
gst_buffer_unmap (buf, &map);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -18,6 +18,10 @@
|
|||
* 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/check/gstcheck.h>
|
||||
|
||||
|
|
|
@ -18,6 +18,10 @@
|
|||
* 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/check/gstcheck.h>
|
||||
|
||||
|
|
|
@ -21,6 +21,10 @@
|
|||
* 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/tag/tag.h>
|
||||
|
||||
|
|
|
@ -64,7 +64,7 @@ test_taglib_id3mux_create_tags (guint32 mask)
|
|||
{
|
||||
GstTagList *tags;
|
||||
|
||||
tags = gst_tag_list_new ();
|
||||
tags = gst_tag_list_new_empty ();
|
||||
|
||||
if (mask & (1 << 0)) {
|
||||
gst_tag_list_add (tags, GST_TAG_MERGE_KEEP,
|
||||
|
@ -130,13 +130,17 @@ static gboolean
|
|||
utf8_string_in_buf (GstBuffer * buf, const gchar * s)
|
||||
{
|
||||
gint i, len;
|
||||
GstMapInfo map;
|
||||
|
||||
len = strlen (s);
|
||||
for (i = 0; i < (GST_BUFFER_SIZE (buf) - len); ++i) {
|
||||
if (memcmp (GST_BUFFER_DATA (buf) + i, s, len) == 0) {
|
||||
gst_buffer_map (buf, &map, GST_MAP_READ);
|
||||
for (i = 0; i < (map.size - len); ++i) {
|
||||
if (memcmp (map.data + i, s, len) == 0) {
|
||||
gst_buffer_unmap (buf, &map);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
gst_buffer_unmap (buf, &map);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -256,21 +260,27 @@ static void
|
|||
fill_mp3_buffer (GstElement * fakesrc, GstBuffer * buf, GstPad * pad,
|
||||
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,
|
||||
*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
|
||||
* because of the extra refcounts taken by the signal emission mechanism;
|
||||
* we know it's fine to use GST_BUFFER_CAPS() here though */
|
||||
GST_BUFFER_CAPS (buf) = gst_caps_new_simple ("audio/mpeg", "mpegversion",
|
||||
G_TYPE_INT, 1, "layer", G_TYPE_INT, 3, NULL);
|
||||
#endif
|
||||
|
||||
GST_BUFFER_OFFSET (buf) = *p_offset;
|
||||
*p_offset += GST_BUFFER_SIZE (buf);
|
||||
*p_offset += size;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -278,40 +288,48 @@ got_buffer (GstElement * fakesink, GstBuffer * buf, GstPad * pad,
|
|||
GstBuffer ** p_buf)
|
||||
{
|
||||
gint64 off;
|
||||
guint size;
|
||||
GstMapInfo map;
|
||||
|
||||
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));
|
||||
|
||||
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;
|
||||
|
||||
/* 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) {
|
||||
memcpy (GST_BUFFER_DATA (newbuf), GST_BUFFER_DATA (*p_buf),
|
||||
GST_BUFFER_SIZE (*p_buf));
|
||||
GstMapInfo pmap;
|
||||
|
||||
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)
|
||||
gst_buffer_unref (*p_buf);
|
||||
*p_buf = newbuf;
|
||||
} 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
|
||||
demux_pad_added (GstElement * id3demux, GstPad * srcpad, GstBuffer ** p_outbuf)
|
||||
{
|
||||
GstElement *fakesink, *pipeline;
|
||||
GstCaps *caps;
|
||||
|
||||
GST_LOG ("id3demux added source pad with caps %" GST_PTR_FORMAT,
|
||||
GST_PAD_CAPS (srcpad));
|
||||
caps = gst_pad_get_current_caps (srcpad);
|
||||
GST_LOG ("id3demux added source pad with caps %" GST_PTR_FORMAT, caps);
|
||||
gst_caps_unref (caps);
|
||||
|
||||
pipeline = id3demux;
|
||||
while (GST_OBJECT_PARENT (pipeline) != NULL)
|
||||
|
@ -333,15 +351,17 @@ demux_pad_added (GstElement * id3demux, GstPad * srcpad, GstBuffer ** p_outbuf)
|
|||
static void
|
||||
test_taglib_id3mux_check_output_buffer (GstBuffer * buf)
|
||||
{
|
||||
guint8 *data = GST_BUFFER_DATA (buf);
|
||||
guint size = GST_BUFFER_SIZE (buf);
|
||||
GstMapInfo map;
|
||||
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) {
|
||||
fail_unless (memcmp (data + off, mp3_dummyhdr, sizeof (mp3_dummyhdr)) == 0);
|
||||
for (off = 0; off < map.size; off += MP3_FRAME_SIZE) {
|
||||
fail_unless (memcmp (map.data + off, mp3_dummyhdr,
|
||||
sizeof (mp3_dummyhdr)) == 0);
|
||||
}
|
||||
gst_buffer_unmap (buf, &map);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -18,6 +18,10 @@
|
|||
* 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
|
||||
# include "config.h"
|
||||
#endif
|
||||
|
|
|
@ -153,8 +153,10 @@ setup_element (const gchar * factory, GstStaticPadTemplate * sink_template,
|
|||
sinkpad = gst_check_setup_sink_pad (element, sink_template);
|
||||
gst_pad_set_active (srcpad, TRUE);
|
||||
gst_pad_set_active (sinkpad, TRUE);
|
||||
fail_unless (gst_pad_set_caps (srcpad, src_caps));
|
||||
fail_unless (gst_pad_set_caps (sinkpad, sink_caps));
|
||||
if (src_caps)
|
||||
fail_unless (gst_pad_set_caps (srcpad, src_caps));
|
||||
if (sink_caps)
|
||||
fail_unless (gst_pad_set_caps (sinkpad, sink_caps));
|
||||
|
||||
bus = gst_bus_new ();
|
||||
gst_element_set_bus (element, bus);
|
||||
|
|
|
@ -20,6 +20,10 @@
|
|||
* 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/audio/audio.h>
|
||||
#include <gst/audio/audio-enumtypes.h>
|
||||
|
|
Loading…
Reference in a new issue