mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-23 18:21:04 +00:00
tests: Fix event handling
This commit is contained in:
parent
c9e20af4cb
commit
e29d352f77
4 changed files with 45 additions and 38 deletions
|
@ -75,7 +75,7 @@ setup_amrnbenc (void)
|
|||
"could not set to playing");
|
||||
|
||||
caps = gst_caps_from_string (SRC_CAPS);
|
||||
fail_unless (gst_pad_set_caps (srcpad, caps));
|
||||
gst_check_setup_events (srcpad, amrnbenc, caps, GST_FORMAT_TIME);
|
||||
gst_caps_unref (caps);
|
||||
|
||||
buffers = NULL;
|
||||
|
|
|
@ -32,7 +32,7 @@ static GstPad *mysrcpad, *mysinkpad;
|
|||
/* mpeg2 video created with gst-launch-0.10 videotestsrc num-buffers=32 pattern=blue ! "video/x-raw,format=(string)I420,width=176,height=144,framerate=(fraction)25/1" ! ffenc_mpeg2video ! filesink location=test.mpg
|
||||
*/
|
||||
|
||||
guint8 test_stream1[] = {
|
||||
static const guint8 test_stream1[] = {
|
||||
0x00, 0x00, 0x01, 0xb3, 0x0b, 0x00, 0x90, 0x13,
|
||||
0xff, 0xff, 0xe0, 0x28, 0x00, 0x00, 0x01, 0xb5,
|
||||
0x14, 0x8a, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
|
||||
|
@ -548,7 +548,7 @@ guint8 test_stream1[] = {
|
|||
0x09, 0x12, 0x70, 0xb3, 0x80,
|
||||
};
|
||||
|
||||
guint test_stream_sizes[] = {
|
||||
static const guint test_stream_sizes[] = {
|
||||
497, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90,
|
||||
497, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90,
|
||||
497, 90
|
||||
|
@ -557,7 +557,7 @@ guint test_stream_sizes[] = {
|
|||
/* mpeg2 video created with gst-launch-0.10 videotestsrc num-buffers=32 pattern=blue ! "video/x-raw,format=(string)I420,width=183,height=217,framerate=(fraction)25/1" ! ffenc_mpeg2video ! filesink location=test.mpg
|
||||
*/
|
||||
|
||||
guint8 test_stream2[] = {
|
||||
static const guint8 test_stream2[] = {
|
||||
0x00, 0x00, 0x01, 0xb3, 0x0b, 0x70, 0xd9, 0x13,
|
||||
0xff, 0xff, 0xe0, 0x28, 0x00, 0x00, 0x01, 0xb5,
|
||||
0x14, 0x8a, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
|
||||
|
@ -1688,7 +1688,7 @@ guint8 test_stream2[] = {
|
|||
0xa5, 0xfb, 0x85, 0xe6, 0xc0
|
||||
};
|
||||
|
||||
guint test_stream2_sizes[] = {
|
||||
static const guint test_stream2_sizes[] = {
|
||||
803, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228,
|
||||
803, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228,
|
||||
803, 228
|
||||
|
@ -1710,7 +1710,7 @@ GstElement *
|
|||
setup_mpeg2dec ()
|
||||
{
|
||||
GstElement *mpeg2dec;
|
||||
GstSegment seg;
|
||||
GstCaps *caps;
|
||||
|
||||
GST_DEBUG ("setup_mpeg2dec");
|
||||
mpeg2dec = gst_check_setup_element ("mpeg2dec");
|
||||
|
@ -1719,8 +1719,11 @@ setup_mpeg2dec ()
|
|||
gst_pad_set_active (mysrcpad, TRUE);
|
||||
gst_pad_set_active (mysinkpad, TRUE);
|
||||
|
||||
gst_segment_init (&seg, GST_FORMAT_TIME);
|
||||
gst_pad_push_event (mysrcpad, gst_event_new_segment (&seg));
|
||||
caps = gst_caps_new_simple ("video/mpeg",
|
||||
"systemstream", G_TYPE_BOOLEAN, FALSE,
|
||||
"mpegversion", G_TYPE_INT, 2, NULL);
|
||||
gst_check_setup_events (mysrcpad, mpeg2dec, caps, GST_FORMAT_TIME);
|
||||
gst_caps_unref (caps);
|
||||
|
||||
return mpeg2dec;
|
||||
}
|
||||
|
@ -1759,8 +1762,8 @@ GST_START_TEST (test_decode_stream1)
|
|||
for (i = 0; i < G_N_ELEMENTS (test_stream_sizes); i++) {
|
||||
inbuffer =
|
||||
gst_buffer_new_wrapped_full (GST_MEMORY_FLAG_READONLY,
|
||||
test_stream1 + offset, test_stream_sizes[i], 0, test_stream_sizes[i],
|
||||
NULL, NULL);
|
||||
(guint8 *) test_stream1 + offset, test_stream_sizes[i], 0,
|
||||
test_stream_sizes[i], NULL, NULL);
|
||||
offset += test_stream_sizes[i];
|
||||
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
||||
gst_buffer_ref (inbuffer);
|
||||
|
@ -1835,8 +1838,8 @@ GST_START_TEST (test_decode_stream2)
|
|||
for (i = 0; i < G_N_ELEMENTS (test_stream2_sizes); i++) {
|
||||
inbuffer =
|
||||
gst_buffer_new_wrapped_full (GST_MEMORY_FLAG_READONLY,
|
||||
test_stream2 + offset, test_stream2_sizes[i], 0, test_stream2_sizes[i],
|
||||
NULL, NULL);
|
||||
(guint8 *) test_stream2 + offset, test_stream2_sizes[i], 0,
|
||||
test_stream2_sizes[i], NULL, NULL);
|
||||
offset += test_stream2_sizes[i];
|
||||
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
||||
gst_buffer_ref (inbuffer);
|
||||
|
|
|
@ -39,30 +39,40 @@ static GstPad *mysrcpad, *mysinkpad;
|
|||
"width = (int) 384, " \
|
||||
"height = (int) 288, " \
|
||||
"framerate = (fraction) 25/1"
|
||||
|
||||
static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink",
|
||||
GST_PAD_SINK,
|
||||
GST_PAD_ALWAYS,
|
||||
GST_STATIC_CAPS (MPEG_CAPS_STRING));
|
||||
|
||||
static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src",
|
||||
GST_PAD_SRC,
|
||||
GST_PAD_ALWAYS,
|
||||
GST_STATIC_CAPS (VIDEO_CAPS_STRING));
|
||||
|
||||
|
||||
static GstElement *
|
||||
setup_x264enc (void)
|
||||
setup_x264enc (const gchar * profile, const gchar * stream_format)
|
||||
{
|
||||
GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink",
|
||||
GST_PAD_SINK,
|
||||
GST_PAD_ALWAYS,
|
||||
GST_STATIC_CAPS (MPEG_CAPS_STRING));
|
||||
|
||||
GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src",
|
||||
GST_PAD_SRC,
|
||||
GST_PAD_ALWAYS,
|
||||
GST_STATIC_CAPS (VIDEO_CAPS_STRING));
|
||||
GstElement *x264enc;
|
||||
gchar *caps_str;
|
||||
GstCaps *caps;
|
||||
|
||||
GST_DEBUG ("setup_x264enc");
|
||||
|
||||
caps_str = g_strdup_printf ("%s, profile = (string) %s, "
|
||||
"stream-format = (string) %s", MPEG_CAPS_STRING, profile, stream_format);
|
||||
sinktemplate.static_caps.string = caps_str;
|
||||
|
||||
x264enc = gst_check_setup_element ("x264enc");
|
||||
mysrcpad = gst_check_setup_src_pad (x264enc, &srctemplate);
|
||||
mysinkpad = gst_check_setup_sink_pad (x264enc, &sinktemplate);
|
||||
gst_pad_set_active (mysrcpad, TRUE);
|
||||
gst_pad_set_active (mysinkpad, TRUE);
|
||||
|
||||
caps = gst_caps_from_string (VIDEO_CAPS_STRING);
|
||||
gst_check_setup_events (mysrcpad, x264enc, caps, GST_FORMAT_TIME);
|
||||
gst_caps_unref (caps);
|
||||
|
||||
g_free (caps_str);
|
||||
|
||||
return x264enc;
|
||||
}
|
||||
|
||||
|
@ -128,23 +138,11 @@ test_video_profile (const gchar * profile, gint profile_id)
|
|||
gsize size;
|
||||
int i, num_buffers;
|
||||
|
||||
x264enc = setup_x264enc ();
|
||||
x264enc = setup_x264enc (profile, "avc");
|
||||
fail_unless (gst_element_set_state (x264enc,
|
||||
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
|
||||
"could not set to playing");
|
||||
|
||||
caps = gst_caps_from_string (MPEG_CAPS_STRING);
|
||||
gst_caps_set_simple (caps, "profile", G_TYPE_STRING, profile, NULL);
|
||||
/* code below assumes avc */
|
||||
gst_caps_set_simple (caps, "stream-format", G_TYPE_STRING, "avc", NULL);
|
||||
gst_pad_set_caps (mysinkpad, caps);
|
||||
gst_caps_unref (caps);
|
||||
gst_pad_use_fixed_caps (mysinkpad);
|
||||
|
||||
caps = gst_caps_from_string (VIDEO_CAPS_STRING);
|
||||
fail_unless (gst_pad_set_caps (mysrcpad, caps));
|
||||
gst_caps_unref (caps);
|
||||
|
||||
/* corresponds to I420 buffer for the size mentioned in the caps */
|
||||
inbuffer = gst_buffer_new_and_alloc (384 * 288 * 3 / 2);
|
||||
/* makes valgrind's memcheck happier */
|
||||
|
|
|
@ -48,6 +48,7 @@ GstElement *
|
|||
setup_xingmux ()
|
||||
{
|
||||
GstElement *xingmux;
|
||||
GstCaps *caps;
|
||||
|
||||
GST_DEBUG ("setup_xingmux");
|
||||
xingmux = gst_check_setup_element ("xingmux");
|
||||
|
@ -56,6 +57,11 @@ setup_xingmux ()
|
|||
gst_pad_set_active (mysrcpad, TRUE);
|
||||
gst_pad_set_active (mysinkpad, TRUE);
|
||||
|
||||
caps = gst_caps_new_simple ("audio/mpeg",
|
||||
"mpegversion", G_TYPE_INT, 1, "layer", G_TYPE_INT, 3, NULL);
|
||||
gst_check_setup_events (mysrcpad, xingmux, caps, GST_FORMAT_TIME);
|
||||
gst_caps_unref (caps);
|
||||
|
||||
return xingmux;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue