mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-22 00:06:36 +00:00
rawparse: Fix and extend unit tests
* Add caps change test to unit tests * Cleanup leftover buffers after each unit test * Add missing rawvideoparse entry in .gitignore https://bugzilla.gnome.org/show_bug.cgi?id=769637
This commit is contained in:
parent
91cf5ac69f
commit
638c442467
3 changed files with 114 additions and 0 deletions
1
tests/check/elements/.gitignore
vendored
1
tests/check/elements/.gitignore
vendored
|
@ -47,6 +47,7 @@ netsim
|
|||
ofa
|
||||
pcapparse
|
||||
rawaudioparse
|
||||
rawvideoparse
|
||||
rtponvif
|
||||
rganalysis
|
||||
rglimiter
|
||||
|
|
|
@ -120,6 +120,8 @@ setup_rawaudioparse (RawAudParseTestCtx * testctx, gboolean use_sink_caps,
|
|||
static void
|
||||
cleanup_rawaudioparse (RawAudParseTestCtx * testctx)
|
||||
{
|
||||
int num_buffers, i;
|
||||
|
||||
gst_pad_set_active (mysrcpad, FALSE);
|
||||
gst_pad_set_active (mysinkpad, FALSE);
|
||||
gst_check_teardown_src_pad (testctx->rawaudioparse);
|
||||
|
@ -127,6 +129,18 @@ cleanup_rawaudioparse (RawAudParseTestCtx * testctx)
|
|||
gst_check_teardown_element (testctx->rawaudioparse);
|
||||
|
||||
g_object_unref (G_OBJECT (testctx->test_data_adapter));
|
||||
|
||||
if (buffers != NULL) {
|
||||
num_buffers = g_list_length (buffers);
|
||||
for (i = 0; i < num_buffers; ++i) {
|
||||
GstBuffer *buf = GST_BUFFER (buffers->data);
|
||||
buffers = g_list_remove (buffers, buf);
|
||||
gst_buffer_unref (buf);
|
||||
}
|
||||
|
||||
g_list_free (buffers);
|
||||
buffers = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -320,6 +334,47 @@ GST_START_TEST (test_config_switch)
|
|||
|
||||
GST_END_TEST;
|
||||
|
||||
GST_START_TEST (test_change_caps)
|
||||
{
|
||||
RawAudParseTestCtx testctx;
|
||||
GstAudioInfo ainfo;
|
||||
GstCaps *caps;
|
||||
|
||||
/* Start processing with the sink caps config active, using the
|
||||
* default channel count and sample format and 20 kHz sample rate
|
||||
* for the caps. Push some data, then change caps (20 kHz -> 40 kHz).
|
||||
* Check that the changed caps are handled properly. */
|
||||
|
||||
gst_audio_info_set_format (&ainfo, TEST_SAMPLE_FORMAT, 20000,
|
||||
NUM_TEST_CHANNELS, NULL);
|
||||
caps = gst_audio_info_to_caps (&ainfo);
|
||||
|
||||
setup_rawaudioparse (&testctx, TRUE, FALSE, caps, GST_FORMAT_BYTES);
|
||||
|
||||
/* Push in data with caps sink config active, expecting duration calculations
|
||||
* to be based on the 20 kHz sample rate */
|
||||
push_data_and_check_output (&testctx, 40, 40, GST_USECOND * 0,
|
||||
GST_USECOND * 500, 1, 4, 0, 512);
|
||||
push_data_and_check_output (&testctx, 20, 20, GST_USECOND * 500,
|
||||
GST_USECOND * 250, 2, 4, 10, 522);
|
||||
|
||||
/* Change caps */
|
||||
gst_audio_info_set_format (&ainfo, TEST_SAMPLE_FORMAT, 40000,
|
||||
NUM_TEST_CHANNELS, NULL);
|
||||
caps = gst_audio_info_to_caps (&ainfo);
|
||||
fail_unless (gst_pad_push_event (mysrcpad, gst_event_new_caps (caps)));
|
||||
gst_caps_unref (caps);
|
||||
|
||||
/* Push in data with the new caps, expecting duration calculations
|
||||
* to be based on the 40 kHz sample rate */
|
||||
push_data_and_check_output (&testctx, 40, 40, GST_USECOND * 750,
|
||||
GST_USECOND * 250, 3, 4, 15, 527);
|
||||
|
||||
cleanup_rawaudioparse (&testctx);
|
||||
}
|
||||
|
||||
GST_END_TEST;
|
||||
|
||||
|
||||
static Suite *
|
||||
rawaudioparse_suite (void)
|
||||
|
@ -332,6 +387,7 @@ rawaudioparse_suite (void)
|
|||
tcase_add_test (tc_chain, test_push_unaligned_data_sink_caps_config);
|
||||
tcase_add_test (tc_chain, test_push_swapped_channels);
|
||||
tcase_add_test (tc_chain, test_config_switch);
|
||||
tcase_add_test (tc_chain, test_change_caps);
|
||||
|
||||
return s;
|
||||
}
|
||||
|
|
|
@ -283,6 +283,8 @@ setup_rawvideoparse (gboolean use_sink_caps,
|
|||
static void
|
||||
cleanup_rawvideoparse (void)
|
||||
{
|
||||
int num_buffers, i;
|
||||
|
||||
gst_pad_set_active (mysrcpad, FALSE);
|
||||
gst_pad_set_active (mysinkpad, FALSE);
|
||||
gst_check_teardown_src_pad (rawvideoparse);
|
||||
|
@ -291,6 +293,18 @@ cleanup_rawvideoparse (void)
|
|||
|
||||
g_object_unref (G_OBJECT (properties_ctx.data));
|
||||
g_object_unref (G_OBJECT (sinkcaps_ctx.data));
|
||||
|
||||
if (buffers != NULL) {
|
||||
num_buffers = g_list_length (buffers);
|
||||
for (i = 0; i < num_buffers; ++i) {
|
||||
GstBuffer *buf = GST_BUFFER (buffers->data);
|
||||
buffers = g_list_remove (buffers, buf);
|
||||
gst_buffer_unref (buf);
|
||||
}
|
||||
|
||||
g_list_free (buffers);
|
||||
buffers = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -551,6 +565,48 @@ GST_START_TEST (test_computed_plane_strides)
|
|||
|
||||
GST_END_TEST;
|
||||
|
||||
GST_START_TEST (test_change_caps)
|
||||
{
|
||||
GstVideoInfo vinfo;
|
||||
GstCaps *caps;
|
||||
|
||||
/* Start processing with the sink caps config active, using the
|
||||
* default width/height/format and 25 Hz frame rate for the caps.
|
||||
* Push some data, then change caps (25 Hz -> 50 Hz).
|
||||
* Check that the changed caps are handled properly. */
|
||||
|
||||
gst_video_info_set_format (&vinfo, TEST_FRAME_FORMAT, TEST_WIDTH,
|
||||
TEST_HEIGHT);
|
||||
GST_VIDEO_INFO_FPS_N (&vinfo) = 25;
|
||||
GST_VIDEO_INFO_FPS_D (&vinfo) = 1;
|
||||
caps = gst_video_info_to_caps (&vinfo);
|
||||
|
||||
setup_rawvideoparse (TRUE, FALSE, caps, GST_FORMAT_BYTES);
|
||||
|
||||
/* Push in data with sink config active, expecting duration calculations
|
||||
* to be based on the 25 Hz frame rate */
|
||||
push_data_and_check_output (&sinkcaps_ctx, 192, 192, GST_MSECOND * 0,
|
||||
GST_MSECOND * 40, 1, 0, 0, 0);
|
||||
push_data_and_check_output (&sinkcaps_ctx, 192, 192, GST_MSECOND * 40,
|
||||
GST_MSECOND * 40, 2, 1, 1, 0);
|
||||
|
||||
/* Change caps */
|
||||
GST_VIDEO_INFO_FPS_N (&vinfo) = 50;
|
||||
GST_VIDEO_INFO_FPS_D (&vinfo) = 1;
|
||||
caps = gst_video_info_to_caps (&vinfo);
|
||||
fail_unless (gst_pad_push_event (mysrcpad, gst_event_new_caps (caps)));
|
||||
gst_caps_unref (caps);
|
||||
|
||||
/* Push in data with sink config active, expecting duration calculations
|
||||
* to be based on the 50 Hz frame rate */
|
||||
push_data_and_check_output (&sinkcaps_ctx, 192, 192, GST_MSECOND * 80,
|
||||
GST_MSECOND * 20, 3, 2, 2, 0);
|
||||
|
||||
cleanup_rawvideoparse ();
|
||||
}
|
||||
|
||||
GST_END_TEST;
|
||||
|
||||
|
||||
static Suite *
|
||||
rawvideoparse_suite (void)
|
||||
|
@ -564,6 +620,7 @@ rawvideoparse_suite (void)
|
|||
tcase_add_test (tc_chain, test_config_switch);
|
||||
tcase_add_test (tc_chain, test_push_with_no_framerate);
|
||||
tcase_add_test (tc_chain, test_computed_plane_strides);
|
||||
tcase_add_test (tc_chain, test_change_caps);
|
||||
|
||||
return s;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue