mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-09-02 18:23:56 +00:00
dashdemux: tests: refactor testFragmentDownloadError
Renamed testFragmentDownloadError to testMediaDownloadErrorLastFragment. Added gst_adaptive_demux_test_unexpected_eos function. Remove unneeded testFragmentDownloadErrorCheckSizeOfDataReceived. https://bugzilla.gnome.org/show_bug.cgi?id=762144
This commit is contained in:
parent
f89fe6cb45
commit
b8ba8a3b7e
3 changed files with 42 additions and 43 deletions
|
@ -218,8 +218,19 @@ gst_adaptive_demux_test_check_received_data (GstAdaptiveDemuxTestEngine *
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* function to check total size of data received by AppSink
|
/* AppSink EOS callback.
|
||||||
* will be called when AppSink receives eos.
|
* To be used by tests that don't expect AppSink to receive EOS.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
gst_adaptive_demux_test_unexpected_eos (GstAdaptiveDemuxTestEngine *
|
||||||
|
engine, GstAdaptiveDemuxTestOutputStream * stream, gpointer user_data)
|
||||||
|
{
|
||||||
|
fail_if (TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* AppSink EOS callback.
|
||||||
|
* To be used by tests that expect AppSink to receive EOS.
|
||||||
|
* Will check total size of data received by AppSink.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
gst_adaptive_demux_test_check_size_of_received_data (GstAdaptiveDemuxTestEngine
|
gst_adaptive_demux_test_check_size_of_received_data (GstAdaptiveDemuxTestEngine
|
||||||
|
|
|
@ -151,6 +151,19 @@ void gst_adaptive_demux_test_seek (const gchar * element_name,
|
||||||
|
|
||||||
/* Utility functions for use within a unit test */
|
/* Utility functions for use within a unit test */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gst_adaptive_demux_test_unexpected_eos:
|
||||||
|
* @engine: The #GstAdaptiveDemuxTestEngine that caused this callback
|
||||||
|
* @stream: The #GstAdaptiveDemuxTestOutputStream that caused this callback
|
||||||
|
* @user_data: A pointer to a #GstAdaptiveDemuxTestCase object
|
||||||
|
*
|
||||||
|
* This function can be used as an EOS callback by tests that don't expect
|
||||||
|
* AppSink to receive EOS.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
gst_adaptive_demux_test_unexpected_eos (GstAdaptiveDemuxTestEngine *
|
||||||
|
engine, GstAdaptiveDemuxTestOutputStream * stream, gpointer user_data);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gst_adaptive_demux_test_check_size_of_received_data:
|
* gst_adaptive_demux_test_check_size_of_received_data:
|
||||||
* @engine: The #GstAdaptiveDemuxTestEngine that caused this callback
|
* @engine: The #GstAdaptiveDemuxTestEngine that caused this callback
|
||||||
|
|
|
@ -818,7 +818,6 @@ testDownloadErrorMessageCallback (GstAdaptiveDemuxTestEngine * engine,
|
||||||
GST_DEBUG ("Error from element %s : %s\n",
|
GST_DEBUG ("Error from element %s : %s\n",
|
||||||
GST_OBJECT_NAME (msg->src), err->message);
|
GST_OBJECT_NAME (msg->src), err->message);
|
||||||
fail_unless_equals_string (GST_OBJECT_NAME (msg->src), DEMUX_ELEMENT_NAME);
|
fail_unless_equals_string (GST_OBJECT_NAME (msg->src), DEMUX_ELEMENT_NAME);
|
||||||
/*GST_DEBUG ("dbg_info=%s\n", dbg_info); */
|
|
||||||
g_error_free (err);
|
g_error_free (err);
|
||||||
g_free (dbg_info);
|
g_free (dbg_info);
|
||||||
g_main_loop_quit (engine->loop);
|
g_main_loop_quit (engine->loop);
|
||||||
|
@ -877,8 +876,7 @@ GST_START_TEST (testDownloadError)
|
||||||
test_callbacks.appsink_received_data =
|
test_callbacks.appsink_received_data =
|
||||||
gst_adaptive_demux_test_check_received_data;
|
gst_adaptive_demux_test_check_received_data;
|
||||||
test_callbacks.bus_error_message = testDownloadErrorMessageCallback;
|
test_callbacks.bus_error_message = testDownloadErrorMessageCallback;
|
||||||
test_callbacks.appsink_eos =
|
test_callbacks.appsink_eos = gst_adaptive_demux_test_unexpected_eos;
|
||||||
gst_adaptive_demux_test_check_size_of_received_data;
|
|
||||||
|
|
||||||
testData = gst_dash_demux_test_case_new ();
|
testData = gst_dash_demux_test_case_new ();
|
||||||
COPY_OUTPUT_TEST_DATA (outputTestData, testData);
|
COPY_OUTPUT_TEST_DATA (outputTestData, testData);
|
||||||
|
@ -908,8 +906,7 @@ test_fragment_download_error_src_create (GstTestHTTPSrc * src,
|
||||||
gst_structure_get_uint64 (http_src_test_data->data, "threshold_for_trigger",
|
gst_structure_get_uint64 (http_src_test_data->data, "threshold_for_trigger",
|
||||||
&threshold_for_trigger);
|
&threshold_for_trigger);
|
||||||
|
|
||||||
if (!g_str_has_suffix (input->uri, ".mpd") && offset > threshold_for_trigger) {
|
if (!g_str_has_suffix (input->uri, ".mpd") && offset >= threshold_for_trigger) {
|
||||||
|
|
||||||
GST_DEBUG ("network_error %s %" G_GUINT64_FORMAT " @ %" G_GUINT64_FORMAT,
|
GST_DEBUG ("network_error %s %" G_GUINT64_FORMAT " @ %" G_GUINT64_FORMAT,
|
||||||
input->uri, offset, threshold_for_trigger);
|
input->uri, offset, threshold_for_trigger);
|
||||||
GST_ELEMENT_ERROR (src, RESOURCE, READ,
|
GST_ELEMENT_ERROR (src, RESOURCE, READ,
|
||||||
|
@ -920,39 +917,15 @@ test_fragment_download_error_src_create (GstTestHTTPSrc * src,
|
||||||
user_data);
|
user_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;
|
|
||||||
|
|
||||||
testOutputStreamData =
|
|
||||||
gst_adaptive_demux_test_find_test_data_by_stream (testData, stream, NULL);
|
|
||||||
fail_unless (testOutputStreamData != NULL);
|
|
||||||
|
|
||||||
/* 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 fragment download error
|
* Test media download error on the last media fragment.
|
||||||
* Let the adaptive demux download a few bytes, then instruct the
|
* Let the adaptive demux download a few bytes, then instruct the
|
||||||
* GstTestHTTPSrc element to generate an error.
|
* GstTestHTTPSrc element to generate an error while the last media fragment
|
||||||
|
* is being downloaded.
|
||||||
|
* Adaptive demux will not retry downloading the last media fragment. It will
|
||||||
|
* be considered eos.
|
||||||
*/
|
*/
|
||||||
GST_START_TEST (testFragmentDownloadError)
|
GST_START_TEST (testMediaDownloadErrorLastFragment)
|
||||||
{
|
{
|
||||||
const gchar *mpd =
|
const gchar *mpd =
|
||||||
"<?xml version=\"1.0\" encoding=\"utf-8\"?>"
|
"<?xml version=\"1.0\" encoding=\"utf-8\"?>"
|
||||||
|
@ -981,19 +954,22 @@ GST_START_TEST (testFragmentDownloadError)
|
||||||
" </SegmentBase>"
|
" </SegmentBase>"
|
||||||
" </Representation></AdaptationSet></Period></MPD>";
|
" </Representation></AdaptationSet></Period></MPD>";
|
||||||
|
|
||||||
|
/* generate error on the first media fragment */
|
||||||
|
guint64 threshold_for_trigger = 4687;
|
||||||
|
|
||||||
GstDashDemuxTestInputData inputTestData[] = {
|
GstDashDemuxTestInputData inputTestData[] = {
|
||||||
{"http://unit.test/test.mpd", (guint8 *) mpd, 0},
|
{"http://unit.test/test.mpd", (guint8 *) mpd, 0},
|
||||||
{"http://unit.test/audio.webm", NULL, 5000},
|
{"http://unit.test/audio.webm", NULL, 5000},
|
||||||
{NULL, NULL, 0},
|
{NULL, NULL, 0},
|
||||||
};
|
};
|
||||||
GstAdaptiveDemuxTestExpectedOutput outputTestData[] = {
|
GstAdaptiveDemuxTestExpectedOutput outputTestData[] = {
|
||||||
{"audio_00", 5000, NULL},
|
/* adaptive demux will not retry because this is the last fragment */
|
||||||
|
{"audio_00", threshold_for_trigger, NULL},
|
||||||
};
|
};
|
||||||
GstTestHTTPSrcCallbacks http_src_callbacks = { 0 };
|
GstTestHTTPSrcCallbacks http_src_callbacks = { 0 };
|
||||||
GstTestHTTPSrcTestData http_src_test_data = { 0 };
|
GstTestHTTPSrcTestData http_src_test_data = { 0 };
|
||||||
GstAdaptiveDemuxTestCallbacks test_callbacks = { 0 };
|
GstAdaptiveDemuxTestCallbacks test_callbacks = { 0 };
|
||||||
GstDashDemuxTestCase *testData;
|
GstDashDemuxTestCase *testData;
|
||||||
guint64 threshold_for_trigger = 2000;
|
|
||||||
|
|
||||||
http_src_callbacks.src_start = gst_dashdemux_http_src_start;
|
http_src_callbacks.src_start = gst_dashdemux_http_src_start;
|
||||||
http_src_callbacks.src_create = test_fragment_download_error_src_create;
|
http_src_callbacks.src_create = test_fragment_download_error_src_create;
|
||||||
|
@ -1006,9 +982,8 @@ GST_START_TEST (testFragmentDownloadError)
|
||||||
|
|
||||||
test_callbacks.appsink_received_data =
|
test_callbacks.appsink_received_data =
|
||||||
gst_adaptive_demux_test_check_received_data;
|
gst_adaptive_demux_test_check_received_data;
|
||||||
test_callbacks.appsink_eos = testFragmentDownloadErrorCheckSizeOfDataReceived;
|
test_callbacks.appsink_eos =
|
||||||
/* test_callbacks.demux_sent_eos = gst_adaptive_demux_test_check_size_of_received_data; */
|
gst_adaptive_demux_test_check_size_of_received_data;
|
||||||
test_callbacks.bus_error_message = testDownloadErrorMessageCallback;
|
|
||||||
|
|
||||||
testData = gst_dash_demux_test_case_new ();
|
testData = gst_dash_demux_test_case_new ();
|
||||||
COPY_OUTPUT_TEST_DATA (outputTestData, testData);
|
COPY_OUTPUT_TEST_DATA (outputTestData, testData);
|
||||||
|
@ -1189,7 +1164,7 @@ dash_demux_suite (void)
|
||||||
tcase_add_test (tc_basicTest, testReverseSeekSnapBeforePosition);
|
tcase_add_test (tc_basicTest, testReverseSeekSnapBeforePosition);
|
||||||
tcase_add_test (tc_basicTest, testReverseSeekSnapAfterPosition);
|
tcase_add_test (tc_basicTest, testReverseSeekSnapAfterPosition);
|
||||||
tcase_add_test (tc_basicTest, testDownloadError);
|
tcase_add_test (tc_basicTest, testDownloadError);
|
||||||
tcase_add_test (tc_basicTest, testFragmentDownloadError);
|
tcase_add_test (tc_basicTest, testMediaDownloadErrorLastFragment);
|
||||||
tcase_add_test (tc_basicTest, testQuery);
|
tcase_add_test (tc_basicTest, testQuery);
|
||||||
|
|
||||||
tcase_add_unchecked_fixture (tc_basicTest, gst_adaptive_demux_test_setup,
|
tcase_add_unchecked_fixture (tc_basicTest, gst_adaptive_demux_test_setup,
|
||||||
|
|
Loading…
Reference in a new issue