From eefcdc9ee169b32d2edd40b9f7b99133ae353043 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Mon, 27 Feb 2017 19:25:35 +0200 Subject: [PATCH] rtp-payloading: Add new test for Vorbis renegotiation Check if encoding, payloading, depayloading and decoding works if the stream configuration (and thus the headers) change. --- tests/check/Makefile.am | 3 + tests/check/elements/rtp-payloading.c | 91 +++++++++++++++++++++++++++ 2 files changed, 94 insertions(+) diff --git a/tests/check/Makefile.am b/tests/check/Makefile.am index e4bcb289d1..4e82aedacd 100644 --- a/tests/check/Makefile.am +++ b/tests/check/Makefile.am @@ -483,6 +483,9 @@ elements_rglimiter_LDADD = $(GST_PLUGINS_BASE_LIBS) -lgstaudio-$(GST_API_VERSION elements_rgvolume_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(CFLAGS) $(AM_CFLAGS) elements_rgvolume_LDADD = $(GST_PLUGINS_BASE_LIBS) -lgstaudio-$(GST_API_VERSION) $(LDADD) +elements_rtp_payloading_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(CFLAGS) $(AM_CFLAGS) +elements_rtp_payloading_LDADD = $(GST_PLUGINS_BASE_LIBS) -lgstaudio-$(GST_API_VERSION) $(LDADD) + elements_spectrum_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(CFLAGS) $(AM_CFLAGS) elements_spectrum_LDADD = $(GST_PLUGINS_BASE_LIBS) -lgstaudio-$(GST_API_VERSION) $(LDADD) diff --git a/tests/check/elements/rtp-payloading.c b/tests/check/elements/rtp-payloading.c index c59f9becfa..d09f303f91 100644 --- a/tests/check/elements/rtp-payloading.c +++ b/tests/check/elements/rtp-payloading.c @@ -19,6 +19,7 @@ */ #include #include +#include #include #include @@ -1329,6 +1330,95 @@ GST_START_TEST (rtp_gst_custom_event) GST_END_TEST; +GST_START_TEST (rtp_vorbis_renegotiate) +{ + GstElement *pipeline; + GstElement *enc, *pay, *depay, *dec, *sink; + GstPad *sinkpad, *srcpad; + GstCaps *templcaps, *caps, *filter, *srccaps; + GstSegment segment; + GstBuffer *buffer; + GstMapInfo map; + GstAudioInfo info; + + pipeline = gst_pipeline_new (NULL); + enc = gst_element_factory_make ("vorbisenc", NULL); + pay = gst_element_factory_make ("rtpvorbispay", NULL); + depay = gst_element_factory_make ("rtpvorbisdepay", NULL); + dec = gst_element_factory_make ("vorbisdec", NULL); + sink = gst_element_factory_make ("fakesink", NULL); + g_object_set (sink, "async", FALSE, NULL); + gst_bin_add_many (GST_BIN (pipeline), enc, pay, depay, dec, sink, NULL); + fail_unless (gst_element_link_many (enc, pay, depay, dec, sink, NULL)); + fail_unless_equals_int (gst_element_set_state (pipeline, GST_STATE_PLAYING), + GST_STATE_CHANGE_SUCCESS); + + sinkpad = gst_element_get_static_pad (enc, "sink"); + srcpad = gst_element_get_static_pad (dec, "src"); + + templcaps = gst_pad_get_pad_template_caps (sinkpad); + filter = + gst_caps_new_simple ("audio/x-raw", "channels", G_TYPE_INT, 2, "rate", + G_TYPE_INT, 44100, NULL); + caps = gst_caps_intersect (templcaps, filter); + caps = gst_caps_fixate (caps); + + gst_segment_init (&segment, GST_FORMAT_TIME); + fail_unless (gst_pad_send_event (sinkpad, + gst_event_new_stream_start ("test"))); + fail_unless (gst_pad_send_event (sinkpad, gst_event_new_caps (caps))); + fail_unless (gst_pad_send_event (sinkpad, gst_event_new_segment (&segment))); + + gst_audio_info_from_caps (&info, caps); + buffer = gst_buffer_new_and_alloc (44100 * info.bpf); + gst_buffer_map (buffer, &map, GST_MAP_WRITE); + gst_audio_format_fill_silence (info.finfo, map.data, map.size); + gst_buffer_unmap (buffer, &map); + GST_BUFFER_PTS (buffer) = 0; + GST_BUFFER_DURATION (buffer) = 1 * GST_SECOND; + + fail_unless_equals_int (gst_pad_chain (sinkpad, buffer), GST_FLOW_OK); + + srccaps = gst_pad_get_current_caps (srcpad); + fail_unless (gst_caps_can_intersect (srccaps, caps)); + gst_caps_unref (srccaps); + + gst_caps_unref (caps); + gst_caps_unref (filter); + filter = + gst_caps_new_simple ("audio/x-raw", "channels", G_TYPE_INT, 2, "rate", + G_TYPE_INT, 48000, NULL); + caps = gst_caps_intersect (templcaps, filter); + caps = gst_caps_fixate (caps); + + fail_unless (gst_pad_send_event (sinkpad, gst_event_new_caps (caps))); + + gst_audio_info_from_caps (&info, caps); + buffer = gst_buffer_new_and_alloc (48000 * info.bpf); + gst_buffer_map (buffer, &map, GST_MAP_WRITE); + gst_audio_format_fill_silence (info.finfo, map.data, map.size); + gst_buffer_unmap (buffer, &map); + GST_BUFFER_PTS (buffer) = 0; + GST_BUFFER_DURATION (buffer) = 1 * GST_SECOND; + GST_BUFFER_FLAG_SET (buffer, GST_BUFFER_FLAG_DISCONT); + + fail_unless_equals_int (gst_pad_chain (sinkpad, buffer), GST_FLOW_OK); + + srccaps = gst_pad_get_current_caps (srcpad); + fail_unless (gst_caps_can_intersect (srccaps, caps)); + gst_caps_unref (srccaps); + + gst_caps_unref (caps); + gst_caps_unref (filter); + gst_caps_unref (templcaps); + gst_object_unref (sinkpad); + gst_object_unref (srcpad); + gst_element_set_state (pipeline, GST_STATE_NULL); + gst_object_unref (pipeline); +} + +GST_END_TEST; + /* * Creates the test suite. * @@ -1388,6 +1478,7 @@ rtp_payloading_suite (void) tcase_add_loop_test (tc_chain, rtp_jpeg_packet_loss, 0, 7); tcase_add_test (tc_chain, rtp_g729); tcase_add_test (tc_chain, rtp_gst_custom_event); + tcase_add_test (tc_chain, rtp_vorbis_renegotiate); return s; }