From a7f1eb234f390a1f03a50e410c5d5cf39b4af5ed Mon Sep 17 00:00:00 2001 From: Florin Apostol Date: Tue, 16 Feb 2016 14:24:49 +0000 Subject: [PATCH] dashdemux: tests: moved testQuery after testFragmentDownloadError Moved testQuery after testFragmentDownloadError so that testDownloadError and testFragmentDownloadError are grouped together. The commit just moved the testQueryCheckDataReceived and GST_START_TEST (testQuery) functions but git gets confused in matching the lines and reports a lot of changes in the patch. https://bugzilla.gnome.org/show_bug.cgi?id=762144 --- tests/check/elements/dash_demux.c | 238 +++++++++++++++++++------------------- 1 file changed, 119 insertions(+), 119 deletions(-) diff --git a/tests/check/elements/dash_demux.c b/tests/check/elements/dash_demux.c index 261455b..87ab7ef 100644 --- a/tests/check/elements/dash_demux.c +++ b/tests/check/elements/dash_demux.c @@ -893,71 +893,66 @@ GST_START_TEST (testDownloadError) GST_END_TEST; -/* generate queries to adaptive demux */ -static gboolean -testQueryCheckDataReceived (GstAdaptiveDemuxTestEngine * engine, - GstAdaptiveDemuxTestOutputStream * stream, - GstBuffer * buffer, gpointer user_data) +static GstFlowReturn +test_fragment_download_error_src_create (GstTestHTTPSrc * src, + guint64 offset, + guint length, GstBuffer ** retbuf, gpointer context, gpointer user_data) { - GList *pads; - GstPad *pad; - GstQuery *query; - gboolean ret; - gint64 duration; - gboolean seekable; - gint64 segment_start; - gint64 segment_end; - gchar *uri; - gchar *redirect_uri; - gboolean redirect_permanent; + const GstDashDemuxTestInputData *input = + (const GstDashDemuxTestInputData *) context; + const GstTestHTTPSrcTestData *http_src_test_data = + (const GstTestHTTPSrcTestData *) user_data; + guint64 threshold_for_trigger; - pads = GST_ELEMENT_PADS (stream->appsink); + fail_unless (input != NULL); + gst_structure_get_uint64 (http_src_test_data->data, "threshold_for_trigger", + &threshold_for_trigger); - /* AppSink should have only 1 pad */ - fail_unless (pads != NULL); - fail_unless (g_list_length (pads) == 1); - pad = GST_PAD (pads->data); + if (!g_str_has_suffix (input->uri, ".mpd") && offset > threshold_for_trigger) { - query = gst_query_new_duration (GST_FORMAT_TIME); - ret = gst_pad_peer_query (pad, query); - fail_unless (ret == TRUE); - gst_query_parse_duration (query, NULL, &duration); - fail_unless (duration == 135743 * GST_MSECOND); - gst_query_unref (query); + GST_DEBUG ("network_error %s %" G_GUINT64_FORMAT " @ %" G_GUINT64_FORMAT, + input->uri, offset, threshold_for_trigger); + GST_ELEMENT_ERROR (src, RESOURCE, READ, + (("A network error occurred, or the server closed the connection unexpectedly.")), ("A network error occurred, or the server closed the connection unexpectedly.")); + return GST_FLOW_ERROR; + } + return gst_dashdemux_http_src_create (src, offset, length, retbuf, context, + user_data); +} - query = gst_query_new_seeking (GST_FORMAT_TIME); - ret = gst_pad_peer_query (pad, query); - fail_unless (ret == TRUE); - gst_query_parse_seeking (query, NULL, &seekable, &segment_start, - &segment_end); - fail_unless (seekable == TRUE); - fail_unless (segment_start == 0); - fail_unless (segment_end == duration); - gst_query_unref (query); +/* function to check total size of data received by AppSink + * will be called when AppSink receives eos. + */ +static void +testFragmentDownloadErrorCheckSizeOfDataReceived (GstAdaptiveDemuxTestEngine * + engine, GstAdaptiveDemuxTestOutputStream * stream, gpointer user_data) +{ + GstAdaptiveDemuxTestCase *testData = GST_ADAPTIVE_DEMUX_TEST_CASE (user_data); + GstAdaptiveDemuxTestExpectedOutput *testOutputStreamData; - query = gst_query_new_uri (); - ret = gst_pad_peer_query (pad, query); - fail_unless (ret == TRUE); - gst_query_parse_uri (query, &uri); - gst_query_parse_uri_redirection (query, &redirect_uri); - gst_query_parse_uri_redirection_permanent (query, &redirect_permanent); - fail_unless (strcmp (uri, "http://unit.test/test.mpd") == 0); - /* adaptive demux does not reply with redirect information */ - fail_unless (redirect_uri == NULL); - fail_unless (redirect_permanent == FALSE); - g_free (uri); - g_free (redirect_uri); - gst_query_unref (query); + testOutputStreamData = + gst_adaptive_demux_test_find_test_data_by_stream (testData, stream, NULL); + fail_unless (testOutputStreamData != NULL); - return gst_adaptive_demux_test_check_received_data (engine, - stream, buffer, user_data); + /* expect to receive more than 0 */ + fail_unless (stream->total_received_size > 0, + "size validation failed for %s, expected > 0, received %d", + testOutputStreamData->name, stream->total_received_size); + + /* expect to receive less than file size */ + fail_unless (stream->total_received_size < + testOutputStreamData->expected_size, + "size validation failed for %s, expected < %d received %d", + testOutputStreamData->name, testOutputStreamData->expected_size, + stream->total_received_size); } /* - * Test queries - * + * Test fragment download error + * Let the adaptive demux download a few bytes, then instruct the + * GstTestHTTPSrc element to generate an error. */ -GST_START_TEST (testQuery) +GST_START_TEST (testFragmentDownloadError) { const gchar *mpd = "" @@ -967,7 +962,7 @@ GST_START_TEST (testQuery) " profiles=\"urn:mpeg:dash:profile:isoff-on-demand:2011\"" " type=\"static\"" " minBufferTime=\"PT1.500S\"" - " mediaPresentationDuration=\"PT135.743S\">" + " mediaPresentationDuration=\"PT0.5S\">" " " " " @@ -998,16 +993,22 @@ GST_START_TEST (testQuery) GstTestHTTPSrcTestData http_src_test_data = { 0 }; GstAdaptiveDemuxTestCallbacks test_callbacks = { 0 }; GstDashDemuxTestCase *testData; + guint64 threshold_for_trigger = 2000; http_src_callbacks.src_start = gst_dashdemux_http_src_start; - http_src_callbacks.src_create = gst_dashdemux_http_src_create; + http_src_callbacks.src_create = test_fragment_download_error_src_create; + http_src_test_data.data = gst_structure_new_empty (__FUNCTION__); + gst_structure_set (http_src_test_data.data, "threshold_for_trigger", + G_TYPE_UINT64, threshold_for_trigger, NULL); http_src_test_data.input = inputTestData; gst_test_http_src_install_callbacks (&http_src_callbacks, &http_src_test_data); - test_callbacks.appsink_received_data = testQueryCheckDataReceived; - test_callbacks.appsink_eos = - gst_adaptive_demux_test_check_size_of_received_data; + test_callbacks.appsink_received_data = + gst_adaptive_demux_test_check_received_data; + test_callbacks.appsink_eos = testFragmentDownloadErrorCheckSizeOfDataReceived; + /* test_callbacks.demux_sent_eos = gst_adaptive_demux_test_check_size_of_received_data; */ + test_callbacks.bus_error_message = testDownloadErrorMessageCallback; testData = gst_dash_demux_test_case_new (); COPY_OUTPUT_TEST_DATA (outputTestData, testData); @@ -1022,66 +1023,71 @@ GST_START_TEST (testQuery) GST_END_TEST; -static GstFlowReturn -test_fragment_download_error_src_create (GstTestHTTPSrc * src, - guint64 offset, - guint length, GstBuffer ** retbuf, gpointer context, gpointer user_data) +/* generate queries to adaptive demux */ +static gboolean +testQueryCheckDataReceived (GstAdaptiveDemuxTestEngine * engine, + GstAdaptiveDemuxTestOutputStream * stream, + GstBuffer * buffer, gpointer user_data) { - const GstDashDemuxTestInputData *input = - (const GstDashDemuxTestInputData *) context; - const GstTestHTTPSrcTestData *http_src_test_data = - (const GstTestHTTPSrcTestData *) user_data; - guint64 threshold_for_trigger; - - fail_unless (input != NULL); - gst_structure_get_uint64 (http_src_test_data->data, "threshold_for_trigger", - &threshold_for_trigger); + GList *pads; + GstPad *pad; + GstQuery *query; + gboolean ret; + gint64 duration; + gboolean seekable; + gint64 segment_start; + gint64 segment_end; + gchar *uri; + gchar *redirect_uri; + gboolean redirect_permanent; - if (!g_str_has_suffix (input->uri, ".mpd") && offset > threshold_for_trigger) { + pads = GST_ELEMENT_PADS (stream->appsink); - GST_DEBUG ("network_error %s %" G_GUINT64_FORMAT " @ %" G_GUINT64_FORMAT, - input->uri, offset, threshold_for_trigger); - GST_ELEMENT_ERROR (src, RESOURCE, READ, - (("A network error occurred, or the server closed the connection unexpectedly.")), ("A network error occurred, or the server closed the connection unexpectedly.")); - return GST_FLOW_ERROR; - } - return gst_dashdemux_http_src_create (src, offset, length, retbuf, context, - user_data); -} + /* AppSink should have only 1 pad */ + fail_unless (pads != NULL); + fail_unless (g_list_length (pads) == 1); + pad = GST_PAD (pads->data); -/* function to check total size of data received by AppSink - * will be called when AppSink receives eos. - */ -static void -testFragmentDownloadErrorCheckSizeOfDataReceived (GstAdaptiveDemuxTestEngine * - engine, GstAdaptiveDemuxTestOutputStream * stream, gpointer user_data) -{ - GstAdaptiveDemuxTestCase *testData = GST_ADAPTIVE_DEMUX_TEST_CASE (user_data); - GstAdaptiveDemuxTestExpectedOutput *testOutputStreamData; + query = gst_query_new_duration (GST_FORMAT_TIME); + ret = gst_pad_peer_query (pad, query); + fail_unless (ret == TRUE); + gst_query_parse_duration (query, NULL, &duration); + fail_unless (duration == 135743 * GST_MSECOND); + gst_query_unref (query); - testOutputStreamData = - gst_adaptive_demux_test_find_test_data_by_stream (testData, stream, NULL); - fail_unless (testOutputStreamData != NULL); + query = gst_query_new_seeking (GST_FORMAT_TIME); + ret = gst_pad_peer_query (pad, query); + fail_unless (ret == TRUE); + gst_query_parse_seeking (query, NULL, &seekable, &segment_start, + &segment_end); + fail_unless (seekable == TRUE); + fail_unless (segment_start == 0); + fail_unless (segment_end == duration); + gst_query_unref (query); - /* expect to receive more than 0 */ - fail_unless (stream->total_received_size > 0, - "size validation failed for %s, expected > 0, received %d", - testOutputStreamData->name, stream->total_received_size); + query = gst_query_new_uri (); + ret = gst_pad_peer_query (pad, query); + fail_unless (ret == TRUE); + gst_query_parse_uri (query, &uri); + gst_query_parse_uri_redirection (query, &redirect_uri); + gst_query_parse_uri_redirection_permanent (query, &redirect_permanent); + fail_unless (strcmp (uri, "http://unit.test/test.mpd") == 0); + /* adaptive demux does not reply with redirect information */ + fail_unless (redirect_uri == NULL); + fail_unless (redirect_permanent == FALSE); + g_free (uri); + g_free (redirect_uri); + gst_query_unref (query); - /* expect to receive less than file size */ - fail_unless (stream->total_received_size < - testOutputStreamData->expected_size, - "size validation failed for %s, expected < %d received %d", - testOutputStreamData->name, testOutputStreamData->expected_size, - stream->total_received_size); + return gst_adaptive_demux_test_check_received_data (engine, + stream, buffer, user_data); } /* - * Test fragment download error - * Let the adaptive demux download a few bytes, then instruct the - * GstTestHTTPSrc element to generate an error. + * Test queries + * */ -GST_START_TEST (testFragmentDownloadError) +GST_START_TEST (testQuery) { const gchar *mpd = "" @@ -1091,7 +1097,7 @@ GST_START_TEST (testFragmentDownloadError) " profiles=\"urn:mpeg:dash:profile:isoff-on-demand:2011\"" " type=\"static\"" " minBufferTime=\"PT1.500S\"" - " mediaPresentationDuration=\"PT0.5S\">" + " mediaPresentationDuration=\"PT135.743S\">" " " " " @@ -1122,22 +1128,16 @@ GST_START_TEST (testFragmentDownloadError) GstTestHTTPSrcTestData http_src_test_data = { 0 }; GstAdaptiveDemuxTestCallbacks test_callbacks = { 0 }; GstDashDemuxTestCase *testData; - guint64 threshold_for_trigger = 2000; http_src_callbacks.src_start = gst_dashdemux_http_src_start; - http_src_callbacks.src_create = test_fragment_download_error_src_create; - http_src_test_data.data = gst_structure_new_empty (__FUNCTION__); - gst_structure_set (http_src_test_data.data, "threshold_for_trigger", - G_TYPE_UINT64, threshold_for_trigger, NULL); + http_src_callbacks.src_create = gst_dashdemux_http_src_create; http_src_test_data.input = inputTestData; gst_test_http_src_install_callbacks (&http_src_callbacks, &http_src_test_data); - test_callbacks.appsink_received_data = - gst_adaptive_demux_test_check_received_data; - test_callbacks.appsink_eos = testFragmentDownloadErrorCheckSizeOfDataReceived; - /* test_callbacks.demux_sent_eos = gst_adaptive_demux_test_check_size_of_received_data; */ - test_callbacks.bus_error_message = testDownloadErrorMessageCallback; + test_callbacks.appsink_received_data = testQueryCheckDataReceived; + test_callbacks.appsink_eos = + gst_adaptive_demux_test_check_size_of_received_data; testData = gst_dash_demux_test_case_new (); COPY_OUTPUT_TEST_DATA (outputTestData, testData); -- 2.7.4