mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-06-05 15:08:53 +00:00
tests: fix some tests
This commit is contained in:
parent
2af62366da
commit
20de8b3ebd
3 changed files with 24 additions and 22 deletions
|
@ -25,7 +25,7 @@
|
||||||
#include <gst/audio/audio.h>
|
#include <gst/audio/audio.h>
|
||||||
|
|
||||||
#define SRC_CAPS "audio/x-raw, format = (string)" GST_AUDIO_NE (S16) ", " \
|
#define SRC_CAPS "audio/x-raw, format = (string)" GST_AUDIO_NE (S16) ", " \
|
||||||
"channels = (int) 1, rate = (int) 8000"
|
"layout = (string) interleaved, channels = (int) 1, rate = (int) 8000"
|
||||||
#define SINK_CAPS "audio/AMR"
|
#define SINK_CAPS "audio/AMR"
|
||||||
|
|
||||||
GList *buffers;
|
GList *buffers;
|
||||||
|
|
|
@ -98,7 +98,7 @@ check_caps (GstCaps * caps)
|
||||||
stream_format = g_value_get_string (sf);
|
stream_format = g_value_get_string (sf);
|
||||||
fail_unless (stream_format != NULL);
|
fail_unless (stream_format != NULL);
|
||||||
if (strcmp (stream_format, "avc") == 0) {
|
if (strcmp (stream_format, "avc") == 0) {
|
||||||
const guint8 *data;
|
GstMapInfo map;
|
||||||
GstBuffer *buf;
|
GstBuffer *buf;
|
||||||
|
|
||||||
avcc = gst_structure_get_value (s, "codec_data");
|
avcc = gst_structure_get_value (s, "codec_data");
|
||||||
|
@ -106,11 +106,12 @@ check_caps (GstCaps * caps)
|
||||||
fail_unless (GST_VALUE_HOLDS_BUFFER (avcc));
|
fail_unless (GST_VALUE_HOLDS_BUFFER (avcc));
|
||||||
buf = gst_value_get_buffer (avcc);
|
buf = gst_value_get_buffer (avcc);
|
||||||
fail_unless (buf != NULL);
|
fail_unless (buf != NULL);
|
||||||
data = gst_buffer_map (buf, NULL, NULL, GST_MAP_READ);
|
gst_buffer_map (buf, &map, GST_MAP_READ);
|
||||||
fail_unless_equals_int (data[0], 1);
|
fail_unless_equals_int (map.data[0], 1);
|
||||||
/* should be either baseline, main profile or extended profile */
|
/* should be either baseline, main profile or extended profile */
|
||||||
fail_unless (data[1] == 0x42 || data[1] == 0x4D || data[1] == 0x58);
|
fail_unless (map.data[1] == 0x42 || map.data[1] == 0x4D
|
||||||
gst_buffer_unmap (buf, (gpointer) data, -1);
|
|| map.data[1] == 0x58);
|
||||||
|
gst_buffer_unmap (buf, &map);
|
||||||
} else if (strcmp (stream_format, "byte-stream") == 0) {
|
} else if (strcmp (stream_format, "byte-stream") == 0) {
|
||||||
fail_if (gst_structure_get_value (s, "codec_data") != NULL);
|
fail_if (gst_structure_get_value (s, "codec_data") != NULL);
|
||||||
} else {
|
} else {
|
||||||
|
@ -123,6 +124,7 @@ GST_START_TEST (test_video_pad)
|
||||||
GstElement *x264enc;
|
GstElement *x264enc;
|
||||||
GstBuffer *inbuffer, *outbuffer;
|
GstBuffer *inbuffer, *outbuffer;
|
||||||
GstCaps *caps;
|
GstCaps *caps;
|
||||||
|
GstMapInfo map;
|
||||||
guint8 *data;
|
guint8 *data;
|
||||||
gsize size;
|
gsize size;
|
||||||
int i, num_buffers;
|
int i, num_buffers;
|
||||||
|
@ -139,9 +141,7 @@ GST_START_TEST (test_video_pad)
|
||||||
/* corresponds to I420 buffer for the size mentioned in the caps */
|
/* corresponds to I420 buffer for the size mentioned in the caps */
|
||||||
inbuffer = gst_buffer_new_and_alloc (384 * 288 * 3 / 2);
|
inbuffer = gst_buffer_new_and_alloc (384 * 288 * 3 / 2);
|
||||||
/* makes valgrind's memcheck happier */
|
/* makes valgrind's memcheck happier */
|
||||||
data = gst_buffer_map (inbuffer, &size, NULL, GST_MAP_WRITE);
|
gst_buffer_memset (inbuffer, 0, 0, -1);
|
||||||
memset (data, 0, size);
|
|
||||||
gst_buffer_unmap (inbuffer, data, size);
|
|
||||||
GST_BUFFER_TIMESTAMP (inbuffer) = 0;
|
GST_BUFFER_TIMESTAMP (inbuffer) = 0;
|
||||||
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
||||||
fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
|
fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
|
||||||
|
@ -170,10 +170,13 @@ GST_START_TEST (test_video_pad)
|
||||||
case 0:
|
case 0:
|
||||||
{
|
{
|
||||||
gint nsize, npos, j, type, next_type;
|
gint nsize, npos, j, type, next_type;
|
||||||
|
GstMapInfo map;
|
||||||
const guint8 *data;
|
const guint8 *data;
|
||||||
gsize size;
|
gsize size;
|
||||||
|
|
||||||
data = gst_buffer_map (outbuffer, &size, NULL, GST_MAP_READ);
|
gst_buffer_map (outbuffer, &map, GST_MAP_READ);
|
||||||
|
data = map.data;
|
||||||
|
size = map.size;
|
||||||
|
|
||||||
npos = 0;
|
npos = 0;
|
||||||
j = 0;
|
j = 0;
|
||||||
|
@ -205,6 +208,7 @@ GST_START_TEST (test_video_pad)
|
||||||
}
|
}
|
||||||
npos += nsize + 4;
|
npos += nsize + 4;
|
||||||
}
|
}
|
||||||
|
gst_buffer_unmap (outbuffer, &map);
|
||||||
/* should have reached the exact end */
|
/* should have reached the exact end */
|
||||||
fail_unless (npos == size);
|
fail_unless (npos == size);
|
||||||
break;
|
break;
|
||||||
|
@ -213,7 +217,6 @@ GST_START_TEST (test_video_pad)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
gst_buffer_unmap (outbuffer, (gpointer) data, size);
|
|
||||||
|
|
||||||
buffers = g_list_remove (buffers, outbuffer);
|
buffers = g_list_remove (buffers, outbuffer);
|
||||||
|
|
||||||
|
|
|
@ -102,30 +102,29 @@ GST_START_TEST (test_xing_remux)
|
||||||
verify_data = test_xing;
|
verify_data = test_xing;
|
||||||
for (it = buffers; it != NULL; it = it->next) {
|
for (it = buffers; it != NULL; it = it->next) {
|
||||||
GstBuffer *outbuffer = (GstBuffer *) it->data;
|
GstBuffer *outbuffer = (GstBuffer *) it->data;
|
||||||
gsize size;
|
GstMapInfo map;
|
||||||
guint8 *data;
|
|
||||||
|
|
||||||
data = gst_buffer_map (outbuffer, &size, NULL, GST_MAP_READ);
|
gst_buffer_map (outbuffer, &map, GST_MAP_READ);
|
||||||
|
|
||||||
if (it == buffers) {
|
if (it == buffers) {
|
||||||
gint j;
|
gint j;
|
||||||
|
|
||||||
/* Empty Xing header, should be the same as input data until the "Xing" marker
|
/* Empty Xing header, should be the same as input data until the "Xing" marker
|
||||||
* and zeroes afterwards. */
|
* and zeroes afterwards. */
|
||||||
fail_unless (memcmp (data, test_xing, 25) == 0);
|
fail_unless (memcmp (map.data, test_xing, 25) == 0);
|
||||||
for (j = 26; j < size; j++)
|
for (j = 26; j < map.size; j++)
|
||||||
fail_unless (data[j] == 0);
|
fail_unless (map.data[j] == 0);
|
||||||
verify_data += size;
|
verify_data += map.size;
|
||||||
} else if (it->next != NULL) {
|
} else if (it->next != NULL) {
|
||||||
/* Should contain the raw MP3 data without changes */
|
/* Should contain the raw MP3 data without changes */
|
||||||
fail_unless (memcmp (data, verify_data, size) == 0);
|
fail_unless (memcmp (map.data, verify_data, map.size) == 0);
|
||||||
verify_data += size;
|
verify_data += map.size;
|
||||||
} else {
|
} else {
|
||||||
/* Last buffer is the rewrite of the first buffer and should be exactly the same
|
/* Last buffer is the rewrite of the first buffer and should be exactly the same
|
||||||
* as the old Xing header we had */
|
* as the old Xing header we had */
|
||||||
fail_unless (memcmp (test_xing, data, size) == 0);
|
fail_unless (memcmp (test_xing, map.data, map.size) == 0);
|
||||||
}
|
}
|
||||||
gst_buffer_unmap (outbuffer, data, size);
|
gst_buffer_unmap (outbuffer, &map);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* cleanup */
|
/* cleanup */
|
||||||
|
|
Loading…
Reference in a new issue