mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-24 08:08:22 +00:00
gst/wavparse/gstwavparse.*: correct partial implementation of push mode (from my last commit)
Original commit message from CVS: * gst/wavparse/gstwavparse.c: (gst_wavparse_base_init), (gst_wavparse_class_init), (gst_wavparse_reset), (gst_wavparse_init), (gst_wavparse_create_sourcepad), (gst_wavparse_parse_adtl), (gst_wavparse_parse_cues), (gst_wavparse_parse_file_header), (gst_wavparse_stream_init), (gst_wavparse_perform_seek), (gst_wavparse_stream_headers), (gst_wavparse_stream_data), (gst_wavparse_loop), (gst_wavparse_chain), (plugin_init): * gst/wavparse/gstwavparse.h: correct partial implementation of push mode (from my last commit)
This commit is contained in:
parent
da6b539bbe
commit
562de2f6e0
3 changed files with 143 additions and 94 deletions
14
ChangeLog
14
ChangeLog
|
@ -1,3 +1,17 @@
|
||||||
|
2006-04-26 Stefan Kost <ensonic@users.sf.net>
|
||||||
|
|
||||||
|
* gst/wavparse/gstwavparse.c: (gst_wavparse_base_init),
|
||||||
|
(gst_wavparse_class_init), (gst_wavparse_reset),
|
||||||
|
(gst_wavparse_init), (gst_wavparse_create_sourcepad),
|
||||||
|
(gst_wavparse_parse_adtl), (gst_wavparse_parse_cues),
|
||||||
|
(gst_wavparse_parse_file_header), (gst_wavparse_stream_init),
|
||||||
|
(gst_wavparse_perform_seek), (gst_wavparse_stream_headers),
|
||||||
|
(gst_wavparse_stream_data), (gst_wavparse_loop),
|
||||||
|
(gst_wavparse_chain), (plugin_init):
|
||||||
|
* gst/wavparse/gstwavparse.h:
|
||||||
|
correct partial implementation of push mode
|
||||||
|
(from my last commit)
|
||||||
|
|
||||||
2006-04-26 Wim Taymans <wim@fluendo.com>
|
2006-04-26 Wim Taymans <wim@fluendo.com>
|
||||||
|
|
||||||
* ext/esd/esdsink.c:
|
* ext/esd/esdsink.c:
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/* -*- Mode: C; tab-width: 2; indent-tabs-mode: t; c-basic-offset: 2 -*- */
|
/* -*- Mode: C; tab-width: 2; indent-tabs-mode: t; c-basic-offset: 2 -*- */
|
||||||
/* GStreamer
|
/* GStreamer
|
||||||
* Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
|
* Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
|
||||||
* Copyright (C) <2006> Nokia Corporation.
|
* Copyright (C) <2006> Nokia Corporation, Stefan Kost <stefan.kost@nokia.com>.
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Library General Public
|
* modify it under the terms of the GNU Library General Public
|
||||||
|
@ -32,11 +32,18 @@
|
||||||
* <title>Example launch line</title>
|
* <title>Example launch line</title>
|
||||||
* <para>
|
* <para>
|
||||||
* <programlisting>
|
* <programlisting>
|
||||||
* gst-launch filesrc sine.wav ! wavparse ! audioconvert ! alsasink
|
* gst-launch filesrc location=sine.wav ! queue ! wavparse ! audioconvert ! alsasink
|
||||||
* </programlisting>
|
* </programlisting>
|
||||||
* Read a wav file and output to the soundcard using the ALSA element. The
|
* Read a wav file and output to the soundcard using the ALSA element. The
|
||||||
* wav file is assumed to contain raw uncompressed samples.
|
* wav file is assumed to contain raw uncompressed samples.
|
||||||
* </para>
|
* </para>
|
||||||
|
* <para>
|
||||||
|
* <programlisting>
|
||||||
|
* gst-launch gnomevfssrc location=http://www.example.org/sine.wav ! wavparse ! audioconvert ! alsasink
|
||||||
|
* </programlisting>
|
||||||
|
* Stream data from
|
||||||
|
* </para>
|
||||||
|
*
|
||||||
* </refsect2>
|
* </refsect2>
|
||||||
*
|
*
|
||||||
* Last reviewed on 2006-03-03 (0.10.3)
|
* Last reviewed on 2006-03-03 (0.10.3)
|
||||||
|
@ -84,6 +91,12 @@ static gboolean gst_wavparse_srcpad_event (GstPad * pad, GstEvent * event);
|
||||||
static void gst_wavparse_get_property (GObject * object, guint prop_id,
|
static void gst_wavparse_get_property (GObject * object, guint prop_id,
|
||||||
GValue * value, GParamSpec * pspec);
|
GValue * value, GParamSpec * pspec);
|
||||||
|
|
||||||
|
static const GstElementDetails gst_wavparse_details =
|
||||||
|
GST_ELEMENT_DETAILS ("WAV audio demuxer",
|
||||||
|
"Codec/Demuxer/Audio",
|
||||||
|
"Parse a .wav file into raw audio",
|
||||||
|
"Erik Walthinsen <omega@cse.ogi.edu>");
|
||||||
|
|
||||||
static GstStaticPadTemplate sink_template_factory =
|
static GstStaticPadTemplate sink_template_factory =
|
||||||
GST_STATIC_PAD_TEMPLATE ("wavparse_sink",
|
GST_STATIC_PAD_TEMPLATE ("wavparse_sink",
|
||||||
GST_PAD_SINK,
|
GST_PAD_SINK,
|
||||||
|
@ -162,22 +175,13 @@ static void
|
||||||
gst_wavparse_base_init (gpointer g_class)
|
gst_wavparse_base_init (gpointer g_class)
|
||||||
{
|
{
|
||||||
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
|
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
|
||||||
GstPadTemplate *templ;
|
|
||||||
static const GstElementDetails gst_wavparse_details =
|
|
||||||
GST_ELEMENT_DETAILS ("WAV audio demuxer",
|
|
||||||
"Codec/Demuxer/Audio",
|
|
||||||
"Parse a .wav file into raw audio",
|
|
||||||
"Erik Walthinsen <omega@cse.ogi.edu>");
|
|
||||||
|
|
||||||
gst_element_class_set_details (element_class, &gst_wavparse_details);
|
|
||||||
|
|
||||||
/* register src pads */
|
/* register src pads */
|
||||||
templ = gst_static_pad_template_get (&sink_template_factory);
|
gst_element_class_add_pad_template (element_class,
|
||||||
gst_element_class_add_pad_template (element_class, templ);
|
gst_static_pad_template_get (&sink_template_factory));
|
||||||
gst_object_unref (templ);
|
gst_element_class_add_pad_template (element_class,
|
||||||
templ = gst_static_pad_template_get (&src_template_factory);
|
gst_static_pad_template_get (&src_template_factory));
|
||||||
gst_element_class_add_pad_template (element_class, templ);
|
gst_element_class_set_details (element_class, &gst_wavparse_details);
|
||||||
gst_object_unref (templ);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -196,8 +200,6 @@ gst_wavparse_class_init (GstWavParseClass * klass)
|
||||||
|
|
||||||
gstelement_class->change_state = gst_wavparse_change_state;
|
gstelement_class->change_state = gst_wavparse_change_state;
|
||||||
gstelement_class->send_event = gst_wavparse_send_event;
|
gstelement_class->send_event = gst_wavparse_send_event;
|
||||||
|
|
||||||
GST_DEBUG_CATEGORY_INIT (wavparse_debug, "wavparse", 0, "WAV parser");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -234,6 +236,7 @@ gst_wavparse_reset (GstWavParse * wavparse)
|
||||||
wavparse->datasize = 0;
|
wavparse->datasize = 0;
|
||||||
wavparse->datastart = 0;
|
wavparse->datastart = 0;
|
||||||
wavparse->got_fmt = FALSE;
|
wavparse->got_fmt = FALSE;
|
||||||
|
wavparse->first = TRUE;
|
||||||
|
|
||||||
if (wavparse->seek_event)
|
if (wavparse->seek_event)
|
||||||
gst_event_unref (wavparse->seek_event);
|
gst_event_unref (wavparse->seek_event);
|
||||||
|
@ -258,6 +261,9 @@ gst_wavparse_init (GstWavParse * wavparse)
|
||||||
gst_pad_set_chain_function (wavparse->sinkpad,
|
gst_pad_set_chain_function (wavparse->sinkpad,
|
||||||
GST_DEBUG_FUNCPTR (gst_wavparse_chain));
|
GST_DEBUG_FUNCPTR (gst_wavparse_chain));
|
||||||
gst_element_add_pad (GST_ELEMENT (wavparse), wavparse->sinkpad);
|
gst_element_add_pad (GST_ELEMENT (wavparse), wavparse->sinkpad);
|
||||||
|
|
||||||
|
/* src, will be created later */
|
||||||
|
wavparse->srcpad = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -285,6 +291,8 @@ gst_wavparse_create_sourcepad (GstWavParse * wavparse)
|
||||||
GST_DEBUG_FUNCPTR (gst_wavparse_pad_query));
|
GST_DEBUG_FUNCPTR (gst_wavparse_pad_query));
|
||||||
gst_pad_set_event_function (wavparse->srcpad,
|
gst_pad_set_event_function (wavparse->srcpad,
|
||||||
GST_DEBUG_FUNCPTR (gst_wavparse_srcpad_event));
|
GST_DEBUG_FUNCPTR (gst_wavparse_srcpad_event));
|
||||||
|
|
||||||
|
GST_DEBUG_OBJECT (wavparse, "srcpad created");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -301,6 +309,8 @@ gst_wavparse_get_property (GObject * object,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
static void
|
static void
|
||||||
gst_wavparse_parse_adtl (GstWavParse * wavparse, int len)
|
gst_wavparse_parse_adtl (GstWavParse * wavparse, int len)
|
||||||
|
@ -484,9 +494,7 @@ gst_wavparse_parse_adtl (GstWavParse * wavparse, int len)
|
||||||
|
|
||||||
g_object_notify (G_OBJECT (wavparse), "metadata");
|
g_object_notify (G_OBJECT (wavparse), "metadata");
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
static void
|
static void
|
||||||
gst_wavparse_parse_cues (GstWavParse * wavparse, int len)
|
gst_wavparse_parse_cues (GstWavParse * wavparse, int len)
|
||||||
{
|
{
|
||||||
|
@ -549,49 +557,7 @@ gst_wavparse_parse_cues (GstWavParse * wavparse, int len)
|
||||||
|
|
||||||
g_object_notify (G_OBJECT (wavparse), "metadata");
|
g_object_notify (G_OBJECT (wavparse), "metadata");
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
static gboolean
|
|
||||||
gst_wavparse_parse_file_header (GstElement * element, GstBuffer * buf)
|
|
||||||
{
|
|
||||||
guint32 doctype;
|
|
||||||
|
|
||||||
if (!gst_riff_parse_file_header (element, buf, &doctype))
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
if (doctype != GST_RIFF_RIFF_WAVE)
|
|
||||||
goto not_wav;
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
|
|
||||||
/* ERRORS */
|
|
||||||
not_wav:
|
|
||||||
{
|
|
||||||
GST_ELEMENT_ERROR (element, STREAM, WRONG_TYPE, (NULL),
|
|
||||||
("File is not an WAVE file: %" GST_FOURCC_FORMAT,
|
|
||||||
GST_FOURCC_ARGS (doctype)));
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static GstFlowReturn
|
|
||||||
gst_wavparse_stream_init (GstWavParse * wav)
|
|
||||||
{
|
|
||||||
GstFlowReturn res;
|
|
||||||
GstBuffer *buf = NULL;
|
|
||||||
|
|
||||||
if ((res = gst_pad_pull_range (wav->sinkpad,
|
|
||||||
wav->offset, 12, &buf)) != GST_FLOW_OK)
|
|
||||||
return res;
|
|
||||||
else if (!gst_wavparse_parse_file_header (GST_ELEMENT (wav), buf))
|
|
||||||
return GST_FLOW_ERROR;
|
|
||||||
|
|
||||||
wav->offset += 12;
|
|
||||||
|
|
||||||
return GST_FLOW_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
/* Read 'fmt ' header */
|
/* Read 'fmt ' header */
|
||||||
static gboolean
|
static gboolean
|
||||||
gst_wavparse_fmt (GstWavParse * wav)
|
gst_wavparse_fmt (GstWavParse * wav)
|
||||||
|
@ -749,6 +715,48 @@ gst_wavparse_other (GstWavParse * wav)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
gst_wavparse_parse_file_header (GstElement * element, GstBuffer * buf)
|
||||||
|
{
|
||||||
|
guint32 doctype;
|
||||||
|
|
||||||
|
if (!gst_riff_parse_file_header (element, buf, &doctype))
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
if (doctype != GST_RIFF_RIFF_WAVE)
|
||||||
|
goto not_wav;
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
|
/* ERRORS */
|
||||||
|
not_wav:
|
||||||
|
{
|
||||||
|
GST_ELEMENT_ERROR (element, STREAM, WRONG_TYPE, (NULL),
|
||||||
|
("File is not an WAVE file: %" GST_FOURCC_FORMAT,
|
||||||
|
GST_FOURCC_ARGS (doctype)));
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static GstFlowReturn
|
||||||
|
gst_wavparse_stream_init (GstWavParse * wav)
|
||||||
|
{
|
||||||
|
GstFlowReturn res;
|
||||||
|
GstBuffer *buf = NULL;
|
||||||
|
|
||||||
|
if ((res = gst_pad_pull_range (wav->sinkpad,
|
||||||
|
wav->offset, 12, &buf)) != GST_FLOW_OK)
|
||||||
|
return res;
|
||||||
|
else if (!gst_wavparse_parse_file_header (GST_ELEMENT (wav), buf))
|
||||||
|
return GST_FLOW_ERROR;
|
||||||
|
|
||||||
|
wav->offset += 12;
|
||||||
|
|
||||||
|
return GST_FLOW_OK;
|
||||||
|
}
|
||||||
|
|
||||||
/* This function is used to perform seeks on the element in
|
/* This function is used to perform seeks on the element in
|
||||||
* pull mode.
|
* pull mode.
|
||||||
*
|
*
|
||||||
|
@ -800,7 +808,7 @@ gst_wavparse_perform_seek (GstWavParse * wav, GstEvent * event)
|
||||||
|
|
||||||
flush = flags & GST_SEEK_FLAG_FLUSH;
|
flush = flags & GST_SEEK_FLAG_FLUSH;
|
||||||
|
|
||||||
if (flush) {
|
if (flush && wav->srcpad) {
|
||||||
GST_DEBUG_OBJECT (wav, "sending flush start");
|
GST_DEBUG_OBJECT (wav, "sending flush start");
|
||||||
gst_pad_push_event (wav->srcpad, gst_event_new_flush_start ());
|
gst_pad_push_event (wav->srcpad, gst_event_new_flush_start ());
|
||||||
} else {
|
} else {
|
||||||
|
@ -846,19 +854,21 @@ gst_wavparse_perform_seek (GstWavParse * wav, GstEvent * event)
|
||||||
GST_TIME_ARGS (seeksegment.start), GST_TIME_ARGS (stop));
|
GST_TIME_ARGS (seeksegment.start), GST_TIME_ARGS (stop));
|
||||||
|
|
||||||
/* prepare for streaming again */
|
/* prepare for streaming again */
|
||||||
if (flush) {
|
if (wav->srcpad) {
|
||||||
GST_DEBUG_OBJECT (wav, "sending flush stop");
|
if (flush) {
|
||||||
gst_pad_push_event (wav->srcpad, gst_event_new_flush_stop ());
|
GST_DEBUG_OBJECT (wav, "sending flush stop");
|
||||||
} else if (wav->segment_running) {
|
gst_pad_push_event (wav->srcpad, gst_event_new_flush_stop ());
|
||||||
/* we are running the current segment and doing a non-flushing seek,
|
} else if (wav->segment_running) {
|
||||||
* close the segment first based on the last_stop. */
|
/* we are running the current segment and doing a non-flushing seek,
|
||||||
GST_DEBUG_OBJECT (wav, "closing running segment %" G_GINT64_FORMAT
|
* close the segment first based on the last_stop. */
|
||||||
" to %" G_GINT64_FORMAT, wav->segment.start, wav->segment.last_stop);
|
GST_DEBUG_OBJECT (wav, "closing running segment %" G_GINT64_FORMAT
|
||||||
|
" to %" G_GINT64_FORMAT, wav->segment.start, wav->segment.last_stop);
|
||||||
|
|
||||||
gst_pad_push_event (wav->srcpad,
|
gst_pad_push_event (wav->srcpad,
|
||||||
gst_event_new_new_segment (TRUE,
|
gst_event_new_new_segment (TRUE,
|
||||||
wav->segment.rate, wav->segment.format,
|
wav->segment.rate, wav->segment.format,
|
||||||
wav->segment.start, wav->segment.last_stop, wav->segment.time));
|
wav->segment.start, wav->segment.last_stop, wav->segment.time));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy (&wav->segment, &seeksegment, sizeof (GstSegment));
|
memcpy (&wav->segment, &seeksegment, sizeof (GstSegment));
|
||||||
|
@ -1080,7 +1090,6 @@ gst_wavparse_stream_headers (GstWavParse * wav)
|
||||||
|
|
||||||
/* loop headers until we get data */
|
/* loop headers until we get data */
|
||||||
while (!gotdata) {
|
while (!gotdata) {
|
||||||
|
|
||||||
if (wav->streaming) {
|
if (wav->streaming) {
|
||||||
if (!gst_wavparse_peek_chunk_info (wav, &tag, &size))
|
if (!gst_wavparse_peek_chunk_info (wav, &tag, &size))
|
||||||
return GST_FLOW_OK;
|
return GST_FLOW_OK;
|
||||||
|
@ -1322,7 +1331,7 @@ gst_wavparse_add_src_pad (GstWavParse * wav, GstBuffer * buf)
|
||||||
#define MAX_BUFFER_SIZE 4096
|
#define MAX_BUFFER_SIZE 4096
|
||||||
|
|
||||||
static GstFlowReturn
|
static GstFlowReturn
|
||||||
gst_wavparse_stream_data (GstWavParse * wav, gboolean first)
|
gst_wavparse_stream_data (GstWavParse * wav)
|
||||||
{
|
{
|
||||||
GstBuffer *buf = NULL;
|
GstBuffer *buf = NULL;
|
||||||
GstFlowReturn res = GST_FLOW_OK;
|
GstFlowReturn res = GST_FLOW_OK;
|
||||||
|
@ -1331,8 +1340,9 @@ gst_wavparse_stream_data (GstWavParse * wav, gboolean first)
|
||||||
guint64 pos, nextpos;
|
guint64 pos, nextpos;
|
||||||
|
|
||||||
iterate_adapter:
|
iterate_adapter:
|
||||||
GST_LOG_OBJECT (wav, "offset: %" G_GINT64_FORMAT " , end: %" G_GINT64_FORMAT,
|
GST_LOG_OBJECT (wav,
|
||||||
wav->offset, wav->end_offset);
|
"offset: %" G_GINT64_FORMAT " , end: %" G_GINT64_FORMAT " , dataleft: %"
|
||||||
|
G_GINT64_FORMAT, wav->offset, wav->end_offset, wav->dataleft);
|
||||||
|
|
||||||
/* Get the next n bytes and output them */
|
/* Get the next n bytes and output them */
|
||||||
if (wav->dataleft == 0 || wav->dataleft < wav->blockalign)
|
if (wav->dataleft == 0 || wav->dataleft < wav->blockalign)
|
||||||
|
@ -1350,8 +1360,12 @@ iterate_adapter:
|
||||||
"from the sinkpad", desired);
|
"from the sinkpad", desired);
|
||||||
|
|
||||||
if (wav->streaming) {
|
if (wav->streaming) {
|
||||||
if (gst_adapter_available (wav->adapter) < desired)
|
guint avail = gst_adapter_available (wav->adapter);
|
||||||
|
|
||||||
|
if (avail < desired) {
|
||||||
|
GST_LOG_OBJECT (wav, "Got only %d bytes of data from the sinkpad", avail);
|
||||||
return GST_FLOW_OK;
|
return GST_FLOW_OK;
|
||||||
|
}
|
||||||
|
|
||||||
buf = gst_buffer_new ();
|
buf = gst_buffer_new ();
|
||||||
GST_BUFFER_DATA (buf) = gst_adapter_take (wav->adapter, desired);
|
GST_BUFFER_DATA (buf) = gst_adapter_take (wav->adapter, desired);
|
||||||
|
@ -1362,14 +1376,15 @@ iterate_adapter:
|
||||||
goto pull_error;
|
goto pull_error;
|
||||||
}
|
}
|
||||||
|
|
||||||
obtained = GST_BUFFER_SIZE (buf);
|
|
||||||
|
|
||||||
/* first chunk of data? create the source pad. We do this only here so
|
/* first chunk of data? create the source pad. We do this only here so
|
||||||
* we can detect broken .wav files with dts disguised as raw PCM (sigh) */
|
* we can detect broken .wav files with dts disguised as raw PCM (sigh) */
|
||||||
if (first) {
|
if (G_UNLIKELY (wav->first)) {
|
||||||
|
wav->first = FALSE;
|
||||||
gst_wavparse_add_src_pad (wav, buf);
|
gst_wavparse_add_src_pad (wav, buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
obtained = GST_BUFFER_SIZE (buf);
|
||||||
|
|
||||||
/* our positions */
|
/* our positions */
|
||||||
pos = wav->offset - wav->datastart;
|
pos = wav->offset - wav->datastart;
|
||||||
nextpos = pos + obtained;
|
nextpos = pos + obtained;
|
||||||
|
@ -1400,16 +1415,17 @@ iterate_adapter:
|
||||||
if ((res = gst_pad_push (wav->srcpad, buf)) != GST_FLOW_OK)
|
if ((res = gst_pad_push (wav->srcpad, buf)) != GST_FLOW_OK)
|
||||||
goto push_error;
|
goto push_error;
|
||||||
} else {
|
} else {
|
||||||
GST_DEBUG ("Srcpad not linked!");
|
|
||||||
gst_buffer_unref (buf);
|
gst_buffer_unref (buf);
|
||||||
|
goto not_linked;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (obtained < wav->dataleft) {
|
if (obtained < wav->dataleft) {
|
||||||
wav->dataleft -= obtained;
|
wav->dataleft -= obtained;
|
||||||
wav->offset += obtained;
|
//wav->offset += obtained;
|
||||||
} else {
|
} else {
|
||||||
wav->dataleft = 0;
|
wav->dataleft = 0;
|
||||||
}
|
}
|
||||||
|
wav->offset += obtained;
|
||||||
/* Iterate until need more data, so adapter size won't grow */
|
/* Iterate until need more data, so adapter size won't grow */
|
||||||
if (wav->streaming) {
|
if (wav->streaming) {
|
||||||
GST_LOG_OBJECT (wav,
|
GST_LOG_OBJECT (wav,
|
||||||
|
@ -1451,6 +1467,11 @@ push_error:
|
||||||
GST_DEBUG_OBJECT (wav, "Error pushing on srcpad");
|
GST_DEBUG_OBJECT (wav, "Error pushing on srcpad");
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
not_linked:
|
||||||
|
{
|
||||||
|
GST_DEBUG_OBJECT (wav, "Srcpad not linked!");
|
||||||
|
return GST_FLOW_ERROR;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -1459,8 +1480,11 @@ gst_wavparse_loop (GstPad * pad)
|
||||||
GstFlowReturn ret;
|
GstFlowReturn ret;
|
||||||
GstWavParse *wav = GST_WAVPARSE (GST_PAD_PARENT (pad));
|
GstWavParse *wav = GST_WAVPARSE (GST_PAD_PARENT (pad));
|
||||||
|
|
||||||
|
GST_LOG_OBJECT (wav, "process data");
|
||||||
|
|
||||||
switch (wav->state) {
|
switch (wav->state) {
|
||||||
case GST_WAVPARSE_START:
|
case GST_WAVPARSE_START:
|
||||||
|
GST_DEBUG_OBJECT (wav, "GST_WAVPARSE_START");
|
||||||
if ((ret = gst_wavparse_stream_init (wav)) != GST_FLOW_OK)
|
if ((ret = gst_wavparse_stream_init (wav)) != GST_FLOW_OK)
|
||||||
goto pause;
|
goto pause;
|
||||||
|
|
||||||
|
@ -1468,15 +1492,15 @@ gst_wavparse_loop (GstPad * pad)
|
||||||
/* fall-through */
|
/* fall-through */
|
||||||
|
|
||||||
case GST_WAVPARSE_HEADER:
|
case GST_WAVPARSE_HEADER:
|
||||||
|
GST_DEBUG_OBJECT (wav, "GST_WAVPARSE_HEADER");
|
||||||
if ((ret = gst_wavparse_stream_headers (wav)) != GST_FLOW_OK)
|
if ((ret = gst_wavparse_stream_headers (wav)) != GST_FLOW_OK)
|
||||||
goto pause;
|
goto pause;
|
||||||
|
|
||||||
wav->state = GST_WAVPARSE_DATA;
|
wav->state = GST_WAVPARSE_DATA;
|
||||||
if ((ret = gst_wavparse_stream_data (wav, TRUE)) != GST_FLOW_OK)
|
/* fall-through */
|
||||||
goto pause;
|
|
||||||
break;
|
|
||||||
case GST_WAVPARSE_DATA:
|
case GST_WAVPARSE_DATA:
|
||||||
if ((ret = gst_wavparse_stream_data (wav, FALSE)) != GST_FLOW_OK)
|
if ((ret = gst_wavparse_stream_data (wav)) != GST_FLOW_OK)
|
||||||
goto pause;
|
goto pause;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -1505,24 +1529,30 @@ gst_wavparse_chain (GstPad * pad, GstBuffer * buf)
|
||||||
GstFlowReturn ret;
|
GstFlowReturn ret;
|
||||||
GstWavParse *wav = GST_WAVPARSE (GST_PAD_PARENT (pad));
|
GstWavParse *wav = GST_WAVPARSE (GST_PAD_PARENT (pad));
|
||||||
|
|
||||||
|
GST_LOG_OBJECT (wav, "adapter_push %" G_GINT64_FORMAT " bytes",
|
||||||
|
GST_BUFFER_SIZE (buf));
|
||||||
|
|
||||||
gst_adapter_push (wav->adapter, buf);
|
gst_adapter_push (wav->adapter, buf);
|
||||||
|
|
||||||
switch (wav->state) {
|
switch (wav->state) {
|
||||||
case GST_WAVPARSE_START:
|
case GST_WAVPARSE_START:
|
||||||
|
GST_DEBUG_OBJECT (wav, "GST_WAVPARSE_START");
|
||||||
if ((ret = gst_wavparse_parse_stream_init (wav)) != GST_FLOW_OK)
|
if ((ret = gst_wavparse_parse_stream_init (wav)) != GST_FLOW_OK)
|
||||||
goto pause;
|
goto pause;
|
||||||
|
|
||||||
|
wav->state = GST_WAVPARSE_HEADER;
|
||||||
/* fall-through */
|
/* fall-through */
|
||||||
|
|
||||||
case GST_WAVPARSE_HEADER:
|
case GST_WAVPARSE_HEADER:
|
||||||
|
GST_DEBUG_OBJECT (wav, "GST_WAVPARSE_HEADER");
|
||||||
if ((ret = gst_wavparse_stream_headers (wav)) != GST_FLOW_OK)
|
if ((ret = gst_wavparse_stream_headers (wav)) != GST_FLOW_OK)
|
||||||
goto pause;
|
goto pause;
|
||||||
|
|
||||||
wav->state = GST_WAVPARSE_DATA;
|
wav->state = GST_WAVPARSE_DATA;
|
||||||
if ((ret = gst_wavparse_stream_data (wav, TRUE)) != GST_FLOW_OK)
|
/* fall-through */
|
||||||
goto pause;
|
|
||||||
break;
|
|
||||||
case GST_WAVPARSE_DATA:
|
case GST_WAVPARSE_DATA:
|
||||||
if ((ret = gst_wavparse_stream_data (wav, FALSE)) != GST_FLOW_OK)
|
if ((ret = gst_wavparse_stream_data (wav)) != GST_FLOW_OK)
|
||||||
goto pause;
|
goto pause;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -1868,6 +1898,8 @@ plugin_init (GstPlugin * plugin)
|
||||||
{
|
{
|
||||||
gst_riff_init ();
|
gst_riff_init ();
|
||||||
|
|
||||||
|
GST_DEBUG_CATEGORY_INIT (wavparse_debug, "wavparse", 0, "WAV parser");
|
||||||
|
|
||||||
return gst_element_register (plugin, "wavparse", GST_RANK_PRIMARY,
|
return gst_element_register (plugin, "wavparse", GST_RANK_PRIMARY,
|
||||||
GST_TYPE_WAVPARSE);
|
GST_TYPE_WAVPARSE);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/* GStreamer
|
/* GStreamer
|
||||||
* Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
|
* Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
|
||||||
* Copyright (C) <2006> Nokia Corporation.
|
* Copyright (C) <2006> Nokia Corporation, Stefan Kost <stefan.kost@nokia.com>.
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Library General Public
|
* modify it under the terms of the GNU Library General Public
|
||||||
|
@ -103,6 +103,9 @@ struct _GstWavParse {
|
||||||
/* configured segment, start/stop expressed in time */
|
/* configured segment, start/stop expressed in time */
|
||||||
GstSegment segment;
|
GstSegment segment;
|
||||||
gboolean segment_running;
|
gboolean segment_running;
|
||||||
|
|
||||||
|
/* for late pad configuration */
|
||||||
|
gboolean first;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _GstWavParseClass {
|
struct _GstWavParseClass {
|
||||||
|
|
Loading…
Reference in a new issue