mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 04:01:08 +00:00
tests: fix more tests
This commit is contained in:
parent
2a91bbbc0b
commit
a6370cdb50
15 changed files with 218 additions and 173 deletions
|
@ -91,6 +91,7 @@ GST_START_TEST (test_equalizer_5bands_passthrough)
|
|||
GstCaps *caps;
|
||||
gdouble *in, *res;
|
||||
gint i;
|
||||
GstMapInfo map;
|
||||
|
||||
equalizer = setup_equalizer ();
|
||||
g_object_set (G_OBJECT (equalizer), "num-bands", 5, NULL);
|
||||
|
@ -103,10 +104,11 @@ GST_START_TEST (test_equalizer_5bands_passthrough)
|
|||
"could not set to playing");
|
||||
|
||||
inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gdouble));
|
||||
in = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE);
|
||||
gst_buffer_map (inbuffer, &map, GST_MAP_WRITE);
|
||||
in = (gdouble *) map.data;
|
||||
for (i = 0; i < 1024; i++)
|
||||
in[i] = g_random_double_range (-1.0, 1.0);
|
||||
gst_buffer_unmap (inbuffer, in, -1);
|
||||
gst_buffer_unmap (inbuffer, &map);
|
||||
|
||||
caps = gst_caps_from_string (EQUALIZER_CAPS_STRING);
|
||||
gst_pad_set_caps (mysrcpad, caps);
|
||||
|
@ -119,11 +121,12 @@ GST_START_TEST (test_equalizer_5bands_passthrough)
|
|||
/* ... and puts a new buffer on the global list */
|
||||
fail_unless (g_list_length (buffers) == 1);
|
||||
|
||||
res = gst_buffer_map (GST_BUFFER (buffers->data), NULL, NULL, GST_MAP_READ);
|
||||
gst_buffer_map (GST_BUFFER (buffers->data), &map, GST_MAP_READ);
|
||||
res = (gdouble *) map.data;
|
||||
|
||||
for (i = 0; i < 1024; i++)
|
||||
fail_unless_equals_float (in[i], res[i]);
|
||||
gst_buffer_unmap (GST_BUFFER (buffers->data), res, -1);
|
||||
gst_buffer_unmap (GST_BUFFER (buffers->data), &map);
|
||||
|
||||
/* cleanup */
|
||||
cleanup_equalizer (equalizer);
|
||||
|
@ -138,6 +141,7 @@ GST_START_TEST (test_equalizer_5bands_minus_24)
|
|||
GstCaps *caps;
|
||||
gdouble *in, *res, rms_in, rms_out;
|
||||
gint i;
|
||||
GstMapInfo map;
|
||||
|
||||
equalizer = setup_equalizer ();
|
||||
g_object_set (G_OBJECT (equalizer), "num-bands", 5, NULL);
|
||||
|
@ -159,10 +163,11 @@ GST_START_TEST (test_equalizer_5bands_minus_24)
|
|||
"could not set to playing");
|
||||
|
||||
inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gdouble));
|
||||
in = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE);
|
||||
gst_buffer_map (inbuffer, &map, GST_MAP_WRITE);
|
||||
in = (gdouble *) map.data;
|
||||
for (i = 0; i < 1024; i++)
|
||||
in[i] = g_random_double_range (-1.0, 1.0);
|
||||
gst_buffer_unmap (inbuffer, in, -1);
|
||||
gst_buffer_unmap (inbuffer, &map);
|
||||
|
||||
rms_in = 0.0;
|
||||
for (i = 0; i < 1024; i++)
|
||||
|
@ -180,13 +185,14 @@ 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 = gst_buffer_map (GST_BUFFER (buffers->data), NULL, NULL, GST_MAP_READ);
|
||||
gst_buffer_map (GST_BUFFER (buffers->data), &map, GST_MAP_READ);
|
||||
res = (gdouble *) map.data;
|
||||
|
||||
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);
|
||||
gst_buffer_unmap (GST_BUFFER (buffers->data), &map);
|
||||
|
||||
fail_unless (rms_in > rms_out);
|
||||
|
||||
|
@ -203,6 +209,7 @@ GST_START_TEST (test_equalizer_5bands_plus_12)
|
|||
GstCaps *caps;
|
||||
gdouble *in, *res, rms_in, rms_out;
|
||||
gint i;
|
||||
GstMapInfo map;
|
||||
|
||||
equalizer = setup_equalizer ();
|
||||
g_object_set (G_OBJECT (equalizer), "num-bands", 5, NULL);
|
||||
|
@ -224,10 +231,11 @@ GST_START_TEST (test_equalizer_5bands_plus_12)
|
|||
"could not set to playing");
|
||||
|
||||
inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gdouble));
|
||||
in = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE);
|
||||
gst_buffer_map (inbuffer, &map, GST_MAP_WRITE);
|
||||
in = (gdouble *) map.data;
|
||||
for (i = 0; i < 1024; i++)
|
||||
in[i] = g_random_double_range (-1.0, 1.0);
|
||||
gst_buffer_unmap (inbuffer, in, -1);
|
||||
gst_buffer_unmap (inbuffer, &map);
|
||||
|
||||
rms_in = 0.0;
|
||||
for (i = 0; i < 1024; i++)
|
||||
|
@ -245,13 +253,14 @@ 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 = gst_buffer_map (GST_BUFFER (buffers->data), NULL, NULL, GST_MAP_READ);
|
||||
gst_buffer_map (GST_BUFFER (buffers->data), &map, GST_MAP_READ);
|
||||
res = (gdouble *) map.data;
|
||||
|
||||
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);
|
||||
gst_buffer_unmap (GST_BUFFER (buffers->data), &map);
|
||||
|
||||
fail_unless (rms_in < rms_out);
|
||||
|
||||
|
|
|
@ -236,8 +236,7 @@ check_unsync_v24 (const GstTagList * tags, const gchar * file)
|
|||
gchar *album = NULL;
|
||||
gchar *title = NULL;
|
||||
gchar *artist = NULL;
|
||||
guint8 *data;
|
||||
gsize size;
|
||||
GstMapInfo map;
|
||||
|
||||
fail_unless (gst_tag_list_get_string (tags, GST_TAG_TITLE, &title));
|
||||
fail_unless (title != NULL);
|
||||
|
@ -262,14 +261,14 @@ check_unsync_v24 (const GstTagList * tags, const gchar * file)
|
|||
fail_unless (gst_sample_get_caps (sample) != NULL);
|
||||
buf = gst_sample_get_buffer (sample);
|
||||
fail_unless (buf != NULL);
|
||||
data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
|
||||
fail_unless_equals_int (size, 38022);
|
||||
gst_buffer_map (buf, &map, GST_MAP_READ);
|
||||
fail_unless_equals_int (map.size, 38022);
|
||||
/* check for jpeg start/end markers */
|
||||
fail_unless_equals_int (data[0], 0xff);
|
||||
fail_unless_equals_int (data[1], 0xd8);
|
||||
fail_unless_equals_int (data[38020], 0xff);
|
||||
fail_unless_equals_int (data[38021], 0xd9);
|
||||
gst_buffer_unmap (buf, data, size);
|
||||
fail_unless_equals_int (map.data[0], 0xff);
|
||||
fail_unless_equals_int (map.data[1], 0xd8);
|
||||
fail_unless_equals_int (map.data[38020], 0xff);
|
||||
fail_unless_equals_int (map.data[38021], 0xd9);
|
||||
gst_buffer_unmap (buf, &map);
|
||||
}
|
||||
|
||||
GST_START_TEST (test_unsync_v24)
|
||||
|
|
|
@ -23,7 +23,8 @@
|
|||
#endif
|
||||
|
||||
#include <gst/check/gstcheck.h>
|
||||
#include <gst/audio/multichannel.h>
|
||||
#include <gst/audio/audio.h>
|
||||
#include <gst/audio/audio-enumtypes.h>
|
||||
|
||||
GST_START_TEST (test_create_and_unref)
|
||||
{
|
||||
|
@ -94,20 +95,21 @@ static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src",
|
|||
static GstFlowReturn
|
||||
interleave_chain_func (GstPad * pad, GstObject * parent, GstBuffer * buffer)
|
||||
{
|
||||
gsize size;
|
||||
GstMapInfo map;
|
||||
gfloat *outdata;
|
||||
gint i;
|
||||
|
||||
fail_unless (GST_IS_BUFFER (buffer));
|
||||
outdata = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
|
||||
fail_unless_equals_int (size, 48000 * 2 * sizeof (gfloat));
|
||||
gst_buffer_map (buffer, &map, GST_MAP_READ);
|
||||
outdata = (gfloat *) map.data;
|
||||
fail_unless_equals_int (map.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_unmap (buffer, &map);
|
||||
gst_buffer_unref (buffer);
|
||||
|
||||
have_data++;
|
||||
|
@ -123,6 +125,7 @@ GST_START_TEST (test_interleave_2ch)
|
|||
gint i;
|
||||
GstBuffer *inbuf;
|
||||
gfloat *indata;
|
||||
GstMapInfo map;
|
||||
|
||||
mysrcpads = g_new0 (GstPad *, 2);
|
||||
|
||||
|
@ -184,34 +187,38 @@ GST_START_TEST (test_interleave_2ch)
|
|||
|
||||
input[0] = -1.0;
|
||||
inbuf = gst_buffer_new_and_alloc (48000 * sizeof (gfloat));
|
||||
indata = gst_buffer_map (inbuf, NULL, NULL, GST_MAP_WRITE);
|
||||
gst_buffer_map (inbuf, &map, GST_MAP_WRITE);
|
||||
indata = (gfloat *) map.data;
|
||||
for (i = 0; i < 48000; i++)
|
||||
indata[i] = -1.0;
|
||||
gst_buffer_unmap (inbuf, indata, -1);
|
||||
gst_buffer_unmap (inbuf, &map);
|
||||
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 = gst_buffer_map (inbuf, NULL, NULL, GST_MAP_WRITE);
|
||||
gst_buffer_map (inbuf, &map, GST_MAP_WRITE);
|
||||
indata = (gfloat *) map.data;
|
||||
for (i = 0; i < 48000; i++)
|
||||
indata[i] = 1.0;
|
||||
gst_buffer_unmap (inbuf, indata, -1);
|
||||
gst_buffer_unmap (inbuf, &map);
|
||||
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 = gst_buffer_map (inbuf, NULL, NULL, GST_MAP_WRITE);
|
||||
gst_buffer_map (inbuf, &map, GST_MAP_WRITE);
|
||||
indata = (gfloat *) map.data;
|
||||
for (i = 0; i < 48000; i++)
|
||||
indata[i] = -1.0;
|
||||
gst_buffer_unmap (inbuf, indata, -1);
|
||||
gst_buffer_unmap (inbuf, &map);
|
||||
fail_unless (gst_pad_push (mysrcpads[0], inbuf) == GST_FLOW_OK);
|
||||
|
||||
inbuf = gst_buffer_new_and_alloc (48000 * sizeof (gfloat));
|
||||
indata = gst_buffer_map (inbuf, NULL, NULL, GST_MAP_WRITE);
|
||||
gst_buffer_map (inbuf, &map, GST_MAP_WRITE);
|
||||
indata = (gfloat *) map.data;
|
||||
for (i = 0; i < 48000; i++)
|
||||
indata[i] = 1.0;
|
||||
gst_buffer_unmap (inbuf, indata, -1);
|
||||
gst_buffer_unmap (inbuf, &map);
|
||||
fail_unless (gst_pad_push (mysrcpads[1], inbuf) == GST_FLOW_OK);
|
||||
|
||||
fail_unless (have_data == 2);
|
||||
|
@ -246,6 +253,7 @@ GST_START_TEST (test_interleave_2ch_1eos)
|
|||
gint i;
|
||||
GstBuffer *inbuf;
|
||||
gfloat *indata;
|
||||
GstMapInfo map;
|
||||
|
||||
mysrcpads = g_new0 (GstPad *, 2);
|
||||
|
||||
|
@ -307,19 +315,21 @@ GST_START_TEST (test_interleave_2ch_1eos)
|
|||
|
||||
input[0] = -1.0;
|
||||
inbuf = gst_buffer_new_and_alloc (48000 * sizeof (gfloat));
|
||||
indata = gst_buffer_map (inbuf, NULL, NULL, GST_MAP_WRITE);
|
||||
gst_buffer_map (inbuf, &map, GST_MAP_WRITE);
|
||||
indata = (gfloat *) map.data;
|
||||
for (i = 0; i < 48000; i++)
|
||||
indata[i] = -1.0;
|
||||
gst_buffer_unmap (inbuf, indata, -1);
|
||||
gst_buffer_unmap (inbuf, &map);
|
||||
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 = gst_buffer_map (inbuf, NULL, NULL, GST_MAP_WRITE);
|
||||
gst_buffer_map (inbuf, &map, GST_MAP_WRITE);
|
||||
indata = (gfloat *) map.data;
|
||||
for (i = 0; i < 48000; i++)
|
||||
indata[i] = 1.0;
|
||||
gst_buffer_unmap (inbuf, indata, -1);
|
||||
gst_buffer_unmap (inbuf, &map);
|
||||
gst_pad_set_caps (mysrcpads[1], caps);
|
||||
fail_unless (gst_pad_push (mysrcpads[1], inbuf) == GST_FLOW_OK);
|
||||
|
||||
|
@ -328,10 +338,11 @@ GST_START_TEST (test_interleave_2ch_1eos)
|
|||
|
||||
input[1] = 1.0;
|
||||
inbuf = gst_buffer_new_and_alloc (48000 * sizeof (gfloat));
|
||||
indata = gst_buffer_map (inbuf, NULL, NULL, GST_MAP_WRITE);
|
||||
gst_buffer_map (inbuf, &map, GST_MAP_WRITE);
|
||||
indata = (gfloat *) map.data;
|
||||
for (i = 0; i < 48000; i++)
|
||||
indata[i] = 1.0;
|
||||
gst_buffer_unmap (inbuf, indata, -1);
|
||||
gst_buffer_unmap (inbuf, &map);
|
||||
fail_unless (gst_pad_push (mysrcpads[1], inbuf) == GST_FLOW_OK);
|
||||
|
||||
fail_unless (have_data == 2);
|
||||
|
@ -363,29 +374,10 @@ src_handoff_float32 (GstElement * element, GstBuffer * buffer, GstPad * pad,
|
|||
gpointer user_data)
|
||||
{
|
||||
gint n = GPOINTER_TO_INT (user_data);
|
||||
GstCaps *caps;
|
||||
gfloat *data;
|
||||
gint i;
|
||||
gsize size;
|
||||
|
||||
caps = gst_pad_get_current_caps (pad);
|
||||
|
||||
if (caps == NULL) {
|
||||
caps = gst_caps_new_simple ("audio/x-raw",
|
||||
"format", G_TYPE_STRING, GST_AUDIO_NE (F32),
|
||||
"channels", G_TYPE_INT, 1, "rate", G_TYPE_INT, 48000, NULL);
|
||||
|
||||
if (n == 2) {
|
||||
GstAudioChannelPosition pos[1] =
|
||||
{ GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT };
|
||||
gst_audio_set_channel_positions (gst_caps_get_structure (caps, 0), pos);
|
||||
} else if (n == 3) {
|
||||
GstAudioChannelPosition pos[1] =
|
||||
{ GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT };
|
||||
gst_audio_set_channel_positions (gst_caps_get_structure (caps, 0), pos);
|
||||
}
|
||||
}
|
||||
|
||||
size = 48000 * sizeof (gfloat);
|
||||
data = g_malloc (size);
|
||||
for (i = 0; i < 48000; i++)
|
||||
|
@ -405,37 +397,40 @@ sink_handoff_float32 (GstElement * element, GstBuffer * buffer, GstPad * pad,
|
|||
gpointer user_data)
|
||||
{
|
||||
gint i;
|
||||
gsize size;
|
||||
GstMapInfo map;
|
||||
gfloat *data;
|
||||
GstCaps *caps, *ccaps;
|
||||
gint n = GPOINTER_TO_INT (user_data);
|
||||
guint64 mask;
|
||||
|
||||
fail_unless (GST_IS_BUFFER (buffer));
|
||||
data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
|
||||
gst_buffer_map (buffer, &map, GST_MAP_READ);
|
||||
data = (gfloat *) map.data;
|
||||
|
||||
fail_unless_equals_int (size, 48000 * 2 * sizeof (gfloat));
|
||||
fail_unless_equals_int (map.size, 48000 * 2 * sizeof (gfloat));
|
||||
fail_unless_equals_int (GST_BUFFER_DURATION (buffer), GST_SECOND);
|
||||
|
||||
caps = gst_caps_new_simple ("audio/x-raw",
|
||||
"format", G_TYPE_STRING, GST_AUDIO_NE (F32),
|
||||
"channels", G_TYPE_INT, 2, "rate", G_TYPE_INT, 48000, NULL);
|
||||
|
||||
if (n == 0) {
|
||||
GstAudioChannelPosition pos[2] =
|
||||
{ GST_AUDIO_CHANNEL_POSITION_NONE, GST_AUDIO_CHANNEL_POSITION_NONE };
|
||||
gst_audio_set_channel_positions (gst_caps_get_structure (caps, 0), pos);
|
||||
gst_audio_channel_positions_to_mask (pos, 2, &mask);
|
||||
} else if (n == 1) {
|
||||
GstAudioChannelPosition pos[2] = { GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT,
|
||||
GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT
|
||||
};
|
||||
gst_audio_set_channel_positions (gst_caps_get_structure (caps, 0), pos);
|
||||
gst_audio_channel_positions_to_mask (pos, 2, &mask);
|
||||
} else if (n == 2) {
|
||||
GstAudioChannelPosition pos[2] = { GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER,
|
||||
GST_AUDIO_CHANNEL_POSITION_REAR_CENTER
|
||||
};
|
||||
gst_audio_set_channel_positions (gst_caps_get_structure (caps, 0), pos);
|
||||
gst_audio_channel_positions_to_mask (pos, 2, &mask);
|
||||
}
|
||||
|
||||
caps = gst_caps_new_simple ("audio/x-raw",
|
||||
"format", G_TYPE_STRING, GST_AUDIO_NE (F32),
|
||||
"channels", G_TYPE_INT, 2, "rate", G_TYPE_INT, 48000,
|
||||
"channel-mask", GST_TYPE_BITMASK, &mask, NULL);
|
||||
|
||||
ccaps = gst_pad_get_current_caps (pad);
|
||||
fail_unless (gst_caps_is_equal (caps, ccaps));
|
||||
gst_caps_unref (ccaps);
|
||||
|
@ -445,7 +440,7 @@ sink_handoff_float32 (GstElement * element, GstBuffer * buffer, GstPad * pad,
|
|||
fail_unless_equals_float (data[i], -1.0);
|
||||
fail_unless_equals_float (data[i + 1], 1.0);
|
||||
}
|
||||
gst_buffer_unmap (buffer, data, size);
|
||||
gst_buffer_unmap (buffer, &map);
|
||||
|
||||
have_data++;
|
||||
}
|
||||
|
|
|
@ -94,6 +94,7 @@ GST_START_TEST (test_int16)
|
|||
GstMessage *message;
|
||||
const GstStructure *structure;
|
||||
int i, j;
|
||||
GstMapInfo map;
|
||||
gint16 *data;
|
||||
const GValue *list, *value;
|
||||
GstClockTime endtime;
|
||||
|
@ -108,12 +109,13 @@ GST_START_TEST (test_int16)
|
|||
|
||||
/* create a fake 0.1 sec buffer with a half-amplitude block signal */
|
||||
inbuffer = gst_buffer_new_and_alloc (400);
|
||||
data = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE);
|
||||
gst_buffer_map (inbuffer, &map, GST_MAP_WRITE);
|
||||
data = (gint16 *) map.data;
|
||||
for (j = 0; j < 200; ++j) {
|
||||
*data = 16536;
|
||||
++data;
|
||||
}
|
||||
gst_buffer_unmap (inbuffer, data, -1);
|
||||
gst_buffer_unmap (inbuffer, &map);
|
||||
caps = gst_caps_from_string (LEVEL_CAPS_STRING);
|
||||
gst_pad_set_caps (mysrcpad, caps);
|
||||
gst_caps_unref (caps);
|
||||
|
@ -192,6 +194,7 @@ GST_START_TEST (test_int16_panned)
|
|||
const GstStructure *structure;
|
||||
int j;
|
||||
gint16 *data;
|
||||
GstMapInfo map;
|
||||
const GValue *list, *value;
|
||||
GstClockTime endtime;
|
||||
gdouble dB;
|
||||
|
@ -206,14 +209,15 @@ GST_START_TEST (test_int16_panned)
|
|||
|
||||
/* create a fake 0.1 sec buffer with a half-amplitude block signal */
|
||||
inbuffer = gst_buffer_new_and_alloc (400);
|
||||
data = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE);
|
||||
gst_buffer_map (inbuffer, &map, GST_MAP_WRITE);
|
||||
data = (gint16 *) map.data;
|
||||
for (j = 0; j < 100; ++j) {
|
||||
*data = 0;
|
||||
++data;
|
||||
*data = 16536;
|
||||
++data;
|
||||
}
|
||||
gst_buffer_unmap (inbuffer, data, -1);
|
||||
gst_buffer_unmap (inbuffer, &map);
|
||||
caps = gst_caps_from_string (LEVEL_CAPS_STRING);
|
||||
gst_pad_set_caps (mysrcpad, caps);
|
||||
gst_caps_unref (caps);
|
||||
|
|
|
@ -349,14 +349,16 @@ static GstBuffer *
|
|||
test_buffer_const_float_mono (gint sample_rate, gsize n_frames, gfloat value)
|
||||
{
|
||||
GstBuffer *buf = gst_buffer_new_and_alloc (n_frames * sizeof (gfloat));
|
||||
gfloat *data, *orig;
|
||||
GstMapInfo map;
|
||||
gfloat *data;
|
||||
GstCaps *caps;
|
||||
gint i;
|
||||
|
||||
data = orig = gst_buffer_map (buf, NULL, NULL, GST_MAP_WRITE);
|
||||
gst_buffer_map (buf, &map, GST_MAP_WRITE);
|
||||
data = (gfloat *) map.data;
|
||||
for (i = n_frames; i--;)
|
||||
*data++ = value;
|
||||
gst_buffer_unmap (buf, orig, -1);
|
||||
gst_buffer_unmap (buf, &map);
|
||||
|
||||
caps = gst_caps_new_simple ("audio/x-raw",
|
||||
"format", G_TYPE_STRING, GST_AUDIO_NE (F32),
|
||||
|
@ -374,16 +376,18 @@ test_buffer_const_float_stereo (gint sample_rate, gsize n_frames,
|
|||
gfloat value_l, gfloat value_r)
|
||||
{
|
||||
GstBuffer *buf = gst_buffer_new_and_alloc (n_frames * sizeof (gfloat) * 2);
|
||||
gfloat *data, *orig;
|
||||
GstMapInfo map;
|
||||
gfloat *data;
|
||||
GstCaps *caps;
|
||||
gint i;
|
||||
|
||||
data = orig = gst_buffer_map (buf, NULL, NULL, GST_MAP_WRITE);
|
||||
gst_buffer_map (buf, &map, GST_MAP_WRITE);
|
||||
data = (gfloat *) map.data;
|
||||
for (i = n_frames; i--;) {
|
||||
*data++ = value_l;
|
||||
*data++ = value_r;
|
||||
}
|
||||
gst_buffer_unmap (buf, orig, -1);
|
||||
gst_buffer_unmap (buf, &map);
|
||||
|
||||
caps = gst_caps_new_simple ("audio/x-raw",
|
||||
"format", G_TYPE_STRING, GST_AUDIO_NE (F32),
|
||||
|
@ -401,14 +405,16 @@ test_buffer_const_int16_mono (gint sample_rate, gint depth, gsize n_frames,
|
|||
gint16 value)
|
||||
{
|
||||
GstBuffer *buf = gst_buffer_new_and_alloc (n_frames * sizeof (gint16));
|
||||
gint16 *data, *orig;
|
||||
gint16 *data;
|
||||
GstMapInfo map;
|
||||
GstCaps *caps;
|
||||
gint i;
|
||||
|
||||
data = orig = gst_buffer_map (buf, NULL, NULL, GST_MAP_WRITE);
|
||||
gst_buffer_map (buf, &map, GST_MAP_WRITE);
|
||||
data = (gint16 *) map.data;
|
||||
for (i = n_frames; i--;)
|
||||
*data++ = value;
|
||||
gst_buffer_unmap (buf, orig, -1);
|
||||
gst_buffer_unmap (buf, &map);
|
||||
|
||||
caps = gst_caps_new_simple ("audio/x-raw",
|
||||
"format", G_TYPE_STRING, GST_AUDIO_NE (S16),
|
||||
|
@ -426,16 +432,18 @@ test_buffer_const_int16_stereo (gint sample_rate, gint depth, gsize n_frames,
|
|||
gint16 value_l, gint16 value_r)
|
||||
{
|
||||
GstBuffer *buf = gst_buffer_new_and_alloc (n_frames * sizeof (gint16) * 2);
|
||||
gint16 *data, *orig;
|
||||
gint16 *data;
|
||||
GstMapInfo map;
|
||||
GstCaps *caps;
|
||||
gint i;
|
||||
|
||||
data = orig = gst_buffer_map (buf, NULL, NULL, GST_MAP_WRITE);
|
||||
gst_buffer_map (buf, &map, GST_MAP_WRITE);
|
||||
data = (gint16 *) map.data;
|
||||
for (i = n_frames; i--;) {
|
||||
*data++ = value_l;
|
||||
*data++ = value_r;
|
||||
}
|
||||
gst_buffer_unmap (buf, orig, -1);
|
||||
gst_buffer_unmap (buf, &map);
|
||||
|
||||
caps = gst_caps_new_simple ("audio/x-raw",
|
||||
"format", G_TYPE_STRING, GST_AUDIO_NE (S16),
|
||||
|
@ -456,11 +464,13 @@ test_buffer_square_float_mono (gint * accumulator, gint sample_rate,
|
|||
gsize n_frames, gfloat value)
|
||||
{
|
||||
GstBuffer *buf = gst_buffer_new_and_alloc (n_frames * sizeof (gfloat));
|
||||
gfloat *data, *orig;
|
||||
gfloat *data;
|
||||
GstMapInfo map;
|
||||
GstCaps *caps;
|
||||
gint i;
|
||||
|
||||
data = orig = gst_buffer_map (buf, NULL, NULL, GST_MAP_WRITE);
|
||||
gst_buffer_map (buf, &map, GST_MAP_WRITE);
|
||||
data = (gfloat *) map.data;
|
||||
for (i = n_frames; i--;) {
|
||||
*accumulator += 1;
|
||||
*accumulator %= 96;
|
||||
|
@ -470,7 +480,7 @@ test_buffer_square_float_mono (gint * accumulator, gint sample_rate,
|
|||
else
|
||||
*data++ = -value;
|
||||
}
|
||||
gst_buffer_unmap (buf, orig, -1);
|
||||
gst_buffer_unmap (buf, &map);
|
||||
|
||||
caps = gst_caps_new_simple ("audio/x-raw",
|
||||
"format", G_TYPE_STRING, GST_AUDIO_NE (F32),
|
||||
|
@ -488,11 +498,13 @@ test_buffer_square_float_stereo (gint * accumulator, gint sample_rate,
|
|||
gsize n_frames, gfloat value_l, gfloat value_r)
|
||||
{
|
||||
GstBuffer *buf = gst_buffer_new_and_alloc (n_frames * sizeof (gfloat) * 2);
|
||||
gfloat *data, *orig;
|
||||
gfloat *data;
|
||||
GstMapInfo map;
|
||||
GstCaps *caps;
|
||||
gint i;
|
||||
|
||||
data = orig = gst_buffer_map (buf, NULL, NULL, GST_MAP_WRITE);
|
||||
gst_buffer_map (buf, &map, GST_MAP_WRITE);
|
||||
data = (gfloat *) map.data;
|
||||
for (i = n_frames; i--;) {
|
||||
*accumulator += 1;
|
||||
*accumulator %= 96;
|
||||
|
@ -505,7 +517,7 @@ test_buffer_square_float_stereo (gint * accumulator, gint sample_rate,
|
|||
*data++ = -value_r;
|
||||
}
|
||||
}
|
||||
gst_buffer_unmap (buf, orig, -1);
|
||||
gst_buffer_unmap (buf, &map);
|
||||
|
||||
caps = gst_caps_new_simple ("audio/x-raw",
|
||||
"format", G_TYPE_STRING, GST_AUDIO_NE (F32),
|
||||
|
@ -523,11 +535,13 @@ test_buffer_square_int16_mono (gint * accumulator, gint sample_rate,
|
|||
gint depth, gsize n_frames, gint16 value)
|
||||
{
|
||||
GstBuffer *buf = gst_buffer_new_and_alloc (n_frames * sizeof (gint16));
|
||||
gint16 *data, *orig;
|
||||
gint16 *data;
|
||||
GstMapInfo map;
|
||||
GstCaps *caps;
|
||||
gint i;
|
||||
|
||||
data = orig = gst_buffer_map (buf, NULL, NULL, GST_MAP_WRITE);
|
||||
gst_buffer_map (buf, &map, GST_MAP_WRITE);
|
||||
data = (gint16 *) map.data;
|
||||
for (i = n_frames; i--;) {
|
||||
*accumulator += 1;
|
||||
*accumulator %= 96;
|
||||
|
@ -537,7 +551,7 @@ test_buffer_square_int16_mono (gint * accumulator, gint sample_rate,
|
|||
else
|
||||
*data++ = -MAX (value, -32767);
|
||||
}
|
||||
gst_buffer_unmap (buf, orig, -1);
|
||||
gst_buffer_unmap (buf, &map);
|
||||
|
||||
caps = gst_caps_new_simple ("audio/x-raw",
|
||||
"format", G_TYPE_STRING, GST_AUDIO_NE (S16),
|
||||
|
@ -555,11 +569,13 @@ test_buffer_square_int16_stereo (gint * accumulator, gint sample_rate,
|
|||
gint depth, gsize n_frames, gint16 value_l, gint16 value_r)
|
||||
{
|
||||
GstBuffer *buf = gst_buffer_new_and_alloc (n_frames * sizeof (gint16) * 2);
|
||||
gint16 *data, *orig;
|
||||
gint16 *data;
|
||||
GstMapInfo map;
|
||||
GstCaps *caps;
|
||||
gint i;
|
||||
|
||||
data = orig = gst_buffer_map (buf, NULL, NULL, GST_MAP_WRITE);
|
||||
gst_buffer_map (buf, &map, GST_MAP_WRITE);
|
||||
data = (gint16 *) map.data;
|
||||
for (i = n_frames; i--;) {
|
||||
*accumulator += 1;
|
||||
*accumulator %= 96;
|
||||
|
@ -572,7 +588,7 @@ test_buffer_square_int16_stereo (gint * accumulator, gint sample_rate,
|
|||
*data++ = -MAX (value_r, -32767);
|
||||
}
|
||||
}
|
||||
gst_buffer_unmap (buf, orig, -1);
|
||||
gst_buffer_unmap (buf, &map);
|
||||
|
||||
caps = gst_caps_new_simple ("audio/x-raw",
|
||||
"format", G_TYPE_STRING, GST_AUDIO_NE (S16),
|
||||
|
|
|
@ -120,19 +120,20 @@ create_test_buffer (void)
|
|||
static void
|
||||
verify_test_buffer (GstBuffer * buf)
|
||||
{
|
||||
gsize size;
|
||||
GstMapInfo map;
|
||||
gfloat *output;
|
||||
gint i;
|
||||
|
||||
output = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
|
||||
fail_unless (size == sizeof (test_output));
|
||||
gst_buffer_map (buf, &map, GST_MAP_READ);
|
||||
output = (gfloat *) map.data;
|
||||
fail_unless (map.size == sizeof (test_output));
|
||||
|
||||
for (i = 0; i < G_N_ELEMENTS (test_input); i++)
|
||||
fail_unless (ABS (output[i] - test_output[i]) < 1.e-6,
|
||||
"Incorrect output value %.6f for input %.2f, expected %.6f",
|
||||
output[i], test_input[i], test_output[i]);
|
||||
|
||||
gst_buffer_unmap (buf, output, size);
|
||||
gst_buffer_unmap (buf, &map);
|
||||
}
|
||||
|
||||
/* Start of tests. */
|
||||
|
@ -214,8 +215,7 @@ GST_START_TEST (test_gap)
|
|||
{
|
||||
GstElement *element = setup_rglimiter ();
|
||||
GstBuffer *buf, *out_buf;
|
||||
gpointer d1, d2;
|
||||
gsize s1, s2;
|
||||
GstMapInfo m1, m2;
|
||||
|
||||
set_playing_state (element);
|
||||
|
||||
|
@ -230,17 +230,17 @@ GST_START_TEST (test_gap)
|
|||
/* Verify that the baseclass does not lift the GAP flag: */
|
||||
fail_unless (GST_BUFFER_FLAG_IS_SET (out_buf, GST_BUFFER_FLAG_GAP));
|
||||
|
||||
d1 = gst_buffer_map (out_buf, &s1, NULL, GST_MAP_READ);
|
||||
d2 = gst_buffer_map (buf, &s2, NULL, GST_MAP_READ);
|
||||
gst_buffer_map (out_buf, &m1, GST_MAP_READ);
|
||||
gst_buffer_map (buf, &m2, GST_MAP_READ);
|
||||
|
||||
g_assert (s1 == s2);
|
||||
g_assert (m1.size == m2.size);
|
||||
/* We cheated by passing an input buffer with non-silence that has the GAP
|
||||
* flag set. The element cannot know that however and must have skipped
|
||||
* adjusting the buffer because of the flag, which we can easily verify: */
|
||||
fail_if (memcmp (d1, d2, s1) != 0);
|
||||
fail_if (memcmp (m1.data, m2.data, m1.size) != 0);
|
||||
|
||||
gst_buffer_unmap (out_buf, d1, s1);
|
||||
gst_buffer_unmap (buf, d2, s2);
|
||||
gst_buffer_unmap (out_buf, &m1);
|
||||
gst_buffer_unmap (buf, &m2);
|
||||
|
||||
cleanup_rglimiter (element);
|
||||
}
|
||||
|
|
|
@ -95,7 +95,7 @@ send_newsegment_and_empty_buffer (void)
|
|||
"Pushing newsegment event failed");
|
||||
|
||||
buf = test_buffer_new (0.0);
|
||||
GST_BUFFER_SIZE (buf) = 0;
|
||||
gst_buffer_resize (buf, 0, 0);
|
||||
GST_BUFFER_DURATION (buf) = 0;
|
||||
GST_BUFFER_OFFSET_END (buf) = GST_BUFFER_OFFSET (buf);
|
||||
fail_unless (gst_pad_push (mysrcpad, buf) == GST_FLOW_OK);
|
||||
|
@ -202,14 +202,16 @@ test_buffer_new (gfloat value)
|
|||
{
|
||||
GstBuffer *buf;
|
||||
GstCaps *caps;
|
||||
GstMapInfo map;
|
||||
gfloat *data;
|
||||
gint i;
|
||||
|
||||
buf = gst_buffer_new_and_alloc (8 * sizeof (gfloat));
|
||||
data = gst_buffer_map (buf, NULL, NULL, GST_MAP_WRITE);
|
||||
gst_buffer_map (buf, &map, GST_MAP_WRITE);
|
||||
data = (gfloat *) map.data;
|
||||
for (i = 0; i < 8; i++)
|
||||
data[i] = value;
|
||||
gst_buffer_unmap (buf, data, -1);
|
||||
gst_buffer_unmap (buf, &map);
|
||||
|
||||
caps = gst_caps_from_string ("audio/x-raw-float, "
|
||||
"rate = 8000, channels = 1, endianness = BYTE_ORDER, width = 32");
|
||||
|
@ -243,6 +245,7 @@ fail_unless_result_gain (GstElement * element, gdouble expected_gain)
|
|||
gdouble gain, prop_gain;
|
||||
gboolean is_passthrough, expect_passthrough;
|
||||
gint i;
|
||||
GstMapInfo map;
|
||||
|
||||
fail_unless (g_list_length (buffers) == 0);
|
||||
|
||||
|
@ -266,14 +269,15 @@ fail_unless_result_gain (GstElement * element, gdouble expected_gain)
|
|||
fail_unless_equals_int (gst_buffer_get_size (output_buf),
|
||||
8 * sizeof (gfloat));
|
||||
|
||||
data = gst_buffer_map (output_buf, NULL, NULL, GST_MAP_READ);
|
||||
gst_buffer_map (output_buf, &map, GST_MAP_READ);
|
||||
data = (gfloat *) map.data;
|
||||
|
||||
output_sample = *data;
|
||||
fail_if (output_sample == 0.0, "First output sample is zero");
|
||||
for (i = 1; i < 8; i++) {
|
||||
fail_unless (output_sample == data[i], "Output samples not uniform");
|
||||
};
|
||||
gst_buffer_unmap (output_buf, data, -1);
|
||||
gst_buffer_unmap (output_buf, &map);
|
||||
|
||||
gain = 20. * log10 (output_sample / input_sample);
|
||||
fail_unless (MATCH_GAIN (gain, expected_gain),
|
||||
|
|
|
@ -130,7 +130,7 @@ chain_rtp_packet (GstPad * pad, CleanupData * data)
|
|||
GstFlowReturn res;
|
||||
static GstCaps *caps = NULL;
|
||||
GstBuffer *buffer;
|
||||
guint8 *datap;
|
||||
GstMapInfo map;
|
||||
|
||||
if (caps == NULL) {
|
||||
caps = gst_caps_from_string ("application/x-rtp,"
|
||||
|
@ -141,14 +141,14 @@ chain_rtp_packet (GstPad * pad, CleanupData * data)
|
|||
}
|
||||
|
||||
buffer = gst_buffer_new_and_alloc (sizeof (rtp_packet));
|
||||
datap = gst_buffer_map (buffer, NULL, NULL, GST_MAP_WRITE);
|
||||
memcpy (datap, rtp_packet, sizeof (rtp_packet));
|
||||
gst_buffer_map (buffer, &map, GST_MAP_WRITE);
|
||||
memcpy (map.data, rtp_packet, sizeof (rtp_packet));
|
||||
|
||||
datap[2] = (data->seqnum >> 8) & 0xff;
|
||||
datap[3] = data->seqnum & 0xff;
|
||||
map.data[2] = (data->seqnum >> 8) & 0xff;
|
||||
map.data[3] = data->seqnum & 0xff;
|
||||
|
||||
data->seqnum++;
|
||||
gst_buffer_unmap (buffer, datap, -1);
|
||||
gst_buffer_unmap (buffer, &map);
|
||||
|
||||
res = gst_pad_chain (pad, buffer);
|
||||
|
||||
|
|
|
@ -166,7 +166,7 @@ check_jitterbuffer_results (GstElement * jitterbuffer, gint num_buffers)
|
|||
GList *node;
|
||||
GstClockTime ts = G_GUINT64_CONSTANT (0);
|
||||
GstClockTime tso = gst_util_uint64_scale (RTP_FRAME_SIZE, GST_SECOND, 8000);
|
||||
guint8 *data;
|
||||
GstMapInfo map;
|
||||
guint16 prev_sn = 0, cur_sn;
|
||||
guint32 prev_ts = 0, cur_ts;
|
||||
|
||||
|
@ -183,11 +183,11 @@ check_jitterbuffer_results (GstElement * jitterbuffer, gint num_buffers)
|
|||
for (node = buffers; node; node = g_list_next (node)) {
|
||||
fail_if ((buffer = (GstBuffer *) node->data) == NULL);
|
||||
fail_if (GST_BUFFER_TIMESTAMP (buffer) != ts);
|
||||
data = gst_buffer_map (buffer, NULL, NULL, GST_MAP_READ);
|
||||
cur_sn = ((guint16) data[2] << 8) | data[3];
|
||||
cur_ts = ((guint32) data[4] << 24) | ((guint32) data[5] << 16) |
|
||||
((guint32) data[6] << 8) | data[7];
|
||||
gst_buffer_unmap (buffer, data, -1);
|
||||
gst_buffer_map (buffer, &map, GST_MAP_READ);
|
||||
cur_sn = ((guint16) map.data[2] << 8) | map.data[3];
|
||||
cur_ts = ((guint32) map.data[4] << 24) | ((guint32) map.data[5] << 16) |
|
||||
((guint32) map.data[6] << 8) | map.data[7];
|
||||
gst_buffer_unmap (buffer, &map);
|
||||
|
||||
if (node != buffers) {
|
||||
fail_unless (cur_sn > prev_sn);
|
||||
|
|
|
@ -81,7 +81,8 @@ GST_START_TEST (test_general)
|
|||
GstCaps *caps;
|
||||
GstBuffer *mask, *input;
|
||||
guint i, j;
|
||||
guint8 *data, *orig;
|
||||
guint8 *data;
|
||||
GstMapInfo map;
|
||||
|
||||
myvideosrcpad =
|
||||
gst_pad_new_from_static_template (&videosrctemplate, "videosrc");
|
||||
|
@ -123,7 +124,8 @@ GST_START_TEST (test_general)
|
|||
caps = gst_caps_from_string (SHAPEWIPE_MASK_CAPS_STRING);
|
||||
gst_pad_set_caps (mymasksrcpad, caps);
|
||||
gst_caps_unref (caps);
|
||||
data = orig = gst_buffer_map (mask, NULL, NULL, GST_MAP_WRITE);
|
||||
gst_buffer_map (mask, &map, GST_MAP_WRITE);
|
||||
data = map.data;
|
||||
for (i = 0; i < 400; i++) {
|
||||
for (j = 0; j < 400; j++) {
|
||||
if (i < 100 && j < 100)
|
||||
|
@ -137,7 +139,7 @@ GST_START_TEST (test_general)
|
|||
data++;
|
||||
}
|
||||
}
|
||||
gst_buffer_unmap (mask, orig, -1);
|
||||
gst_buffer_unmap (mask, &map);
|
||||
|
||||
fail_unless (gst_pad_push (mymasksrcpad, mask) == GST_FLOW_OK);
|
||||
|
||||
|
@ -145,7 +147,8 @@ GST_START_TEST (test_general)
|
|||
caps = gst_caps_from_string (SHAPEWIPE_VIDEO_CAPS_STRING);
|
||||
gst_pad_set_caps (myvideosrcpad, caps);
|
||||
gst_caps_unref (caps);
|
||||
data = orig = gst_buffer_map (input, NULL, NULL, GST_MAP_WRITE);
|
||||
gst_buffer_map (input, &map, GST_MAP_WRITE);
|
||||
data = map.data;
|
||||
for (i = 0; i < 400; i++) {
|
||||
for (j = 0; j < 400; j++) {
|
||||
/* This is green */
|
||||
|
@ -156,14 +159,15 @@ GST_START_TEST (test_general)
|
|||
data += 4;
|
||||
}
|
||||
}
|
||||
gst_buffer_unmap (input, orig, -1);
|
||||
gst_buffer_unmap (input, &map);
|
||||
|
||||
g_object_set (G_OBJECT (shapewipe), "position", 0.0, NULL);
|
||||
output = NULL;
|
||||
fail_unless (gst_pad_push (myvideosrcpad,
|
||||
gst_buffer_ref (input)) == GST_FLOW_OK);
|
||||
fail_unless (output != NULL);
|
||||
data = orig = gst_buffer_map (output, NULL, NULL, GST_MAP_WRITE);
|
||||
gst_buffer_map (output, &map, GST_MAP_WRITE);
|
||||
data = map.data;
|
||||
for (i = 0; i < 400; i++) {
|
||||
for (j = 0; j < 400; j++) {
|
||||
fail_unless_equals_int (data[0], 255); /* A */
|
||||
|
@ -173,7 +177,7 @@ GST_START_TEST (test_general)
|
|||
data += 4;
|
||||
}
|
||||
}
|
||||
gst_buffer_unmap (output, orig, -1);
|
||||
gst_buffer_unmap (output, &map);
|
||||
gst_buffer_unref (output);
|
||||
output = NULL;
|
||||
|
||||
|
@ -182,7 +186,8 @@ GST_START_TEST (test_general)
|
|||
fail_unless (gst_pad_push (myvideosrcpad,
|
||||
gst_buffer_ref (input)) == GST_FLOW_OK);
|
||||
fail_unless (output != NULL);
|
||||
data = orig = gst_buffer_map (output, NULL, NULL, GST_MAP_WRITE);
|
||||
gst_buffer_map (output, &map, GST_MAP_READ);
|
||||
data = map.data;
|
||||
for (i = 0; i < 400; i++) {
|
||||
for (j = 0; j < 400; j++) {
|
||||
if (i < 100 && j < 100) {
|
||||
|
@ -199,7 +204,7 @@ GST_START_TEST (test_general)
|
|||
data += 4;
|
||||
}
|
||||
}
|
||||
gst_buffer_unmap (output, orig, -1);
|
||||
gst_buffer_unmap (output, &map);
|
||||
gst_buffer_unref (output);
|
||||
output = NULL;
|
||||
|
||||
|
@ -208,7 +213,8 @@ GST_START_TEST (test_general)
|
|||
fail_unless (gst_pad_push (myvideosrcpad,
|
||||
gst_buffer_ref (input)) == GST_FLOW_OK);
|
||||
fail_unless (output != NULL);
|
||||
data = orig = gst_buffer_map (output, NULL, NULL, GST_MAP_WRITE);
|
||||
gst_buffer_map (output, &map, GST_MAP_READ);
|
||||
data = map.data;
|
||||
for (i = 0; i < 400; i++) {
|
||||
for (j = 0; j < 400; j++) {
|
||||
if (i < 200 && j < 200) {
|
||||
|
@ -225,7 +231,7 @@ GST_START_TEST (test_general)
|
|||
data += 4;
|
||||
}
|
||||
}
|
||||
gst_buffer_unmap (output, orig, -1);
|
||||
gst_buffer_unmap (output, &map);
|
||||
gst_buffer_unref (output);
|
||||
output = NULL;
|
||||
|
||||
|
@ -234,7 +240,8 @@ GST_START_TEST (test_general)
|
|||
fail_unless (gst_pad_push (myvideosrcpad,
|
||||
gst_buffer_ref (input)) == GST_FLOW_OK);
|
||||
fail_unless (output != NULL);
|
||||
data = orig = gst_buffer_map (output, NULL, NULL, GST_MAP_WRITE);
|
||||
gst_buffer_map (output, &map, GST_MAP_READ);
|
||||
data = map.data;
|
||||
for (i = 0; i < 400; i++) {
|
||||
for (j = 0; j < 400; j++) {
|
||||
if (i < 300 && j < 300) {
|
||||
|
@ -251,7 +258,7 @@ GST_START_TEST (test_general)
|
|||
data += 4;
|
||||
}
|
||||
}
|
||||
gst_buffer_unmap (output, orig, -1);
|
||||
gst_buffer_unmap (output, &map);
|
||||
gst_buffer_unref (output);
|
||||
output = NULL;
|
||||
|
||||
|
@ -260,7 +267,8 @@ GST_START_TEST (test_general)
|
|||
fail_unless (gst_pad_push (myvideosrcpad,
|
||||
gst_buffer_ref (input)) == GST_FLOW_OK);
|
||||
fail_unless (output != NULL);
|
||||
data = orig = gst_buffer_map (output, NULL, NULL, GST_MAP_WRITE);
|
||||
gst_buffer_map (output, &map, GST_MAP_READ);
|
||||
data = map.data;
|
||||
for (i = 0; i < 400; i++) {
|
||||
for (j = 0; j < 400; j++) {
|
||||
fail_unless_equals_int (data[0], 0); /* A */
|
||||
|
@ -270,7 +278,7 @@ GST_START_TEST (test_general)
|
|||
data += 4;
|
||||
}
|
||||
}
|
||||
gst_buffer_unmap (output, orig, -1);
|
||||
gst_buffer_unmap (output, &map);
|
||||
gst_buffer_unref (output);
|
||||
output = NULL;
|
||||
|
||||
|
|
|
@ -121,7 +121,8 @@ GST_START_TEST (test_int16)
|
|||
GstMessage *message;
|
||||
const GstStructure *structure;
|
||||
int i, j;
|
||||
gint16 *buf_data, *data;
|
||||
gint16 *data;
|
||||
GstMapInfo map;
|
||||
const GValue *list, *value;
|
||||
GstClockTime endtime;
|
||||
gfloat level;
|
||||
|
@ -136,8 +137,8 @@ GST_START_TEST (test_int16)
|
|||
|
||||
/* create a 1 sec buffer with an 11025 Hz sine wave */
|
||||
inbuffer = gst_buffer_new_allocate (NULL, 44100 * sizeof (gint16), 0);
|
||||
buf_data = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE);
|
||||
data = buf_data;
|
||||
gst_buffer_map (inbuffer, &map, GST_MAP_WRITE);
|
||||
data = (gint16 *) map.data;
|
||||
for (j = 0; j < 44100; j += 4) {
|
||||
*data = 0;
|
||||
++data;
|
||||
|
@ -148,7 +149,7 @@ GST_START_TEST (test_int16)
|
|||
*data = -32767;
|
||||
++data;
|
||||
}
|
||||
gst_buffer_unmap (inbuffer, buf_data, -1);
|
||||
gst_buffer_unmap (inbuffer, &map);
|
||||
|
||||
caps = gst_caps_from_string (SPECT_CAPS_STRING_S16);
|
||||
fail_unless (gst_pad_set_caps (mysrcpad, caps));
|
||||
|
@ -225,7 +226,8 @@ GST_START_TEST (test_int32)
|
|||
GstMessage *message;
|
||||
const GstStructure *structure;
|
||||
int i, j;
|
||||
gint32 *buf_data, *data;
|
||||
gint32 *data;
|
||||
GstMapInfo map;
|
||||
const GValue *list, *value;
|
||||
GstClockTime endtime;
|
||||
gfloat level;
|
||||
|
@ -240,8 +242,8 @@ GST_START_TEST (test_int32)
|
|||
|
||||
/* create a 1 sec buffer with an 11025 Hz sine wave */
|
||||
inbuffer = gst_buffer_new_allocate (NULL, 44100 * sizeof (gint32), 0);
|
||||
buf_data = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE);
|
||||
data = buf_data;
|
||||
gst_buffer_map (inbuffer, &map, GST_MAP_WRITE);
|
||||
data = (gint32 *) map.data;
|
||||
for (j = 0; j < 44100; j += 4) {
|
||||
*data = 0;
|
||||
++data;
|
||||
|
@ -252,7 +254,7 @@ GST_START_TEST (test_int32)
|
|||
*data = -2147483647;
|
||||
++data;
|
||||
}
|
||||
gst_buffer_unmap (inbuffer, buf_data, -1);
|
||||
gst_buffer_unmap (inbuffer, &map);
|
||||
|
||||
caps = gst_caps_from_string (SPECT_CAPS_STRING_S32);
|
||||
fail_unless (gst_pad_set_caps (mysrcpad, caps));
|
||||
|
@ -329,7 +331,8 @@ GST_START_TEST (test_float32)
|
|||
GstMessage *message;
|
||||
const GstStructure *structure;
|
||||
int i, j;
|
||||
gfloat *buf_data, *data;
|
||||
gfloat *data;
|
||||
GstMapInfo map;
|
||||
const GValue *list, *value;
|
||||
GstClockTime endtime;
|
||||
gfloat level;
|
||||
|
@ -344,8 +347,8 @@ GST_START_TEST (test_float32)
|
|||
|
||||
/* create a 1 sec buffer with an 11025 Hz sine wave */
|
||||
inbuffer = gst_buffer_new_allocate (NULL, 44100 * sizeof (gfloat), 0);
|
||||
buf_data = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE);
|
||||
data = buf_data;
|
||||
gst_buffer_map (inbuffer, &map, GST_MAP_WRITE);
|
||||
data = (gfloat *) map.data;
|
||||
for (j = 0; j < 44100; j += 4) {
|
||||
*data = 0.0;
|
||||
++data;
|
||||
|
@ -356,7 +359,7 @@ GST_START_TEST (test_float32)
|
|||
*data = -1.0;
|
||||
++data;
|
||||
}
|
||||
gst_buffer_unmap (inbuffer, buf_data, -1);
|
||||
gst_buffer_unmap (inbuffer, &map);
|
||||
|
||||
caps = gst_caps_from_string (SPECT_CAPS_STRING_F32);
|
||||
fail_unless (gst_pad_set_caps (mysrcpad, caps));
|
||||
|
@ -433,7 +436,8 @@ GST_START_TEST (test_float64)
|
|||
GstMessage *message;
|
||||
const GstStructure *structure;
|
||||
int i, j;
|
||||
gdouble *buf_data, *data;
|
||||
gdouble *data;
|
||||
GstMapInfo map;
|
||||
const GValue *list, *value;
|
||||
GstClockTime endtime;
|
||||
gfloat level;
|
||||
|
@ -448,8 +452,8 @@ GST_START_TEST (test_float64)
|
|||
|
||||
/* create a 1 sec buffer with an 11025 Hz sine wave */
|
||||
inbuffer = gst_buffer_new_allocate (NULL, 44100 * sizeof (gdouble), 0);
|
||||
buf_data = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE);
|
||||
data = buf_data;
|
||||
gst_buffer_map (inbuffer, &map, GST_MAP_WRITE);
|
||||
data = (gdouble *) map.data;
|
||||
for (j = 0; j < 44100; j += 4) {
|
||||
*data = 0.0;
|
||||
++data;
|
||||
|
@ -460,7 +464,7 @@ GST_START_TEST (test_float64)
|
|||
*data = -1.0;
|
||||
++data;
|
||||
}
|
||||
gst_buffer_unmap (inbuffer, buf_data, -1);
|
||||
gst_buffer_unmap (inbuffer, &map);
|
||||
|
||||
caps = gst_caps_from_string (SPECT_CAPS_STRING_F64);
|
||||
fail_unless (gst_pad_set_caps (mysrcpad, caps));
|
||||
|
|
|
@ -62,6 +62,7 @@ GST_START_TEST (test_udpsrc_empty_packet)
|
|||
if (g_socket_send_to (socket, sa, "HeLL0", 0, NULL, NULL) == 0) {
|
||||
GST_INFO ("sent 0 bytes");
|
||||
if (g_socket_send_to (socket, sa, "HeLL0", 6, NULL, NULL) == 6) {
|
||||
GstMapInfo map;
|
||||
GstBuffer *buf;
|
||||
guint len;
|
||||
|
||||
|
@ -75,13 +76,15 @@ GST_START_TEST (test_udpsrc_empty_packet)
|
|||
|
||||
/* last buffer should be our HeLL0 string */
|
||||
buf = GST_BUFFER (g_list_nth_data (buffers, len - 1));
|
||||
fail_unless_equals_int (GST_BUFFER_SIZE (buf), 6);
|
||||
fail_unless_equals_string ((gchar *) GST_BUFFER_DATA (buf), "HeLL0");
|
||||
gst_buffer_map (buf, &map, GST_MAP_READ);
|
||||
fail_unless_equals_int (map.size, 6);
|
||||
fail_unless_equals_string ((gchar *) map.data, "HeLL0");
|
||||
gst_buffer_unmap (buf, &map);
|
||||
|
||||
/* if there's another buffer, it should be 0 bytes */
|
||||
if (len == 2) {
|
||||
buf = GST_BUFFER (g_list_nth_data (buffers, 0));
|
||||
fail_unless_equals_int (GST_BUFFER_SIZE (buf), 0);
|
||||
fail_unless_equals_int (gst_buffer_get_size (buf), 0);
|
||||
}
|
||||
} else {
|
||||
GST_WARNING ("send_to(6 bytes) failed");
|
||||
|
|
|
@ -110,7 +110,8 @@ GST_START_TEST (test_y4m)
|
|||
|
||||
/* clean up buffers */
|
||||
for (i = 0; i < num_buffers; ++i) {
|
||||
gchar *data, *orig;
|
||||
GstMapInfo map;
|
||||
gchar *data;
|
||||
gsize outsize;
|
||||
|
||||
outbuffer = GST_BUFFER (buffers->data);
|
||||
|
@ -118,7 +119,9 @@ GST_START_TEST (test_y4m)
|
|||
|
||||
switch (i) {
|
||||
case 0:
|
||||
data = orig = gst_buffer_map (outbuffer, &outsize, NULL, GST_MAP_READ);
|
||||
gst_buffer_map (outbuffer, &map, GST_MAP_READ);
|
||||
outsize = map.size;
|
||||
data = (gchar *) map.data;
|
||||
|
||||
fail_unless (outsize > size);
|
||||
fail_unless (memcmp (data, data0, strlen (data0)) == 0 ||
|
||||
|
@ -130,8 +133,8 @@ GST_START_TEST (test_y4m)
|
|||
fail_unless (memcmp (data2, data, strlen (data2)) == 0);
|
||||
data += strlen (data2);
|
||||
/* remainder must be frame data */
|
||||
fail_unless (data - orig + size == outsize);
|
||||
gst_buffer_unmap (outbuffer, orig, outsize);
|
||||
fail_unless (data - (gchar *) map.data + size == outsize);
|
||||
gst_buffer_unmap (outbuffer, &map);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
|
|
@ -27,8 +27,7 @@ _get_first_sample (GstSample * sample)
|
|||
GstAudioInfo info;
|
||||
GstCaps *caps;
|
||||
GstBuffer *buf;
|
||||
guint8 *data;
|
||||
gsize size;
|
||||
GstMapInfo map;
|
||||
guint16 res;
|
||||
|
||||
fail_unless (sample != NULL, "NULL sample");
|
||||
|
@ -40,9 +39,9 @@ _get_first_sample (GstSample * sample)
|
|||
GST_DEBUG ("buffer with size=%u, caps=%" GST_PTR_FORMAT,
|
||||
gst_buffer_get_size (buf), caps);
|
||||
|
||||
data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
|
||||
gst_buffer_map (buf, &map, GST_MAP_READ);
|
||||
/* log buffer details */
|
||||
GST_MEMDUMP ("buffer data from decoder", data, size);
|
||||
GST_MEMDUMP ("buffer data from decoder", map.data, map.size);
|
||||
|
||||
/* make sure it's the format we expect */
|
||||
fail_unless (gst_audio_info_from_caps (&info, caps));
|
||||
|
@ -53,11 +52,11 @@ _get_first_sample (GstSample * sample)
|
|||
fail_unless_equals_int (GST_AUDIO_INFO_CHANNELS (&info), 1);
|
||||
|
||||
if (GST_AUDIO_INFO_IS_LITTLE_ENDIAN (&info))
|
||||
res = GST_READ_UINT16_LE (data);
|
||||
res = GST_READ_UINT16_LE (map.data);
|
||||
else
|
||||
res = GST_READ_UINT16_BE (data);
|
||||
res = GST_READ_UINT16_BE (map.data);
|
||||
|
||||
gst_buffer_unmap (buf, data, size);
|
||||
gst_buffer_unmap (buf, &map);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
|
|
@ -21,7 +21,8 @@
|
|||
*/
|
||||
|
||||
#include <gst/check/gstcheck.h>
|
||||
#include <gst/audio/multichannel.h>
|
||||
#include <gst/audio/audio.h>
|
||||
#include <gst/audio/audio-enumtypes.h>
|
||||
|
||||
static gboolean
|
||||
bus_handler (GstBus * bus, GstMessage * message, gpointer data)
|
||||
|
|
Loading…
Reference in a new issue