Commit 06b3c265 authored by Wim Taymans's avatar Wim Taymans

test: make more unit tests compile

parent 08d8b810
......@@ -233,6 +233,16 @@ elements_audiowsincband_LDADD = $(GST_PLUGINS_BASE_LIBS) -lgstaudio-$(GST_MAJORM
elements_audiowsinclimit_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(CFLAGS) $(AM_CFLAGS)
elements_audiowsinclimit_LDADD = $(GST_PLUGINS_BASE_LIBS) -lgstaudio-$(GST_MAJORMINOR) $(LDADD)
elements_equalizer_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(CFLAGS) $(AM_CFLAGS)
elements_equalizer_LDADD = $(GST_PLUGINS_BASE_LIBS) -lgstaudio-$(GST_MAJORMINOR) $(LDADD)
elements_rganalysis_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(CFLAGS) $(AM_CFLAGS)
elements_rganalysis_LDADD = $(GST_PLUGINS_BASE_LIBS) -lgstaudio-$(GST_MAJORMINOR) $(LDADD)
elements_rglimiter_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(CFLAGS) $(AM_CFLAGS)
elements_rglimiter_LDADD = $(GST_PLUGINS_BASE_LIBS) -lgstaudio-$(GST_MAJORMINOR) $(LDADD)
elements_rgvolume_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(CFLAGS) $(AM_CFLAGS)
elements_rgvolume_LDADD = $(GST_PLUGINS_BASE_LIBS) -lgstaudio-$(GST_MAJORMINOR) $(LDADD)
elements_cmmldec_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(CFLAGS) $(AM_CFLAGS)
elements_cmmlenc_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(CFLAGS) $(AM_CFLAGS)
......@@ -246,6 +256,9 @@ elements_deinterleave_LDADD = $(GST_PLUGINS_BASE_LIBS) -lgstaudio-$(GST_MAJORMIN
elements_interleave_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(CFLAGS) $(AM_CFLAGS)
elements_interleave_LDADD = $(GST_PLUGINS_BASE_LIBS) -lgstaudio-$(GST_MAJORMINOR) $(LDADD)
elements_level_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(CFLAGS) $(AM_CFLAGS)
elements_level_LDADD = $(GST_PLUGINS_BASE_LIBS) -lgstaudio-$(GST_MAJORMINOR) $(LDADD)
elements_imagefreeze_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_BASE_CFLAGS) $(AM_CFLAGS)
elements_imagefreeze_LDADD = $(GST_PLUGINS_BASE_LIBS) -lgstvideo-$(GST_MAJORMINOR) $(GST_BASE_LIBS) $(LDADD)
......
......@@ -21,6 +21,7 @@
*/
#include <gst/gst.h>
#include <gst/audio/audio.h>
#include <gst/base/gstbasetransform.h>
#include <gst/check/gstcheck.h>
......@@ -31,28 +32,25 @@
* get_peer, and then remove references in every test function */
GstPad *mysrcpad, *mysinkpad;
#define EQUALIZER_CAPS_STRING \
"audio/x-raw-float, " \
"channels = (int) 1, " \
"rate = (int) 48000, " \
"endianness = (int) BYTE_ORDER, " \
"width = (int) 64" \
#define EQUALIZER_CAPS_STRING \
"audio/x-raw, " \
"format = (string) "GST_AUDIO_NE (F64) ", " \
"channels = (int) 1, " \
"rate = (int) 48000"
static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_STATIC_CAPS ("audio/x-raw-float, "
"channels = (int) 1, "
"rate = (int) 48000, "
"endianness = (int) BYTE_ORDER, " "width = (int) 64 ")
GST_STATIC_CAPS ("audio/x-raw, "
"format = (string) " GST_AUDIO_NE (F64) ", "
"channels = (int) 1, " "rate = (int) 48000")
);
static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
GST_STATIC_CAPS ("audio/x-raw-float, "
"channels = (int) 1, "
"rate = (int) 48000, "
"endianness = (int) BYTE_ORDER, " "width = (int) 64 ")
GST_STATIC_CAPS ("audio/x-raw, "
"format = (string) " GST_AUDIO_NE (F64) ", "
"channels = (int) 1, " "rate = (int) 48000")
);
static GstElement *
......@@ -105,12 +103,13 @@ GST_START_TEST (test_equalizer_5bands_passthrough)
"could not set to playing");
inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gdouble));
in = (gdouble *) GST_BUFFER_DATA (inbuffer);
in = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE);
for (i = 0; i < 1024; i++)
in[i] = g_random_double_range (-1.0, 1.0);
gst_buffer_unmap (inbuffer, in, -1);
caps = gst_caps_from_string (EQUALIZER_CAPS_STRING);
gst_buffer_set_caps (inbuffer, caps);
gst_pad_set_caps (mysrcpad, caps);
gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
......@@ -120,10 +119,11 @@ GST_START_TEST (test_equalizer_5bands_passthrough)
/* ... and puts a new buffer on the global list */
fail_unless (g_list_length (buffers) == 1);
res = (gdouble *) GST_BUFFER_DATA (GST_BUFFER (buffers->data));
res = gst_buffer_map (GST_BUFFER (buffers->data), NULL, NULL, GST_MAP_READ);
for (i = 0; i < 1024; i++)
fail_unless_equals_float (in[i], res[i]);
gst_buffer_unmap (GST_BUFFER (buffers->data), res, -1);
/* cleanup */
cleanup_equalizer (equalizer);
......@@ -159,9 +159,10 @@ GST_START_TEST (test_equalizer_5bands_minus_24)
"could not set to playing");
inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gdouble));
in = (gdouble *) GST_BUFFER_DATA (inbuffer);
in = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE);
for (i = 0; i < 1024; i++)
in[i] = g_random_double_range (-1.0, 1.0);
gst_buffer_unmap (inbuffer, in, -1);
rms_in = 0.0;
for (i = 0; i < 1024; i++)
......@@ -169,7 +170,7 @@ GST_START_TEST (test_equalizer_5bands_minus_24)
rms_in = sqrt (rms_in / 1024);
caps = gst_caps_from_string (EQUALIZER_CAPS_STRING);
gst_buffer_set_caps (inbuffer, caps);
gst_pad_set_caps (mysrcpad, caps);
gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
......@@ -179,12 +180,13 @@ GST_START_TEST (test_equalizer_5bands_minus_24)
/* ... and puts a new buffer on the global list */
fail_unless (g_list_length (buffers) == 1);
res = (gdouble *) GST_BUFFER_DATA (GST_BUFFER (buffers->data));
res = gst_buffer_map (GST_BUFFER (buffers->data), NULL, NULL, GST_MAP_READ);
rms_out = 0.0;
for (i = 0; i < 1024; i++)
rms_out += res[i] * res[i];
rms_out = sqrt (rms_out / 1024);
gst_buffer_unmap (GST_BUFFER (buffers->data), res, -1);
fail_unless (rms_in > rms_out);
......@@ -222,9 +224,10 @@ GST_START_TEST (test_equalizer_5bands_plus_12)
"could not set to playing");
inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gdouble));
in = (gdouble *) GST_BUFFER_DATA (inbuffer);
in = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE);
for (i = 0; i < 1024; i++)
in[i] = g_random_double_range (-1.0, 1.0);
gst_buffer_unmap (inbuffer, in, -1);
rms_in = 0.0;
for (i = 0; i < 1024; i++)
......@@ -232,7 +235,7 @@ GST_START_TEST (test_equalizer_5bands_plus_12)
rms_in = sqrt (rms_in / 1024);
caps = gst_caps_from_string (EQUALIZER_CAPS_STRING);
gst_buffer_set_caps (inbuffer, caps);
gst_pad_set_caps (mysrcpad, caps);
gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
......@@ -242,12 +245,13 @@ GST_START_TEST (test_equalizer_5bands_plus_12)
/* ... and puts a new buffer on the global list */
fail_unless (g_list_length (buffers) == 1);
res = (gdouble *) GST_BUFFER_DATA (GST_BUFFER (buffers->data));
res = gst_buffer_map (GST_BUFFER (buffers->data), NULL, NULL, GST_MAP_READ);
rms_out = 0.0;
for (i = 0; i < 1024; i++)
rms_out += res[i] * res[i];
rms_out = sqrt (rms_out / 1024);
gst_buffer_unmap (GST_BUFFER (buffers->data), res, -1);
fail_unless (rms_in < rms_out);
......
......@@ -229,11 +229,13 @@ GST_START_TEST (test_parse_flac_detect_stream)
fail_unless (G_VALUE_TYPE (bufval) == GST_TYPE_BUFFER);
buf = g_value_peek_pointer (bufval);
if (i == 0) {
fail_unless (GST_BUFFER_SIZE (buf) == sizeof (streaminfo_header));
fail_unless (memcmp (buf, streaminfo_header, sizeof (streaminfo_header)));
fail_unless (gst_buffer_get_size (buf) == sizeof (streaminfo_header));
fail_unless (gst_buffer_memcmp (buf, 0, streaminfo_header,
sizeof (streaminfo_header)));
} else if (i == 1) {
fail_unless (GST_BUFFER_SIZE (buf) == sizeof (comment_header));
fail_unless (memcmp (buf, comment_header, sizeof (comment_header)));
fail_unless (gst_buffer_get_size (buf) == sizeof (comment_header));
fail_unless (gst_buffer_memcmp (buf, 0, comment_header,
sizeof (comment_header)));
}
}
......@@ -242,24 +244,6 @@ GST_START_TEST (test_parse_flac_detect_stream)
GST_END_TEST;
GST_START_TEST (test_parse_flac_set_index)
{
GstElement *parse;
GstIndex *idx;
idx = gst_index_factory_make ("memindex");
if (idx == NULL)
return;
parse = gst_element_factory_make ("flacparse", NULL);
fail_unless (parse != NULL);
gst_object_ref_sink (idx);
gst_element_set_index (parse, GST_INDEX (idx));
gst_object_unref (idx);
gst_object_unref (parse);
}
GST_END_TEST;
static Suite *
flacparse_suite (void)
{
......@@ -275,7 +259,6 @@ flacparse_suite (void)
/* Other tests */
tcase_add_test (tc_chain, test_parse_flac_detect_stream);
tcase_add_test (tc_chain, test_parse_flac_set_index);
return s;
}
......
......@@ -55,8 +55,6 @@ handoff_cb (GstElement * element, GstBuffer * buf, GstPad * pad,
{
*p_counter += 1;
GST_LOG ("counter = %d", *p_counter);
fail_unless (GST_BUFFER_CAPS (buf) != NULL);
}
static void
......
......@@ -42,8 +42,6 @@ handoff_cb (GstElement * element, GstBuffer * buf, GstPad * pad,
{
*p_counter += 1;
GST_LOG ("counter = %d", *p_counter);
fail_unless (GST_BUFFER_CAPS (buf) != NULL);
}
static void
......
......@@ -140,11 +140,11 @@ push_data (const guint8 * data, int len, GstCaps * caps, gint64 offset)
GstFlowReturn res;
GstBuffer *buffer = gst_buffer_new_and_alloc (len);
memcpy (GST_BUFFER_DATA (buffer), data, len);
gst_buffer_set_caps (buffer, caps);
gst_buffer_fill (buffer, 0, data, len);
GST_BUFFER_OFFSET (buffer) = offset;
gst_pad_set_caps (srcpad, caps);
res = gst_pad_push (srcpad, buffer);
fail_unless (res == GST_FLOW_OK, "Failed pushing buffer: %d", res);
......@@ -228,9 +228,6 @@ GST_START_TEST (test_first_buf_offset_when_merged_for_typefinding)
/* first buffer should have offset 0 even after it was merged with 2nd buf */
fail_unless (GST_BUFFER_OFFSET (GST_BUFFER_CAST (buffers->data)) == 0);
/* first buffer should have caps set */
fail_unless (GST_BUFFER_CAPS (GST_BUFFER_CAST (buffers->data)) != NULL);
gst_caps_unref (icy_caps);
cleanup_icydemux ();
......
......@@ -125,11 +125,17 @@ GST_START_TEST (test_imagefreeze_0_1)
GMainLoop *loop;
guint n_buffers = G_MAXUINT;
guint bus_watch = 0;
GstVideoInfo i1, i2;
caps1 =
gst_video_format_new_caps (GST_VIDEO_FORMAT_xRGB, 640, 480, 25, 1, 1, 1);
caps2 =
gst_video_format_new_caps (GST_VIDEO_FORMAT_xRGB, 640, 480, 0, 1, 1, 1);
gst_video_info_init (&i1);
gst_video_info_set_format (&i1, GST_VIDEO_FORMAT_xRGB, 640, 480);
i1.fps_n = 25;
i1.fps_d = 1;
caps1 = gst_video_info_to_caps (&i1);
gst_video_info_init (&i2);
gst_video_info_set_format (&i2, GST_VIDEO_FORMAT_xRGB, 640, 480);
caps2 = gst_video_info_to_caps (&i2);
pipeline =
setup_imagefreeze (caps1, caps2, G_CALLBACK (sink_handoff_cb_0_1),
......@@ -188,11 +194,19 @@ GST_START_TEST (test_imagefreeze_25_1_0ms_400ms)
GMainLoop *loop;
guint n_buffers = G_MAXUINT;
guint bus_watch = 0;
GstVideoInfo i1, i2;
gst_video_info_init (&i1);
gst_video_info_set_format (&i1, GST_VIDEO_FORMAT_xRGB, 640, 480);
i1.fps_n = 25;
i1.fps_d = 1;
caps1 = gst_video_info_to_caps (&i1);
caps1 =
gst_video_format_new_caps (GST_VIDEO_FORMAT_xRGB, 640, 480, 25, 1, 1, 1);
caps2 =
gst_video_format_new_caps (GST_VIDEO_FORMAT_xRGB, 640, 480, 25, 1, 1, 1);
gst_video_info_init (&i2);
gst_video_info_set_format (&i2, GST_VIDEO_FORMAT_xRGB, 640, 480);
i2.fps_n = 25;
i2.fps_d = 1;
caps2 = gst_video_info_to_caps (&i2);
pipeline =
setup_imagefreeze (caps1, caps2,
......@@ -260,11 +274,19 @@ GST_START_TEST (test_imagefreeze_25_1_200ms_400ms)
GMainLoop *loop;
guint n_buffers = G_MAXUINT;
guint bus_watch = 0;
GstVideoInfo i1, i2;
gst_video_info_init (&i1);
gst_video_info_set_format (&i1, GST_VIDEO_FORMAT_xRGB, 640, 480);
i1.fps_n = 25;
i1.fps_d = 1;
caps1 = gst_video_info_to_caps (&i1);
caps1 =
gst_video_format_new_caps (GST_VIDEO_FORMAT_xRGB, 640, 480, 25, 1, 1, 1);
caps2 =
gst_video_format_new_caps (GST_VIDEO_FORMAT_xRGB, 640, 480, 25, 1, 1, 1);
gst_video_info_init (&i2);
gst_video_info_set_format (&i2, GST_VIDEO_FORMAT_xRGB, 640, 480);
i2.fps_n = 25;
i2.fps_d = 1;
caps2 = gst_video_info_to_caps (&i2);
pipeline =
setup_imagefreeze (caps1, caps2,
......@@ -332,11 +354,19 @@ GST_START_TEST (test_imagefreeze_25_1_400ms_0ms)
GMainLoop *loop;
guint n_buffers = G_MAXUINT;
guint bus_watch = 0;
GstVideoInfo i1, i2;
caps1 =
gst_video_format_new_caps (GST_VIDEO_FORMAT_xRGB, 640, 480, 25, 1, 1, 1);
caps2 =
gst_video_format_new_caps (GST_VIDEO_FORMAT_xRGB, 640, 480, 25, 1, 1, 1);
gst_video_info_init (&i1);
gst_video_info_set_format (&i1, GST_VIDEO_FORMAT_xRGB, 640, 480);
i1.fps_n = 25;
i1.fps_d = 1;
caps1 = gst_video_info_to_caps (&i1);
gst_video_info_init (&i2);
gst_video_info_set_format (&i2, GST_VIDEO_FORMAT_xRGB, 640, 480);
i2.fps_n = 25;
i2.fps_d = 1;
caps2 = gst_video_info_to_caps (&i2);
pipeline =
setup_imagefreeze (caps1, caps2,
......@@ -415,11 +445,19 @@ GST_START_TEST (test_imagefreeze_25_1_220ms_380ms)
GMainLoop *loop;
guint n_buffers = G_MAXUINT;
guint bus_watch = 0;
GstVideoInfo i1, i2;
gst_video_info_init (&i1);
gst_video_info_set_format (&i1, GST_VIDEO_FORMAT_xRGB, 640, 480);
i1.fps_n = 25;
i1.fps_d = 1;
caps1 = gst_video_info_to_caps (&i1);
caps1 =
gst_video_format_new_caps (GST_VIDEO_FORMAT_xRGB, 640, 480, 25, 1, 1, 1);
caps2 =
gst_video_format_new_caps (GST_VIDEO_FORMAT_xRGB, 640, 480, 25, 1, 1, 1);
gst_video_info_init (&i2);
gst_video_info_set_format (&i2, GST_VIDEO_FORMAT_xRGB, 640, 480);
i2.fps_n = 25;
i2.fps_d = 1;
caps2 = gst_video_info_to_caps (&i2);
pipeline =
setup_imagefreeze (caps1, caps2,
......@@ -460,104 +498,6 @@ GST_START_TEST (test_imagefreeze_25_1_220ms_380ms)
GST_END_TEST;
static GstBuffer *test_buffer = NULL;
static GstFlowReturn
test_bufferalloc (GstPad * pad, guint64 offset, guint size, GstCaps * caps,
GstBuffer ** buf)
{
fail_if (test_buffer != NULL);
test_buffer = gst_buffer_new_and_alloc (size);
gst_buffer_set_caps (test_buffer, caps);
*buf = gst_buffer_ref (test_buffer);
return GST_FLOW_OK;
}
static void
sink_handoff_cb_bufferalloc (GstElement * object, GstBuffer * buffer,
GstPad * pad, gpointer user_data)
{
guint *n_buffers = (guint *) user_data;
if (*n_buffers == G_MAXUINT)
return;
fail_unless (buffer->parent != NULL);
fail_unless (test_buffer != NULL);
fail_unless (buffer->parent == test_buffer);
*n_buffers = *n_buffers + 1;
}
GST_START_TEST (test_imagefreeze_bufferalloc)
{
GstElement *pipeline;
GstElement *sink;
GstPad *sinkpad;
GstCaps *caps1, *caps2;
GstBus *bus;
GMainLoop *loop;
guint n_buffers = G_MAXUINT;
guint bus_watch = 0;
caps1 =
gst_video_format_new_caps (GST_VIDEO_FORMAT_xRGB, 640, 480, 25, 1, 1, 1);
caps2 =
gst_video_format_new_caps (GST_VIDEO_FORMAT_xRGB, 640, 480, 25, 1, 1, 1);
pipeline =
setup_imagefreeze (caps1, caps2, G_CALLBACK (sink_handoff_cb_bufferalloc),
&n_buffers);
sink = gst_bin_get_by_name (GST_BIN (pipeline), "sink");
fail_unless (sink != NULL);
sinkpad = gst_element_get_static_pad (sink, "sink");
fail_unless (sinkpad != NULL);
gst_pad_set_bufferalloc_function (sinkpad, test_bufferalloc);
gst_object_unref (sinkpad);
gst_object_unref (sink);
loop = g_main_loop_new (NULL, TRUE);
fail_unless (loop != NULL);
bus = gst_element_get_bus (pipeline);
fail_unless (bus != NULL);
bus_watch = gst_bus_add_watch (bus, bus_handler, loop);
gst_object_unref (bus);
fail_unless_equals_int (gst_element_set_state (pipeline, GST_STATE_PAUSED),
GST_STATE_CHANGE_SUCCESS);
fail_unless (gst_element_seek (pipeline, 1.0, GST_FORMAT_TIME,
GST_SEEK_FLAG_FLUSH, GST_SEEK_TYPE_SET, 0, GST_SEEK_TYPE_SET,
400 * GST_MSECOND));
n_buffers = 0;
fail_unless_equals_int (gst_element_set_state (pipeline, GST_STATE_PLAYING),
GST_STATE_CHANGE_SUCCESS);
g_main_loop_run (loop);
fail_unless (test_buffer != NULL);
fail_unless (n_buffers >= 1);
gst_element_set_state (pipeline, GST_STATE_NULL);
gst_buffer_unref (test_buffer);
test_buffer = NULL;
gst_object_unref (pipeline);
g_main_loop_unref (loop);
gst_caps_unref (caps1);
gst_caps_unref (caps2);
g_source_remove (bus_watch);
}
GST_END_TEST;
GST_START_TEST (test_imagefreeze_eos)
{
GstElement *pipeline;
......@@ -568,11 +508,19 @@ GST_START_TEST (test_imagefreeze_eos)
GstFormat fmt = GST_FORMAT_TIME;
gint64 position;
guint bus_watch = 0;
GstVideoInfo i1, i2;
gst_video_info_init (&i1);
gst_video_info_set_format (&i1, GST_VIDEO_FORMAT_xRGB, 640, 480);
i1.fps_n = 25;
i1.fps_d = 1;
caps1 = gst_video_info_to_caps (&i1);
caps1 =
gst_video_format_new_caps (GST_VIDEO_FORMAT_xRGB, 640, 480, 25, 1, 1, 1);
caps2 =
gst_video_format_new_caps (GST_VIDEO_FORMAT_xRGB, 640, 480, 25, 1, 1, 1);
gst_video_info_init (&i2);
gst_video_info_set_format (&i2, GST_VIDEO_FORMAT_xRGB, 640, 480);
i2.fps_n = 25;
i2.fps_d = 1;
caps2 = gst_video_info_to_caps (&i2);
pipeline = setup_imagefreeze (caps1, caps2, NULL, NULL);
......@@ -600,7 +548,7 @@ GST_START_TEST (test_imagefreeze_eos)
g_main_loop_run (loop);
fail_unless (gst_element_query_position (src, &fmt, &position));
fail_unless (gst_element_query_position (src, fmt, &position));
fail_unless_equals_uint64 (position, 40 * GST_MSECOND);
gst_element_set_state (pipeline, GST_STATE_NULL);
......@@ -631,7 +579,6 @@ imagefreeze_suite (void)
tcase_add_test (tc_chain, test_imagefreeze_25_1_400ms_0ms);
tcase_add_test (tc_chain, test_imagefreeze_25_1_220ms_380ms);
tcase_add_test (tc_chain, test_imagefreeze_bufferalloc);
tcase_add_test (tc_chain, test_imagefreeze_eos);
return s;
......
......@@ -74,48 +74,44 @@ static gfloat input[2];
static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_STATIC_CAPS ("audio/x-raw-float, "
"width = (int) 32, "
"channels = (int) 2, "
"rate = (int) 48000, " "endianness = (int) BYTE_ORDER"));
GST_STATIC_CAPS ("audio/x-raw, "
"format = (string) " GST_AUDIO_NE (F32) ", "
"channels = (int) 2, " "rate = (int) 48000"));
static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
GST_STATIC_CAPS ("audio/x-raw-float, "
"width = (int) 32, "
"channels = (int) 1, "
"rate = (int) 48000, " "endianness = (int) BYTE_ORDER"));
GST_STATIC_CAPS ("audio/x-raw, "
"format = (string) " GST_AUDIO_NE (F32) ", "
"channels = (int) 1, " "rate = (int) 48000"));
#define CAPS_48khz \
"audio/x-raw-float, " \
"width = (int) 32, " \
"audio/x-raw, " \
"format = (string) " GST_AUDIO_NE (F32) ", " \
"channels = (int) 1, " \
"rate = (int) 48000, " \
"endianness = (int) BYTE_ORDER"
"rate = (int) 48000"
static GstFlowReturn
interleave_chain_func (GstPad * pad, GstBuffer * buffer)
interleave_chain_func (GstPad * pad, GstObject * parent, GstBuffer * buffer)
{
gsize size;
gfloat *outdata;
gint i;
fail_unless (GST_IS_BUFFER (buffer));
fail_unless_equals_int (GST_BUFFER_SIZE (buffer),
48000 * 2 * sizeof (gfloat));
fail_unless (GST_BUFFER_DATA (buffer) != NULL);
outdata = (gfloat *) GST_BUFFER_DATA (buffer);
outdata = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
fail_unless_equals_int (size, 48000 * 2 * sizeof (gfloat));
fail_unless (outdata != NULL);
for (i = 0; i < 48000 * 2; i += 2) {
fail_unless_equals_float (outdata[i], input[0]);
fail_unless_equals_float (outdata[i + 1], input[1]);
}
gst_buffer_unmap (buffer, outdata, size);
gst_buffer_unref (buffer);
have_data++;
gst_buffer_unref (buffer);
return GST_FLOW_OK;
}
......@@ -188,32 +184,34 @@ GST_START_TEST (test_interleave_2ch)
input[0] = -1.0;
inbuf = gst_buffer_new_and_alloc (48000 * sizeof (gfloat));
indata = (gfloat *) GST_BUFFER_DATA (inbuf);
indata = gst_buffer_map (inbuf, NULL, NULL, GST_MAP_WRITE);
for (i = 0; i < 48000; i++)
indata[i] = -1.0;
gst_buffer_set_caps (inbuf, caps);
gst_buffer_unmap (inbuf, indata, -1);
gst_pad_set_caps (mysrcpads[0], caps);
fail_unless (gst_pad_push (mysrcpads[0], inbuf) == GST_FLOW_OK);
input[1] = 1.0;
inbuf = gst_buffer_new_and_alloc (48000 * sizeof (gfloat));
indata = (gfloat *) GST_BUFFER_DATA (inbuf);
indata = gst_buffer_map (inbuf, NULL, NULL, GST_MAP_WRITE);
for (i = 0; i < 48000; i++)
indata[i] = 1.0;
gst_buffer_set_caps (inbuf, caps);
gst_buffer_unmap (inbuf, indata, -1);
gst_pad_set_caps (mysrcpads[1], caps);
fail_unless (gst_pad_push (mysrcpads[1], inbuf) == GST_FLOW_OK);
inbuf = gst_buffer_new_and_alloc (48000 * sizeof (gfloat));
indata = (gfloat *) GST_BUFFER_DATA (inbuf);
indata = gst_buffer_map (inbuf, NULL, NULL, GST_MAP_WRITE);
for (i = 0; i < 48000; i++)
indata[i] = -1.0;
gst_buffer_set_caps (inbuf, caps);
gst_buffer_unmap (inbuf, indata, -1);
fail_unless (gst_pad_push (mysrcpads[0], inbuf) == GST_FLOW_OK);
inbuf = gst_buffer_new_and_alloc (48000 * sizeof (gfloat));
indata = (gfloat *) GST_BUFFER_DATA (inbuf);