2004-06-08 11:53:13 +00:00
|
|
|
/* GStreamer
|
|
|
|
* Copyright (C) <2004> Thomas Vander Stichele <thomas at apestaart dot org>
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "vorbisparse.h"
|
|
|
|
|
|
|
|
GST_DEBUG_CATEGORY_EXTERN (vorbisparse_debug);
|
|
|
|
#define GST_CAT_DEFAULT vorbisparse_debug
|
|
|
|
|
|
|
|
static GstElementDetails vorbis_parse_details = {
|
|
|
|
"VorbisParse",
|
|
|
|
"Codec/Parser/Audio",
|
|
|
|
"parse raw vorbis streams",
|
|
|
|
"Thomas Vander Stichele <thomas at apestaart dot org>"
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Filter signals and args */
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
/* FILL ME */
|
|
|
|
LAST_SIGNAL
|
|
|
|
};
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
ARG_0
|
|
|
|
};
|
|
|
|
|
|
|
|
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")
|
|
|
|
);
|
|
|
|
|
|
|
|
GST_BOILERPLATE (GstVorbisParse, gst_vorbis_parse, GstElement,
|
|
|
|
GST_TYPE_ELEMENT);
|
|
|
|
|
2005-03-31 09:43:49 +00:00
|
|
|
static GstFlowReturn vorbis_parse_chain (GstPad * pad, GstBuffer * buffer);
|
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
|
|
|
|
|
|
|
static void
|
|
|
|
gst_vorbis_parse_base_init (gpointer g_class)
|
|
|
|
{
|
|
|
|
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
|
|
|
|
|
|
|
|
gst_element_class_add_pad_template (element_class,
|
|
|
|
gst_static_pad_template_get (&vorbis_parse_src_factory));
|
|
|
|
gst_element_class_add_pad_template (element_class,
|
|
|
|
gst_static_pad_template_get (&vorbis_parse_sink_factory));
|
|
|
|
gst_element_class_set_details (element_class, &vorbis_parse_details);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_vorbis_parse_class_init (GstVorbisParseClass * klass)
|
|
|
|
{
|
|
|
|
GstElementClass *gstelement_class = GST_ELEMENT_CLASS (klass);
|
|
|
|
|
|
|
|
gstelement_class->change_state = vorbis_parse_change_state;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2005-08-28 17:52:45 +00:00
|
|
|
gst_vorbis_parse_init (GstVorbisParse * parse, GstVorbisParseClass * g_class)
|
2004-06-08 11:53:13 +00:00
|
|
|
{
|
|
|
|
parse->sinkpad =
|
|
|
|
gst_pad_new_from_template (gst_static_pad_template_get
|
|
|
|
(&vorbis_parse_sink_factory), "sink");
|
|
|
|
gst_pad_set_chain_function (parse->sinkpad, vorbis_parse_chain);
|
|
|
|
gst_element_add_pad (GST_ELEMENT (parse), parse->sinkpad);
|
|
|
|
|
|
|
|
parse->srcpad =
|
|
|
|
gst_pad_new_from_template (gst_static_pad_template_get
|
|
|
|
(&vorbis_parse_src_factory), "src");
|
|
|
|
gst_element_add_pad (GST_ELEMENT (parse), parse->srcpad);
|
|
|
|
}
|
|
|
|
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;
|
|
|
|
GValue list = { 0 };
|
|
|
|
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 */
|
Port from GstData to GstMiniObject.
Original commit message from CVS:
Port from GstData to GstMiniObject.
* ext/ogg/gstoggdemux.c: (gst_ogg_pad_dispose):
* ext/ogg/gstoggmux.c: (gst_ogg_mux_buffer_from_page),
(gst_ogg_mux_queue_pads), (gst_ogg_mux_set_header_on_caps),
(gst_ogg_mux_collected):
* ext/ogg/gstogmparse.c: (gst_ogm_parse_chain):
* ext/theora/theoradec.c: (theora_handle_comment_packet),
(theora_handle_data_packet):
* ext/theora/theoraenc.c: (theora_buffer_from_packet),
(theora_set_header_on_caps), (theora_enc_chain):
* ext/vorbis/vorbisdec.c: (vorbis_dec_sink_event),
(vorbis_handle_comment_packet):
* ext/vorbis/vorbisenc.c: (gst_vorbisenc_set_header_on_caps):
* ext/vorbis/vorbisparse.c: (vorbis_parse_set_header_on_caps):
* gst-libs/gst/audio/gstaudiofilter.c: (gst_audiofilter_chain):
* gst-libs/gst/tag/gstvorbistag.c: (gst_vorbis_tag_chain):
* gst/audioconvert/gstaudioconvert.c:
(gst_audio_convert_get_buffer):
* gst/playback/gstdecodebin.c: (gst_decode_bin_class_init):
* gst/playback/gstplaybasebin.c: (check_queue), (probe_triggered),
(mute_stream), (silence_stream):
* gst/playback/gstplaybin.c: (gst_play_bin_class_init):
* gst/volume/gstvolume.c: (volume_transform):
* sys/ximage/ximagesink.c: (gst_ximage_buffer_finalize),
(gst_ximage_buffer_init), (gst_ximage_buffer_class_init),
(gst_ximage_buffer_get_type), (gst_ximagesink_check_xshm_calls),
(gst_ximagesink_ximage_new), (gst_ximagesink_ximage_destroy),
(gst_ximagesink_ximage_put), (gst_ximagesink_imagepool_clear),
(gst_ximagesink_show_frame), (gst_ximagesink_buffer_free),
(gst_ximagesink_buffer_alloc):
* sys/ximage/ximagesink.h:
2005-05-16 15:35:52 +00:00
|
|
|
GST_BUFFER_FLAG_SET (buf1, GST_BUFFER_FLAG_IN_CAPS);
|
|
|
|
GST_BUFFER_FLAG_SET (buf2, GST_BUFFER_FLAG_IN_CAPS);
|
|
|
|
GST_BUFFER_FLAG_SET (buf3, GST_BUFFER_FLAG_IN_CAPS);
|
2004-06-08 11:53:13 +00:00
|
|
|
|
|
|
|
/* put buffers in a fixed list */
|
2005-07-20 17:16:54 +00:00
|
|
|
g_value_init (&list, GST_TYPE_ARRAY);
|
2004-06-08 11:53:13 +00:00
|
|
|
g_value_init (&value, GST_TYPE_BUFFER);
|
|
|
|
g_value_set_boxed (&value, buf1);
|
|
|
|
gst_value_list_append_value (&list, &value);
|
|
|
|
g_value_unset (&value);
|
|
|
|
g_value_init (&value, GST_TYPE_BUFFER);
|
|
|
|
g_value_set_boxed (&value, buf2);
|
|
|
|
gst_value_list_append_value (&list, &value);
|
|
|
|
g_value_unset (&value);
|
|
|
|
g_value_init (&value, GST_TYPE_BUFFER);
|
|
|
|
g_value_set_boxed (&value, buf3);
|
|
|
|
gst_value_list_append_value (&list, &value);
|
|
|
|
gst_structure_set_value (structure, "streamheader", &list);
|
|
|
|
g_value_unset (&value);
|
|
|
|
g_value_unset (&list);
|
|
|
|
}
|
|
|
|
|
2005-03-31 09:43:49 +00:00
|
|
|
static GstFlowReturn
|
|
|
|
vorbis_parse_chain (GstPad * pad, GstBuffer * buffer)
|
2004-06-08 11:53:13 +00:00
|
|
|
{
|
|
|
|
GstBuffer *buf;
|
|
|
|
GstVorbisParse *parse;
|
|
|
|
|
2005-03-31 09:43:49 +00:00
|
|
|
parse = GST_VORBIS_PARSE (GST_PAD_PARENT (pad));
|
2004-06-08 11:53:13 +00:00
|
|
|
|
2005-03-31 09:43:49 +00:00
|
|
|
buf = GST_BUFFER (buffer);
|
2004-06-08 11:53:13 +00:00
|
|
|
parse->packetno++;
|
|
|
|
|
|
|
|
/* if 1 <= packetno <= 3, it's streamheader,
|
|
|
|
* so put it on the streamheader list and return */
|
|
|
|
if (parse->packetno <= 3) {
|
|
|
|
parse->streamheader = g_list_append (parse->streamheader, buf);
|
2005-03-31 09:43:49 +00:00
|
|
|
return GST_FLOW_OK;
|
2004-06-08 11:53:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* else, if we haven't sent streamheader buffers yet,
|
|
|
|
* set caps again, and send out the streamheader buffers */
|
|
|
|
if (!parse->streamheader_sent) {
|
|
|
|
/* mark and put on caps */
|
|
|
|
GstCaps *caps = gst_pad_get_caps (parse->srcpad);
|
|
|
|
|
|
|
|
vorbis_parse_set_header_on_caps (parse, caps);
|
|
|
|
|
|
|
|
/* negotiate with these caps */
|
|
|
|
GST_DEBUG ("here are the caps: %" GST_PTR_FORMAT, caps);
|
2005-03-31 09:43:49 +00:00
|
|
|
gst_pad_set_caps (parse->srcpad, caps);
|
2004-06-08 11:53:13 +00:00
|
|
|
|
|
|
|
/* push out buffers */
|
|
|
|
gst_pad_push (parse->srcpad, parse->streamheader->data);
|
|
|
|
gst_pad_push (parse->srcpad, parse->streamheader->next->data);
|
|
|
|
gst_pad_push (parse->srcpad, parse->streamheader->next->next->data);
|
|
|
|
|
|
|
|
parse->streamheader_sent = TRUE;
|
|
|
|
}
|
|
|
|
/* just send on buffer by default */
|
2005-03-31 09:43:49 +00:00
|
|
|
gst_pad_push (parse->srcpad, buf);
|
|
|
|
|
|
|
|
return GST_FLOW_OK;
|
2004-06-08 11:53:13 +00:00
|
|
|
}
|
|
|
|
|
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);
|
|
|
|
|
2005-09-02 15:43:18 +00:00
|
|
|
switch (transition) {
|
|
|
|
case GST_STATE_CHANGE_PAUSED_TO_READY:
|
2004-06-08 11:53:13 +00:00
|
|
|
parse->packetno = 0;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2005-09-02 15:43:18 +00:00
|
|
|
return parent_class->change_state (element, transition);
|
2004-06-08 11:53:13 +00:00
|
|
|
}
|