mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-02 04:22:27 +00:00
wavparse: error out if we receive eos before any valid data
https://bugzilla.gnome.org/show_bug.cgi?id=696684
This commit is contained in:
parent
67c2219687
commit
79d5a7d03c
3 changed files with 129 additions and 53 deletions
|
@ -2053,7 +2053,8 @@ gst_wavparse_add_src_pad (GstWavParse * wav, GstBuffer * buf)
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (wav, "adding src pad");
|
GST_DEBUG_OBJECT (wav, "adding src pad");
|
||||||
|
|
||||||
if (wav->caps) {
|
g_assert (wav->caps != NULL);
|
||||||
|
|
||||||
s = gst_caps_get_structure (wav->caps, 0);
|
s = gst_caps_get_structure (wav->caps, 0);
|
||||||
if (s && gst_structure_has_name (s, "audio/x-raw") && buf != NULL) {
|
if (s && gst_structure_has_name (s, "audio/x-raw") && buf != NULL) {
|
||||||
GstTypeFindProbability prob;
|
GstTypeFindProbability prob;
|
||||||
|
@ -2076,7 +2077,6 @@ gst_wavparse_add_src_pad (GstWavParse * wav, GstBuffer * buf)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
gst_pad_set_caps (wav->srcpad, wav->caps);
|
gst_pad_set_caps (wav->srcpad, wav->caps);
|
||||||
gst_caps_replace (&wav->caps, NULL);
|
gst_caps_replace (&wav->caps, NULL);
|
||||||
|
@ -2353,16 +2353,17 @@ pause:
|
||||||
else if (wav->segment.rate < 0.0)
|
else if (wav->segment.rate < 0.0)
|
||||||
wav->segment.position = wav->segment.start;
|
wav->segment.position = wav->segment.start;
|
||||||
}
|
}
|
||||||
|
if (wav->state == GST_WAVPARSE_START) {
|
||||||
|
GST_ELEMENT_ERROR (wav, STREAM, WRONG_TYPE, (NULL),
|
||||||
|
("No valid input found before end of stream"));
|
||||||
|
gst_pad_push_event (wav->srcpad, gst_event_new_eos ());
|
||||||
|
} else {
|
||||||
/* add pad before we perform EOS */
|
/* add pad before we perform EOS */
|
||||||
if (G_UNLIKELY (wav->first)) {
|
if (G_UNLIKELY (wav->first)) {
|
||||||
wav->first = FALSE;
|
wav->first = FALSE;
|
||||||
gst_wavparse_add_src_pad (wav, NULL);
|
gst_wavparse_add_src_pad (wav, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wav->state == GST_WAVPARSE_START)
|
|
||||||
GST_ELEMENT_ERROR (wav, STREAM, WRONG_TYPE,
|
|
||||||
("No valid input found before end of stream"), (NULL));
|
|
||||||
|
|
||||||
/* perform EOS logic */
|
/* perform EOS logic */
|
||||||
if (wav->segment.flags & GST_SEEK_FLAG_SEGMENT) {
|
if (wav->segment.flags & GST_SEEK_FLAG_SEGMENT) {
|
||||||
GstClockTime stop;
|
GstClockTime stop;
|
||||||
|
@ -2378,6 +2379,7 @@ pause:
|
||||||
} else {
|
} else {
|
||||||
gst_pad_push_event (wav->srcpad, gst_event_new_eos ());
|
gst_pad_push_event (wav->srcpad, gst_event_new_eos ());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else if (ret == GST_FLOW_NOT_LINKED || ret < GST_FLOW_EOS) {
|
} else if (ret == GST_FLOW_NOT_LINKED || ret < GST_FLOW_EOS) {
|
||||||
/* for fatal errors we post an error message, post the error
|
/* for fatal errors we post an error message, post the error
|
||||||
* first so the app knows about the error first. */
|
* first so the app knows about the error first. */
|
||||||
|
@ -2561,6 +2563,10 @@ gst_wavparse_sink_event (GstPad * pad, GstObject * parent, GstEvent * event)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case GST_EVENT_EOS:
|
case GST_EVENT_EOS:
|
||||||
|
if (wav->state == GST_WAVPARSE_START) {
|
||||||
|
GST_ELEMENT_ERROR (wav, STREAM, WRONG_TYPE, (NULL),
|
||||||
|
("No valid input found before end of stream"));
|
||||||
|
} else {
|
||||||
/* add pad if needed so EOS is seen downstream */
|
/* add pad if needed so EOS is seen downstream */
|
||||||
if (G_UNLIKELY (wav->first)) {
|
if (G_UNLIKELY (wav->first)) {
|
||||||
wav->first = FALSE;
|
wav->first = FALSE;
|
||||||
|
@ -2569,10 +2575,7 @@ gst_wavparse_sink_event (GstPad * pad, GstObject * parent, GstEvent * event)
|
||||||
/* stream leftover data in current segment */
|
/* stream leftover data in current segment */
|
||||||
gst_wavparse_flush_data (wav);
|
gst_wavparse_flush_data (wav);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (wav->state == GST_WAVPARSE_START)
|
|
||||||
GST_ELEMENT_ERROR (wav, STREAM, WRONG_TYPE,
|
|
||||||
("No valid input found before end of stream"), (NULL));
|
|
||||||
|
|
||||||
/* fall-through */
|
/* fall-through */
|
||||||
case GST_EVENT_FLUSH_STOP:
|
case GST_EVENT_FLUSH_STOP:
|
||||||
|
|
|
@ -151,6 +151,7 @@ check_PROGRAMS = \
|
||||||
elements/videocrop \
|
elements/videocrop \
|
||||||
elements/videofilter \
|
elements/videofilter \
|
||||||
elements/wavpackparse \
|
elements/wavpackparse \
|
||||||
|
elements/wavparse \
|
||||||
elements/y4menc \
|
elements/y4menc \
|
||||||
pipelines/simple-launch-lines \
|
pipelines/simple-launch-lines \
|
||||||
pipelines/effectv \
|
pipelines/effectv \
|
||||||
|
|
72
tests/check/elements/wavparse.c
Normal file
72
tests/check/elements/wavparse.c
Normal file
|
@ -0,0 +1,72 @@
|
||||||
|
/* GStreamer WavParse unit tests
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Library General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Library General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Library General Public
|
||||||
|
* License along with this library; if not, write to the
|
||||||
|
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
||||||
|
* Boston, MA 02110-1301, USA.
|
||||||
|
*/
|
||||||
|
#include <gst/check/gstcheck.h>
|
||||||
|
#include <gio/gio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
GST_START_TEST (test_empty_file)
|
||||||
|
{
|
||||||
|
GstElement *pipeline;
|
||||||
|
GstElement *filesrc;
|
||||||
|
GstElement *wavparse;
|
||||||
|
GstElement *fakesink;
|
||||||
|
|
||||||
|
pipeline = gst_pipeline_new ("testpipe");
|
||||||
|
filesrc = gst_element_factory_make ("filesrc", NULL);
|
||||||
|
fail_if (filesrc == NULL);
|
||||||
|
wavparse = gst_element_factory_make ("wavparse", NULL);
|
||||||
|
fail_if (wavparse == NULL);
|
||||||
|
fakesink = gst_element_factory_make ("fakesink", NULL);
|
||||||
|
fail_if (fakesink == NULL);
|
||||||
|
|
||||||
|
gst_object_ref_sink (filesrc);
|
||||||
|
gst_object_ref_sink (wavparse);
|
||||||
|
gst_object_ref_sink (fakesink);
|
||||||
|
|
||||||
|
gst_bin_add_many (GST_BIN (pipeline), filesrc, wavparse, fakesink, NULL);
|
||||||
|
g_object_set (filesrc, "location", "/dev/null", NULL);
|
||||||
|
|
||||||
|
fail_unless (gst_element_link_many (filesrc, wavparse, fakesink, NULL));
|
||||||
|
|
||||||
|
gst_element_set_state (pipeline, GST_STATE_PLAYING);
|
||||||
|
|
||||||
|
gst_element_get_state (pipeline, NULL, NULL, GST_CLOCK_TIME_NONE);
|
||||||
|
|
||||||
|
gst_element_set_state (pipeline, GST_STATE_NULL);
|
||||||
|
|
||||||
|
gst_object_unref (filesrc);
|
||||||
|
gst_object_unref (wavparse);
|
||||||
|
gst_object_unref (fakesink);
|
||||||
|
gst_object_unref (pipeline);
|
||||||
|
}
|
||||||
|
|
||||||
|
GST_END_TEST;
|
||||||
|
|
||||||
|
static Suite *
|
||||||
|
wavparse_suite (void)
|
||||||
|
{
|
||||||
|
Suite *s = suite_create ("wavparse");
|
||||||
|
TCase *tc_chain = tcase_create ("wavparse");
|
||||||
|
|
||||||
|
suite_add_tcase (s, tc_chain);
|
||||||
|
tcase_add_test (tc_chain, test_empty_file);
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
GST_CHECK_MAIN (wavparse)
|
Loading…
Reference in a new issue