mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-22 05:56:31 +00:00
baseparse: only post 'no valid frames' error if buffers were received
Otherwise baseparse will consider empty streams to be an error while an empty stream is a valid scenario. With this patch, errors would only be emitted if the parser received data but wasn't able to produce any output from it. This change is only for push-mode operation as in pull mode an empty file can be considered an error for the one driving the pipeline Includes a unit test for it https://bugzilla.gnome.org/show_bug.cgi?id=733171
This commit is contained in:
parent
3e8e0a7065
commit
a041d8862d
2 changed files with 32 additions and 1 deletions
|
@ -1165,7 +1165,8 @@ gst_base_parse_sink_event_default (GstBaseParse * parse, GstEvent * event)
|
|||
gst_base_parse_finish_fragment (parse, TRUE);
|
||||
|
||||
/* If we STILL have zero frames processed, fire an error */
|
||||
if (parse->priv->framecount == 0 && !parse->priv->saw_gaps) {
|
||||
if (parse->priv->framecount == 0 && !parse->priv->saw_gaps &&
|
||||
!parse->priv->first_buffer) {
|
||||
GST_ELEMENT_ERROR (parse, STREAM, WRONG_TYPE,
|
||||
("No valid frames found before end of stream"), (NULL));
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
|
||||
static GstPad *mysrcpad, *mysinkpad;
|
||||
static GstElement *parsetest;
|
||||
static GstBus *bus;
|
||||
|
||||
#define TEST_VIDEO_WIDTH 640
|
||||
#define TEST_VIDEO_HEIGHT 480
|
||||
|
@ -134,11 +135,17 @@ setup_parsertester (void)
|
|||
parsetest = g_object_new (GST_PARSER_TESTER_TYPE, NULL);
|
||||
mysrcpad = gst_check_setup_src_pad (parsetest, &srctemplate);
|
||||
mysinkpad = gst_check_setup_sink_pad (parsetest, &sinktemplate);
|
||||
bus = gst_bus_new ();
|
||||
gst_element_set_bus (parsetest, bus);
|
||||
}
|
||||
|
||||
static void
|
||||
cleanup_parsertest (void)
|
||||
{
|
||||
/* release the bus first to get rid of all refcounts */
|
||||
gst_element_set_bus (parsetest, NULL);
|
||||
gst_object_unref (bus);
|
||||
|
||||
gst_pad_set_active (mysrcpad, FALSE);
|
||||
gst_pad_set_active (mysinkpad, FALSE);
|
||||
gst_check_teardown_src_pad (parsetest);
|
||||
|
@ -183,6 +190,17 @@ send_startup_events (void)
|
|||
gst_caps_unref (caps);
|
||||
}
|
||||
|
||||
static void
|
||||
check_no_error_received (void)
|
||||
{
|
||||
GstMessage *msg;
|
||||
|
||||
msg = gst_bus_pop_filtered (bus, GST_MESSAGE_ERROR);
|
||||
fail_unless (msg == NULL);
|
||||
if (msg)
|
||||
gst_message_unref (msg);
|
||||
}
|
||||
|
||||
static void
|
||||
run_parser_playback_test (GList * input, gint expected_output, gdouble rate)
|
||||
{
|
||||
|
@ -238,6 +256,8 @@ run_parser_playback_test (GList * input, gint expected_output, gdouble rate)
|
|||
g_list_free_full (buffers, (GDestroyNotify) gst_buffer_unref);
|
||||
buffers = NULL;
|
||||
|
||||
check_no_error_received ();
|
||||
|
||||
cleanup_parsertest ();
|
||||
}
|
||||
|
||||
|
@ -287,6 +307,15 @@ GST_START_TEST (parser_reverse_playback_on_passthrough)
|
|||
|
||||
GST_END_TEST;
|
||||
|
||||
GST_START_TEST (parser_empty_stream)
|
||||
{
|
||||
setup_parsertester ();
|
||||
|
||||
run_parser_playback_test (NULL, 0, 1.0);
|
||||
}
|
||||
|
||||
GST_END_TEST;
|
||||
|
||||
|
||||
static Suite *
|
||||
gst_baseparse_suite (void)
|
||||
|
@ -296,6 +325,7 @@ gst_baseparse_suite (void)
|
|||
|
||||
suite_add_tcase (s, tc);
|
||||
tcase_add_test (tc, parser_playback);
|
||||
tcase_add_test (tc, parser_empty_stream);
|
||||
tcase_add_test (tc, parser_reverse_playback_on_passthrough);
|
||||
|
||||
return s;
|
||||
|
|
Loading…
Reference in a new issue