From 9c2982d22cb7449cbae26f88f259420e4db86de1 Mon Sep 17 00:00:00 2001 From: "Jan Alexander Steffens (heftig)" Date: Tue, 7 Jul 2020 14:02:06 +0200 Subject: [PATCH] tests: mpegtsmux: Test we don't crash releasing unused pad Part-of: --- tests/check/elements/mpegtsmux.c | 33 ++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/tests/check/elements/mpegtsmux.c b/tests/check/elements/mpegtsmux.c index 6abca47f95..d0df51aaae 100644 --- a/tests/check/elements/mpegtsmux.c +++ b/tests/check/elements/mpegtsmux.c @@ -388,6 +388,38 @@ GST_START_TEST (test_reappearing_pad) GST_END_TEST; +GST_START_TEST (test_unused_pad) +{ + gchar *padname; + GstElement *mux; + GstPad *pad; + + mux = gst_check_setup_element ("mpegtsmux"); + mysrcpad = setup_src_pad (mux, &video_src_template, "sink_%d", &padname); + mysinkpad = gst_check_setup_sink_pad (mux, &sink_template); + gst_pad_set_active (mysrcpad, TRUE); + gst_pad_set_active (mysinkpad, TRUE); + + fail_unless (gst_element_set_state (mux, + GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS, + "could not set to playing"); + + pad = gst_element_get_static_pad (mux, padname); + gst_pad_set_active (mysrcpad, FALSE); + teardown_src_pad (mux, padname); + gst_element_release_request_pad (mux, pad); + gst_object_unref (pad); + g_free (padname); + + mysrcpad = setup_src_pad (mux, &video_src_template, "sink_%d", &padname); + gst_pad_set_active (mysrcpad, TRUE); + + cleanup_tsmux (mux, padname); + g_free (padname); +} + +GST_END_TEST; + GST_START_TEST (test_video) { check_tsmux_pad (&video_src_template, VIDEO_CAPS_STRING, 0xE0, 0x1b, @@ -526,6 +558,7 @@ mpegtsmux_suite (void) tcase_add_test (tc_chain, test_align); tcase_add_test (tc_chain, test_keyframe_flag_propagation); tcase_add_test (tc_chain, test_reappearing_pad); + tcase_add_test (tc_chain, test_unused_pad); return s; }