/**
* GstWavParse:ignore-length
- *
+ *
* This selects whether the length found in a data chunk
* should be ignored. This may be useful for streamed audio
* where the length is unknown until the end of streaming,
GST_DEBUG_OBJECT (wav, "adding src pad");
- if (wav->caps) {
- s = gst_caps_get_structure (wav->caps, 0);
- if (s && gst_structure_has_name (s, "audio/x-raw") && buf != NULL) {
- GstTypeFindProbability prob;
- GstCaps *tf_caps;
-
- tf_caps = gst_type_find_helper_for_buffer (GST_OBJECT (wav), buf, &prob);
- if (tf_caps != NULL) {
- GST_LOG ("typefind caps = %" GST_PTR_FORMAT ", P=%d", tf_caps, prob);
- if (gst_wavparse_have_dts_caps (tf_caps, prob)) {
- GST_INFO_OBJECT (wav, "Found DTS marker in file marked as raw PCM");
- gst_caps_unref (wav->caps);
- wav->caps = tf_caps;
-
- gst_tag_list_add (wav->tags, GST_TAG_MERGE_REPLACE,
- GST_TAG_AUDIO_CODEC, "dts", NULL);
- } else {
- GST_DEBUG_OBJECT (wav, "found caps %" GST_PTR_FORMAT " for stream "
- "marked as raw PCM audio, but ignoring for now", tf_caps);
- gst_caps_unref (tf_caps);
- }
+ g_assert (wav->caps != NULL);
+
+ s = gst_caps_get_structure (wav->caps, 0);
+ if (s && gst_structure_has_name (s, "audio/x-raw") && buf != NULL) {
+ GstTypeFindProbability prob;
+ GstCaps *tf_caps;
+
+ tf_caps = gst_type_find_helper_for_buffer (GST_OBJECT (wav), buf, &prob);
+ if (tf_caps != NULL) {
+ GST_LOG ("typefind caps = %" GST_PTR_FORMAT ", P=%d", tf_caps, prob);
+ if (gst_wavparse_have_dts_caps (tf_caps, prob)) {
+ GST_INFO_OBJECT (wav, "Found DTS marker in file marked as raw PCM");
+ gst_caps_unref (wav->caps);
+ wav->caps = tf_caps;
+
+ gst_tag_list_add (wav->tags, GST_TAG_MERGE_REPLACE,
+ GST_TAG_AUDIO_CODEC, "dts", NULL);
+ } else {
+ GST_DEBUG_OBJECT (wav, "found caps %" GST_PTR_FORMAT " for stream "
+ "marked as raw PCM audio, but ignoring for now", tf_caps);
+ gst_caps_unref (tf_caps);
}
}
}
else if (wav->segment.rate < 0.0)
wav->segment.position = wav->segment.start;
}
- /* add pad before we perform EOS */
- if (G_UNLIKELY (wav->first)) {
- wav->first = FALSE;
- 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));
+ 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 */
+ if (G_UNLIKELY (wav->first)) {
+ wav->first = FALSE;
+ gst_wavparse_add_src_pad (wav, NULL);
+ }
- /* perform EOS logic */
- if (wav->segment.flags & GST_SEEK_FLAG_SEGMENT) {
- GstClockTime stop;
+ /* perform EOS logic */
+ if (wav->segment.flags & GST_SEEK_FLAG_SEGMENT) {
+ GstClockTime stop;
- if ((stop = wav->segment.stop) == -1)
- stop = wav->segment.duration;
+ if ((stop = wav->segment.stop) == -1)
+ stop = wav->segment.duration;
- gst_element_post_message (GST_ELEMENT_CAST (wav),
- gst_message_new_segment_done (GST_OBJECT_CAST (wav),
- wav->segment.format, stop));
- gst_pad_push_event (wav->srcpad,
- gst_event_new_segment_done (wav->segment.format, stop));
- } else {
- gst_pad_push_event (wav->srcpad, gst_event_new_eos ());
+ gst_element_post_message (GST_ELEMENT_CAST (wav),
+ gst_message_new_segment_done (GST_OBJECT_CAST (wav),
+ wav->segment.format, stop));
+ gst_pad_push_event (wav->srcpad,
+ gst_event_new_segment_done (wav->segment.format, stop));
+ } else {
+ gst_pad_push_event (wav->srcpad, gst_event_new_eos ());
+ }
}
} else if (ret == GST_FLOW_NOT_LINKED || ret < GST_FLOW_EOS) {
/* for fatal errors we post an error message, post the error
break;
}
case GST_EVENT_EOS:
- /* add pad if needed so EOS is seen downstream */
- if (G_UNLIKELY (wav->first)) {
- wav->first = FALSE;
- gst_wavparse_add_src_pad (wav, NULL);
+ if (wav->state == GST_WAVPARSE_START) {
+ GST_ELEMENT_ERROR (wav, STREAM, WRONG_TYPE, (NULL),
+ ("No valid input found before end of stream"));
} else {
- /* stream leftover data in current segment */
- gst_wavparse_flush_data (wav);
+ /* add pad if needed so EOS is seen downstream */
+ if (G_UNLIKELY (wav->first)) {
+ wav->first = FALSE;
+ gst_wavparse_add_src_pad (wav, NULL);
+ } else {
+ /* stream leftover data in current segment */
+ 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 */
case GST_EVENT_FLUSH_STOP:
{
--- /dev/null
+/* 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)