mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-17 22:06:41 +00:00
tests: port wavpack tests to 0.11
This commit is contained in:
parent
2f7d8f55a4
commit
e637cfb212
5 changed files with 86 additions and 123 deletions
|
@ -83,7 +83,6 @@ endif
|
||||||
|
|
||||||
if USE_WAVPACK
|
if USE_WAVPACK
|
||||||
check_wavpack = \
|
check_wavpack = \
|
||||||
elements/wavpackparse \
|
|
||||||
elements/wavpackdec \
|
elements/wavpackdec \
|
||||||
elements/wavpackenc \
|
elements/wavpackenc \
|
||||||
pipelines/wavpack
|
pipelines/wavpack
|
||||||
|
@ -150,6 +149,7 @@ check_PROGRAMS = \
|
||||||
elements/udpsrc \
|
elements/udpsrc \
|
||||||
elements/videocrop \
|
elements/videocrop \
|
||||||
elements/videofilter \
|
elements/videofilter \
|
||||||
|
elements/wavpackparse \
|
||||||
elements/y4menc \
|
elements/y4menc \
|
||||||
pipelines/simple-launch-lines \
|
pipelines/simple-launch-lines \
|
||||||
pipelines/effectv \
|
pipelines/effectv \
|
||||||
|
|
|
@ -29,6 +29,12 @@
|
||||||
* get_peer, and then remove references in every test function */
|
* get_peer, and then remove references in every test function */
|
||||||
static GstPad *mysrcpad, *mysinkpad;
|
static GstPad *mysrcpad, *mysinkpad;
|
||||||
|
|
||||||
|
#if G_BYTE_ORDER == G_BIG_ENDIAN
|
||||||
|
#define AUDIO_FORMAT "S16BE"
|
||||||
|
#else
|
||||||
|
#define AUDIO_FORMAT "S16LE"
|
||||||
|
#endif
|
||||||
|
|
||||||
guint8 test_frame[] = {
|
guint8 test_frame[] = {
|
||||||
0x77, 0x76, 0x70, 0x6B, /* "wvpk" */
|
0x77, 0x76, 0x70, 0x6B, /* "wvpk" */
|
||||||
0x2E, 0x00, 0x00, 0x00, /* ckSize */
|
0x2E, 0x00, 0x00, 0x00, /* ckSize */
|
||||||
|
@ -51,13 +57,12 @@ guint8 test_frame[] = {
|
||||||
static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink",
|
static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink",
|
||||||
GST_PAD_SINK,
|
GST_PAD_SINK,
|
||||||
GST_PAD_ALWAYS,
|
GST_PAD_ALWAYS,
|
||||||
GST_STATIC_CAPS ("audio/x-raw-int, "
|
GST_STATIC_CAPS ("audio/x-raw, "
|
||||||
"width = (int) 16, "
|
"format = (string) " AUDIO_FORMAT ", "
|
||||||
"depth = (int) 16, "
|
"layout = (string) interleaved, "
|
||||||
"channels = (int) 1, "
|
"channels = (int) 1, " "rate = (int) 44100")
|
||||||
"rate = (int) 44100, "
|
|
||||||
"endianness = (int) BYTE_ORDER, " "signed = (boolean) true")
|
|
||||||
);
|
);
|
||||||
|
|
||||||
static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src",
|
static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src",
|
||||||
GST_PAD_SRC,
|
GST_PAD_SRC,
|
||||||
GST_PAD_ALWAYS,
|
GST_PAD_ALWAYS,
|
||||||
|
@ -73,8 +78,8 @@ setup_wavpackdec (void)
|
||||||
|
|
||||||
GST_DEBUG ("setup_wavpackdec");
|
GST_DEBUG ("setup_wavpackdec");
|
||||||
wavpackdec = gst_check_setup_element ("wavpackdec");
|
wavpackdec = gst_check_setup_element ("wavpackdec");
|
||||||
mysrcpad = gst_check_setup_src_pad (wavpackdec, &srctemplate, NULL);
|
mysrcpad = gst_check_setup_src_pad (wavpackdec, &srctemplate);
|
||||||
mysinkpad = gst_check_setup_sink_pad (wavpackdec, &sinktemplate, NULL);
|
mysinkpad = gst_check_setup_sink_pad (wavpackdec, &sinktemplate);
|
||||||
gst_pad_set_active (mysrcpad, TRUE);
|
gst_pad_set_active (mysrcpad, TRUE);
|
||||||
gst_pad_set_active (mysinkpad, TRUE);
|
gst_pad_set_active (mysinkpad, TRUE);
|
||||||
|
|
||||||
|
@ -100,6 +105,7 @@ GST_START_TEST (test_decode_frame)
|
||||||
GstBuffer *inbuffer, *outbuffer;
|
GstBuffer *inbuffer, *outbuffer;
|
||||||
GstBus *bus;
|
GstBus *bus;
|
||||||
int i;
|
int i;
|
||||||
|
GstMapInfo map;
|
||||||
|
|
||||||
wavpackdec = setup_wavpackdec ();
|
wavpackdec = setup_wavpackdec ();
|
||||||
|
|
||||||
|
@ -109,7 +115,7 @@ GST_START_TEST (test_decode_frame)
|
||||||
bus = gst_bus_new ();
|
bus = gst_bus_new ();
|
||||||
|
|
||||||
inbuffer = gst_buffer_new_and_alloc (sizeof (test_frame));
|
inbuffer = gst_buffer_new_and_alloc (sizeof (test_frame));
|
||||||
memcpy (GST_BUFFER_DATA (inbuffer), test_frame, sizeof (test_frame));
|
gst_buffer_fill (inbuffer, 0, test_frame, sizeof (test_frame));
|
||||||
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
||||||
GST_BUFFER_TIMESTAMP (inbuffer) = 0;
|
GST_BUFFER_TIMESTAMP (inbuffer) = 0;
|
||||||
|
|
||||||
|
@ -121,12 +127,17 @@ GST_START_TEST (test_decode_frame)
|
||||||
outbuffer = GST_BUFFER (buffers->data);
|
outbuffer = GST_BUFFER (buffers->data);
|
||||||
|
|
||||||
fail_if (outbuffer == NULL);
|
fail_if (outbuffer == NULL);
|
||||||
|
|
||||||
|
gst_buffer_map (outbuffer, &map, GST_MAP_READ);
|
||||||
|
|
||||||
/* uncompressed data should be 102400 bytes */
|
/* uncompressed data should be 102400 bytes */
|
||||||
fail_unless_equals_int (GST_BUFFER_SIZE (outbuffer), 51200);
|
fail_unless_equals_int (map.size, 51200);
|
||||||
|
|
||||||
/* and all bytes must be 0, i.e. silence */
|
/* and all bytes must be 0, i.e. silence */
|
||||||
for (i = 0; i < 51200; i++)
|
for (i = 0; i < 51200; i++)
|
||||||
fail_unless_equals_int (GST_BUFFER_DATA (outbuffer)[i], 0);
|
fail_unless_equals_int (map.data[i], 0);
|
||||||
|
|
||||||
|
gst_buffer_unmap (outbuffer, &map);
|
||||||
|
|
||||||
ASSERT_BUFFER_REFCOUNT (outbuffer, "outbuffer", 1);
|
ASSERT_BUFFER_REFCOUNT (outbuffer, "outbuffer", 1);
|
||||||
gst_buffer_unref (outbuffer);
|
gst_buffer_unref (outbuffer);
|
||||||
|
@ -158,9 +169,9 @@ GST_START_TEST (test_decode_frame_with_broken_header)
|
||||||
bus = gst_bus_new ();
|
bus = gst_bus_new ();
|
||||||
|
|
||||||
inbuffer = gst_buffer_new_and_alloc (sizeof (test_frame));
|
inbuffer = gst_buffer_new_and_alloc (sizeof (test_frame));
|
||||||
memcpy (GST_BUFFER_DATA (inbuffer), test_frame, sizeof (test_frame));
|
gst_buffer_fill (inbuffer, 0, test_frame, sizeof (test_frame));
|
||||||
/* break header */
|
/* break header */
|
||||||
GST_BUFFER_DATA (inbuffer)[2] = 'e';
|
gst_buffer_memset (inbuffer, 2, 'e', 1);
|
||||||
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
||||||
GST_BUFFER_TIMESTAMP (inbuffer) = 0;
|
GST_BUFFER_TIMESTAMP (inbuffer) = 0;
|
||||||
|
|
||||||
|
@ -195,7 +206,7 @@ GST_START_TEST (test_decode_frame_with_incomplete_frame)
|
||||||
bus = gst_bus_new ();
|
bus = gst_bus_new ();
|
||||||
|
|
||||||
inbuffer = gst_buffer_new_and_alloc (sizeof (test_frame) - 2);
|
inbuffer = gst_buffer_new_and_alloc (sizeof (test_frame) - 2);
|
||||||
memcpy (GST_BUFFER_DATA (inbuffer), test_frame, sizeof (test_frame) - 2);
|
gst_buffer_fill (inbuffer, 0, test_frame, sizeof (test_frame) - 2);
|
||||||
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
||||||
GST_BUFFER_TIMESTAMP (inbuffer) = 0;
|
GST_BUFFER_TIMESTAMP (inbuffer) = 0;
|
||||||
|
|
||||||
|
|
|
@ -30,13 +30,17 @@
|
||||||
static GstPad *mysrcpad, *mysinkpad;
|
static GstPad *mysrcpad, *mysinkpad;
|
||||||
static GstBus *bus;
|
static GstBus *bus;
|
||||||
|
|
||||||
#define RAW_CAPS_STRING "audio/x-raw-int, " \
|
#if G_BYTE_ORDER == G_BIG_ENDIAN
|
||||||
"width = (int) 32, " \
|
#define AUDIO_FORMAT "S32BE"
|
||||||
"depth = (int) 32, " \
|
#else
|
||||||
|
#define AUDIO_FORMAT "S32LE"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define RAW_CAPS_STRING "audio/x-raw, " \
|
||||||
|
"format = (string) " AUDIO_FORMAT ", " \
|
||||||
|
"layout = (string) interleaved, " \
|
||||||
"channels = (int) 1, " \
|
"channels = (int) 1, " \
|
||||||
"rate = (int) 44100, " \
|
"rate = (int) 44100"
|
||||||
"endianness = (int) BYTE_ORDER, " \
|
|
||||||
"signed = (boolean) true"
|
|
||||||
|
|
||||||
#define WAVPACK_CAPS_STRING "audio/x-wavpack, " \
|
#define WAVPACK_CAPS_STRING "audio/x-wavpack, " \
|
||||||
"width = (int) 32, " \
|
"width = (int) 32, " \
|
||||||
|
@ -55,12 +59,10 @@ static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink",
|
||||||
static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src",
|
static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src",
|
||||||
GST_PAD_SRC,
|
GST_PAD_SRC,
|
||||||
GST_PAD_ALWAYS,
|
GST_PAD_ALWAYS,
|
||||||
GST_STATIC_CAPS ("audio/x-raw-int, "
|
GST_STATIC_CAPS ("audio/x-raw, "
|
||||||
"width = (int) 32, "
|
"format = (string) " AUDIO_FORMAT ", "
|
||||||
"depth = (int) 32, "
|
"layout = (string) interleaved, "
|
||||||
"channels = (int) 1, "
|
"channels = (int) 1, " "rate = (int) 44100"));
|
||||||
"rate = (int) 44100, "
|
|
||||||
"endianness = (int) BYTE_ORDER, " "signed = (boolean) true"));
|
|
||||||
|
|
||||||
static GstElement *
|
static GstElement *
|
||||||
setup_wavpackenc (void)
|
setup_wavpackenc (void)
|
||||||
|
@ -69,8 +71,8 @@ setup_wavpackenc (void)
|
||||||
|
|
||||||
GST_DEBUG ("setup_wavpackenc");
|
GST_DEBUG ("setup_wavpackenc");
|
||||||
wavpackenc = gst_check_setup_element ("wavpackenc");
|
wavpackenc = gst_check_setup_element ("wavpackenc");
|
||||||
mysrcpad = gst_check_setup_src_pad (wavpackenc, &srctemplate, NULL);
|
mysrcpad = gst_check_setup_src_pad (wavpackenc, &srctemplate);
|
||||||
mysinkpad = gst_check_setup_sink_pad (wavpackenc, &sinktemplate, NULL);
|
mysinkpad = gst_check_setup_sink_pad (wavpackenc, &sinktemplate);
|
||||||
gst_pad_set_active (mysrcpad, TRUE);
|
gst_pad_set_active (mysrcpad, TRUE);
|
||||||
gst_pad_set_active (mysinkpad, TRUE);
|
gst_pad_set_active (mysinkpad, TRUE);
|
||||||
|
|
||||||
|
@ -111,10 +113,9 @@ GST_START_TEST (test_encode_silence)
|
||||||
wavpackenc = setup_wavpackenc ();
|
wavpackenc = setup_wavpackenc ();
|
||||||
|
|
||||||
inbuffer = gst_buffer_new_and_alloc (1000);
|
inbuffer = gst_buffer_new_and_alloc (1000);
|
||||||
for (i = 0; i < 1000; i++)
|
gst_buffer_memset (inbuffer, 0, 0, 1000);
|
||||||
GST_BUFFER_DATA (inbuffer)[i] = 0;
|
|
||||||
caps = gst_caps_from_string (RAW_CAPS_STRING);
|
caps = gst_caps_from_string (RAW_CAPS_STRING);
|
||||||
gst_buffer_set_caps (inbuffer, caps);
|
fail_unless (gst_pad_set_caps (mysrcpad, caps));
|
||||||
gst_caps_unref (caps);
|
gst_caps_unref (caps);
|
||||||
GST_BUFFER_TIMESTAMP (inbuffer) = 0;
|
GST_BUFFER_TIMESTAMP (inbuffer) = 0;
|
||||||
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
||||||
|
@ -133,7 +134,7 @@ GST_START_TEST (test_encode_silence)
|
||||||
fail_unless_equals_int (GST_BUFFER_TIMESTAMP (outbuffer), 0);
|
fail_unless_equals_int (GST_BUFFER_TIMESTAMP (outbuffer), 0);
|
||||||
fail_unless_equals_int (GST_BUFFER_DURATION (outbuffer), 5668934);
|
fail_unless_equals_int (GST_BUFFER_DURATION (outbuffer), 5668934);
|
||||||
|
|
||||||
fail_unless (memcmp (GST_BUFFER_DATA (outbuffer), "wvpk", 4) == 0,
|
fail_unless (gst_buffer_memcmp (outbuffer, 0, "wvpk", 4) == 0,
|
||||||
"Failed to encode to valid Wavpack frames");
|
"Failed to encode to valid Wavpack frames");
|
||||||
|
|
||||||
/* free all buffers */
|
/* free all buffers */
|
||||||
|
|
|
@ -28,8 +28,6 @@
|
||||||
* src and sink pads we create; otherwise we always have to do get_pad,
|
* src and sink pads we create; otherwise we always have to do get_pad,
|
||||||
* get_peer, and then remove references in every test function */
|
* get_peer, and then remove references in every test function */
|
||||||
static GstPad *mysrcpad, *mysinkpad;
|
static GstPad *mysrcpad, *mysinkpad;
|
||||||
static GstBus *bus;
|
|
||||||
static GstElement *wavpackparse;
|
|
||||||
|
|
||||||
/* Wavpack file with 2 frames of silence */
|
/* Wavpack file with 2 frames of silence */
|
||||||
guint8 test_file[] = {
|
guint8 test_file[] = {
|
||||||
|
@ -69,99 +67,53 @@ static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src",
|
||||||
GST_PAD_ALWAYS,
|
GST_PAD_ALWAYS,
|
||||||
GST_STATIC_CAPS ("audio/x-wavpack"));
|
GST_STATIC_CAPS ("audio/x-wavpack"));
|
||||||
|
|
||||||
static void
|
static GstElement *
|
||||||
wavpackparse_found_pad (GstElement * src, GstPad * pad, gpointer data)
|
|
||||||
{
|
|
||||||
GstPad *srcpad;
|
|
||||||
|
|
||||||
mysinkpad = gst_pad_new_from_static_template (&sinktemplate, "sink");
|
|
||||||
fail_if (mysinkpad == NULL, "Couldn't create sinkpad");
|
|
||||||
srcpad = gst_element_get_static_pad (wavpackparse, "src");
|
|
||||||
fail_if (srcpad == NULL, "Failed to get srcpad from wavpackparse");
|
|
||||||
gst_pad_set_chain_function (mysinkpad, gst_check_chain_func);
|
|
||||||
fail_unless (gst_pad_link (srcpad, mysinkpad) == GST_PAD_LINK_OK,
|
|
||||||
"Failed to link pads");
|
|
||||||
gst_pad_set_active (mysinkpad, TRUE);
|
|
||||||
gst_object_unref (srcpad);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
setup_wavpackparse (void)
|
setup_wavpackparse (void)
|
||||||
{
|
{
|
||||||
GstPad *sinkpad;
|
GstElement *wavpackparse;
|
||||||
|
|
||||||
GST_DEBUG ("setup_wavpackparse");
|
GST_DEBUG ("setup_wavpackparse");
|
||||||
|
|
||||||
wavpackparse = gst_element_factory_make ("wavpackparse", "wavpackparse");
|
wavpackparse = gst_check_setup_element ("wavpackparse");
|
||||||
fail_if (wavpackparse == NULL, "Could not create wavpackparse");
|
mysrcpad = gst_check_setup_src_pad (wavpackparse, &srctemplate);
|
||||||
|
mysinkpad = gst_check_setup_sink_pad (wavpackparse, &sinktemplate);
|
||||||
|
gst_pad_set_active (mysrcpad, TRUE);
|
||||||
|
gst_pad_set_active (mysinkpad, TRUE);
|
||||||
|
|
||||||
mysrcpad = gst_pad_new_from_static_template (&srctemplate, "src");
|
return wavpackparse;
|
||||||
fail_if (mysrcpad == NULL, "Could not create srcpad");
|
|
||||||
|
|
||||||
sinkpad = gst_element_get_static_pad (wavpackparse, "sink");
|
|
||||||
fail_if (sinkpad == NULL, "Failed to get sinkpad from wavpackparse");
|
|
||||||
fail_unless (gst_pad_link (mysrcpad, sinkpad) == GST_PAD_LINK_OK,
|
|
||||||
"Failed to link pads");
|
|
||||||
gst_object_unref (sinkpad);
|
|
||||||
|
|
||||||
g_signal_connect (wavpackparse, "pad-added",
|
|
||||||
G_CALLBACK (wavpackparse_found_pad), NULL);
|
|
||||||
|
|
||||||
bus = gst_bus_new ();
|
|
||||||
gst_element_set_bus (wavpackparse, bus);
|
|
||||||
|
|
||||||
fail_unless (gst_element_set_state (wavpackparse,
|
|
||||||
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
|
|
||||||
"could not set to playing");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
cleanup_wavpackparse (void)
|
cleanup_wavpackparse (GstElement * wavpackparse)
|
||||||
{
|
{
|
||||||
GstPad *sinkpad, *srcpad;
|
|
||||||
|
|
||||||
GST_DEBUG ("cleanup_wavpackparse");
|
GST_DEBUG ("cleanup_wavpackparse");
|
||||||
|
gst_element_set_state (wavpackparse, GST_STATE_NULL);
|
||||||
|
|
||||||
gst_bus_set_flushing (bus, TRUE);
|
gst_pad_set_active (mysrcpad, FALSE);
|
||||||
gst_element_set_bus (wavpackparse, NULL);
|
gst_pad_set_active (mysinkpad, FALSE);
|
||||||
gst_object_unref (GST_OBJECT (bus));
|
gst_check_teardown_src_pad (wavpackparse);
|
||||||
|
gst_check_teardown_sink_pad (wavpackparse);
|
||||||
sinkpad = gst_element_get_static_pad (wavpackparse, "sink");
|
gst_check_teardown_element (wavpackparse);
|
||||||
fail_if (sinkpad == NULL, "Failed to get sinkpad from wavpackparse");
|
|
||||||
fail_unless (gst_pad_unlink (mysrcpad, sinkpad), "Failed to unlink pads");
|
|
||||||
gst_pad_set_caps (mysrcpad, NULL);
|
|
||||||
gst_object_unref (sinkpad);
|
|
||||||
gst_object_unref (mysrcpad);
|
|
||||||
|
|
||||||
srcpad = gst_element_get_static_pad (wavpackparse, "src");
|
|
||||||
fail_if (srcpad == NULL, "Failed to get srcpad from wavpackparse");
|
|
||||||
fail_unless (gst_pad_unlink (srcpad, mysinkpad), "Failed to unlink pads");
|
|
||||||
gst_pad_set_caps (mysinkpad, NULL);
|
|
||||||
gst_object_unref (srcpad);
|
|
||||||
gst_object_unref (mysinkpad);
|
|
||||||
|
|
||||||
fail_unless (gst_element_set_state (wavpackparse, GST_STATE_NULL) ==
|
|
||||||
GST_STATE_CHANGE_SUCCESS, "could not set to null");
|
|
||||||
|
|
||||||
gst_object_unref (wavpackparse);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GST_START_TEST (test_parsing_valid_frames)
|
GST_START_TEST (test_parsing_valid_frames)
|
||||||
{
|
{
|
||||||
|
GstElement *wavpackparse;
|
||||||
GstBuffer *inbuffer, *outbuffer;
|
GstBuffer *inbuffer, *outbuffer;
|
||||||
int i, num_buffers;
|
int i, num_buffers;
|
||||||
GstFormat format = GST_FORMAT_DEFAULT;
|
GstFormat format = GST_FORMAT_TIME;
|
||||||
gint64 pos;
|
gint64 pos;
|
||||||
|
|
||||||
setup_wavpackparse ();
|
wavpackparse = setup_wavpackparse ();
|
||||||
|
fail_unless (gst_element_set_state (wavpackparse,
|
||||||
|
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
|
||||||
|
"could not set to playing");
|
||||||
|
|
||||||
inbuffer = gst_buffer_new_and_alloc (sizeof (test_file));
|
inbuffer = gst_buffer_new_and_alloc (sizeof (test_file));
|
||||||
memcpy (GST_BUFFER_DATA (inbuffer), test_file, sizeof (test_file));
|
gst_buffer_fill (inbuffer, 0, test_file, sizeof (test_file));
|
||||||
gst_buffer_ref (inbuffer);
|
|
||||||
|
|
||||||
/* should decode the buffer without problems */
|
/* should decode the buffer without problems */
|
||||||
fail_unless_equals_int (gst_pad_push (mysrcpad, inbuffer), GST_FLOW_OK);
|
fail_unless_equals_int (gst_pad_push (mysrcpad, inbuffer), GST_FLOW_OK);
|
||||||
gst_buffer_unref (inbuffer);
|
|
||||||
|
|
||||||
num_buffers = g_list_length (buffers);
|
num_buffers = g_list_length (buffers);
|
||||||
/* should get 2 buffers, each one complete wavpack frame */
|
/* should get 2 buffers, each one complete wavpack frame */
|
||||||
|
@ -171,21 +123,17 @@ GST_START_TEST (test_parsing_valid_frames)
|
||||||
outbuffer = GST_BUFFER (buffers->data);
|
outbuffer = GST_BUFFER (buffers->data);
|
||||||
fail_if (outbuffer == NULL);
|
fail_if (outbuffer == NULL);
|
||||||
|
|
||||||
fail_unless (memcmp (GST_BUFFER_DATA (outbuffer), "wvpk", 4) == 0,
|
fail_unless (gst_buffer_memcmp (outbuffer, 0, "wvpk", 4) == 0,
|
||||||
"Buffer contains no Wavpack frame");
|
"Buffer contains no Wavpack frame");
|
||||||
fail_unless_equals_int (GST_BUFFER_DURATION (outbuffer), 580498866);
|
fail_unless_equals_int (GST_BUFFER_DURATION (outbuffer), 580498866);
|
||||||
|
|
||||||
switch (i) {
|
switch (i) {
|
||||||
case 0:{
|
case 0:{
|
||||||
fail_unless_equals_int (GST_BUFFER_TIMESTAMP (outbuffer), 0);
|
fail_unless_equals_int (GST_BUFFER_TIMESTAMP (outbuffer), 0);
|
||||||
fail_unless_equals_int (GST_BUFFER_OFFSET (outbuffer), 0);
|
|
||||||
fail_unless_equals_int (GST_BUFFER_OFFSET_END (outbuffer), 25600);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 1:{
|
case 1:{
|
||||||
fail_unless_equals_int (GST_BUFFER_TIMESTAMP (outbuffer), 580498866);
|
fail_unless_equals_int (GST_BUFFER_TIMESTAMP (outbuffer), 580498866);
|
||||||
fail_unless_equals_int (GST_BUFFER_OFFSET (outbuffer), 25600);
|
|
||||||
fail_unless_equals_int (GST_BUFFER_OFFSET_END (outbuffer), 51200);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -196,35 +144,37 @@ GST_START_TEST (test_parsing_valid_frames)
|
||||||
outbuffer = NULL;
|
outbuffer = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
fail_unless (gst_element_query_position (wavpackparse, &format, &pos),
|
fail_unless (gst_element_query_position (wavpackparse, format, &pos),
|
||||||
"Position query failed");
|
"Position query failed");
|
||||||
fail_unless_equals_int (pos, 51200);
|
fail_unless_equals_int64 (pos, 580498866 * 2);
|
||||||
fail_unless (gst_element_query_duration (wavpackparse, &format, NULL),
|
fail_unless (gst_element_query_duration (wavpackparse, format, NULL),
|
||||||
"Duration query failed");
|
"Duration query failed");
|
||||||
|
|
||||||
g_list_free (buffers);
|
g_list_free (buffers);
|
||||||
buffers = NULL;
|
buffers = NULL;
|
||||||
|
|
||||||
cleanup_wavpackparse ();
|
cleanup_wavpackparse (wavpackparse);
|
||||||
}
|
}
|
||||||
|
|
||||||
GST_END_TEST;
|
GST_END_TEST;
|
||||||
|
|
||||||
GST_START_TEST (test_parsing_invalid_first_header)
|
GST_START_TEST (test_parsing_invalid_first_header)
|
||||||
{
|
{
|
||||||
|
GstElement *wavpackparse;
|
||||||
GstBuffer *inbuffer, *outbuffer;
|
GstBuffer *inbuffer, *outbuffer;
|
||||||
int i, num_buffers;
|
int i, num_buffers;
|
||||||
|
|
||||||
setup_wavpackparse ();
|
wavpackparse = setup_wavpackparse ();
|
||||||
|
fail_unless (gst_element_set_state (wavpackparse,
|
||||||
|
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
|
||||||
|
"could not set to playing");
|
||||||
|
|
||||||
inbuffer = gst_buffer_new_and_alloc (sizeof (test_file));
|
inbuffer = gst_buffer_new_and_alloc (sizeof (test_file));
|
||||||
memcpy (GST_BUFFER_DATA (inbuffer), test_file, sizeof (test_file));
|
gst_buffer_fill (inbuffer, 0, test_file, sizeof (test_file));
|
||||||
GST_BUFFER_DATA (inbuffer)[0] = 'k';
|
gst_buffer_memset (inbuffer, 0, 'k', 1);
|
||||||
gst_buffer_ref (inbuffer);
|
|
||||||
|
|
||||||
/* should decode the buffer without problems */
|
/* should decode the buffer without problems */
|
||||||
fail_unless_equals_int (gst_pad_push (mysrcpad, inbuffer), GST_FLOW_OK);
|
fail_unless_equals_int (gst_pad_push (mysrcpad, inbuffer), GST_FLOW_OK);
|
||||||
gst_buffer_unref (inbuffer);
|
|
||||||
|
|
||||||
num_buffers = g_list_length (buffers);
|
num_buffers = g_list_length (buffers);
|
||||||
|
|
||||||
|
@ -235,14 +185,13 @@ GST_START_TEST (test_parsing_invalid_first_header)
|
||||||
outbuffer = GST_BUFFER (buffers->data);
|
outbuffer = GST_BUFFER (buffers->data);
|
||||||
fail_if (outbuffer == NULL);
|
fail_if (outbuffer == NULL);
|
||||||
|
|
||||||
fail_unless (memcmp (GST_BUFFER_DATA (outbuffer), "wvpk", 4) == 0,
|
fail_unless (gst_buffer_memcmp (outbuffer, 0, "wvpk", 4) == 0,
|
||||||
"Buffer contains no Wavpack frame");
|
"Buffer contains no Wavpack frame");
|
||||||
fail_unless_equals_int (GST_BUFFER_DURATION (outbuffer), 580498866);
|
fail_unless_equals_int (GST_BUFFER_DURATION (outbuffer), 580498866);
|
||||||
|
|
||||||
switch (i) {
|
switch (i) {
|
||||||
case 0:{
|
case 0:{
|
||||||
fail_unless_equals_int (GST_BUFFER_TIMESTAMP (outbuffer), 580498866);
|
fail_unless_equals_int (GST_BUFFER_TIMESTAMP (outbuffer), 580498866);
|
||||||
fail_unless_equals_int (GST_BUFFER_OFFSET (outbuffer), 25600);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -256,7 +205,7 @@ GST_START_TEST (test_parsing_invalid_first_header)
|
||||||
g_list_free (buffers);
|
g_list_free (buffers);
|
||||||
buffers = NULL;
|
buffers = NULL;
|
||||||
|
|
||||||
cleanup_wavpackparse ();
|
cleanup_wavpackparse (wavpackparse);
|
||||||
}
|
}
|
||||||
|
|
||||||
GST_END_TEST;
|
GST_END_TEST;
|
||||||
|
|
|
@ -96,6 +96,7 @@ GST_START_TEST (test_encode_decode)
|
||||||
GMainLoop *loop;
|
GMainLoop *loop;
|
||||||
GstBuffer *in, *out;
|
GstBuffer *in, *out;
|
||||||
guint bus_watch = 0;
|
guint bus_watch = 0;
|
||||||
|
GstMapInfo map;
|
||||||
|
|
||||||
srcadapter = gst_adapter_new ();
|
srcadapter = gst_adapter_new ();
|
||||||
fail_unless (srcadapter != NULL);
|
fail_unless (srcadapter != NULL);
|
||||||
|
@ -170,9 +171,10 @@ GST_START_TEST (test_encode_decode)
|
||||||
gst_adapter_available (sinkadapter));
|
gst_adapter_available (sinkadapter));
|
||||||
fail_unless (out != NULL);
|
fail_unless (out != NULL);
|
||||||
|
|
||||||
fail_unless_equals_int (GST_BUFFER_SIZE (in), GST_BUFFER_SIZE (out));
|
fail_unless_equals_int (gst_buffer_get_size (in), gst_buffer_get_size (out));
|
||||||
fail_unless (memcmp (GST_BUFFER_DATA (in), GST_BUFFER_DATA (out),
|
gst_buffer_map (out, &map, GST_MAP_READ);
|
||||||
GST_BUFFER_SIZE (in)) == 0);
|
fail_unless (gst_buffer_memcmp (in, 0, map.data, map.size) == 0);
|
||||||
|
gst_buffer_unmap (out, &map);
|
||||||
|
|
||||||
gst_buffer_unref (in);
|
gst_buffer_unref (in);
|
||||||
gst_buffer_unref (out);
|
gst_buffer_unref (out);
|
||||||
|
|
Loading…
Reference in a new issue