2004-06-08 11:53:13 +00:00
|
|
|
/* GStreamer
|
|
|
|
* Copyright (C) <2004> Thomas Vander Stichele <thomas at apestaart dot org>
|
2006-04-03 08:28:58 +00:00
|
|
|
* Copyright (C) 2006 Andy Wingo <wingo@pobox.com>
|
2004-06-08 11:53:13 +00:00
|
|
|
*
|
|
|
|
* 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., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
2006-03-01 17:39:28 +00:00
|
|
|
/**
|
|
|
|
* SECTION:element-vorbisparse
|
2006-04-03 08:28:58 +00:00
|
|
|
* @see_also: vorbisdec, oggdemux, theoraparse
|
2006-03-01 17:39:28 +00:00
|
|
|
*
|
|
|
|
* The vorbisparse element will parse the header packets of the Vorbis
|
|
|
|
* stream and put them as the streamheader in the caps. This is used in the
|
|
|
|
* multifdsink case where you want to stream live vorbis streams to multiple
|
|
|
|
* clients, each client has to receive the streamheaders first before they can
|
|
|
|
* consume the vorbis packets.
|
2008-07-10 21:06:06 +00:00
|
|
|
*
|
2006-04-03 08:28:58 +00:00
|
|
|
* This element also makes sure that the buffers that it pushes out are properly
|
|
|
|
* timestamped and that their offset and offset_end are set. The buffers that
|
|
|
|
* vorbisparse outputs have all of the metadata that oggmux expects to receive,
|
|
|
|
* which allows you to (for example) remux an ogg/vorbis file.
|
2008-07-10 21:06:06 +00:00
|
|
|
*
|
|
|
|
* <refsect2>
|
2006-03-01 17:39:28 +00:00
|
|
|
* <title>Example pipelines</title>
|
2008-07-10 21:06:06 +00:00
|
|
|
* |[
|
2006-03-01 17:39:28 +00:00
|
|
|
* gst-launch -v filesrc location=sine.ogg ! oggdemux ! vorbisparse ! fakesink
|
2008-07-10 21:06:06 +00:00
|
|
|
* ]| This pipeline shows that the streamheader is set in the caps, and that each
|
2006-04-03 08:28:58 +00:00
|
|
|
* buffer has the timestamp, duration, offset, and offset_end set.
|
2008-07-10 21:06:06 +00:00
|
|
|
* |[
|
2006-04-03 08:28:58 +00:00
|
|
|
* gst-launch filesrc location=sine.ogg ! oggdemux ! vorbisparse \
|
|
|
|
* ! oggmux ! filesink location=sine-remuxed.ogg
|
2008-07-10 21:06:06 +00:00
|
|
|
* ]| This pipeline shows remuxing. sine-remuxed.ogg might not be exactly the same
|
2006-04-03 08:28:58 +00:00
|
|
|
* as sine.ogg, but they should produce exactly the same decoded data.
|
2006-03-01 17:39:28 +00:00
|
|
|
* </refsect2>
|
|
|
|
*
|
2006-04-03 08:28:58 +00:00
|
|
|
* Last reviewed on 2006-04-01 (0.10.4.1)
|
2006-03-01 17:39:28 +00:00
|
|
|
*/
|
|
|
|
|
2004-06-08 11:53:13 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
|
|
|
|
2009-02-24 13:36:39 +00:00
|
|
|
#include "gstvorbisparse.h"
|
2004-06-08 11:53:13 +00:00
|
|
|
|
|
|
|
GST_DEBUG_CATEGORY_EXTERN (vorbisparse_debug);
|
|
|
|
#define GST_CAT_DEFAULT vorbisparse_debug
|
|
|
|
|
|
|
|
static GstStaticPadTemplate vorbis_parse_sink_factory =
|
|
|
|
GST_STATIC_PAD_TEMPLATE ("sink",
|
|
|
|
GST_PAD_SINK,
|
|
|
|
GST_PAD_ALWAYS,
|
|
|
|
GST_STATIC_CAPS ("audio/x-vorbis")
|
|
|
|
);
|
|
|
|
|
|
|
|
static GstStaticPadTemplate vorbis_parse_src_factory =
|
|
|
|
GST_STATIC_PAD_TEMPLATE ("src",
|
|
|
|
GST_PAD_SRC,
|
|
|
|
GST_PAD_ALWAYS,
|
|
|
|
GST_STATIC_CAPS ("audio/x-vorbis")
|
|
|
|
);
|
|
|
|
|
2011-04-19 12:11:32 +00:00
|
|
|
#define gst_vorbis_parse_parent_class parent_class
|
|
|
|
G_DEFINE_TYPE (GstVorbisParse, gst_vorbis_parse, GST_TYPE_ELEMENT);
|
2004-06-08 11:53:13 +00:00
|
|
|
|
2011-11-17 11:48:25 +00:00
|
|
|
static GstFlowReturn vorbis_parse_chain (GstPad * pad, GstObject * parent,
|
|
|
|
GstBuffer * buffer);
|
2005-09-02 15:43:18 +00:00
|
|
|
static GstStateChangeReturn vorbis_parse_change_state (GstElement * element,
|
|
|
|
GstStateChange transition);
|
2011-11-17 11:48:25 +00:00
|
|
|
static gboolean vorbis_parse_sink_event (GstPad * pad, GstObject * parent,
|
|
|
|
GstEvent * event);
|
2011-11-16 16:25:17 +00:00
|
|
|
static gboolean vorbis_parse_src_query (GstPad * pad, GstObject * parent,
|
|
|
|
GstQuery * query);
|
|
|
|
static gboolean vorbis_parse_convert (GstPad * pad, GstFormat src_format,
|
|
|
|
gint64 src_value, GstFormat * dest_format, gint64 * dest_value);
|
ext/vorbis/: Add new vorbistag element which derives from vorbisparse and is essentially the same as well, only that ...
Original commit message from CVS:
Patch by: James "Doc" Livingston <doclivingston at gmail com>
* ext/vorbis/Makefile.am:
* ext/vorbis/vorbis.c: (plugin_init):
* ext/vorbis/vorbisparse.c: (gst_vorbis_parse_class_init),
(vorbis_parse_parse_packet), (vorbis_parse_chain):
* ext/vorbis/vorbisparse.h:
* ext/vorbis/vorbistag.c: (gst_vorbis_tag_base_init),
(gst_vorbis_tag_class_init), (gst_vorbis_tag_init),
(gst_vorbis_tag_parse_packet):
* ext/vorbis/vorbistag.h:
Add new vorbistag element which derives from vorbisparse
and is essentially the same as well, only that it implements
the GstTagSetter interface and can modify the stream's
vorbiscomment on the fly (#335635).
* tests/check/Makefile.am:
* tests/check/elements/.cvsignore:
* tests/check/elements/vorbistag.c: (setup_vorbistag),
(cleanup_vorbistag), (buffer_probe), (start_pipeline),
(get_buffer), (stop_pipeline), (_create_codebook_header_buffer),
(_create_audio_buffer), (GST_START_TEST), (vorbistag_suite):
Add unit test for new vorbistag element.
2006-10-03 11:51:48 +00:00
|
|
|
static GstFlowReturn vorbis_parse_parse_packet (GstVorbisParse * parse,
|
|
|
|
GstBuffer * buf);
|
2004-06-08 11:53:13 +00:00
|
|
|
|
|
|
|
static void
|
2011-04-19 12:11:32 +00:00
|
|
|
gst_vorbis_parse_class_init (GstVorbisParseClass * klass)
|
2004-06-08 11:53:13 +00:00
|
|
|
{
|
2011-04-19 12:11:32 +00:00
|
|
|
GstElementClass *gstelement_class = GST_ELEMENT_CLASS (klass);
|
|
|
|
|
|
|
|
gstelement_class->change_state = vorbis_parse_change_state;
|
2004-06-08 11:53:13 +00:00
|
|
|
|
2011-04-19 12:11:32 +00:00
|
|
|
gst_element_class_add_pad_template (gstelement_class,
|
2004-06-08 11:53:13 +00:00
|
|
|
gst_static_pad_template_get (&vorbis_parse_src_factory));
|
2011-04-19 12:11:32 +00:00
|
|
|
gst_element_class_add_pad_template (gstelement_class,
|
2004-06-08 11:53:13 +00:00
|
|
|
gst_static_pad_template_get (&vorbis_parse_sink_factory));
|
2011-04-19 12:11:32 +00:00
|
|
|
gst_element_class_set_details_simple (gstelement_class,
|
2010-03-16 14:45:23 +00:00
|
|
|
"VorbisParse", "Codec/Parser/Audio",
|
|
|
|
"parse raw vorbis streams",
|
|
|
|
"Thomas Vander Stichele <thomas at apestaart dot org>");
|
ext/vorbis/: Add new vorbistag element which derives from vorbisparse and is essentially the same as well, only that ...
Original commit message from CVS:
Patch by: James "Doc" Livingston <doclivingston at gmail com>
* ext/vorbis/Makefile.am:
* ext/vorbis/vorbis.c: (plugin_init):
* ext/vorbis/vorbisparse.c: (gst_vorbis_parse_class_init),
(vorbis_parse_parse_packet), (vorbis_parse_chain):
* ext/vorbis/vorbisparse.h:
* ext/vorbis/vorbistag.c: (gst_vorbis_tag_base_init),
(gst_vorbis_tag_class_init), (gst_vorbis_tag_init),
(gst_vorbis_tag_parse_packet):
* ext/vorbis/vorbistag.h:
Add new vorbistag element which derives from vorbisparse
and is essentially the same as well, only that it implements
the GstTagSetter interface and can modify the stream's
vorbiscomment on the fly (#335635).
* tests/check/Makefile.am:
* tests/check/elements/.cvsignore:
* tests/check/elements/vorbistag.c: (setup_vorbistag),
(cleanup_vorbistag), (buffer_probe), (start_pipeline),
(get_buffer), (stop_pipeline), (_create_codebook_header_buffer),
(_create_audio_buffer), (GST_START_TEST), (vorbistag_suite):
Add unit test for new vorbistag element.
2006-10-03 11:51:48 +00:00
|
|
|
|
|
|
|
klass->parse_packet = GST_DEBUG_FUNCPTR (vorbis_parse_parse_packet);
|
2004-06-08 11:53:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2011-04-19 12:11:32 +00:00
|
|
|
gst_vorbis_parse_init (GstVorbisParse * parse)
|
2004-06-08 11:53:13 +00:00
|
|
|
{
|
|
|
|
parse->sinkpad =
|
2005-11-16 18:21:46 +00:00
|
|
|
gst_pad_new_from_static_template (&vorbis_parse_sink_factory, "sink");
|
2006-10-03 10:36:38 +00:00
|
|
|
gst_pad_set_chain_function (parse->sinkpad,
|
|
|
|
GST_DEBUG_FUNCPTR (vorbis_parse_chain));
|
|
|
|
gst_pad_set_event_function (parse->sinkpad,
|
|
|
|
GST_DEBUG_FUNCPTR (vorbis_parse_sink_event));
|
2004-06-08 11:53:13 +00:00
|
|
|
gst_element_add_pad (GST_ELEMENT (parse), parse->sinkpad);
|
|
|
|
|
|
|
|
parse->srcpad =
|
2005-11-16 18:21:46 +00:00
|
|
|
gst_pad_new_from_static_template (&vorbis_parse_src_factory, "src");
|
2006-10-03 10:36:38 +00:00
|
|
|
gst_pad_set_query_function (parse->srcpad,
|
|
|
|
GST_DEBUG_FUNCPTR (vorbis_parse_src_query));
|
2004-06-08 11:53:13 +00:00
|
|
|
gst_element_add_pad (GST_ELEMENT (parse), parse->srcpad);
|
|
|
|
}
|
2005-11-16 18:21:46 +00:00
|
|
|
|
2004-06-08 11:53:13 +00:00
|
|
|
static void
|
|
|
|
vorbis_parse_set_header_on_caps (GstVorbisParse * parse, GstCaps * caps)
|
|
|
|
{
|
|
|
|
GstBuffer *buf1, *buf2, *buf3;
|
2004-09-02 02:48:46 +00:00
|
|
|
GstStructure *structure;
|
2005-11-21 12:36:22 +00:00
|
|
|
GValue array = { 0 };
|
2004-09-02 02:48:46 +00:00
|
|
|
GValue value = { 0 };
|
2004-06-08 11:53:13 +00:00
|
|
|
|
|
|
|
g_assert (parse);
|
|
|
|
g_assert (parse->streamheader);
|
|
|
|
g_assert (parse->streamheader->next);
|
|
|
|
g_assert (parse->streamheader->next->next);
|
|
|
|
buf1 = parse->streamheader->data;
|
|
|
|
g_assert (buf1);
|
|
|
|
buf2 = parse->streamheader->next->data;
|
|
|
|
g_assert (buf2);
|
|
|
|
buf3 = parse->streamheader->next->next->data;
|
|
|
|
g_assert (buf3);
|
|
|
|
|
2004-09-02 02:48:46 +00:00
|
|
|
structure = gst_caps_get_structure (caps, 0);
|
2004-06-08 11:53:13 +00:00
|
|
|
|
|
|
|
/* mark buffers */
|
2012-01-30 16:16:17 +00:00
|
|
|
GST_BUFFER_FLAG_SET (buf1, GST_BUFFER_FLAG_HEADER);
|
|
|
|
GST_BUFFER_FLAG_SET (buf2, GST_BUFFER_FLAG_HEADER);
|
|
|
|
GST_BUFFER_FLAG_SET (buf3, GST_BUFFER_FLAG_HEADER);
|
2004-06-08 11:53:13 +00:00
|
|
|
|
|
|
|
/* put buffers in a fixed list */
|
2005-11-21 12:36:22 +00:00
|
|
|
g_value_init (&array, GST_TYPE_ARRAY);
|
2004-06-08 11:53:13 +00:00
|
|
|
g_value_init (&value, GST_TYPE_BUFFER);
|
2006-03-01 17:39:28 +00:00
|
|
|
gst_value_set_buffer (&value, buf1);
|
2005-11-21 12:36:22 +00:00
|
|
|
gst_value_array_append_value (&array, &value);
|
2004-06-08 11:53:13 +00:00
|
|
|
g_value_unset (&value);
|
|
|
|
g_value_init (&value, GST_TYPE_BUFFER);
|
2006-03-01 17:39:28 +00:00
|
|
|
gst_value_set_buffer (&value, buf2);
|
2005-11-21 12:36:22 +00:00
|
|
|
gst_value_array_append_value (&array, &value);
|
2004-06-08 11:53:13 +00:00
|
|
|
g_value_unset (&value);
|
|
|
|
g_value_init (&value, GST_TYPE_BUFFER);
|
2006-03-01 17:39:28 +00:00
|
|
|
gst_value_set_buffer (&value, buf3);
|
2005-11-21 12:36:22 +00:00
|
|
|
gst_value_array_append_value (&array, &value);
|
|
|
|
gst_structure_set_value (structure, "streamheader", &array);
|
2004-06-08 11:53:13 +00:00
|
|
|
g_value_unset (&value);
|
2005-11-21 12:36:22 +00:00
|
|
|
g_value_unset (&array);
|
2004-06-08 11:53:13 +00:00
|
|
|
}
|
|
|
|
|
2006-07-14 16:45:17 +00:00
|
|
|
static void
|
|
|
|
vorbis_parse_drain_event_queue (GstVorbisParse * parse)
|
|
|
|
{
|
|
|
|
while (parse->event_queue->length) {
|
|
|
|
GstEvent *event;
|
|
|
|
|
|
|
|
event = GST_EVENT_CAST (g_queue_pop_head (parse->event_queue));
|
2011-11-17 11:48:25 +00:00
|
|
|
gst_pad_event_default (parse->sinkpad, GST_OBJECT_CAST (parse), event);
|
2006-07-14 16:45:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-03-31 16:43:43 +00:00
|
|
|
static void
|
|
|
|
vorbis_parse_push_headers (GstVorbisParse * parse)
|
|
|
|
{
|
|
|
|
/* mark and put on caps */
|
|
|
|
GstCaps *caps;
|
2006-07-14 16:45:17 +00:00
|
|
|
GstBuffer *outbuf, *outbuf1, *outbuf2, *outbuf3;
|
2006-03-31 16:43:43 +00:00
|
|
|
ogg_packet packet;
|
2012-01-20 15:11:54 +00:00
|
|
|
GstMapInfo map;
|
2006-03-31 16:43:43 +00:00
|
|
|
|
|
|
|
outbuf = GST_BUFFER_CAST (parse->streamheader->data);
|
2012-01-20 15:11:54 +00:00
|
|
|
gst_buffer_map (outbuf, &map, GST_MAP_READ);
|
|
|
|
packet.packet = map.data;
|
|
|
|
packet.bytes = map.size;
|
2006-03-31 16:43:43 +00:00
|
|
|
packet.granulepos = GST_BUFFER_OFFSET_END (outbuf);
|
|
|
|
packet.packetno = 1;
|
|
|
|
packet.e_o_s = 0;
|
2006-10-03 10:36:38 +00:00
|
|
|
packet.b_o_s = 1;
|
2006-03-31 16:43:43 +00:00
|
|
|
vorbis_synthesis_headerin (&parse->vi, &parse->vc, &packet);
|
2012-01-20 15:11:54 +00:00
|
|
|
gst_buffer_unmap (outbuf, &map);
|
2006-03-31 16:43:43 +00:00
|
|
|
parse->sample_rate = parse->vi.rate;
|
2012-01-27 11:08:33 +00:00
|
|
|
parse->channels = parse->vi.channels;
|
2006-07-14 16:45:17 +00:00
|
|
|
outbuf1 = outbuf;
|
2006-03-31 16:43:43 +00:00
|
|
|
|
|
|
|
outbuf = GST_BUFFER_CAST (parse->streamheader->next->data);
|
2012-01-20 15:11:54 +00:00
|
|
|
gst_buffer_map (outbuf, &map, GST_MAP_READ);
|
|
|
|
packet.packet = map.data;
|
|
|
|
packet.bytes = map.size;
|
2006-03-31 16:43:43 +00:00
|
|
|
packet.granulepos = GST_BUFFER_OFFSET_END (outbuf);
|
|
|
|
packet.packetno = 2;
|
|
|
|
packet.e_o_s = 0;
|
2006-10-03 10:36:38 +00:00
|
|
|
packet.b_o_s = 0;
|
2006-03-31 16:43:43 +00:00
|
|
|
vorbis_synthesis_headerin (&parse->vi, &parse->vc, &packet);
|
2012-01-20 15:11:54 +00:00
|
|
|
gst_buffer_unmap (outbuf, &map);
|
2006-07-14 16:45:17 +00:00
|
|
|
outbuf2 = outbuf;
|
2006-03-31 16:43:43 +00:00
|
|
|
|
|
|
|
outbuf = GST_BUFFER_CAST (parse->streamheader->next->next->data);
|
2012-01-20 15:11:54 +00:00
|
|
|
gst_buffer_map (outbuf, &map, GST_MAP_READ);
|
|
|
|
packet.packet = map.data;
|
2012-01-27 11:08:33 +00:00
|
|
|
packet.bytes = map.size;
|
2006-03-31 16:43:43 +00:00
|
|
|
packet.granulepos = GST_BUFFER_OFFSET_END (outbuf);
|
|
|
|
packet.packetno = 3;
|
|
|
|
packet.e_o_s = 0;
|
2006-10-03 10:36:38 +00:00
|
|
|
packet.b_o_s = 0;
|
2006-03-31 16:43:43 +00:00
|
|
|
vorbis_synthesis_headerin (&parse->vi, &parse->vc, &packet);
|
2012-01-20 15:11:54 +00:00
|
|
|
gst_buffer_unmap (outbuf, &map);
|
2006-07-14 16:45:17 +00:00
|
|
|
outbuf3 = outbuf;
|
2006-03-31 16:43:43 +00:00
|
|
|
|
2012-01-27 11:08:33 +00:00
|
|
|
/* get the headers into the caps, passing them to vorbis as we go */
|
|
|
|
caps = gst_caps_new_simple ("audio/x-vorbis",
|
|
|
|
"rate", G_TYPE_INT, parse->sample_rate,
|
|
|
|
"channels", G_TYPE_INT, parse->channels, NULL);;
|
|
|
|
vorbis_parse_set_header_on_caps (parse, caps);
|
|
|
|
GST_DEBUG_OBJECT (parse, "here are the caps: %" GST_PTR_FORMAT, caps);
|
|
|
|
gst_pad_set_caps (parse->srcpad, caps);
|
|
|
|
gst_caps_unref (caps);
|
|
|
|
|
2006-07-14 16:45:17 +00:00
|
|
|
/* first process queued events */
|
|
|
|
vorbis_parse_drain_event_queue (parse);
|
|
|
|
|
|
|
|
/* push out buffers, ignoring return value... */
|
|
|
|
gst_pad_push (parse->srcpad, outbuf1);
|
|
|
|
gst_pad_push (parse->srcpad, outbuf2);
|
|
|
|
gst_pad_push (parse->srcpad, outbuf3);
|
2006-03-31 16:43:43 +00:00
|
|
|
|
|
|
|
g_list_free (parse->streamheader);
|
|
|
|
parse->streamheader = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
vorbis_parse_clear_queue (GstVorbisParse * parse)
|
|
|
|
{
|
|
|
|
while (parse->buffer_queue->length) {
|
|
|
|
GstBuffer *buf;
|
|
|
|
|
|
|
|
buf = GST_BUFFER_CAST (g_queue_pop_head (parse->buffer_queue));
|
|
|
|
gst_buffer_unref (buf);
|
|
|
|
}
|
2006-07-14 16:45:17 +00:00
|
|
|
while (parse->event_queue->length) {
|
|
|
|
GstEvent *event;
|
|
|
|
|
|
|
|
event = GST_EVENT_CAST (g_queue_pop_head (parse->event_queue));
|
|
|
|
gst_event_unref (event);
|
|
|
|
}
|
2006-03-31 16:43:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static GstFlowReturn
|
|
|
|
vorbis_parse_push_buffer (GstVorbisParse * parse, GstBuffer * buf,
|
|
|
|
gint64 granulepos)
|
|
|
|
{
|
|
|
|
guint64 samples;
|
|
|
|
|
|
|
|
/* our hack as noted below */
|
|
|
|
samples = GST_BUFFER_OFFSET (buf);
|
|
|
|
|
|
|
|
GST_BUFFER_OFFSET_END (buf) = granulepos;
|
|
|
|
GST_BUFFER_DURATION (buf) = samples * GST_SECOND / parse->sample_rate;
|
|
|
|
GST_BUFFER_OFFSET (buf) = granulepos * GST_SECOND / parse->sample_rate;
|
|
|
|
GST_BUFFER_TIMESTAMP (buf) =
|
|
|
|
GST_BUFFER_OFFSET (buf) - GST_BUFFER_DURATION (buf);
|
|
|
|
|
|
|
|
return gst_pad_push (parse->srcpad, buf);
|
|
|
|
}
|
|
|
|
|
|
|
|
static GstFlowReturn
|
|
|
|
vorbis_parse_drain_queue_prematurely (GstVorbisParse * parse)
|
|
|
|
{
|
|
|
|
GstFlowReturn ret = GST_FLOW_OK;
|
|
|
|
gint64 granulepos = MAX (parse->prev_granulepos, 0);
|
|
|
|
|
|
|
|
/* got an EOS event, make sure to push out any buffers that were in the queue
|
|
|
|
* -- won't normally be the case, but this catches the
|
|
|
|
* didn't-get-a-granulepos-on-the-last-packet case. Assuming a continuous
|
|
|
|
* stream. */
|
|
|
|
|
2006-07-14 16:45:17 +00:00
|
|
|
/* if we got EOS before any buffers came, go ahead and push the other events
|
|
|
|
* first */
|
|
|
|
vorbis_parse_drain_event_queue (parse);
|
|
|
|
|
2006-03-31 16:43:43 +00:00
|
|
|
while (!g_queue_is_empty (parse->buffer_queue)) {
|
|
|
|
GstBuffer *buf;
|
|
|
|
|
|
|
|
buf = GST_BUFFER_CAST (g_queue_pop_head (parse->buffer_queue));
|
|
|
|
|
|
|
|
granulepos += GST_BUFFER_OFFSET (buf);
|
|
|
|
ret = vorbis_parse_push_buffer (parse, buf, granulepos);
|
|
|
|
|
|
|
|
if (ret != GST_FLOW_OK)
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
parse->prev_granulepos = granulepos;
|
|
|
|
|
|
|
|
done:
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static GstFlowReturn
|
|
|
|
vorbis_parse_drain_queue (GstVorbisParse * parse, gint64 granulepos)
|
|
|
|
{
|
2006-03-31 16:57:47 +00:00
|
|
|
GstFlowReturn ret = GST_FLOW_OK;
|
2006-03-31 16:43:43 +00:00
|
|
|
GList *walk;
|
|
|
|
gint64 cur = granulepos;
|
|
|
|
gint64 gp;
|
|
|
|
|
|
|
|
for (walk = parse->buffer_queue->head; walk; walk = walk->next)
|
|
|
|
cur -= GST_BUFFER_OFFSET (walk->data);
|
|
|
|
|
|
|
|
if (parse->prev_granulepos != -1)
|
|
|
|
cur = MAX (cur, parse->prev_granulepos);
|
|
|
|
|
|
|
|
while (!g_queue_is_empty (parse->buffer_queue)) {
|
|
|
|
GstBuffer *buf;
|
|
|
|
|
|
|
|
buf = GST_BUFFER_CAST (g_queue_pop_head (parse->buffer_queue));
|
|
|
|
|
|
|
|
cur += GST_BUFFER_OFFSET (buf);
|
|
|
|
gp = CLAMP (cur, 0, granulepos);
|
|
|
|
|
|
|
|
ret = vorbis_parse_push_buffer (parse, buf, gp);
|
|
|
|
|
|
|
|
if (ret != GST_FLOW_OK)
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
parse->prev_granulepos = granulepos;
|
|
|
|
|
|
|
|
done:
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static GstFlowReturn
|
|
|
|
vorbis_parse_queue_buffer (GstVorbisParse * parse, GstBuffer * buf)
|
|
|
|
{
|
|
|
|
GstFlowReturn ret = GST_FLOW_OK;
|
|
|
|
long blocksize;
|
|
|
|
ogg_packet packet;
|
2012-01-20 15:11:54 +00:00
|
|
|
GstMapInfo map;
|
2006-03-31 16:43:43 +00:00
|
|
|
|
2011-03-28 08:20:06 +00:00
|
|
|
buf = gst_buffer_make_writable (buf);
|
2006-03-31 16:43:43 +00:00
|
|
|
|
2012-01-20 15:11:54 +00:00
|
|
|
gst_buffer_map (buf, &map, GST_MAP_READ);
|
|
|
|
packet.packet = map.data;
|
|
|
|
packet.bytes = map.size;
|
2012-02-26 19:36:46 +00:00
|
|
|
GST_DEBUG ("%p, %" G_GSIZE_FORMAT, map.data, map.size);
|
2006-03-31 16:43:43 +00:00
|
|
|
packet.granulepos = GST_BUFFER_OFFSET_END (buf);
|
|
|
|
packet.packetno = parse->packetno + parse->buffer_queue->length;
|
|
|
|
packet.e_o_s = 0;
|
|
|
|
|
|
|
|
blocksize = vorbis_packet_blocksize (&parse->vi, &packet);
|
2012-01-20 15:11:54 +00:00
|
|
|
gst_buffer_unmap (buf, &map);
|
2006-03-31 16:43:43 +00:00
|
|
|
|
|
|
|
/* temporarily store the sample count in OFFSET -- we overwrite this later */
|
|
|
|
|
|
|
|
if (parse->prev_blocksize < 0)
|
|
|
|
GST_BUFFER_OFFSET (buf) = 0;
|
|
|
|
else
|
|
|
|
GST_BUFFER_OFFSET (buf) = (blocksize + parse->prev_blocksize) / 4;
|
|
|
|
|
|
|
|
parse->prev_blocksize = blocksize;
|
|
|
|
|
|
|
|
g_queue_push_tail (parse->buffer_queue, buf);
|
|
|
|
|
|
|
|
if (GST_BUFFER_OFFSET_END_IS_VALID (buf))
|
|
|
|
ret = vorbis_parse_drain_queue (parse, GST_BUFFER_OFFSET_END (buf));
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2005-03-31 09:43:49 +00:00
|
|
|
static GstFlowReturn
|
ext/vorbis/: Add new vorbistag element which derives from vorbisparse and is essentially the same as well, only that ...
Original commit message from CVS:
Patch by: James "Doc" Livingston <doclivingston at gmail com>
* ext/vorbis/Makefile.am:
* ext/vorbis/vorbis.c: (plugin_init):
* ext/vorbis/vorbisparse.c: (gst_vorbis_parse_class_init),
(vorbis_parse_parse_packet), (vorbis_parse_chain):
* ext/vorbis/vorbisparse.h:
* ext/vorbis/vorbistag.c: (gst_vorbis_tag_base_init),
(gst_vorbis_tag_class_init), (gst_vorbis_tag_init),
(gst_vorbis_tag_parse_packet):
* ext/vorbis/vorbistag.h:
Add new vorbistag element which derives from vorbisparse
and is essentially the same as well, only that it implements
the GstTagSetter interface and can modify the stream's
vorbiscomment on the fly (#335635).
* tests/check/Makefile.am:
* tests/check/elements/.cvsignore:
* tests/check/elements/vorbistag.c: (setup_vorbistag),
(cleanup_vorbistag), (buffer_probe), (start_pipeline),
(get_buffer), (stop_pipeline), (_create_codebook_header_buffer),
(_create_audio_buffer), (GST_START_TEST), (vorbistag_suite):
Add unit test for new vorbistag element.
2006-10-03 11:51:48 +00:00
|
|
|
vorbis_parse_parse_packet (GstVorbisParse * parse, GstBuffer * buf)
|
2004-06-08 11:53:13 +00:00
|
|
|
{
|
2006-03-01 17:39:28 +00:00
|
|
|
GstFlowReturn ret;
|
2012-01-20 15:11:54 +00:00
|
|
|
GstMapInfo map;
|
2009-03-13 14:29:29 +00:00
|
|
|
gboolean have_header;
|
|
|
|
|
2004-06-08 11:53:13 +00:00
|
|
|
parse->packetno++;
|
|
|
|
|
2009-03-13 14:29:29 +00:00
|
|
|
have_header = FALSE;
|
2012-01-20 15:11:54 +00:00
|
|
|
gst_buffer_map (buf, &map, GST_MAP_READ);
|
|
|
|
if (map.size >= 1) {
|
2012-02-10 14:41:06 +00:00
|
|
|
if (map.data[0] & 1)
|
2009-03-13 14:29:29 +00:00
|
|
|
have_header = TRUE;
|
|
|
|
}
|
2012-01-20 15:11:54 +00:00
|
|
|
gst_buffer_unmap (buf, &map);
|
2009-03-13 14:29:29 +00:00
|
|
|
|
|
|
|
if (have_header) {
|
|
|
|
if (!parse->streamheader_sent) {
|
|
|
|
/* we need to collect the headers still */
|
|
|
|
/* so put it on the streamheader list and return */
|
|
|
|
parse->streamheader = g_list_append (parse->streamheader, buf);
|
|
|
|
}
|
2006-03-31 16:43:43 +00:00
|
|
|
ret = GST_FLOW_OK;
|
|
|
|
} else {
|
2009-03-13 14:29:29 +00:00
|
|
|
/* data packet, push the headers we collected before */
|
|
|
|
if (!parse->streamheader_sent) {
|
2006-03-31 16:43:43 +00:00
|
|
|
vorbis_parse_push_headers (parse);
|
2009-03-13 14:29:29 +00:00
|
|
|
parse->streamheader_sent = TRUE;
|
|
|
|
}
|
2006-03-31 16:43:43 +00:00
|
|
|
ret = vorbis_parse_queue_buffer (parse, buf);
|
2004-06-08 11:53:13 +00:00
|
|
|
}
|
|
|
|
|
2006-03-31 16:43:43 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
ext/vorbis/: Add new vorbistag element which derives from vorbisparse and is essentially the same as well, only that ...
Original commit message from CVS:
Patch by: James "Doc" Livingston <doclivingston at gmail com>
* ext/vorbis/Makefile.am:
* ext/vorbis/vorbis.c: (plugin_init):
* ext/vorbis/vorbisparse.c: (gst_vorbis_parse_class_init),
(vorbis_parse_parse_packet), (vorbis_parse_chain):
* ext/vorbis/vorbisparse.h:
* ext/vorbis/vorbistag.c: (gst_vorbis_tag_base_init),
(gst_vorbis_tag_class_init), (gst_vorbis_tag_init),
(gst_vorbis_tag_parse_packet):
* ext/vorbis/vorbistag.h:
Add new vorbistag element which derives from vorbisparse
and is essentially the same as well, only that it implements
the GstTagSetter interface and can modify the stream's
vorbiscomment on the fly (#335635).
* tests/check/Makefile.am:
* tests/check/elements/.cvsignore:
* tests/check/elements/vorbistag.c: (setup_vorbistag),
(cleanup_vorbistag), (buffer_probe), (start_pipeline),
(get_buffer), (stop_pipeline), (_create_codebook_header_buffer),
(_create_audio_buffer), (GST_START_TEST), (vorbistag_suite):
Add unit test for new vorbistag element.
2006-10-03 11:51:48 +00:00
|
|
|
static GstFlowReturn
|
2011-11-17 11:48:25 +00:00
|
|
|
vorbis_parse_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
|
ext/vorbis/: Add new vorbistag element which derives from vorbisparse and is essentially the same as well, only that ...
Original commit message from CVS:
Patch by: James "Doc" Livingston <doclivingston at gmail com>
* ext/vorbis/Makefile.am:
* ext/vorbis/vorbis.c: (plugin_init):
* ext/vorbis/vorbisparse.c: (gst_vorbis_parse_class_init),
(vorbis_parse_parse_packet), (vorbis_parse_chain):
* ext/vorbis/vorbisparse.h:
* ext/vorbis/vorbistag.c: (gst_vorbis_tag_base_init),
(gst_vorbis_tag_class_init), (gst_vorbis_tag_init),
(gst_vorbis_tag_parse_packet):
* ext/vorbis/vorbistag.h:
Add new vorbistag element which derives from vorbisparse
and is essentially the same as well, only that it implements
the GstTagSetter interface and can modify the stream's
vorbiscomment on the fly (#335635).
* tests/check/Makefile.am:
* tests/check/elements/.cvsignore:
* tests/check/elements/vorbistag.c: (setup_vorbistag),
(cleanup_vorbistag), (buffer_probe), (start_pipeline),
(get_buffer), (stop_pipeline), (_create_codebook_header_buffer),
(_create_audio_buffer), (GST_START_TEST), (vorbistag_suite):
Add unit test for new vorbistag element.
2006-10-03 11:51:48 +00:00
|
|
|
{
|
|
|
|
GstVorbisParseClass *klass;
|
|
|
|
GstVorbisParse *parse;
|
|
|
|
|
2011-11-17 11:48:25 +00:00
|
|
|
parse = GST_VORBIS_PARSE (parent);
|
ext/vorbis/: Add new vorbistag element which derives from vorbisparse and is essentially the same as well, only that ...
Original commit message from CVS:
Patch by: James "Doc" Livingston <doclivingston at gmail com>
* ext/vorbis/Makefile.am:
* ext/vorbis/vorbis.c: (plugin_init):
* ext/vorbis/vorbisparse.c: (gst_vorbis_parse_class_init),
(vorbis_parse_parse_packet), (vorbis_parse_chain):
* ext/vorbis/vorbisparse.h:
* ext/vorbis/vorbistag.c: (gst_vorbis_tag_base_init),
(gst_vorbis_tag_class_init), (gst_vorbis_tag_init),
(gst_vorbis_tag_parse_packet):
* ext/vorbis/vorbistag.h:
Add new vorbistag element which derives from vorbisparse
and is essentially the same as well, only that it implements
the GstTagSetter interface and can modify the stream's
vorbiscomment on the fly (#335635).
* tests/check/Makefile.am:
* tests/check/elements/.cvsignore:
* tests/check/elements/vorbistag.c: (setup_vorbistag),
(cleanup_vorbistag), (buffer_probe), (start_pipeline),
(get_buffer), (stop_pipeline), (_create_codebook_header_buffer),
(_create_audio_buffer), (GST_START_TEST), (vorbistag_suite):
Add unit test for new vorbistag element.
2006-10-03 11:51:48 +00:00
|
|
|
klass = GST_VORBIS_PARSE_CLASS (G_OBJECT_GET_CLASS (parse));
|
|
|
|
|
|
|
|
g_assert (klass->parse_packet != NULL);
|
|
|
|
|
|
|
|
return klass->parse_packet (parse, buffer);
|
|
|
|
}
|
|
|
|
|
2006-07-14 16:45:17 +00:00
|
|
|
static gboolean
|
|
|
|
vorbis_parse_queue_event (GstVorbisParse * parse, GstEvent * event)
|
|
|
|
{
|
|
|
|
GstFlowReturn ret = TRUE;
|
|
|
|
|
|
|
|
g_queue_push_tail (parse->event_queue, event);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2006-03-31 16:43:43 +00:00
|
|
|
static gboolean
|
2011-11-17 11:48:25 +00:00
|
|
|
vorbis_parse_sink_event (GstPad * pad, GstObject * parent, GstEvent * event)
|
2006-03-31 16:43:43 +00:00
|
|
|
{
|
|
|
|
gboolean ret;
|
|
|
|
GstVorbisParse *parse;
|
|
|
|
|
2011-11-17 11:48:25 +00:00
|
|
|
parse = GST_VORBIS_PARSE (parent);
|
2006-03-31 16:43:43 +00:00
|
|
|
|
|
|
|
switch (GST_EVENT_TYPE (event)) {
|
|
|
|
case GST_EVENT_FLUSH_START:
|
|
|
|
vorbis_parse_clear_queue (parse);
|
|
|
|
parse->prev_granulepos = -1;
|
|
|
|
parse->prev_blocksize = -1;
|
2011-11-17 11:48:25 +00:00
|
|
|
ret = gst_pad_event_default (pad, parent, event);
|
2006-03-31 16:43:43 +00:00
|
|
|
break;
|
|
|
|
case GST_EVENT_EOS:
|
|
|
|
vorbis_parse_drain_queue_prematurely (parse);
|
2011-11-17 11:48:25 +00:00
|
|
|
ret = gst_pad_event_default (pad, parent, event);
|
2006-03-31 16:43:43 +00:00
|
|
|
break;
|
|
|
|
default:
|
2006-07-14 16:45:17 +00:00
|
|
|
if (!parse->streamheader_sent && GST_EVENT_IS_SERIALIZED (event))
|
|
|
|
ret = vorbis_parse_queue_event (parse, event);
|
|
|
|
else
|
2011-11-17 11:48:25 +00:00
|
|
|
ret = gst_pad_event_default (pad, parent, event);
|
2006-03-31 16:43:43 +00:00
|
|
|
break;
|
2004-06-08 11:53:13 +00:00
|
|
|
}
|
2006-03-31 16:43:43 +00:00
|
|
|
|
2006-03-01 17:39:28 +00:00
|
|
|
return ret;
|
2004-06-08 11:53:13 +00:00
|
|
|
}
|
|
|
|
|
2006-05-05 16:34:15 +00:00
|
|
|
static gboolean
|
|
|
|
vorbis_parse_convert (GstPad * pad,
|
|
|
|
GstFormat src_format, gint64 src_value,
|
|
|
|
GstFormat * dest_format, gint64 * dest_value)
|
|
|
|
{
|
|
|
|
gboolean res = TRUE;
|
|
|
|
GstVorbisParse *parse;
|
|
|
|
guint64 scale = 1;
|
|
|
|
|
|
|
|
parse = GST_VORBIS_PARSE (GST_PAD_PARENT (pad));
|
|
|
|
|
|
|
|
/* fixme: assumes atomic access to lots of instance variables modified from
|
|
|
|
* the streaming thread, including 64-bit variables */
|
|
|
|
|
|
|
|
if (parse->packetno < 4)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (src_format == *dest_format) {
|
|
|
|
*dest_value = src_value;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (parse->sinkpad == pad &&
|
|
|
|
(src_format == GST_FORMAT_BYTES || *dest_format == GST_FORMAT_BYTES))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
switch (src_format) {
|
|
|
|
case GST_FORMAT_TIME:
|
|
|
|
switch (*dest_format) {
|
|
|
|
case GST_FORMAT_BYTES:
|
|
|
|
scale = sizeof (float) * parse->vi.channels;
|
|
|
|
case GST_FORMAT_DEFAULT:
|
|
|
|
*dest_value =
|
|
|
|
scale * gst_util_uint64_scale_int (src_value, parse->vi.rate,
|
|
|
|
GST_SECOND);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
res = FALSE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case GST_FORMAT_DEFAULT:
|
|
|
|
switch (*dest_format) {
|
|
|
|
case GST_FORMAT_BYTES:
|
|
|
|
*dest_value = src_value * sizeof (float) * parse->vi.channels;
|
|
|
|
break;
|
|
|
|
case GST_FORMAT_TIME:
|
|
|
|
*dest_value =
|
|
|
|
gst_util_uint64_scale_int (src_value, GST_SECOND, parse->vi.rate);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
res = FALSE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case GST_FORMAT_BYTES:
|
|
|
|
switch (*dest_format) {
|
|
|
|
case GST_FORMAT_DEFAULT:
|
|
|
|
*dest_value = src_value / (sizeof (float) * parse->vi.channels);
|
|
|
|
break;
|
|
|
|
case GST_FORMAT_TIME:
|
|
|
|
*dest_value = gst_util_uint64_scale_int (src_value, GST_SECOND,
|
|
|
|
parse->vi.rate * sizeof (float) * parse->vi.channels);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
res = FALSE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
res = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2011-11-16 16:25:17 +00:00
|
|
|
vorbis_parse_src_query (GstPad * pad, GstObject * parent, GstQuery * query)
|
2006-05-05 16:34:15 +00:00
|
|
|
{
|
|
|
|
gint64 granulepos;
|
|
|
|
GstVorbisParse *parse;
|
|
|
|
gboolean res = FALSE;
|
|
|
|
|
2011-11-16 16:25:17 +00:00
|
|
|
parse = GST_VORBIS_PARSE (parent);
|
2006-05-05 16:34:15 +00:00
|
|
|
|
2011-05-17 09:25:31 +00:00
|
|
|
switch (GST_QUERY_TYPE (query)) {
|
2006-05-05 16:34:15 +00:00
|
|
|
case GST_QUERY_POSITION:
|
|
|
|
{
|
|
|
|
GstFormat format;
|
|
|
|
gint64 value;
|
|
|
|
|
|
|
|
granulepos = parse->prev_granulepos;
|
|
|
|
|
2011-05-17 09:25:31 +00:00
|
|
|
gst_query_parse_position (query, &format, NULL);
|
2006-05-05 16:34:15 +00:00
|
|
|
|
|
|
|
/* and convert to the final format */
|
|
|
|
if (!(res =
|
|
|
|
vorbis_parse_convert (pad, GST_FORMAT_DEFAULT, granulepos,
|
|
|
|
&format, &value)))
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
/* fixme: support segments
|
|
|
|
value = (value - parse->segment_start) + parse->segment_time;
|
|
|
|
*/
|
|
|
|
|
2011-05-17 09:25:31 +00:00
|
|
|
gst_query_set_position (query, format, value);
|
2006-05-05 16:34:15 +00:00
|
|
|
|
2006-10-05 15:55:21 +00:00
|
|
|
GST_LOG_OBJECT (parse, "query %p: peer returned granulepos: %"
|
|
|
|
G_GUINT64_FORMAT " - we return %" G_GUINT64_FORMAT " (format %u)",
|
2011-05-17 09:25:31 +00:00
|
|
|
query, granulepos, value, format);
|
2006-05-05 16:34:15 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case GST_QUERY_DURATION:
|
|
|
|
{
|
|
|
|
/* fixme: not threadsafe */
|
|
|
|
/* query peer for total length */
|
|
|
|
if (!gst_pad_is_linked (parse->sinkpad)) {
|
|
|
|
GST_WARNING_OBJECT (parse, "sink pad %" GST_PTR_FORMAT " is not linked",
|
|
|
|
parse->sinkpad);
|
|
|
|
goto error;
|
|
|
|
}
|
2011-11-16 16:25:17 +00:00
|
|
|
if (!(res = gst_pad_peer_query (parse->sinkpad, query)))
|
2006-05-05 16:34:15 +00:00
|
|
|
goto error;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case GST_QUERY_CONVERT:
|
|
|
|
{
|
|
|
|
GstFormat src_fmt, dest_fmt;
|
|
|
|
gint64 src_val, dest_val;
|
|
|
|
|
2011-05-17 09:25:31 +00:00
|
|
|
gst_query_parse_convert (query, &src_fmt, &src_val, &dest_fmt, &dest_val);
|
2006-05-05 16:34:15 +00:00
|
|
|
if (!(res =
|
|
|
|
vorbis_parse_convert (pad, src_fmt, src_val, &dest_fmt,
|
|
|
|
&dest_val)))
|
|
|
|
goto error;
|
2011-05-17 09:25:31 +00:00
|
|
|
gst_query_set_convert (query, src_fmt, src_val, dest_fmt, dest_val);
|
2006-05-05 16:34:15 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
2011-11-16 16:25:17 +00:00
|
|
|
res = gst_pad_query_default (pad, parent, query);
|
2006-05-05 16:34:15 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
return res;
|
|
|
|
|
|
|
|
error:
|
|
|
|
{
|
|
|
|
GST_WARNING_OBJECT (parse, "error handling query");
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-09-02 15:43:18 +00:00
|
|
|
static GstStateChangeReturn
|
|
|
|
vorbis_parse_change_state (GstElement * element, GstStateChange transition)
|
2004-06-08 11:53:13 +00:00
|
|
|
{
|
|
|
|
GstVorbisParse *parse = GST_VORBIS_PARSE (element);
|
2006-03-01 17:39:28 +00:00
|
|
|
GstStateChangeReturn ret;
|
2004-06-08 11:53:13 +00:00
|
|
|
|
2005-09-02 15:43:18 +00:00
|
|
|
switch (transition) {
|
2006-03-01 17:39:28 +00:00
|
|
|
case GST_STATE_CHANGE_READY_TO_PAUSED:
|
2006-03-31 16:43:43 +00:00
|
|
|
vorbis_info_init (&parse->vi);
|
|
|
|
vorbis_comment_init (&parse->vc);
|
|
|
|
parse->prev_granulepos = -1;
|
|
|
|
parse->prev_blocksize = -1;
|
2004-06-08 11:53:13 +00:00
|
|
|
parse->packetno = 0;
|
2006-03-01 17:39:28 +00:00
|
|
|
parse->streamheader_sent = FALSE;
|
2006-03-31 16:43:43 +00:00
|
|
|
parse->buffer_queue = g_queue_new ();
|
2006-07-14 16:45:17 +00:00
|
|
|
parse->event_queue = g_queue_new ();
|
2004-06-08 11:53:13 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2006-03-31 16:43:43 +00:00
|
|
|
|
2011-04-19 12:11:32 +00:00
|
|
|
ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
|
2004-06-08 11:53:13 +00:00
|
|
|
|
2006-03-31 16:43:43 +00:00
|
|
|
switch (transition) {
|
|
|
|
case GST_STATE_CHANGE_PAUSED_TO_READY:
|
|
|
|
vorbis_info_clear (&parse->vi);
|
|
|
|
vorbis_comment_clear (&parse->vc);
|
|
|
|
vorbis_parse_clear_queue (parse);
|
|
|
|
g_queue_free (parse->buffer_queue);
|
|
|
|
parse->buffer_queue = NULL;
|
2006-07-14 16:45:17 +00:00
|
|
|
g_queue_free (parse->event_queue);
|
|
|
|
parse->event_queue = NULL;
|
2006-03-31 16:43:43 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2006-03-01 17:39:28 +00:00
|
|
|
return ret;
|
2004-06-08 11:53:13 +00:00
|
|
|
}
|