2002-03-20 21:45:03 +00:00
|
|
|
/* GStreamer
|
2001-12-22 23:22:05 +00:00
|
|
|
* Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
|
gst/auparse/gstauparse.*: Rewrite auparse to suck a little bit less: make source pad dynamic, so decodebin/playbin wo...
Original commit message from CVS:
* gst/auparse/gstauparse.c: (gst_au_parse_base_init),
(gst_au_parse_class_init), (gst_au_parse_init),
(gst_au_parse_reset), (gst_au_parse_add_srcpad),
(gst_au_parse_remove_srcpad), (gst_au_parse_parse_header),
(gst_au_parse_chain), (gst_au_parse_src_convert),
(gst_au_parse_src_query), (gst_au_parse_handle_seek),
(gst_au_parse_sink_event), (gst_au_parse_src_event),
(gst_au_parse_change_state):
* gst/auparse/gstauparse.h:
Rewrite auparse to suck a little bit less: make source pad
dynamic, so decodebin/playbin work with non-raw formats
like alaw/mulaw; add query function for duration/position
queries; check whether we have enough data before attempting
to parse the header (instead of crashing when that is not the
case); work around audioconvert sucking by swapping endianness
to the native endianness ourselves for float formats; send
initial newsegment event. Fixes #161712.
2006-04-26 17:08:24 +00:00
|
|
|
* Copyright (C) <2006> Tim-Philipp Müller <tim centricular net>
|
2001-12-22 23:22:05 +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
|
2012-11-04 00:07:18 +00:00
|
|
|
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
2001-12-22 23:22:05 +00:00
|
|
|
*/
|
|
|
|
|
gst/auparse/gstauparse.*: Rewrite auparse to suck a little bit less: make source pad dynamic, so decodebin/playbin wo...
Original commit message from CVS:
* gst/auparse/gstauparse.c: (gst_au_parse_base_init),
(gst_au_parse_class_init), (gst_au_parse_init),
(gst_au_parse_reset), (gst_au_parse_add_srcpad),
(gst_au_parse_remove_srcpad), (gst_au_parse_parse_header),
(gst_au_parse_chain), (gst_au_parse_src_convert),
(gst_au_parse_src_query), (gst_au_parse_handle_seek),
(gst_au_parse_sink_event), (gst_au_parse_src_event),
(gst_au_parse_change_state):
* gst/auparse/gstauparse.h:
Rewrite auparse to suck a little bit less: make source pad
dynamic, so decodebin/playbin work with non-raw formats
like alaw/mulaw; add query function for duration/position
queries; check whether we have enough data before attempting
to parse the header (instead of crashing when that is not the
case); work around audioconvert sucking by swapping endianness
to the native endianness ourselves for float formats; send
initial newsegment event. Fixes #161712.
2006-04-26 17:08:24 +00:00
|
|
|
/**
|
|
|
|
* SECTION:element-auparse
|
2007-04-10 12:01:33 +00:00
|
|
|
*
|
2009-01-28 10:29:42 +00:00
|
|
|
* Parses .au files mostly originating from sun os based computers.
|
2001-12-22 23:22:05 +00:00
|
|
|
*/
|
|
|
|
|
2003-06-29 19:46:12 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
2005-12-12 10:30:20 +00:00
|
|
|
|
2001-12-22 23:22:05 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
2004-07-26 22:11:21 +00:00
|
|
|
#include "gstauparse.h"
|
2003-12-22 01:47:09 +00:00
|
|
|
#include <gst/audio/audio.h>
|
2001-12-22 23:22:05 +00:00
|
|
|
|
gst/auparse/gstauparse.*: Rewrite auparse to suck a little bit less: make source pad dynamic, so decodebin/playbin wo...
Original commit message from CVS:
* gst/auparse/gstauparse.c: (gst_au_parse_base_init),
(gst_au_parse_class_init), (gst_au_parse_init),
(gst_au_parse_reset), (gst_au_parse_add_srcpad),
(gst_au_parse_remove_srcpad), (gst_au_parse_parse_header),
(gst_au_parse_chain), (gst_au_parse_src_convert),
(gst_au_parse_src_query), (gst_au_parse_handle_seek),
(gst_au_parse_sink_event), (gst_au_parse_src_event),
(gst_au_parse_change_state):
* gst/auparse/gstauparse.h:
Rewrite auparse to suck a little bit less: make source pad
dynamic, so decodebin/playbin work with non-raw formats
like alaw/mulaw; add query function for duration/position
queries; check whether we have enough data before attempting
to parse the header (instead of crashing when that is not the
case); work around audioconvert sucking by swapping endianness
to the native endianness ourselves for float formats; send
initial newsegment event. Fixes #161712.
2006-04-26 17:08:24 +00:00
|
|
|
GST_DEBUG_CATEGORY_STATIC (auparse_debug);
|
|
|
|
#define GST_CAT_DEFAULT (auparse_debug)
|
|
|
|
|
|
|
|
static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink",
|
2004-03-14 22:34:33 +00:00
|
|
|
GST_PAD_SINK,
|
|
|
|
GST_PAD_ALWAYS,
|
|
|
|
GST_STATIC_CAPS ("audio/x-au")
|
|
|
|
);
|
2001-12-22 23:22:05 +00:00
|
|
|
|
2011-08-19 12:01:45 +00:00
|
|
|
#define GST_AU_PARSE_RAW_PAD_TEMPLATE_CAPS \
|
|
|
|
"audio/x-raw, " \
|
2011-09-06 11:16:27 +00:00
|
|
|
"format= (string) { S8, S16LE, S16BE, S24LE, S24BE, " \
|
|
|
|
"S32LE, S32BE, F32LE, F32BE, " \
|
|
|
|
"F64LE, F64BE }, " \
|
2011-08-19 12:01:45 +00:00
|
|
|
"rate = (int) [ 8000, 192000 ], " \
|
2012-01-04 10:06:28 +00:00
|
|
|
"channels = (int) 1, " \
|
|
|
|
"layout = (string) interleaved;" \
|
|
|
|
"audio/x-raw, " \
|
|
|
|
"format= (string) { S8, S16LE, S16BE, S24LE, S24BE, " \
|
|
|
|
"S32LE, S32BE, F32LE, F32BE, " \
|
|
|
|
"F64LE, F64BE }, " \
|
|
|
|
"rate = (int) [ 8000, 192000 ], " \
|
|
|
|
"channels = (int) 2, " \
|
|
|
|
"channel-mask = (bitmask) 0x3," \
|
2012-01-05 13:18:03 +00:00
|
|
|
"layout = (string) interleaved"
|
2011-08-19 12:01:45 +00:00
|
|
|
|
2005-12-12 10:30:20 +00:00
|
|
|
#define GST_AU_PARSE_ALAW_PAD_TEMPLATE_CAPS \
|
|
|
|
"audio/x-alaw, " \
|
|
|
|
"rate = (int) [ 8000, 192000 ], " \
|
|
|
|
"channels = (int) [ 1, 2 ]"
|
|
|
|
|
|
|
|
#define GST_AU_PARSE_MULAW_PAD_TEMPLATE_CAPS \
|
|
|
|
"audio/x-mulaw, " \
|
|
|
|
"rate = (int) [ 8000, 192000 ], " \
|
|
|
|
"channels = (int) [ 1, 2 ]"
|
|
|
|
|
|
|
|
/* Nothing to decode those ADPCM streams for now */
|
|
|
|
#define GST_AU_PARSE_ADPCM_PAD_TEMPLATE_CAPS \
|
|
|
|
"audio/x-adpcm, " \
|
|
|
|
"layout = (string) { g721, g722, g723_3, g723_5 }"
|
|
|
|
|
gst/auparse/gstauparse.*: Rewrite auparse to suck a little bit less: make source pad dynamic, so decodebin/playbin wo...
Original commit message from CVS:
* gst/auparse/gstauparse.c: (gst_au_parse_base_init),
(gst_au_parse_class_init), (gst_au_parse_init),
(gst_au_parse_reset), (gst_au_parse_add_srcpad),
(gst_au_parse_remove_srcpad), (gst_au_parse_parse_header),
(gst_au_parse_chain), (gst_au_parse_src_convert),
(gst_au_parse_src_query), (gst_au_parse_handle_seek),
(gst_au_parse_sink_event), (gst_au_parse_src_event),
(gst_au_parse_change_state):
* gst/auparse/gstauparse.h:
Rewrite auparse to suck a little bit less: make source pad
dynamic, so decodebin/playbin work with non-raw formats
like alaw/mulaw; add query function for duration/position
queries; check whether we have enough data before attempting
to parse the header (instead of crashing when that is not the
case); work around audioconvert sucking by swapping endianness
to the native endianness ourselves for float formats; send
initial newsegment event. Fixes #161712.
2006-04-26 17:08:24 +00:00
|
|
|
static GstStaticPadTemplate src_template = GST_STATIC_PAD_TEMPLATE ("src",
|
2004-03-14 22:34:33 +00:00
|
|
|
GST_PAD_SRC,
|
2011-07-07 09:22:26 +00:00
|
|
|
GST_PAD_ALWAYS,
|
2011-08-19 12:01:45 +00:00
|
|
|
GST_STATIC_CAPS (GST_AU_PARSE_RAW_PAD_TEMPLATE_CAPS "; "
|
2005-12-12 10:30:20 +00:00
|
|
|
GST_AU_PARSE_ALAW_PAD_TEMPLATE_CAPS ";"
|
|
|
|
GST_AU_PARSE_MULAW_PAD_TEMPLATE_CAPS ";"
|
|
|
|
GST_AU_PARSE_ADPCM_PAD_TEMPLATE_CAPS));
|
2001-12-22 23:22:05 +00:00
|
|
|
|
|
|
|
|
2005-12-12 10:30:20 +00:00
|
|
|
static void gst_au_parse_dispose (GObject * object);
|
2011-11-17 14:02:55 +00:00
|
|
|
static GstFlowReturn gst_au_parse_chain (GstPad * pad, GstObject * parent,
|
|
|
|
GstBuffer * buf);
|
2005-12-12 10:30:20 +00:00
|
|
|
static GstStateChangeReturn gst_au_parse_change_state (GstElement * element,
|
2005-09-02 15:44:50 +00:00
|
|
|
GstStateChange transition);
|
gst/auparse/gstauparse.*: Rewrite auparse to suck a little bit less: make source pad dynamic, so decodebin/playbin wo...
Original commit message from CVS:
* gst/auparse/gstauparse.c: (gst_au_parse_base_init),
(gst_au_parse_class_init), (gst_au_parse_init),
(gst_au_parse_reset), (gst_au_parse_add_srcpad),
(gst_au_parse_remove_srcpad), (gst_au_parse_parse_header),
(gst_au_parse_chain), (gst_au_parse_src_convert),
(gst_au_parse_src_query), (gst_au_parse_handle_seek),
(gst_au_parse_sink_event), (gst_au_parse_src_event),
(gst_au_parse_change_state):
* gst/auparse/gstauparse.h:
Rewrite auparse to suck a little bit less: make source pad
dynamic, so decodebin/playbin work with non-raw formats
like alaw/mulaw; add query function for duration/position
queries; check whether we have enough data before attempting
to parse the header (instead of crashing when that is not the
case); work around audioconvert sucking by swapping endianness
to the native endianness ourselves for float formats; send
initial newsegment event. Fixes #161712.
2006-04-26 17:08:24 +00:00
|
|
|
static void gst_au_parse_reset (GstAuParse * auparse);
|
2011-11-16 16:27:13 +00:00
|
|
|
static gboolean gst_au_parse_src_query (GstPad * pad, GstObject * parent,
|
|
|
|
GstQuery * query);
|
2011-11-17 14:02:55 +00:00
|
|
|
static gboolean gst_au_parse_src_event (GstPad * pad, GstObject * parent,
|
|
|
|
GstEvent * event);
|
|
|
|
static gboolean gst_au_parse_sink_event (GstPad * pad, GstObject * parent,
|
|
|
|
GstEvent * event);
|
2011-04-20 19:25:58 +00:00
|
|
|
static gboolean gst_au_parse_src_convert (GstAuParse * auparse,
|
|
|
|
GstFormat src_format, gint64 srcval, GstFormat dest_format,
|
|
|
|
gint64 * destval);
|
2004-05-11 00:20:02 +00:00
|
|
|
|
2011-06-07 09:23:55 +00:00
|
|
|
#define gst_au_parse_parent_class parent_class
|
|
|
|
G_DEFINE_TYPE (GstAuParse, gst_au_parse, GST_TYPE_ELEMENT);
|
2003-11-01 01:32:29 +00:00
|
|
|
|
2001-12-22 23:22:05 +00:00
|
|
|
static void
|
2005-12-12 10:30:20 +00:00
|
|
|
gst_au_parse_class_init (GstAuParseClass * klass)
|
2001-12-22 23:22:05 +00:00
|
|
|
{
|
2005-11-21 17:18:01 +00:00
|
|
|
GObjectClass *gobject_class;
|
2001-12-22 23:22:05 +00:00
|
|
|
GstElementClass *gstelement_class;
|
|
|
|
|
2011-06-07 09:23:55 +00:00
|
|
|
GST_DEBUG_CATEGORY_INIT (auparse_debug, "auparse", 0, ".au parser");
|
|
|
|
|
2005-11-21 17:18:01 +00:00
|
|
|
gobject_class = (GObjectClass *) klass;
|
2004-03-14 22:34:33 +00:00
|
|
|
gstelement_class = (GstElementClass *) klass;
|
2001-12-22 23:22:05 +00:00
|
|
|
|
2005-12-12 10:30:20 +00:00
|
|
|
gobject_class->dispose = gst_au_parse_dispose;
|
2005-11-21 17:18:01 +00:00
|
|
|
|
2005-12-12 10:30:20 +00:00
|
|
|
gstelement_class->change_state =
|
|
|
|
GST_DEBUG_FUNCPTR (gst_au_parse_change_state);
|
2011-06-07 09:23:55 +00:00
|
|
|
gst_element_class_add_pad_template (gstelement_class,
|
|
|
|
gst_static_pad_template_get (&sink_template));
|
|
|
|
gst_element_class_add_pad_template (gstelement_class,
|
|
|
|
gst_static_pad_template_get (&src_template));
|
2012-04-09 23:51:41 +00:00
|
|
|
gst_element_class_set_static_metadata (gstelement_class,
|
2011-06-07 09:23:55 +00:00
|
|
|
"AU audio demuxer",
|
|
|
|
"Codec/Demuxer/Audio",
|
|
|
|
"Parse an .au file into raw audio",
|
|
|
|
"Erik Walthinsen <omega@cse.ogi.edu>");
|
2001-12-22 23:22:05 +00:00
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
static void
|
2011-06-07 09:23:55 +00:00
|
|
|
gst_au_parse_init (GstAuParse * auparse)
|
2001-12-22 23:22:05 +00:00
|
|
|
{
|
gst/auparse/gstauparse.*: Rewrite auparse to suck a little bit less: make source pad dynamic, so decodebin/playbin wo...
Original commit message from CVS:
* gst/auparse/gstauparse.c: (gst_au_parse_base_init),
(gst_au_parse_class_init), (gst_au_parse_init),
(gst_au_parse_reset), (gst_au_parse_add_srcpad),
(gst_au_parse_remove_srcpad), (gst_au_parse_parse_header),
(gst_au_parse_chain), (gst_au_parse_src_convert),
(gst_au_parse_src_query), (gst_au_parse_handle_seek),
(gst_au_parse_sink_event), (gst_au_parse_src_event),
(gst_au_parse_change_state):
* gst/auparse/gstauparse.h:
Rewrite auparse to suck a little bit less: make source pad
dynamic, so decodebin/playbin work with non-raw formats
like alaw/mulaw; add query function for duration/position
queries; check whether we have enough data before attempting
to parse the header (instead of crashing when that is not the
case); work around audioconvert sucking by swapping endianness
to the native endianness ourselves for float formats; send
initial newsegment event. Fixes #161712.
2006-04-26 17:08:24 +00:00
|
|
|
auparse->sinkpad = gst_pad_new_from_static_template (&sink_template, "sink");
|
|
|
|
gst_pad_set_chain_function (auparse->sinkpad,
|
|
|
|
GST_DEBUG_FUNCPTR (gst_au_parse_chain));
|
|
|
|
gst_pad_set_event_function (auparse->sinkpad,
|
|
|
|
GST_DEBUG_FUNCPTR (gst_au_parse_sink_event));
|
2006-03-30 15:37:05 +00:00
|
|
|
gst_element_add_pad (GST_ELEMENT (auparse), auparse->sinkpad);
|
2001-12-22 23:22:05 +00:00
|
|
|
|
2011-07-07 09:22:26 +00:00
|
|
|
auparse->srcpad = gst_pad_new_from_static_template (&src_template, "src");
|
|
|
|
gst_pad_set_query_function (auparse->srcpad,
|
|
|
|
GST_DEBUG_FUNCPTR (gst_au_parse_src_query));
|
|
|
|
gst_pad_set_event_function (auparse->srcpad,
|
|
|
|
GST_DEBUG_FUNCPTR (gst_au_parse_src_event));
|
|
|
|
gst_pad_use_fixed_caps (auparse->srcpad);
|
|
|
|
gst_element_add_pad (GST_ELEMENT (auparse), auparse->srcpad);
|
|
|
|
|
2005-11-21 17:18:01 +00:00
|
|
|
auparse->adapter = gst_adapter_new ();
|
gst/auparse/gstauparse.*: Rewrite auparse to suck a little bit less: make source pad dynamic, so decodebin/playbin wo...
Original commit message from CVS:
* gst/auparse/gstauparse.c: (gst_au_parse_base_init),
(gst_au_parse_class_init), (gst_au_parse_init),
(gst_au_parse_reset), (gst_au_parse_add_srcpad),
(gst_au_parse_remove_srcpad), (gst_au_parse_parse_header),
(gst_au_parse_chain), (gst_au_parse_src_convert),
(gst_au_parse_src_query), (gst_au_parse_handle_seek),
(gst_au_parse_sink_event), (gst_au_parse_src_event),
(gst_au_parse_change_state):
* gst/auparse/gstauparse.h:
Rewrite auparse to suck a little bit less: make source pad
dynamic, so decodebin/playbin work with non-raw formats
like alaw/mulaw; add query function for duration/position
queries; check whether we have enough data before attempting
to parse the header (instead of crashing when that is not the
case); work around audioconvert sucking by swapping endianness
to the native endianness ourselves for float formats; send
initial newsegment event. Fixes #161712.
2006-04-26 17:08:24 +00:00
|
|
|
gst_au_parse_reset (auparse);
|
2001-12-22 23:22:05 +00:00
|
|
|
}
|
|
|
|
|
2005-11-21 17:18:01 +00:00
|
|
|
static void
|
2005-12-12 10:30:20 +00:00
|
|
|
gst_au_parse_dispose (GObject * object)
|
2005-11-21 17:18:01 +00:00
|
|
|
{
|
2005-12-12 10:30:20 +00:00
|
|
|
GstAuParse *au = GST_AU_PARSE (object);
|
2005-11-21 17:18:01 +00:00
|
|
|
|
|
|
|
if (au->adapter != NULL) {
|
2005-12-29 11:26:12 +00:00
|
|
|
g_object_unref (au->adapter);
|
2005-11-21 17:18:01 +00:00
|
|
|
au->adapter = NULL;
|
|
|
|
}
|
|
|
|
G_OBJECT_CLASS (parent_class)->dispose (object);
|
|
|
|
}
|
|
|
|
|
gst/auparse/gstauparse.*: Rewrite auparse to suck a little bit less: make source pad dynamic, so decodebin/playbin wo...
Original commit message from CVS:
* gst/auparse/gstauparse.c: (gst_au_parse_base_init),
(gst_au_parse_class_init), (gst_au_parse_init),
(gst_au_parse_reset), (gst_au_parse_add_srcpad),
(gst_au_parse_remove_srcpad), (gst_au_parse_parse_header),
(gst_au_parse_chain), (gst_au_parse_src_convert),
(gst_au_parse_src_query), (gst_au_parse_handle_seek),
(gst_au_parse_sink_event), (gst_au_parse_src_event),
(gst_au_parse_change_state):
* gst/auparse/gstauparse.h:
Rewrite auparse to suck a little bit less: make source pad
dynamic, so decodebin/playbin work with non-raw formats
like alaw/mulaw; add query function for duration/position
queries; check whether we have enough data before attempting
to parse the header (instead of crashing when that is not the
case); work around audioconvert sucking by swapping endianness
to the native endianness ourselves for float formats; send
initial newsegment event. Fixes #161712.
2006-04-26 17:08:24 +00:00
|
|
|
static void
|
|
|
|
gst_au_parse_reset (GstAuParse * auparse)
|
|
|
|
{
|
|
|
|
auparse->offset = 0;
|
|
|
|
auparse->buffer_offset = 0;
|
|
|
|
auparse->encoding = 0;
|
|
|
|
auparse->samplerate = 0;
|
|
|
|
auparse->channels = 0;
|
|
|
|
|
|
|
|
gst_adapter_clear (auparse->adapter);
|
|
|
|
|
|
|
|
/* gst_segment_init (&auparse->segment, GST_FORMAT_TIME); */
|
|
|
|
}
|
|
|
|
|
2011-07-07 09:22:26 +00:00
|
|
|
static void
|
|
|
|
gst_au_parse_negotiate_srcpad (GstAuParse * auparse, GstCaps * new_caps)
|
gst/auparse/gstauparse.*: Rewrite auparse to suck a little bit less: make source pad dynamic, so decodebin/playbin wo...
Original commit message from CVS:
* gst/auparse/gstauparse.c: (gst_au_parse_base_init),
(gst_au_parse_class_init), (gst_au_parse_init),
(gst_au_parse_reset), (gst_au_parse_add_srcpad),
(gst_au_parse_remove_srcpad), (gst_au_parse_parse_header),
(gst_au_parse_chain), (gst_au_parse_src_convert),
(gst_au_parse_src_query), (gst_au_parse_handle_seek),
(gst_au_parse_sink_event), (gst_au_parse_src_event),
(gst_au_parse_change_state):
* gst/auparse/gstauparse.h:
Rewrite auparse to suck a little bit less: make source pad
dynamic, so decodebin/playbin work with non-raw formats
like alaw/mulaw; add query function for duration/position
queries; check whether we have enough data before attempting
to parse the header (instead of crashing when that is not the
case); work around audioconvert sucking by swapping endianness
to the native endianness ourselves for float formats; send
initial newsegment event. Fixes #161712.
2006-04-26 17:08:24 +00:00
|
|
|
{
|
|
|
|
if (auparse->src_caps && gst_caps_is_equal (new_caps, auparse->src_caps)) {
|
|
|
|
GST_LOG_OBJECT (auparse, "same caps, nothing to do");
|
2011-07-07 09:22:26 +00:00
|
|
|
return;
|
gst/auparse/gstauparse.*: Rewrite auparse to suck a little bit less: make source pad dynamic, so decodebin/playbin wo...
Original commit message from CVS:
* gst/auparse/gstauparse.c: (gst_au_parse_base_init),
(gst_au_parse_class_init), (gst_au_parse_init),
(gst_au_parse_reset), (gst_au_parse_add_srcpad),
(gst_au_parse_remove_srcpad), (gst_au_parse_parse_header),
(gst_au_parse_chain), (gst_au_parse_src_convert),
(gst_au_parse_src_query), (gst_au_parse_handle_seek),
(gst_au_parse_sink_event), (gst_au_parse_src_event),
(gst_au_parse_change_state):
* gst/auparse/gstauparse.h:
Rewrite auparse to suck a little bit less: make source pad
dynamic, so decodebin/playbin work with non-raw formats
like alaw/mulaw; add query function for duration/position
queries; check whether we have enough data before attempting
to parse the header (instead of crashing when that is not the
case); work around audioconvert sucking by swapping endianness
to the native endianness ourselves for float formats; send
initial newsegment event. Fixes #161712.
2006-04-26 17:08:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
gst_caps_replace (&auparse->src_caps, new_caps);
|
2011-07-07 09:22:26 +00:00
|
|
|
GST_DEBUG_OBJECT (auparse, "Changing src pad caps to %" GST_PTR_FORMAT,
|
|
|
|
auparse->src_caps);
|
|
|
|
gst_pad_set_caps (auparse->srcpad, auparse->src_caps);
|
gst/auparse/gstauparse.*: Rewrite auparse to suck a little bit less: make source pad dynamic, so decodebin/playbin wo...
Original commit message from CVS:
* gst/auparse/gstauparse.c: (gst_au_parse_base_init),
(gst_au_parse_class_init), (gst_au_parse_init),
(gst_au_parse_reset), (gst_au_parse_add_srcpad),
(gst_au_parse_remove_srcpad), (gst_au_parse_parse_header),
(gst_au_parse_chain), (gst_au_parse_src_convert),
(gst_au_parse_src_query), (gst_au_parse_handle_seek),
(gst_au_parse_sink_event), (gst_au_parse_src_event),
(gst_au_parse_change_state):
* gst/auparse/gstauparse.h:
Rewrite auparse to suck a little bit less: make source pad
dynamic, so decodebin/playbin work with non-raw formats
like alaw/mulaw; add query function for duration/position
queries; check whether we have enough data before attempting
to parse the header (instead of crashing when that is not the
case); work around audioconvert sucking by swapping endianness
to the native endianness ourselves for float formats; send
initial newsegment event. Fixes #161712.
2006-04-26 17:08:24 +00:00
|
|
|
|
2011-07-07 09:22:26 +00:00
|
|
|
return;
|
gst/auparse/gstauparse.*: Rewrite auparse to suck a little bit less: make source pad dynamic, so decodebin/playbin wo...
Original commit message from CVS:
* gst/auparse/gstauparse.c: (gst_au_parse_base_init),
(gst_au_parse_class_init), (gst_au_parse_init),
(gst_au_parse_reset), (gst_au_parse_add_srcpad),
(gst_au_parse_remove_srcpad), (gst_au_parse_parse_header),
(gst_au_parse_chain), (gst_au_parse_src_convert),
(gst_au_parse_src_query), (gst_au_parse_handle_seek),
(gst_au_parse_sink_event), (gst_au_parse_src_event),
(gst_au_parse_change_state):
* gst/auparse/gstauparse.h:
Rewrite auparse to suck a little bit less: make source pad
dynamic, so decodebin/playbin work with non-raw formats
like alaw/mulaw; add query function for duration/position
queries; check whether we have enough data before attempting
to parse the header (instead of crashing when that is not the
case); work around audioconvert sucking by swapping endianness
to the native endianness ourselves for float formats; send
initial newsegment event. Fixes #161712.
2006-04-26 17:08:24 +00:00
|
|
|
}
|
|
|
|
|
2005-09-22 22:38:48 +00:00
|
|
|
static GstFlowReturn
|
gst/auparse/gstauparse.*: Rewrite auparse to suck a little bit less: make source pad dynamic, so decodebin/playbin wo...
Original commit message from CVS:
* gst/auparse/gstauparse.c: (gst_au_parse_base_init),
(gst_au_parse_class_init), (gst_au_parse_init),
(gst_au_parse_reset), (gst_au_parse_add_srcpad),
(gst_au_parse_remove_srcpad), (gst_au_parse_parse_header),
(gst_au_parse_chain), (gst_au_parse_src_convert),
(gst_au_parse_src_query), (gst_au_parse_handle_seek),
(gst_au_parse_sink_event), (gst_au_parse_src_event),
(gst_au_parse_change_state):
* gst/auparse/gstauparse.h:
Rewrite auparse to suck a little bit less: make source pad
dynamic, so decodebin/playbin work with non-raw formats
like alaw/mulaw; add query function for duration/position
queries; check whether we have enough data before attempting
to parse the header (instead of crashing when that is not the
case); work around audioconvert sucking by swapping endianness
to the native endianness ourselves for float formats; send
initial newsegment event. Fixes #161712.
2006-04-26 17:08:24 +00:00
|
|
|
gst_au_parse_parse_header (GstAuParse * auparse)
|
2001-12-22 23:22:05 +00:00
|
|
|
{
|
2003-12-22 01:47:09 +00:00
|
|
|
GstCaps *tempcaps;
|
gst/auparse/gstauparse.*: Rewrite auparse to suck a little bit less: make source pad dynamic, so decodebin/playbin wo...
Original commit message from CVS:
* gst/auparse/gstauparse.c: (gst_au_parse_base_init),
(gst_au_parse_class_init), (gst_au_parse_init),
(gst_au_parse_reset), (gst_au_parse_add_srcpad),
(gst_au_parse_remove_srcpad), (gst_au_parse_parse_header),
(gst_au_parse_chain), (gst_au_parse_src_convert),
(gst_au_parse_src_query), (gst_au_parse_handle_seek),
(gst_au_parse_sink_event), (gst_au_parse_src_event),
(gst_au_parse_change_state):
* gst/auparse/gstauparse.h:
Rewrite auparse to suck a little bit less: make source pad
dynamic, so decodebin/playbin work with non-raw formats
like alaw/mulaw; add query function for duration/position
queries; check whether we have enough data before attempting
to parse the header (instead of crashing when that is not the
case); work around audioconvert sucking by swapping endianness
to the native endianness ourselves for float formats; send
initial newsegment event. Fixes #161712.
2006-04-26 17:08:24 +00:00
|
|
|
guint32 size;
|
|
|
|
guint8 *head;
|
|
|
|
gchar layout[7] = { 0, };
|
2011-08-19 12:01:45 +00:00
|
|
|
GstAudioFormat format = GST_AUDIO_FORMAT_UNKNOWN;
|
|
|
|
gint law = 0;
|
|
|
|
guint endianness;
|
2004-05-14 10:01:23 +00:00
|
|
|
|
2011-07-07 09:14:16 +00:00
|
|
|
head = (guint8 *) gst_adapter_map (auparse->adapter, 24);
|
gst/auparse/gstauparse.*: Rewrite auparse to suck a little bit less: make source pad dynamic, so decodebin/playbin wo...
Original commit message from CVS:
* gst/auparse/gstauparse.c: (gst_au_parse_base_init),
(gst_au_parse_class_init), (gst_au_parse_init),
(gst_au_parse_reset), (gst_au_parse_add_srcpad),
(gst_au_parse_remove_srcpad), (gst_au_parse_parse_header),
(gst_au_parse_chain), (gst_au_parse_src_convert),
(gst_au_parse_src_query), (gst_au_parse_handle_seek),
(gst_au_parse_sink_event), (gst_au_parse_src_event),
(gst_au_parse_change_state):
* gst/auparse/gstauparse.h:
Rewrite auparse to suck a little bit less: make source pad
dynamic, so decodebin/playbin work with non-raw formats
like alaw/mulaw; add query function for duration/position
queries; check whether we have enough data before attempting
to parse the header (instead of crashing when that is not the
case); work around audioconvert sucking by swapping endianness
to the native endianness ourselves for float formats; send
initial newsegment event. Fixes #161712.
2006-04-26 17:08:24 +00:00
|
|
|
g_assert (head != NULL);
|
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (auparse, "[%c%c%c%c]", head[0], head[1], head[2], head[3]);
|
|
|
|
|
|
|
|
switch (GST_READ_UINT32_BE (head)) {
|
|
|
|
/* normal format is big endian (au is a Sparc format) */
|
|
|
|
case 0x2e736e64:{ /* ".snd" */
|
2011-08-19 12:01:45 +00:00
|
|
|
endianness = G_BIG_ENDIAN;
|
gst/auparse/gstauparse.*: Rewrite auparse to suck a little bit less: make source pad dynamic, so decodebin/playbin wo...
Original commit message from CVS:
* gst/auparse/gstauparse.c: (gst_au_parse_base_init),
(gst_au_parse_class_init), (gst_au_parse_init),
(gst_au_parse_reset), (gst_au_parse_add_srcpad),
(gst_au_parse_remove_srcpad), (gst_au_parse_parse_header),
(gst_au_parse_chain), (gst_au_parse_src_convert),
(gst_au_parse_src_query), (gst_au_parse_handle_seek),
(gst_au_parse_sink_event), (gst_au_parse_src_event),
(gst_au_parse_change_state):
* gst/auparse/gstauparse.h:
Rewrite auparse to suck a little bit less: make source pad
dynamic, so decodebin/playbin work with non-raw formats
like alaw/mulaw; add query function for duration/position
queries; check whether we have enough data before attempting
to parse the header (instead of crashing when that is not the
case); work around audioconvert sucking by swapping endianness
to the native endianness ourselves for float formats; send
initial newsegment event. Fixes #161712.
2006-04-26 17:08:24 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
/* and of course, someone had to invent a little endian
|
|
|
|
* version. Used by DEC systems. */
|
|
|
|
case 0x646e732e: /* dns. */
|
|
|
|
case 0x0064732e:{ /* other source say it is "dns." */
|
2011-08-19 12:01:45 +00:00
|
|
|
endianness = G_LITTLE_ENDIAN;
|
gst/auparse/gstauparse.*: Rewrite auparse to suck a little bit less: make source pad dynamic, so decodebin/playbin wo...
Original commit message from CVS:
* gst/auparse/gstauparse.c: (gst_au_parse_base_init),
(gst_au_parse_class_init), (gst_au_parse_init),
(gst_au_parse_reset), (gst_au_parse_add_srcpad),
(gst_au_parse_remove_srcpad), (gst_au_parse_parse_header),
(gst_au_parse_chain), (gst_au_parse_src_convert),
(gst_au_parse_src_query), (gst_au_parse_handle_seek),
(gst_au_parse_sink_event), (gst_au_parse_src_event),
(gst_au_parse_change_state):
* gst/auparse/gstauparse.h:
Rewrite auparse to suck a little bit less: make source pad
dynamic, so decodebin/playbin work with non-raw formats
like alaw/mulaw; add query function for duration/position
queries; check whether we have enough data before attempting
to parse the header (instead of crashing when that is not the
case); work around audioconvert sucking by swapping endianness
to the native endianness ourselves for float formats; send
initial newsegment event. Fixes #161712.
2006-04-26 17:08:24 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:{
|
|
|
|
goto unknown_header;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
auparse->offset = GST_READ_UINT32_BE (head + 4);
|
2011-04-20 19:25:58 +00:00
|
|
|
/* Do not trust size, could be set to -1 : unknown
|
|
|
|
* otherwise: filesize = size + auparse->offset
|
|
|
|
*/
|
gst/auparse/gstauparse.*: Rewrite auparse to suck a little bit less: make source pad dynamic, so decodebin/playbin wo...
Original commit message from CVS:
* gst/auparse/gstauparse.c: (gst_au_parse_base_init),
(gst_au_parse_class_init), (gst_au_parse_init),
(gst_au_parse_reset), (gst_au_parse_add_srcpad),
(gst_au_parse_remove_srcpad), (gst_au_parse_parse_header),
(gst_au_parse_chain), (gst_au_parse_src_convert),
(gst_au_parse_src_query), (gst_au_parse_handle_seek),
(gst_au_parse_sink_event), (gst_au_parse_src_event),
(gst_au_parse_change_state):
* gst/auparse/gstauparse.h:
Rewrite auparse to suck a little bit less: make source pad
dynamic, so decodebin/playbin work with non-raw formats
like alaw/mulaw; add query function for duration/position
queries; check whether we have enough data before attempting
to parse the header (instead of crashing when that is not the
case); work around audioconvert sucking by swapping endianness
to the native endianness ourselves for float formats; send
initial newsegment event. Fixes #161712.
2006-04-26 17:08:24 +00:00
|
|
|
size = GST_READ_UINT32_BE (head + 8);
|
|
|
|
auparse->encoding = GST_READ_UINT32_BE (head + 12);
|
|
|
|
auparse->samplerate = GST_READ_UINT32_BE (head + 16);
|
|
|
|
auparse->channels = GST_READ_UINT32_BE (head + 20);
|
|
|
|
|
2007-04-10 12:01:33 +00:00
|
|
|
if (auparse->samplerate < 8000 || auparse->samplerate > 192000)
|
|
|
|
goto unsupported_sample_rate;
|
|
|
|
|
|
|
|
if (auparse->channels < 1 || auparse->channels > 2)
|
|
|
|
goto unsupported_number_of_channels;
|
|
|
|
|
2006-10-05 16:37:33 +00:00
|
|
|
GST_DEBUG_OBJECT (auparse, "offset %" G_GINT64_FORMAT ", size %u, "
|
|
|
|
"encoding %u, frequency %u, channels %u", auparse->offset, size,
|
gst/auparse/gstauparse.*: Rewrite auparse to suck a little bit less: make source pad dynamic, so decodebin/playbin wo...
Original commit message from CVS:
* gst/auparse/gstauparse.c: (gst_au_parse_base_init),
(gst_au_parse_class_init), (gst_au_parse_init),
(gst_au_parse_reset), (gst_au_parse_add_srcpad),
(gst_au_parse_remove_srcpad), (gst_au_parse_parse_header),
(gst_au_parse_chain), (gst_au_parse_src_convert),
(gst_au_parse_src_query), (gst_au_parse_handle_seek),
(gst_au_parse_sink_event), (gst_au_parse_src_event),
(gst_au_parse_change_state):
* gst/auparse/gstauparse.h:
Rewrite auparse to suck a little bit less: make source pad
dynamic, so decodebin/playbin work with non-raw formats
like alaw/mulaw; add query function for duration/position
queries; check whether we have enough data before attempting
to parse the header (instead of crashing when that is not the
case); work around audioconvert sucking by swapping endianness
to the native endianness ourselves for float formats; send
initial newsegment event. Fixes #161712.
2006-04-26 17:08:24 +00:00
|
|
|
auparse->encoding, auparse->samplerate, auparse->channels);
|
|
|
|
|
|
|
|
/* Docs:
|
|
|
|
* http://www.opengroup.org/public/pubs/external/auformat.html
|
|
|
|
* http://astronomy.swin.edu.au/~pbourke/dataformats/au/
|
|
|
|
* Solaris headers : /usr/include/audio/au.h
|
|
|
|
* libsndfile : src/au.c
|
|
|
|
*
|
|
|
|
* Samples :
|
|
|
|
* http://www.tsp.ece.mcgill.ca/MMSP/Documents/AudioFormats/AU/Samples.html
|
|
|
|
*/
|
|
|
|
|
|
|
|
switch (auparse->encoding) {
|
|
|
|
case 1: /* 8-bit ISDN mu-law G.711 */
|
|
|
|
law = 1;
|
|
|
|
break;
|
|
|
|
case 27: /* 8-bit ISDN A-law G.711 */
|
|
|
|
law = 2;
|
|
|
|
break;
|
|
|
|
|
2011-08-19 12:01:45 +00:00
|
|
|
case 2: /* 8-bit linear PCM, FIXME signed? */
|
|
|
|
format = GST_AUDIO_FORMAT_S8;
|
|
|
|
auparse->sample_size = auparse->channels;
|
gst/auparse/gstauparse.*: Rewrite auparse to suck a little bit less: make source pad dynamic, so decodebin/playbin wo...
Original commit message from CVS:
* gst/auparse/gstauparse.c: (gst_au_parse_base_init),
(gst_au_parse_class_init), (gst_au_parse_init),
(gst_au_parse_reset), (gst_au_parse_add_srcpad),
(gst_au_parse_remove_srcpad), (gst_au_parse_parse_header),
(gst_au_parse_chain), (gst_au_parse_src_convert),
(gst_au_parse_src_query), (gst_au_parse_handle_seek),
(gst_au_parse_sink_event), (gst_au_parse_src_event),
(gst_au_parse_change_state):
* gst/auparse/gstauparse.h:
Rewrite auparse to suck a little bit less: make source pad
dynamic, so decodebin/playbin work with non-raw formats
like alaw/mulaw; add query function for duration/position
queries; check whether we have enough data before attempting
to parse the header (instead of crashing when that is not the
case); work around audioconvert sucking by swapping endianness
to the native endianness ourselves for float formats; send
initial newsegment event. Fixes #161712.
2006-04-26 17:08:24 +00:00
|
|
|
break;
|
|
|
|
case 3: /* 16-bit linear PCM */
|
2011-08-19 12:01:45 +00:00
|
|
|
if (endianness == G_LITTLE_ENDIAN)
|
2011-09-06 11:16:27 +00:00
|
|
|
format = GST_AUDIO_FORMAT_S16LE;
|
2011-08-19 12:01:45 +00:00
|
|
|
else
|
2011-09-06 11:16:27 +00:00
|
|
|
format = GST_AUDIO_FORMAT_S16BE;
|
2011-08-19 12:01:45 +00:00
|
|
|
auparse->sample_size = auparse->channels * 2;
|
gst/auparse/gstauparse.*: Rewrite auparse to suck a little bit less: make source pad dynamic, so decodebin/playbin wo...
Original commit message from CVS:
* gst/auparse/gstauparse.c: (gst_au_parse_base_init),
(gst_au_parse_class_init), (gst_au_parse_init),
(gst_au_parse_reset), (gst_au_parse_add_srcpad),
(gst_au_parse_remove_srcpad), (gst_au_parse_parse_header),
(gst_au_parse_chain), (gst_au_parse_src_convert),
(gst_au_parse_src_query), (gst_au_parse_handle_seek),
(gst_au_parse_sink_event), (gst_au_parse_src_event),
(gst_au_parse_change_state):
* gst/auparse/gstauparse.h:
Rewrite auparse to suck a little bit less: make source pad
dynamic, so decodebin/playbin work with non-raw formats
like alaw/mulaw; add query function for duration/position
queries; check whether we have enough data before attempting
to parse the header (instead of crashing when that is not the
case); work around audioconvert sucking by swapping endianness
to the native endianness ourselves for float formats; send
initial newsegment event. Fixes #161712.
2006-04-26 17:08:24 +00:00
|
|
|
break;
|
|
|
|
case 4: /* 24-bit linear PCM */
|
2011-08-19 12:01:45 +00:00
|
|
|
if (endianness == G_LITTLE_ENDIAN)
|
2011-09-06 11:16:27 +00:00
|
|
|
format = GST_AUDIO_FORMAT_S24LE;
|
2011-08-19 12:01:45 +00:00
|
|
|
else
|
2011-09-06 11:16:27 +00:00
|
|
|
format = GST_AUDIO_FORMAT_S24BE;
|
2011-08-19 12:01:45 +00:00
|
|
|
auparse->sample_size = auparse->channels * 3;
|
gst/auparse/gstauparse.*: Rewrite auparse to suck a little bit less: make source pad dynamic, so decodebin/playbin wo...
Original commit message from CVS:
* gst/auparse/gstauparse.c: (gst_au_parse_base_init),
(gst_au_parse_class_init), (gst_au_parse_init),
(gst_au_parse_reset), (gst_au_parse_add_srcpad),
(gst_au_parse_remove_srcpad), (gst_au_parse_parse_header),
(gst_au_parse_chain), (gst_au_parse_src_convert),
(gst_au_parse_src_query), (gst_au_parse_handle_seek),
(gst_au_parse_sink_event), (gst_au_parse_src_event),
(gst_au_parse_change_state):
* gst/auparse/gstauparse.h:
Rewrite auparse to suck a little bit less: make source pad
dynamic, so decodebin/playbin work with non-raw formats
like alaw/mulaw; add query function for duration/position
queries; check whether we have enough data before attempting
to parse the header (instead of crashing when that is not the
case); work around audioconvert sucking by swapping endianness
to the native endianness ourselves for float formats; send
initial newsegment event. Fixes #161712.
2006-04-26 17:08:24 +00:00
|
|
|
break;
|
|
|
|
case 5: /* 32-bit linear PCM */
|
2011-08-19 12:01:45 +00:00
|
|
|
if (endianness == G_LITTLE_ENDIAN)
|
2011-09-06 11:16:27 +00:00
|
|
|
format = GST_AUDIO_FORMAT_S32LE;
|
2011-08-19 12:01:45 +00:00
|
|
|
else
|
2011-09-06 11:16:27 +00:00
|
|
|
format = GST_AUDIO_FORMAT_S32BE;
|
2011-08-19 12:01:45 +00:00
|
|
|
auparse->sample_size = auparse->channels * 4;
|
gst/auparse/gstauparse.*: Rewrite auparse to suck a little bit less: make source pad dynamic, so decodebin/playbin wo...
Original commit message from CVS:
* gst/auparse/gstauparse.c: (gst_au_parse_base_init),
(gst_au_parse_class_init), (gst_au_parse_init),
(gst_au_parse_reset), (gst_au_parse_add_srcpad),
(gst_au_parse_remove_srcpad), (gst_au_parse_parse_header),
(gst_au_parse_chain), (gst_au_parse_src_convert),
(gst_au_parse_src_query), (gst_au_parse_handle_seek),
(gst_au_parse_sink_event), (gst_au_parse_src_event),
(gst_au_parse_change_state):
* gst/auparse/gstauparse.h:
Rewrite auparse to suck a little bit less: make source pad
dynamic, so decodebin/playbin work with non-raw formats
like alaw/mulaw; add query function for duration/position
queries; check whether we have enough data before attempting
to parse the header (instead of crashing when that is not the
case); work around audioconvert sucking by swapping endianness
to the native endianness ourselves for float formats; send
initial newsegment event. Fixes #161712.
2006-04-26 17:08:24 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 6: /* 32-bit IEEE floating point */
|
2011-08-19 12:01:45 +00:00
|
|
|
if (endianness == G_LITTLE_ENDIAN)
|
2011-09-06 11:16:27 +00:00
|
|
|
format = GST_AUDIO_FORMAT_F32LE;
|
2011-08-19 12:01:45 +00:00
|
|
|
else
|
2011-09-06 11:16:27 +00:00
|
|
|
format = GST_AUDIO_FORMAT_F32BE;
|
2011-08-19 12:01:45 +00:00
|
|
|
auparse->sample_size = auparse->channels * 4;
|
gst/auparse/gstauparse.*: Rewrite auparse to suck a little bit less: make source pad dynamic, so decodebin/playbin wo...
Original commit message from CVS:
* gst/auparse/gstauparse.c: (gst_au_parse_base_init),
(gst_au_parse_class_init), (gst_au_parse_init),
(gst_au_parse_reset), (gst_au_parse_add_srcpad),
(gst_au_parse_remove_srcpad), (gst_au_parse_parse_header),
(gst_au_parse_chain), (gst_au_parse_src_convert),
(gst_au_parse_src_query), (gst_au_parse_handle_seek),
(gst_au_parse_sink_event), (gst_au_parse_src_event),
(gst_au_parse_change_state):
* gst/auparse/gstauparse.h:
Rewrite auparse to suck a little bit less: make source pad
dynamic, so decodebin/playbin work with non-raw formats
like alaw/mulaw; add query function for duration/position
queries; check whether we have enough data before attempting
to parse the header (instead of crashing when that is not the
case); work around audioconvert sucking by swapping endianness
to the native endianness ourselves for float formats; send
initial newsegment event. Fixes #161712.
2006-04-26 17:08:24 +00:00
|
|
|
break;
|
|
|
|
case 7: /* 64-bit IEEE floating point */
|
2011-08-19 12:01:45 +00:00
|
|
|
if (endianness == G_LITTLE_ENDIAN)
|
2011-09-06 11:16:27 +00:00
|
|
|
format = GST_AUDIO_FORMAT_F64LE;
|
2011-08-19 12:01:45 +00:00
|
|
|
else
|
2011-09-06 11:16:27 +00:00
|
|
|
format = GST_AUDIO_FORMAT_F64BE;
|
2011-08-19 12:01:45 +00:00
|
|
|
auparse->sample_size = auparse->channels * 8;
|
gst/auparse/gstauparse.*: Rewrite auparse to suck a little bit less: make source pad dynamic, so decodebin/playbin wo...
Original commit message from CVS:
* gst/auparse/gstauparse.c: (gst_au_parse_base_init),
(gst_au_parse_class_init), (gst_au_parse_init),
(gst_au_parse_reset), (gst_au_parse_add_srcpad),
(gst_au_parse_remove_srcpad), (gst_au_parse_parse_header),
(gst_au_parse_chain), (gst_au_parse_src_convert),
(gst_au_parse_src_query), (gst_au_parse_handle_seek),
(gst_au_parse_sink_event), (gst_au_parse_src_event),
(gst_au_parse_change_state):
* gst/auparse/gstauparse.h:
Rewrite auparse to suck a little bit less: make source pad
dynamic, so decodebin/playbin work with non-raw formats
like alaw/mulaw; add query function for duration/position
queries; check whether we have enough data before attempting
to parse the header (instead of crashing when that is not the
case); work around audioconvert sucking by swapping endianness
to the native endianness ourselves for float formats; send
initial newsegment event. Fixes #161712.
2006-04-26 17:08:24 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 23: /* 4-bit CCITT G.721 ADPCM 32kbps -> modplug/libsndfile (compressed 8-bit mu-law) */
|
|
|
|
strcpy (layout, "g721");
|
|
|
|
break;
|
|
|
|
case 24: /* 8-bit CCITT G.722 ADPCM -> rtp */
|
|
|
|
strcpy (layout, "g722");
|
|
|
|
break;
|
|
|
|
case 25: /* 3-bit CCITT G.723.3 ADPCM 24kbps -> rtp/xine/modplug/libsndfile */
|
|
|
|
strcpy (layout, "g723_3");
|
|
|
|
break;
|
|
|
|
case 26: /* 5-bit CCITT G.723.5 ADPCM 40kbps -> rtp/xine/modplug/libsndfile */
|
|
|
|
strcpy (layout, "g723_5");
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 8: /* Fragmented sample data */
|
|
|
|
case 9: /* AU_ENCODING_NESTED */
|
|
|
|
|
|
|
|
case 10: /* DSP program */
|
|
|
|
case 11: /* DSP 8-bit fixed point */
|
|
|
|
case 12: /* DSP 16-bit fixed point */
|
|
|
|
case 13: /* DSP 24-bit fixed point */
|
|
|
|
case 14: /* DSP 32-bit fixed point */
|
|
|
|
|
|
|
|
case 16: /* AU_ENCODING_DISPLAY : non-audio display data */
|
|
|
|
case 17: /* AU_ENCODING_MULAW_SQUELCH */
|
|
|
|
|
|
|
|
case 18: /* 16-bit linear with emphasis */
|
|
|
|
case 19: /* 16-bit linear compressed (NeXT) */
|
|
|
|
case 20: /* 16-bit linear with emphasis and compression */
|
|
|
|
|
|
|
|
case 21: /* Music kit DSP commands */
|
|
|
|
case 22: /* Music kit DSP commands samples */
|
|
|
|
|
|
|
|
default:
|
|
|
|
goto unknown_format;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (law) {
|
|
|
|
tempcaps =
|
|
|
|
gst_caps_new_simple ((law == 1) ? "audio/x-mulaw" : "audio/x-alaw",
|
|
|
|
"rate", G_TYPE_INT, auparse->samplerate,
|
|
|
|
"channels", G_TYPE_INT, auparse->channels, NULL);
|
|
|
|
auparse->sample_size = auparse->channels;
|
2011-08-19 12:01:45 +00:00
|
|
|
} else if (format != GST_AUDIO_FORMAT_UNKNOWN) {
|
2012-03-10 09:51:44 +00:00
|
|
|
GstCaps *templ_caps = gst_pad_get_pad_template_caps (auparse->srcpad);
|
2012-01-04 10:06:28 +00:00
|
|
|
GstCaps *intersection;
|
|
|
|
|
2011-08-19 12:01:45 +00:00
|
|
|
tempcaps = gst_caps_new_simple ("audio/x-raw",
|
|
|
|
"format", G_TYPE_STRING, gst_audio_format_to_string (format),
|
gst/auparse/gstauparse.*: Rewrite auparse to suck a little bit less: make source pad dynamic, so decodebin/playbin wo...
Original commit message from CVS:
* gst/auparse/gstauparse.c: (gst_au_parse_base_init),
(gst_au_parse_class_init), (gst_au_parse_init),
(gst_au_parse_reset), (gst_au_parse_add_srcpad),
(gst_au_parse_remove_srcpad), (gst_au_parse_parse_header),
(gst_au_parse_chain), (gst_au_parse_src_convert),
(gst_au_parse_src_query), (gst_au_parse_handle_seek),
(gst_au_parse_sink_event), (gst_au_parse_src_event),
(gst_au_parse_change_state):
* gst/auparse/gstauparse.h:
Rewrite auparse to suck a little bit less: make source pad
dynamic, so decodebin/playbin work with non-raw formats
like alaw/mulaw; add query function for duration/position
queries; check whether we have enough data before attempting
to parse the header (instead of crashing when that is not the
case); work around audioconvert sucking by swapping endianness
to the native endianness ourselves for float formats; send
initial newsegment event. Fixes #161712.
2006-04-26 17:08:24 +00:00
|
|
|
"rate", G_TYPE_INT, auparse->samplerate,
|
2011-08-19 12:01:45 +00:00
|
|
|
"channels", G_TYPE_INT, auparse->channels, NULL);
|
2012-01-04 10:06:28 +00:00
|
|
|
|
|
|
|
intersection = gst_caps_intersect (tempcaps, templ_caps);
|
|
|
|
gst_caps_unref (tempcaps);
|
2012-03-10 09:51:44 +00:00
|
|
|
gst_caps_unref (templ_caps);
|
2012-01-04 10:06:28 +00:00
|
|
|
tempcaps = intersection;
|
gst/auparse/gstauparse.*: Rewrite auparse to suck a little bit less: make source pad dynamic, so decodebin/playbin wo...
Original commit message from CVS:
* gst/auparse/gstauparse.c: (gst_au_parse_base_init),
(gst_au_parse_class_init), (gst_au_parse_init),
(gst_au_parse_reset), (gst_au_parse_add_srcpad),
(gst_au_parse_remove_srcpad), (gst_au_parse_parse_header),
(gst_au_parse_chain), (gst_au_parse_src_convert),
(gst_au_parse_src_query), (gst_au_parse_handle_seek),
(gst_au_parse_sink_event), (gst_au_parse_src_event),
(gst_au_parse_change_state):
* gst/auparse/gstauparse.h:
Rewrite auparse to suck a little bit less: make source pad
dynamic, so decodebin/playbin work with non-raw formats
like alaw/mulaw; add query function for duration/position
queries; check whether we have enough data before attempting
to parse the header (instead of crashing when that is not the
case); work around audioconvert sucking by swapping endianness
to the native endianness ourselves for float formats; send
initial newsegment event. Fixes #161712.
2006-04-26 17:08:24 +00:00
|
|
|
} else if (layout[0]) {
|
|
|
|
tempcaps = gst_caps_new_simple ("audio/x-adpcm",
|
|
|
|
"layout", G_TYPE_STRING, layout, NULL);
|
|
|
|
auparse->sample_size = 0;
|
2011-08-19 12:01:45 +00:00
|
|
|
} else
|
|
|
|
goto unknown_format;
|
gst/auparse/gstauparse.*: Rewrite auparse to suck a little bit less: make source pad dynamic, so decodebin/playbin wo...
Original commit message from CVS:
* gst/auparse/gstauparse.c: (gst_au_parse_base_init),
(gst_au_parse_class_init), (gst_au_parse_init),
(gst_au_parse_reset), (gst_au_parse_add_srcpad),
(gst_au_parse_remove_srcpad), (gst_au_parse_parse_header),
(gst_au_parse_chain), (gst_au_parse_src_convert),
(gst_au_parse_src_query), (gst_au_parse_handle_seek),
(gst_au_parse_sink_event), (gst_au_parse_src_event),
(gst_au_parse_change_state):
* gst/auparse/gstauparse.h:
Rewrite auparse to suck a little bit less: make source pad
dynamic, so decodebin/playbin work with non-raw formats
like alaw/mulaw; add query function for duration/position
queries; check whether we have enough data before attempting
to parse the header (instead of crashing when that is not the
case); work around audioconvert sucking by swapping endianness
to the native endianness ourselves for float formats; send
initial newsegment event. Fixes #161712.
2006-04-26 17:08:24 +00:00
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (auparse, "sample_size=%d", auparse->sample_size);
|
|
|
|
|
2011-07-07 09:22:26 +00:00
|
|
|
gst_au_parse_negotiate_srcpad (auparse, tempcaps);
|
gst/auparse/gstauparse.*: Rewrite auparse to suck a little bit less: make source pad dynamic, so decodebin/playbin wo...
Original commit message from CVS:
* gst/auparse/gstauparse.c: (gst_au_parse_base_init),
(gst_au_parse_class_init), (gst_au_parse_init),
(gst_au_parse_reset), (gst_au_parse_add_srcpad),
(gst_au_parse_remove_srcpad), (gst_au_parse_parse_header),
(gst_au_parse_chain), (gst_au_parse_src_convert),
(gst_au_parse_src_query), (gst_au_parse_handle_seek),
(gst_au_parse_sink_event), (gst_au_parse_src_event),
(gst_au_parse_change_state):
* gst/auparse/gstauparse.h:
Rewrite auparse to suck a little bit less: make source pad
dynamic, so decodebin/playbin work with non-raw formats
like alaw/mulaw; add query function for duration/position
queries; check whether we have enough data before attempting
to parse the header (instead of crashing when that is not the
case); work around audioconvert sucking by swapping endianness
to the native endianness ourselves for float formats; send
initial newsegment event. Fixes #161712.
2006-04-26 17:08:24 +00:00
|
|
|
|
2006-10-05 16:37:33 +00:00
|
|
|
GST_DEBUG_OBJECT (auparse, "offset=%" G_GINT64_FORMAT, auparse->offset);
|
2011-11-10 17:32:58 +00:00
|
|
|
gst_adapter_unmap (auparse->adapter);
|
|
|
|
gst_adapter_flush (auparse->adapter, auparse->offset);
|
gst/auparse/gstauparse.*: Rewrite auparse to suck a little bit less: make source pad dynamic, so decodebin/playbin wo...
Original commit message from CVS:
* gst/auparse/gstauparse.c: (gst_au_parse_base_init),
(gst_au_parse_class_init), (gst_au_parse_init),
(gst_au_parse_reset), (gst_au_parse_add_srcpad),
(gst_au_parse_remove_srcpad), (gst_au_parse_parse_header),
(gst_au_parse_chain), (gst_au_parse_src_convert),
(gst_au_parse_src_query), (gst_au_parse_handle_seek),
(gst_au_parse_sink_event), (gst_au_parse_src_event),
(gst_au_parse_change_state):
* gst/auparse/gstauparse.h:
Rewrite auparse to suck a little bit less: make source pad
dynamic, so decodebin/playbin work with non-raw formats
like alaw/mulaw; add query function for duration/position
queries; check whether we have enough data before attempting
to parse the header (instead of crashing when that is not the
case); work around audioconvert sucking by swapping endianness
to the native endianness ourselves for float formats; send
initial newsegment event. Fixes #161712.
2006-04-26 17:08:24 +00:00
|
|
|
|
|
|
|
gst_caps_unref (tempcaps);
|
|
|
|
return GST_FLOW_OK;
|
|
|
|
|
|
|
|
/* ERRORS */
|
|
|
|
unknown_header:
|
|
|
|
{
|
2011-11-10 17:32:58 +00:00
|
|
|
gst_adapter_unmap (auparse->adapter);
|
gst/auparse/gstauparse.*: Rewrite auparse to suck a little bit less: make source pad dynamic, so decodebin/playbin wo...
Original commit message from CVS:
* gst/auparse/gstauparse.c: (gst_au_parse_base_init),
(gst_au_parse_class_init), (gst_au_parse_init),
(gst_au_parse_reset), (gst_au_parse_add_srcpad),
(gst_au_parse_remove_srcpad), (gst_au_parse_parse_header),
(gst_au_parse_chain), (gst_au_parse_src_convert),
(gst_au_parse_src_query), (gst_au_parse_handle_seek),
(gst_au_parse_sink_event), (gst_au_parse_src_event),
(gst_au_parse_change_state):
* gst/auparse/gstauparse.h:
Rewrite auparse to suck a little bit less: make source pad
dynamic, so decodebin/playbin work with non-raw formats
like alaw/mulaw; add query function for duration/position
queries; check whether we have enough data before attempting
to parse the header (instead of crashing when that is not the
case); work around audioconvert sucking by swapping endianness
to the native endianness ourselves for float formats; send
initial newsegment event. Fixes #161712.
2006-04-26 17:08:24 +00:00
|
|
|
GST_ELEMENT_ERROR (auparse, STREAM, WRONG_TYPE, (NULL), (NULL));
|
|
|
|
return GST_FLOW_ERROR;
|
|
|
|
}
|
2007-04-10 12:01:33 +00:00
|
|
|
unsupported_sample_rate:
|
|
|
|
{
|
2011-11-10 17:32:58 +00:00
|
|
|
gst_adapter_unmap (auparse->adapter);
|
2007-04-10 12:01:33 +00:00
|
|
|
GST_ELEMENT_ERROR (auparse, STREAM, FORMAT, (NULL),
|
|
|
|
("Unsupported samplerate: %u", auparse->samplerate));
|
|
|
|
return GST_FLOW_ERROR;
|
|
|
|
}
|
|
|
|
unsupported_number_of_channels:
|
|
|
|
{
|
2011-11-10 17:32:58 +00:00
|
|
|
gst_adapter_unmap (auparse->adapter);
|
2007-04-10 12:01:33 +00:00
|
|
|
GST_ELEMENT_ERROR (auparse, STREAM, FORMAT, (NULL),
|
|
|
|
("Unsupported number of channels: %u", auparse->channels));
|
|
|
|
return GST_FLOW_ERROR;
|
|
|
|
}
|
gst/auparse/gstauparse.*: Rewrite auparse to suck a little bit less: make source pad dynamic, so decodebin/playbin wo...
Original commit message from CVS:
* gst/auparse/gstauparse.c: (gst_au_parse_base_init),
(gst_au_parse_class_init), (gst_au_parse_init),
(gst_au_parse_reset), (gst_au_parse_add_srcpad),
(gst_au_parse_remove_srcpad), (gst_au_parse_parse_header),
(gst_au_parse_chain), (gst_au_parse_src_convert),
(gst_au_parse_src_query), (gst_au_parse_handle_seek),
(gst_au_parse_sink_event), (gst_au_parse_src_event),
(gst_au_parse_change_state):
* gst/auparse/gstauparse.h:
Rewrite auparse to suck a little bit less: make source pad
dynamic, so decodebin/playbin work with non-raw formats
like alaw/mulaw; add query function for duration/position
queries; check whether we have enough data before attempting
to parse the header (instead of crashing when that is not the
case); work around audioconvert sucking by swapping endianness
to the native endianness ourselves for float formats; send
initial newsegment event. Fixes #161712.
2006-04-26 17:08:24 +00:00
|
|
|
unknown_format:
|
|
|
|
{
|
2011-11-10 17:32:58 +00:00
|
|
|
gst_adapter_unmap (auparse->adapter);
|
2007-04-10 12:01:33 +00:00
|
|
|
GST_ELEMENT_ERROR (auparse, STREAM, FORMAT, (NULL),
|
|
|
|
("Unsupported encoding: %u", auparse->encoding));
|
gst/auparse/gstauparse.*: Rewrite auparse to suck a little bit less: make source pad dynamic, so decodebin/playbin wo...
Original commit message from CVS:
* gst/auparse/gstauparse.c: (gst_au_parse_base_init),
(gst_au_parse_class_init), (gst_au_parse_init),
(gst_au_parse_reset), (gst_au_parse_add_srcpad),
(gst_au_parse_remove_srcpad), (gst_au_parse_parse_header),
(gst_au_parse_chain), (gst_au_parse_src_convert),
(gst_au_parse_src_query), (gst_au_parse_handle_seek),
(gst_au_parse_sink_event), (gst_au_parse_src_event),
(gst_au_parse_change_state):
* gst/auparse/gstauparse.h:
Rewrite auparse to suck a little bit less: make source pad
dynamic, so decodebin/playbin work with non-raw formats
like alaw/mulaw; add query function for duration/position
queries; check whether we have enough data before attempting
to parse the header (instead of crashing when that is not the
case); work around audioconvert sucking by swapping endianness
to the native endianness ourselves for float formats; send
initial newsegment event. Fixes #161712.
2006-04-26 17:08:24 +00:00
|
|
|
return GST_FLOW_ERROR;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#define AU_HEADER_SIZE 24
|
|
|
|
|
|
|
|
static GstFlowReturn
|
2011-11-17 14:02:55 +00:00
|
|
|
gst_au_parse_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
|
gst/auparse/gstauparse.*: Rewrite auparse to suck a little bit less: make source pad dynamic, so decodebin/playbin wo...
Original commit message from CVS:
* gst/auparse/gstauparse.c: (gst_au_parse_base_init),
(gst_au_parse_class_init), (gst_au_parse_init),
(gst_au_parse_reset), (gst_au_parse_add_srcpad),
(gst_au_parse_remove_srcpad), (gst_au_parse_parse_header),
(gst_au_parse_chain), (gst_au_parse_src_convert),
(gst_au_parse_src_query), (gst_au_parse_handle_seek),
(gst_au_parse_sink_event), (gst_au_parse_src_event),
(gst_au_parse_change_state):
* gst/auparse/gstauparse.h:
Rewrite auparse to suck a little bit less: make source pad
dynamic, so decodebin/playbin work with non-raw formats
like alaw/mulaw; add query function for duration/position
queries; check whether we have enough data before attempting
to parse the header (instead of crashing when that is not the
case); work around audioconvert sucking by swapping endianness
to the native endianness ourselves for float formats; send
initial newsegment event. Fixes #161712.
2006-04-26 17:08:24 +00:00
|
|
|
{
|
|
|
|
GstFlowReturn ret = GST_FLOW_OK;
|
|
|
|
GstAuParse *auparse;
|
|
|
|
gint avail, sendnow = 0;
|
2011-04-20 19:25:58 +00:00
|
|
|
gint64 timestamp;
|
|
|
|
gint64 duration;
|
|
|
|
gint64 offset;
|
2011-07-07 09:14:16 +00:00
|
|
|
GstSegment segment;
|
2001-12-22 23:22:05 +00:00
|
|
|
|
2011-11-17 14:02:55 +00:00
|
|
|
auparse = GST_AU_PARSE (parent);
|
2001-12-22 23:22:05 +00:00
|
|
|
|
2011-11-21 19:31:31 +00:00
|
|
|
GST_LOG_OBJECT (auparse, "got buffer of size %" G_GSIZE_FORMAT,
|
|
|
|
gst_buffer_get_size (buf));
|
2001-12-22 23:22:05 +00:00
|
|
|
|
gst/auparse/gstauparse.*: Rewrite auparse to suck a little bit less: make source pad dynamic, so decodebin/playbin wo...
Original commit message from CVS:
* gst/auparse/gstauparse.c: (gst_au_parse_base_init),
(gst_au_parse_class_init), (gst_au_parse_init),
(gst_au_parse_reset), (gst_au_parse_add_srcpad),
(gst_au_parse_remove_srcpad), (gst_au_parse_parse_header),
(gst_au_parse_chain), (gst_au_parse_src_convert),
(gst_au_parse_src_query), (gst_au_parse_handle_seek),
(gst_au_parse_sink_event), (gst_au_parse_src_event),
(gst_au_parse_change_state):
* gst/auparse/gstauparse.h:
Rewrite auparse to suck a little bit less: make source pad
dynamic, so decodebin/playbin work with non-raw formats
like alaw/mulaw; add query function for duration/position
queries; check whether we have enough data before attempting
to parse the header (instead of crashing when that is not the
case); work around audioconvert sucking by swapping endianness
to the native endianness ourselves for float formats; send
initial newsegment event. Fixes #161712.
2006-04-26 17:08:24 +00:00
|
|
|
gst_adapter_push (auparse->adapter, buf);
|
|
|
|
buf = NULL;
|
2005-12-12 10:30:20 +00:00
|
|
|
|
2001-12-22 23:22:05 +00:00
|
|
|
/* if we haven't seen any data yet... */
|
2011-07-07 09:22:26 +00:00
|
|
|
if (!gst_pad_has_current_caps (auparse->srcpad)) {
|
gst/auparse/gstauparse.*: Rewrite auparse to suck a little bit less: make source pad dynamic, so decodebin/playbin wo...
Original commit message from CVS:
* gst/auparse/gstauparse.c: (gst_au_parse_base_init),
(gst_au_parse_class_init), (gst_au_parse_init),
(gst_au_parse_reset), (gst_au_parse_add_srcpad),
(gst_au_parse_remove_srcpad), (gst_au_parse_parse_header),
(gst_au_parse_chain), (gst_au_parse_src_convert),
(gst_au_parse_src_query), (gst_au_parse_handle_seek),
(gst_au_parse_sink_event), (gst_au_parse_src_event),
(gst_au_parse_change_state):
* gst/auparse/gstauparse.h:
Rewrite auparse to suck a little bit less: make source pad
dynamic, so decodebin/playbin work with non-raw formats
like alaw/mulaw; add query function for duration/position
queries; check whether we have enough data before attempting
to parse the header (instead of crashing when that is not the
case); work around audioconvert sucking by swapping endianness
to the native endianness ourselves for float formats; send
initial newsegment event. Fixes #161712.
2006-04-26 17:08:24 +00:00
|
|
|
if (gst_adapter_available (auparse->adapter) < AU_HEADER_SIZE) {
|
|
|
|
GST_DEBUG_OBJECT (auparse, "need more data to parse header");
|
|
|
|
ret = GST_FLOW_OK;
|
|
|
|
goto out;
|
|
|
|
}
|
2001-12-22 23:22:05 +00:00
|
|
|
|
gst/auparse/gstauparse.*: Rewrite auparse to suck a little bit less: make source pad dynamic, so decodebin/playbin wo...
Original commit message from CVS:
* gst/auparse/gstauparse.c: (gst_au_parse_base_init),
(gst_au_parse_class_init), (gst_au_parse_init),
(gst_au_parse_reset), (gst_au_parse_add_srcpad),
(gst_au_parse_remove_srcpad), (gst_au_parse_parse_header),
(gst_au_parse_chain), (gst_au_parse_src_convert),
(gst_au_parse_src_query), (gst_au_parse_handle_seek),
(gst_au_parse_sink_event), (gst_au_parse_src_event),
(gst_au_parse_change_state):
* gst/auparse/gstauparse.h:
Rewrite auparse to suck a little bit less: make source pad
dynamic, so decodebin/playbin work with non-raw formats
like alaw/mulaw; add query function for duration/position
queries; check whether we have enough data before attempting
to parse the header (instead of crashing when that is not the
case); work around audioconvert sucking by swapping endianness
to the native endianness ourselves for float formats; send
initial newsegment event. Fixes #161712.
2006-04-26 17:08:24 +00:00
|
|
|
ret = gst_au_parse_parse_header (auparse);
|
|
|
|
if (ret != GST_FLOW_OK)
|
|
|
|
goto out;
|
|
|
|
|
2011-07-07 09:14:16 +00:00
|
|
|
gst_segment_init (&segment, GST_FORMAT_TIME);
|
|
|
|
gst_pad_push_event (auparse->srcpad, gst_event_new_segment (&segment));
|
gst/auparse/gstauparse.*: Rewrite auparse to suck a little bit less: make source pad dynamic, so decodebin/playbin wo...
Original commit message from CVS:
* gst/auparse/gstauparse.c: (gst_au_parse_base_init),
(gst_au_parse_class_init), (gst_au_parse_init),
(gst_au_parse_reset), (gst_au_parse_add_srcpad),
(gst_au_parse_remove_srcpad), (gst_au_parse_parse_header),
(gst_au_parse_chain), (gst_au_parse_src_convert),
(gst_au_parse_src_query), (gst_au_parse_handle_seek),
(gst_au_parse_sink_event), (gst_au_parse_src_event),
(gst_au_parse_change_state):
* gst/auparse/gstauparse.h:
Rewrite auparse to suck a little bit less: make source pad
dynamic, so decodebin/playbin work with non-raw formats
like alaw/mulaw; add query function for duration/position
queries; check whether we have enough data before attempting
to parse the header (instead of crashing when that is not the
case); work around audioconvert sucking by swapping endianness
to the native endianness ourselves for float formats; send
initial newsegment event. Fixes #161712.
2006-04-26 17:08:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
avail = gst_adapter_available (auparse->adapter);
|
|
|
|
|
|
|
|
if (auparse->sample_size > 0) {
|
|
|
|
/* Ensure we push a buffer that's a multiple of the frame size downstream */
|
|
|
|
sendnow = avail - (avail % auparse->sample_size);
|
|
|
|
} else {
|
|
|
|
/* It's something non-trivial (such as ADPCM), we don't understand it, so
|
|
|
|
* just push downstream and assume it will know what to do with it */
|
|
|
|
sendnow = avail;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sendnow > 0) {
|
|
|
|
GstBuffer *outbuf;
|
2011-04-20 19:25:58 +00:00
|
|
|
gint64 pos;
|
gst/auparse/gstauparse.*: Rewrite auparse to suck a little bit less: make source pad dynamic, so decodebin/playbin wo...
Original commit message from CVS:
* gst/auparse/gstauparse.c: (gst_au_parse_base_init),
(gst_au_parse_class_init), (gst_au_parse_init),
(gst_au_parse_reset), (gst_au_parse_add_srcpad),
(gst_au_parse_remove_srcpad), (gst_au_parse_parse_header),
(gst_au_parse_chain), (gst_au_parse_src_convert),
(gst_au_parse_src_query), (gst_au_parse_handle_seek),
(gst_au_parse_sink_event), (gst_au_parse_src_event),
(gst_au_parse_change_state):
* gst/auparse/gstauparse.h:
Rewrite auparse to suck a little bit less: make source pad
dynamic, so decodebin/playbin work with non-raw formats
like alaw/mulaw; add query function for duration/position
queries; check whether we have enough data before attempting
to parse the header (instead of crashing when that is not the
case); work around audioconvert sucking by swapping endianness
to the native endianness ourselves for float formats; send
initial newsegment event. Fixes #161712.
2006-04-26 17:08:24 +00:00
|
|
|
|
2011-07-07 09:14:16 +00:00
|
|
|
outbuf = gst_adapter_take_buffer (auparse->adapter, sendnow);
|
|
|
|
outbuf = gst_buffer_make_writable (outbuf);
|
2004-05-10 23:55:17 +00:00
|
|
|
|
2011-04-20 19:25:58 +00:00
|
|
|
pos = auparse->buffer_offset - auparse->offset;
|
|
|
|
pos = MAX (pos, 0);
|
|
|
|
|
|
|
|
if (auparse->sample_size > 0 && auparse->samplerate > 0) {
|
|
|
|
gst_au_parse_src_convert (auparse, GST_FORMAT_BYTES, pos,
|
|
|
|
GST_FORMAT_DEFAULT, &offset);
|
|
|
|
gst_au_parse_src_convert (auparse, GST_FORMAT_BYTES, pos,
|
|
|
|
GST_FORMAT_TIME, ×tamp);
|
|
|
|
gst_au_parse_src_convert (auparse, GST_FORMAT_BYTES,
|
|
|
|
sendnow, GST_FORMAT_TIME, &duration);
|
|
|
|
|
|
|
|
GST_BUFFER_OFFSET (outbuf) = offset;
|
|
|
|
GST_BUFFER_TIMESTAMP (outbuf) = timestamp;
|
|
|
|
GST_BUFFER_DURATION (outbuf) = duration;
|
|
|
|
}
|
|
|
|
|
gst/auparse/gstauparse.*: Rewrite auparse to suck a little bit less: make source pad dynamic, so decodebin/playbin wo...
Original commit message from CVS:
* gst/auparse/gstauparse.c: (gst_au_parse_base_init),
(gst_au_parse_class_init), (gst_au_parse_init),
(gst_au_parse_reset), (gst_au_parse_add_srcpad),
(gst_au_parse_remove_srcpad), (gst_au_parse_parse_header),
(gst_au_parse_chain), (gst_au_parse_src_convert),
(gst_au_parse_src_query), (gst_au_parse_handle_seek),
(gst_au_parse_sink_event), (gst_au_parse_src_event),
(gst_au_parse_change_state):
* gst/auparse/gstauparse.h:
Rewrite auparse to suck a little bit less: make source pad
dynamic, so decodebin/playbin work with non-raw formats
like alaw/mulaw; add query function for duration/position
queries; check whether we have enough data before attempting
to parse the header (instead of crashing when that is not the
case); work around audioconvert sucking by swapping endianness
to the native endianness ourselves for float formats; send
initial newsegment event. Fixes #161712.
2006-04-26 17:08:24 +00:00
|
|
|
auparse->buffer_offset += sendnow;
|
2004-05-14 10:01:23 +00:00
|
|
|
|
gst/auparse/gstauparse.*: Rewrite auparse to suck a little bit less: make source pad dynamic, so decodebin/playbin wo...
Original commit message from CVS:
* gst/auparse/gstauparse.c: (gst_au_parse_base_init),
(gst_au_parse_class_init), (gst_au_parse_init),
(gst_au_parse_reset), (gst_au_parse_add_srcpad),
(gst_au_parse_remove_srcpad), (gst_au_parse_parse_header),
(gst_au_parse_chain), (gst_au_parse_src_convert),
(gst_au_parse_src_query), (gst_au_parse_handle_seek),
(gst_au_parse_sink_event), (gst_au_parse_src_event),
(gst_au_parse_change_state):
* gst/auparse/gstauparse.h:
Rewrite auparse to suck a little bit less: make source pad
dynamic, so decodebin/playbin work with non-raw formats
like alaw/mulaw; add query function for duration/position
queries; check whether we have enough data before attempting
to parse the header (instead of crashing when that is not the
case); work around audioconvert sucking by swapping endianness
to the native endianness ourselves for float formats; send
initial newsegment event. Fixes #161712.
2006-04-26 17:08:24 +00:00
|
|
|
ret = gst_pad_push (auparse->srcpad, outbuf);
|
|
|
|
}
|
2004-05-11 22:55:35 +00:00
|
|
|
|
gst/auparse/gstauparse.*: Rewrite auparse to suck a little bit less: make source pad dynamic, so decodebin/playbin wo...
Original commit message from CVS:
* gst/auparse/gstauparse.c: (gst_au_parse_base_init),
(gst_au_parse_class_init), (gst_au_parse_init),
(gst_au_parse_reset), (gst_au_parse_add_srcpad),
(gst_au_parse_remove_srcpad), (gst_au_parse_parse_header),
(gst_au_parse_chain), (gst_au_parse_src_convert),
(gst_au_parse_src_query), (gst_au_parse_handle_seek),
(gst_au_parse_sink_event), (gst_au_parse_src_event),
(gst_au_parse_change_state):
* gst/auparse/gstauparse.h:
Rewrite auparse to suck a little bit less: make source pad
dynamic, so decodebin/playbin work with non-raw formats
like alaw/mulaw; add query function for duration/position
queries; check whether we have enough data before attempting
to parse the header (instead of crashing when that is not the
case); work around audioconvert sucking by swapping endianness
to the native endianness ourselves for float formats; send
initial newsegment event. Fixes #161712.
2006-04-26 17:08:24 +00:00
|
|
|
out:
|
2004-05-11 22:55:35 +00:00
|
|
|
|
gst/auparse/gstauparse.*: Rewrite auparse to suck a little bit less: make source pad dynamic, so decodebin/playbin wo...
Original commit message from CVS:
* gst/auparse/gstauparse.c: (gst_au_parse_base_init),
(gst_au_parse_class_init), (gst_au_parse_init),
(gst_au_parse_reset), (gst_au_parse_add_srcpad),
(gst_au_parse_remove_srcpad), (gst_au_parse_parse_header),
(gst_au_parse_chain), (gst_au_parse_src_convert),
(gst_au_parse_src_query), (gst_au_parse_handle_seek),
(gst_au_parse_sink_event), (gst_au_parse_src_event),
(gst_au_parse_change_state):
* gst/auparse/gstauparse.h:
Rewrite auparse to suck a little bit less: make source pad
dynamic, so decodebin/playbin work with non-raw formats
like alaw/mulaw; add query function for duration/position
queries; check whether we have enough data before attempting
to parse the header (instead of crashing when that is not the
case); work around audioconvert sucking by swapping endianness
to the native endianness ourselves for float formats; send
initial newsegment event. Fixes #161712.
2006-04-26 17:08:24 +00:00
|
|
|
return ret;
|
|
|
|
}
|
2004-05-11 22:55:35 +00:00
|
|
|
|
gst/auparse/gstauparse.*: Rewrite auparse to suck a little bit less: make source pad dynamic, so decodebin/playbin wo...
Original commit message from CVS:
* gst/auparse/gstauparse.c: (gst_au_parse_base_init),
(gst_au_parse_class_init), (gst_au_parse_init),
(gst_au_parse_reset), (gst_au_parse_add_srcpad),
(gst_au_parse_remove_srcpad), (gst_au_parse_parse_header),
(gst_au_parse_chain), (gst_au_parse_src_convert),
(gst_au_parse_src_query), (gst_au_parse_handle_seek),
(gst_au_parse_sink_event), (gst_au_parse_src_event),
(gst_au_parse_change_state):
* gst/auparse/gstauparse.h:
Rewrite auparse to suck a little bit less: make source pad
dynamic, so decodebin/playbin work with non-raw formats
like alaw/mulaw; add query function for duration/position
queries; check whether we have enough data before attempting
to parse the header (instead of crashing when that is not the
case); work around audioconvert sucking by swapping endianness
to the native endianness ourselves for float formats; send
initial newsegment event. Fixes #161712.
2006-04-26 17:08:24 +00:00
|
|
|
static gboolean
|
|
|
|
gst_au_parse_src_convert (GstAuParse * auparse, GstFormat src_format,
|
|
|
|
gint64 srcval, GstFormat dest_format, gint64 * destval)
|
|
|
|
{
|
|
|
|
gboolean ret = TRUE;
|
|
|
|
guint samplesize, rate;
|
2004-05-11 22:55:35 +00:00
|
|
|
|
gst/auparse/gstauparse.*: Rewrite auparse to suck a little bit less: make source pad dynamic, so decodebin/playbin wo...
Original commit message from CVS:
* gst/auparse/gstauparse.c: (gst_au_parse_base_init),
(gst_au_parse_class_init), (gst_au_parse_init),
(gst_au_parse_reset), (gst_au_parse_add_srcpad),
(gst_au_parse_remove_srcpad), (gst_au_parse_parse_header),
(gst_au_parse_chain), (gst_au_parse_src_convert),
(gst_au_parse_src_query), (gst_au_parse_handle_seek),
(gst_au_parse_sink_event), (gst_au_parse_src_event),
(gst_au_parse_change_state):
* gst/auparse/gstauparse.h:
Rewrite auparse to suck a little bit less: make source pad
dynamic, so decodebin/playbin work with non-raw formats
like alaw/mulaw; add query function for duration/position
queries; check whether we have enough data before attempting
to parse the header (instead of crashing when that is not the
case); work around audioconvert sucking by swapping endianness
to the native endianness ourselves for float formats; send
initial newsegment event. Fixes #161712.
2006-04-26 17:08:24 +00:00
|
|
|
if (dest_format == src_format) {
|
|
|
|
*destval = srcval;
|
|
|
|
return TRUE;
|
|
|
|
}
|
2004-05-11 22:55:35 +00:00
|
|
|
|
gst/auparse/gstauparse.*: Rewrite auparse to suck a little bit less: make source pad dynamic, so decodebin/playbin wo...
Original commit message from CVS:
* gst/auparse/gstauparse.c: (gst_au_parse_base_init),
(gst_au_parse_class_init), (gst_au_parse_init),
(gst_au_parse_reset), (gst_au_parse_add_srcpad),
(gst_au_parse_remove_srcpad), (gst_au_parse_parse_header),
(gst_au_parse_chain), (gst_au_parse_src_convert),
(gst_au_parse_src_query), (gst_au_parse_handle_seek),
(gst_au_parse_sink_event), (gst_au_parse_src_event),
(gst_au_parse_change_state):
* gst/auparse/gstauparse.h:
Rewrite auparse to suck a little bit less: make source pad
dynamic, so decodebin/playbin work with non-raw formats
like alaw/mulaw; add query function for duration/position
queries; check whether we have enough data before attempting
to parse the header (instead of crashing when that is not the
case); work around audioconvert sucking by swapping endianness
to the native endianness ourselves for float formats; send
initial newsegment event. Fixes #161712.
2006-04-26 17:08:24 +00:00
|
|
|
GST_OBJECT_LOCK (auparse);
|
|
|
|
samplesize = auparse->sample_size;
|
|
|
|
rate = auparse->samplerate;
|
|
|
|
GST_OBJECT_UNLOCK (auparse);
|
|
|
|
|
|
|
|
if (samplesize == 0 || rate == 0) {
|
|
|
|
GST_LOG_OBJECT (auparse, "cannot convert, sample_size or rate unknown");
|
|
|
|
return FALSE;
|
|
|
|
}
|
2001-12-22 23:22:05 +00:00
|
|
|
|
gst/auparse/gstauparse.*: Rewrite auparse to suck a little bit less: make source pad dynamic, so decodebin/playbin wo...
Original commit message from CVS:
* gst/auparse/gstauparse.c: (gst_au_parse_base_init),
(gst_au_parse_class_init), (gst_au_parse_init),
(gst_au_parse_reset), (gst_au_parse_add_srcpad),
(gst_au_parse_remove_srcpad), (gst_au_parse_parse_header),
(gst_au_parse_chain), (gst_au_parse_src_convert),
(gst_au_parse_src_query), (gst_au_parse_handle_seek),
(gst_au_parse_sink_event), (gst_au_parse_src_event),
(gst_au_parse_change_state):
* gst/auparse/gstauparse.h:
Rewrite auparse to suck a little bit less: make source pad
dynamic, so decodebin/playbin work with non-raw formats
like alaw/mulaw; add query function for duration/position
queries; check whether we have enough data before attempting
to parse the header (instead of crashing when that is not the
case); work around audioconvert sucking by swapping endianness
to the native endianness ourselves for float formats; send
initial newsegment event. Fixes #161712.
2006-04-26 17:08:24 +00:00
|
|
|
switch (src_format) {
|
|
|
|
case GST_FORMAT_BYTES:
|
|
|
|
srcval /= samplesize;
|
|
|
|
/* fallthrough */
|
|
|
|
case GST_FORMAT_DEFAULT:{
|
|
|
|
switch (dest_format) {
|
2011-04-20 19:25:58 +00:00
|
|
|
case GST_FORMAT_DEFAULT:
|
|
|
|
*destval = srcval;
|
|
|
|
break;
|
gst/auparse/gstauparse.*: Rewrite auparse to suck a little bit less: make source pad dynamic, so decodebin/playbin wo...
Original commit message from CVS:
* gst/auparse/gstauparse.c: (gst_au_parse_base_init),
(gst_au_parse_class_init), (gst_au_parse_init),
(gst_au_parse_reset), (gst_au_parse_add_srcpad),
(gst_au_parse_remove_srcpad), (gst_au_parse_parse_header),
(gst_au_parse_chain), (gst_au_parse_src_convert),
(gst_au_parse_src_query), (gst_au_parse_handle_seek),
(gst_au_parse_sink_event), (gst_au_parse_src_event),
(gst_au_parse_change_state):
* gst/auparse/gstauparse.h:
Rewrite auparse to suck a little bit less: make source pad
dynamic, so decodebin/playbin work with non-raw formats
like alaw/mulaw; add query function for duration/position
queries; check whether we have enough data before attempting
to parse the header (instead of crashing when that is not the
case); work around audioconvert sucking by swapping endianness
to the native endianness ourselves for float formats; send
initial newsegment event. Fixes #161712.
2006-04-26 17:08:24 +00:00
|
|
|
case GST_FORMAT_BYTES:
|
|
|
|
*destval = srcval * samplesize;
|
|
|
|
break;
|
|
|
|
case GST_FORMAT_TIME:
|
|
|
|
*destval = gst_util_uint64_scale_int (srcval, GST_SECOND, rate);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ret = FALSE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case GST_FORMAT_TIME:{
|
|
|
|
switch (dest_format) {
|
|
|
|
case GST_FORMAT_BYTES:
|
2011-04-20 19:25:58 +00:00
|
|
|
*destval = samplesize *
|
|
|
|
gst_util_uint64_scale_int (srcval, rate, GST_SECOND);
|
gst/auparse/gstauparse.*: Rewrite auparse to suck a little bit less: make source pad dynamic, so decodebin/playbin wo...
Original commit message from CVS:
* gst/auparse/gstauparse.c: (gst_au_parse_base_init),
(gst_au_parse_class_init), (gst_au_parse_init),
(gst_au_parse_reset), (gst_au_parse_add_srcpad),
(gst_au_parse_remove_srcpad), (gst_au_parse_parse_header),
(gst_au_parse_chain), (gst_au_parse_src_convert),
(gst_au_parse_src_query), (gst_au_parse_handle_seek),
(gst_au_parse_sink_event), (gst_au_parse_src_event),
(gst_au_parse_change_state):
* gst/auparse/gstauparse.h:
Rewrite auparse to suck a little bit less: make source pad
dynamic, so decodebin/playbin work with non-raw formats
like alaw/mulaw; add query function for duration/position
queries; check whether we have enough data before attempting
to parse the header (instead of crashing when that is not the
case); work around audioconvert sucking by swapping endianness
to the native endianness ourselves for float formats; send
initial newsegment event. Fixes #161712.
2006-04-26 17:08:24 +00:00
|
|
|
break;
|
|
|
|
case GST_FORMAT_DEFAULT:
|
|
|
|
*destval = gst_util_uint64_scale_int (srcval, rate, GST_SECOND);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ret = FALSE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:{
|
|
|
|
ret = FALSE;
|
|
|
|
break;
|
2003-07-06 20:49:52 +00:00
|
|
|
}
|
gst/auparse/gstauparse.*: Rewrite auparse to suck a little bit less: make source pad dynamic, so decodebin/playbin wo...
Original commit message from CVS:
* gst/auparse/gstauparse.c: (gst_au_parse_base_init),
(gst_au_parse_class_init), (gst_au_parse_init),
(gst_au_parse_reset), (gst_au_parse_add_srcpad),
(gst_au_parse_remove_srcpad), (gst_au_parse_parse_header),
(gst_au_parse_chain), (gst_au_parse_src_convert),
(gst_au_parse_src_query), (gst_au_parse_handle_seek),
(gst_au_parse_sink_event), (gst_au_parse_src_event),
(gst_au_parse_change_state):
* gst/auparse/gstauparse.h:
Rewrite auparse to suck a little bit less: make source pad
dynamic, so decodebin/playbin work with non-raw formats
like alaw/mulaw; add query function for duration/position
queries; check whether we have enough data before attempting
to parse the header (instead of crashing when that is not the
case); work around audioconvert sucking by swapping endianness
to the native endianness ourselves for float formats; send
initial newsegment event. Fixes #161712.
2006-04-26 17:08:24 +00:00
|
|
|
}
|
2002-01-13 22:27:25 +00:00
|
|
|
|
gst/auparse/gstauparse.*: Rewrite auparse to suck a little bit less: make source pad dynamic, so decodebin/playbin wo...
Original commit message from CVS:
* gst/auparse/gstauparse.c: (gst_au_parse_base_init),
(gst_au_parse_class_init), (gst_au_parse_init),
(gst_au_parse_reset), (gst_au_parse_add_srcpad),
(gst_au_parse_remove_srcpad), (gst_au_parse_parse_header),
(gst_au_parse_chain), (gst_au_parse_src_convert),
(gst_au_parse_src_query), (gst_au_parse_handle_seek),
(gst_au_parse_sink_event), (gst_au_parse_src_event),
(gst_au_parse_change_state):
* gst/auparse/gstauparse.h:
Rewrite auparse to suck a little bit less: make source pad
dynamic, so decodebin/playbin work with non-raw formats
like alaw/mulaw; add query function for duration/position
queries; check whether we have enough data before attempting
to parse the header (instead of crashing when that is not the
case); work around audioconvert sucking by swapping endianness
to the native endianness ourselves for float formats; send
initial newsegment event. Fixes #161712.
2006-04-26 17:08:24 +00:00
|
|
|
if (!ret) {
|
|
|
|
GST_DEBUG_OBJECT (auparse, "could not convert from %s to %s format",
|
|
|
|
gst_format_get_name (src_format), gst_format_get_name (dest_format));
|
|
|
|
}
|
2005-09-22 22:38:48 +00:00
|
|
|
|
gst/auparse/gstauparse.*: Rewrite auparse to suck a little bit less: make source pad dynamic, so decodebin/playbin wo...
Original commit message from CVS:
* gst/auparse/gstauparse.c: (gst_au_parse_base_init),
(gst_au_parse_class_init), (gst_au_parse_init),
(gst_au_parse_reset), (gst_au_parse_add_srcpad),
(gst_au_parse_remove_srcpad), (gst_au_parse_parse_header),
(gst_au_parse_chain), (gst_au_parse_src_convert),
(gst_au_parse_src_query), (gst_au_parse_handle_seek),
(gst_au_parse_sink_event), (gst_au_parse_src_event),
(gst_au_parse_change_state):
* gst/auparse/gstauparse.h:
Rewrite auparse to suck a little bit less: make source pad
dynamic, so decodebin/playbin work with non-raw formats
like alaw/mulaw; add query function for duration/position
queries; check whether we have enough data before attempting
to parse the header (instead of crashing when that is not the
case); work around audioconvert sucking by swapping endianness
to the native endianness ourselves for float formats; send
initial newsegment event. Fixes #161712.
2006-04-26 17:08:24 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2011-11-16 16:27:13 +00:00
|
|
|
gst_au_parse_src_query (GstPad * pad, GstObject * parent, GstQuery * query)
|
gst/auparse/gstauparse.*: Rewrite auparse to suck a little bit less: make source pad dynamic, so decodebin/playbin wo...
Original commit message from CVS:
* gst/auparse/gstauparse.c: (gst_au_parse_base_init),
(gst_au_parse_class_init), (gst_au_parse_init),
(gst_au_parse_reset), (gst_au_parse_add_srcpad),
(gst_au_parse_remove_srcpad), (gst_au_parse_parse_header),
(gst_au_parse_chain), (gst_au_parse_src_convert),
(gst_au_parse_src_query), (gst_au_parse_handle_seek),
(gst_au_parse_sink_event), (gst_au_parse_src_event),
(gst_au_parse_change_state):
* gst/auparse/gstauparse.h:
Rewrite auparse to suck a little bit less: make source pad
dynamic, so decodebin/playbin work with non-raw formats
like alaw/mulaw; add query function for duration/position
queries; check whether we have enough data before attempting
to parse the header (instead of crashing when that is not the
case); work around audioconvert sucking by swapping endianness
to the native endianness ourselves for float formats; send
initial newsegment event. Fixes #161712.
2006-04-26 17:08:24 +00:00
|
|
|
{
|
|
|
|
GstAuParse *auparse;
|
|
|
|
gboolean ret = FALSE;
|
|
|
|
|
2011-11-16 16:27:13 +00:00
|
|
|
auparse = GST_AU_PARSE (parent);
|
gst/auparse/gstauparse.*: Rewrite auparse to suck a little bit less: make source pad dynamic, so decodebin/playbin wo...
Original commit message from CVS:
* gst/auparse/gstauparse.c: (gst_au_parse_base_init),
(gst_au_parse_class_init), (gst_au_parse_init),
(gst_au_parse_reset), (gst_au_parse_add_srcpad),
(gst_au_parse_remove_srcpad), (gst_au_parse_parse_header),
(gst_au_parse_chain), (gst_au_parse_src_convert),
(gst_au_parse_src_query), (gst_au_parse_handle_seek),
(gst_au_parse_sink_event), (gst_au_parse_src_event),
(gst_au_parse_change_state):
* gst/auparse/gstauparse.h:
Rewrite auparse to suck a little bit less: make source pad
dynamic, so decodebin/playbin work with non-raw formats
like alaw/mulaw; add query function for duration/position
queries; check whether we have enough data before attempting
to parse the header (instead of crashing when that is not the
case); work around audioconvert sucking by swapping endianness
to the native endianness ourselves for float formats; send
initial newsegment event. Fixes #161712.
2006-04-26 17:08:24 +00:00
|
|
|
|
|
|
|
switch (GST_QUERY_TYPE (query)) {
|
|
|
|
case GST_QUERY_DURATION:{
|
|
|
|
GstFormat format;
|
|
|
|
gint64 len, val;
|
|
|
|
|
|
|
|
gst_query_parse_duration (query, &format, NULL);
|
2011-11-15 17:01:16 +00:00
|
|
|
if (!gst_pad_peer_query_duration (auparse->sinkpad, GST_FORMAT_BYTES,
|
2011-07-28 09:54:38 +00:00
|
|
|
&len)) {
|
gst/auparse/gstauparse.*: Rewrite auparse to suck a little bit less: make source pad dynamic, so decodebin/playbin wo...
Original commit message from CVS:
* gst/auparse/gstauparse.c: (gst_au_parse_base_init),
(gst_au_parse_class_init), (gst_au_parse_init),
(gst_au_parse_reset), (gst_au_parse_add_srcpad),
(gst_au_parse_remove_srcpad), (gst_au_parse_parse_header),
(gst_au_parse_chain), (gst_au_parse_src_convert),
(gst_au_parse_src_query), (gst_au_parse_handle_seek),
(gst_au_parse_sink_event), (gst_au_parse_src_event),
(gst_au_parse_change_state):
* gst/auparse/gstauparse.h:
Rewrite auparse to suck a little bit less: make source pad
dynamic, so decodebin/playbin work with non-raw formats
like alaw/mulaw; add query function for duration/position
queries; check whether we have enough data before attempting
to parse the header (instead of crashing when that is not the
case); work around audioconvert sucking by swapping endianness
to the native endianness ourselves for float formats; send
initial newsegment event. Fixes #161712.
2006-04-26 17:08:24 +00:00
|
|
|
GST_DEBUG_OBJECT (auparse, "failed to query upstream length");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
GST_OBJECT_LOCK (auparse);
|
|
|
|
len -= auparse->offset;
|
|
|
|
GST_OBJECT_UNLOCK (auparse);
|
2006-03-30 15:37:05 +00:00
|
|
|
|
2011-07-28 09:54:38 +00:00
|
|
|
ret =
|
|
|
|
gst_au_parse_src_convert (auparse, GST_FORMAT_BYTES, len, format,
|
|
|
|
&val);
|
2001-12-22 23:22:05 +00:00
|
|
|
|
gst/auparse/gstauparse.*: Rewrite auparse to suck a little bit less: make source pad dynamic, so decodebin/playbin wo...
Original commit message from CVS:
* gst/auparse/gstauparse.c: (gst_au_parse_base_init),
(gst_au_parse_class_init), (gst_au_parse_init),
(gst_au_parse_reset), (gst_au_parse_add_srcpad),
(gst_au_parse_remove_srcpad), (gst_au_parse_parse_header),
(gst_au_parse_chain), (gst_au_parse_src_convert),
(gst_au_parse_src_query), (gst_au_parse_handle_seek),
(gst_au_parse_sink_event), (gst_au_parse_src_event),
(gst_au_parse_change_state):
* gst/auparse/gstauparse.h:
Rewrite auparse to suck a little bit less: make source pad
dynamic, so decodebin/playbin work with non-raw formats
like alaw/mulaw; add query function for duration/position
queries; check whether we have enough data before attempting
to parse the header (instead of crashing when that is not the
case); work around audioconvert sucking by swapping endianness
to the native endianness ourselves for float formats; send
initial newsegment event. Fixes #161712.
2006-04-26 17:08:24 +00:00
|
|
|
if (ret) {
|
|
|
|
gst_query_set_duration (query, format, val);
|
|
|
|
}
|
|
|
|
break;
|
2006-03-30 15:37:05 +00:00
|
|
|
}
|
gst/auparse/gstauparse.*: Rewrite auparse to suck a little bit less: make source pad dynamic, so decodebin/playbin wo...
Original commit message from CVS:
* gst/auparse/gstauparse.c: (gst_au_parse_base_init),
(gst_au_parse_class_init), (gst_au_parse_init),
(gst_au_parse_reset), (gst_au_parse_add_srcpad),
(gst_au_parse_remove_srcpad), (gst_au_parse_parse_header),
(gst_au_parse_chain), (gst_au_parse_src_convert),
(gst_au_parse_src_query), (gst_au_parse_handle_seek),
(gst_au_parse_sink_event), (gst_au_parse_src_event),
(gst_au_parse_change_state):
* gst/auparse/gstauparse.h:
Rewrite auparse to suck a little bit less: make source pad
dynamic, so decodebin/playbin work with non-raw formats
like alaw/mulaw; add query function for duration/position
queries; check whether we have enough data before attempting
to parse the header (instead of crashing when that is not the
case); work around audioconvert sucking by swapping endianness
to the native endianness ourselves for float formats; send
initial newsegment event. Fixes #161712.
2006-04-26 17:08:24 +00:00
|
|
|
case GST_QUERY_POSITION:{
|
|
|
|
GstFormat format;
|
|
|
|
gint64 pos, val;
|
|
|
|
|
|
|
|
gst_query_parse_position (query, &format, NULL);
|
2011-11-15 17:01:16 +00:00
|
|
|
if (!gst_pad_peer_query_position (auparse->sinkpad, GST_FORMAT_BYTES,
|
2011-07-28 09:54:38 +00:00
|
|
|
&pos)) {
|
gst/auparse/gstauparse.*: Rewrite auparse to suck a little bit less: make source pad dynamic, so decodebin/playbin wo...
Original commit message from CVS:
* gst/auparse/gstauparse.c: (gst_au_parse_base_init),
(gst_au_parse_class_init), (gst_au_parse_init),
(gst_au_parse_reset), (gst_au_parse_add_srcpad),
(gst_au_parse_remove_srcpad), (gst_au_parse_parse_header),
(gst_au_parse_chain), (gst_au_parse_src_convert),
(gst_au_parse_src_query), (gst_au_parse_handle_seek),
(gst_au_parse_sink_event), (gst_au_parse_src_event),
(gst_au_parse_change_state):
* gst/auparse/gstauparse.h:
Rewrite auparse to suck a little bit less: make source pad
dynamic, so decodebin/playbin work with non-raw formats
like alaw/mulaw; add query function for duration/position
queries; check whether we have enough data before attempting
to parse the header (instead of crashing when that is not the
case); work around audioconvert sucking by swapping endianness
to the native endianness ourselves for float formats; send
initial newsegment event. Fixes #161712.
2006-04-26 17:08:24 +00:00
|
|
|
GST_DEBUG_OBJECT (auparse, "failed to query upstream position");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
GST_OBJECT_LOCK (auparse);
|
|
|
|
pos -= auparse->offset;
|
|
|
|
GST_OBJECT_UNLOCK (auparse);
|
2004-05-11 00:20:02 +00:00
|
|
|
|
gst/auparse/gstauparse.*: Rewrite auparse to suck a little bit less: make source pad dynamic, so decodebin/playbin wo...
Original commit message from CVS:
* gst/auparse/gstauparse.c: (gst_au_parse_base_init),
(gst_au_parse_class_init), (gst_au_parse_init),
(gst_au_parse_reset), (gst_au_parse_add_srcpad),
(gst_au_parse_remove_srcpad), (gst_au_parse_parse_header),
(gst_au_parse_chain), (gst_au_parse_src_convert),
(gst_au_parse_src_query), (gst_au_parse_handle_seek),
(gst_au_parse_sink_event), (gst_au_parse_src_event),
(gst_au_parse_change_state):
* gst/auparse/gstauparse.h:
Rewrite auparse to suck a little bit less: make source pad
dynamic, so decodebin/playbin work with non-raw formats
like alaw/mulaw; add query function for duration/position
queries; check whether we have enough data before attempting
to parse the header (instead of crashing when that is not the
case); work around audioconvert sucking by swapping endianness
to the native endianness ourselves for float formats; send
initial newsegment event. Fixes #161712.
2006-04-26 17:08:24 +00:00
|
|
|
ret = gst_au_parse_src_convert (auparse, GST_FORMAT_BYTES, pos,
|
|
|
|
format, &val);
|
2001-12-22 23:22:05 +00:00
|
|
|
|
gst/auparse/gstauparse.*: Rewrite auparse to suck a little bit less: make source pad dynamic, so decodebin/playbin wo...
Original commit message from CVS:
* gst/auparse/gstauparse.c: (gst_au_parse_base_init),
(gst_au_parse_class_init), (gst_au_parse_init),
(gst_au_parse_reset), (gst_au_parse_add_srcpad),
(gst_au_parse_remove_srcpad), (gst_au_parse_parse_header),
(gst_au_parse_chain), (gst_au_parse_src_convert),
(gst_au_parse_src_query), (gst_au_parse_handle_seek),
(gst_au_parse_sink_event), (gst_au_parse_src_event),
(gst_au_parse_change_state):
* gst/auparse/gstauparse.h:
Rewrite auparse to suck a little bit less: make source pad
dynamic, so decodebin/playbin work with non-raw formats
like alaw/mulaw; add query function for duration/position
queries; check whether we have enough data before attempting
to parse the header (instead of crashing when that is not the
case); work around audioconvert sucking by swapping endianness
to the native endianness ourselves for float formats; send
initial newsegment event. Fixes #161712.
2006-04-26 17:08:24 +00:00
|
|
|
if (ret) {
|
|
|
|
gst_query_set_position (query, format, val);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2011-04-20 19:25:58 +00:00
|
|
|
case GST_QUERY_SEEKING:{
|
|
|
|
GstFormat format;
|
|
|
|
|
|
|
|
gst_query_parse_seeking (query, &format, NULL, NULL, NULL);
|
|
|
|
/* FIXME: query duration in 'format'
|
|
|
|
gst_query_set_seeking (query, format, TRUE, 0, duration);
|
|
|
|
*/
|
|
|
|
gst_query_set_seeking (query, format, TRUE, 0, GST_CLOCK_TIME_NONE);
|
|
|
|
ret = TRUE;
|
|
|
|
break;
|
|
|
|
}
|
gst/auparse/gstauparse.*: Rewrite auparse to suck a little bit less: make source pad dynamic, so decodebin/playbin wo...
Original commit message from CVS:
* gst/auparse/gstauparse.c: (gst_au_parse_base_init),
(gst_au_parse_class_init), (gst_au_parse_init),
(gst_au_parse_reset), (gst_au_parse_add_srcpad),
(gst_au_parse_remove_srcpad), (gst_au_parse_parse_header),
(gst_au_parse_chain), (gst_au_parse_src_convert),
(gst_au_parse_src_query), (gst_au_parse_handle_seek),
(gst_au_parse_sink_event), (gst_au_parse_src_event),
(gst_au_parse_change_state):
* gst/auparse/gstauparse.h:
Rewrite auparse to suck a little bit less: make source pad
dynamic, so decodebin/playbin work with non-raw formats
like alaw/mulaw; add query function for duration/position
queries; check whether we have enough data before attempting
to parse the header (instead of crashing when that is not the
case); work around audioconvert sucking by swapping endianness
to the native endianness ourselves for float formats; send
initial newsegment event. Fixes #161712.
2006-04-26 17:08:24 +00:00
|
|
|
default:
|
2011-11-16 16:27:13 +00:00
|
|
|
ret = gst_pad_query_default (pad, parent, query);
|
gst/auparse/gstauparse.*: Rewrite auparse to suck a little bit less: make source pad dynamic, so decodebin/playbin wo...
Original commit message from CVS:
* gst/auparse/gstauparse.c: (gst_au_parse_base_init),
(gst_au_parse_class_init), (gst_au_parse_init),
(gst_au_parse_reset), (gst_au_parse_add_srcpad),
(gst_au_parse_remove_srcpad), (gst_au_parse_parse_header),
(gst_au_parse_chain), (gst_au_parse_src_convert),
(gst_au_parse_src_query), (gst_au_parse_handle_seek),
(gst_au_parse_sink_event), (gst_au_parse_src_event),
(gst_au_parse_change_state):
* gst/auparse/gstauparse.h:
Rewrite auparse to suck a little bit less: make source pad
dynamic, so decodebin/playbin work with non-raw formats
like alaw/mulaw; add query function for duration/position
queries; check whether we have enough data before attempting
to parse the header (instead of crashing when that is not the
case); work around audioconvert sucking by swapping endianness
to the native endianness ourselves for float formats; send
initial newsegment event. Fixes #161712.
2006-04-26 17:08:24 +00:00
|
|
|
break;
|
2005-11-21 17:18:01 +00:00
|
|
|
}
|
2005-09-22 22:38:48 +00:00
|
|
|
|
gst/auparse/gstauparse.*: Rewrite auparse to suck a little bit less: make source pad dynamic, so decodebin/playbin wo...
Original commit message from CVS:
* gst/auparse/gstauparse.c: (gst_au_parse_base_init),
(gst_au_parse_class_init), (gst_au_parse_init),
(gst_au_parse_reset), (gst_au_parse_add_srcpad),
(gst_au_parse_remove_srcpad), (gst_au_parse_parse_header),
(gst_au_parse_chain), (gst_au_parse_src_convert),
(gst_au_parse_src_query), (gst_au_parse_handle_seek),
(gst_au_parse_sink_event), (gst_au_parse_src_event),
(gst_au_parse_change_state):
* gst/auparse/gstauparse.h:
Rewrite auparse to suck a little bit less: make source pad
dynamic, so decodebin/playbin work with non-raw formats
like alaw/mulaw; add query function for duration/position
queries; check whether we have enough data before attempting
to parse the header (instead of crashing when that is not the
case); work around audioconvert sucking by swapping endianness
to the native endianness ourselves for float formats; send
initial newsegment event. Fixes #161712.
2006-04-26 17:08:24 +00:00
|
|
|
return ret;
|
|
|
|
}
|
2005-09-22 22:38:48 +00:00
|
|
|
|
gst/auparse/gstauparse.*: Rewrite auparse to suck a little bit less: make source pad dynamic, so decodebin/playbin wo...
Original commit message from CVS:
* gst/auparse/gstauparse.c: (gst_au_parse_base_init),
(gst_au_parse_class_init), (gst_au_parse_init),
(gst_au_parse_reset), (gst_au_parse_add_srcpad),
(gst_au_parse_remove_srcpad), (gst_au_parse_parse_header),
(gst_au_parse_chain), (gst_au_parse_src_convert),
(gst_au_parse_src_query), (gst_au_parse_handle_seek),
(gst_au_parse_sink_event), (gst_au_parse_src_event),
(gst_au_parse_change_state):
* gst/auparse/gstauparse.h:
Rewrite auparse to suck a little bit less: make source pad
dynamic, so decodebin/playbin work with non-raw formats
like alaw/mulaw; add query function for duration/position
queries; check whether we have enough data before attempting
to parse the header (instead of crashing when that is not the
case); work around audioconvert sucking by swapping endianness
to the native endianness ourselves for float formats; send
initial newsegment event. Fixes #161712.
2006-04-26 17:08:24 +00:00
|
|
|
static gboolean
|
|
|
|
gst_au_parse_handle_seek (GstAuParse * auparse, GstEvent * event)
|
|
|
|
{
|
|
|
|
GstSeekType start_type, stop_type;
|
|
|
|
GstSeekFlags flags;
|
|
|
|
GstFormat format;
|
|
|
|
gdouble rate;
|
|
|
|
gint64 start, stop;
|
2011-04-20 19:25:58 +00:00
|
|
|
gboolean res;
|
2006-02-01 11:01:04 +00:00
|
|
|
|
gst/auparse/gstauparse.*: Rewrite auparse to suck a little bit less: make source pad dynamic, so decodebin/playbin wo...
Original commit message from CVS:
* gst/auparse/gstauparse.c: (gst_au_parse_base_init),
(gst_au_parse_class_init), (gst_au_parse_init),
(gst_au_parse_reset), (gst_au_parse_add_srcpad),
(gst_au_parse_remove_srcpad), (gst_au_parse_parse_header),
(gst_au_parse_chain), (gst_au_parse_src_convert),
(gst_au_parse_src_query), (gst_au_parse_handle_seek),
(gst_au_parse_sink_event), (gst_au_parse_src_event),
(gst_au_parse_change_state):
* gst/auparse/gstauparse.h:
Rewrite auparse to suck a little bit less: make source pad
dynamic, so decodebin/playbin work with non-raw formats
like alaw/mulaw; add query function for duration/position
queries; check whether we have enough data before attempting
to parse the header (instead of crashing when that is not the
case); work around audioconvert sucking by swapping endianness
to the native endianness ourselves for float formats; send
initial newsegment event. Fixes #161712.
2006-04-26 17:08:24 +00:00
|
|
|
gst_event_parse_seek (event, &rate, &format, &flags, &start_type, &start,
|
|
|
|
&stop_type, &stop);
|
2005-09-22 22:38:48 +00:00
|
|
|
|
gst/auparse/gstauparse.*: Rewrite auparse to suck a little bit less: make source pad dynamic, so decodebin/playbin wo...
Original commit message from CVS:
* gst/auparse/gstauparse.c: (gst_au_parse_base_init),
(gst_au_parse_class_init), (gst_au_parse_init),
(gst_au_parse_reset), (gst_au_parse_add_srcpad),
(gst_au_parse_remove_srcpad), (gst_au_parse_parse_header),
(gst_au_parse_chain), (gst_au_parse_src_convert),
(gst_au_parse_src_query), (gst_au_parse_handle_seek),
(gst_au_parse_sink_event), (gst_au_parse_src_event),
(gst_au_parse_change_state):
* gst/auparse/gstauparse.h:
Rewrite auparse to suck a little bit less: make source pad
dynamic, so decodebin/playbin work with non-raw formats
like alaw/mulaw; add query function for duration/position
queries; check whether we have enough data before attempting
to parse the header (instead of crashing when that is not the
case); work around audioconvert sucking by swapping endianness
to the native endianness ourselves for float formats; send
initial newsegment event. Fixes #161712.
2006-04-26 17:08:24 +00:00
|
|
|
if (format != GST_FORMAT_TIME) {
|
|
|
|
GST_DEBUG_OBJECT (auparse, "only support seeks in TIME format");
|
|
|
|
return FALSE;
|
|
|
|
}
|
2005-09-22 22:38:48 +00:00
|
|
|
|
2011-04-20 19:25:58 +00:00
|
|
|
res = gst_au_parse_src_convert (auparse, GST_FORMAT_TIME, start,
|
|
|
|
GST_FORMAT_BYTES, &start);
|
|
|
|
|
|
|
|
if (stop > 0) {
|
|
|
|
res = gst_au_parse_src_convert (auparse, GST_FORMAT_TIME, stop,
|
|
|
|
GST_FORMAT_BYTES, &stop);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_INFO_OBJECT (auparse,
|
|
|
|
"seeking: %" G_GINT64_FORMAT " ... %" G_GINT64_FORMAT, start, stop);
|
|
|
|
|
|
|
|
event = gst_event_new_seek (rate, GST_FORMAT_BYTES, flags, start_type, start,
|
|
|
|
stop_type, stop);
|
|
|
|
res = gst_pad_push_event (auparse->sinkpad, event);
|
|
|
|
return res;
|
gst/auparse/gstauparse.*: Rewrite auparse to suck a little bit less: make source pad dynamic, so decodebin/playbin wo...
Original commit message from CVS:
* gst/auparse/gstauparse.c: (gst_au_parse_base_init),
(gst_au_parse_class_init), (gst_au_parse_init),
(gst_au_parse_reset), (gst_au_parse_add_srcpad),
(gst_au_parse_remove_srcpad), (gst_au_parse_parse_header),
(gst_au_parse_chain), (gst_au_parse_src_convert),
(gst_au_parse_src_query), (gst_au_parse_handle_seek),
(gst_au_parse_sink_event), (gst_au_parse_src_event),
(gst_au_parse_change_state):
* gst/auparse/gstauparse.h:
Rewrite auparse to suck a little bit less: make source pad
dynamic, so decodebin/playbin work with non-raw formats
like alaw/mulaw; add query function for duration/position
queries; check whether we have enough data before attempting
to parse the header (instead of crashing when that is not the
case); work around audioconvert sucking by swapping endianness
to the native endianness ourselves for float formats; send
initial newsegment event. Fixes #161712.
2006-04-26 17:08:24 +00:00
|
|
|
}
|
2005-11-21 17:18:01 +00:00
|
|
|
|
gst/auparse/gstauparse.*: Rewrite auparse to suck a little bit less: make source pad dynamic, so decodebin/playbin wo...
Original commit message from CVS:
* gst/auparse/gstauparse.c: (gst_au_parse_base_init),
(gst_au_parse_class_init), (gst_au_parse_init),
(gst_au_parse_reset), (gst_au_parse_add_srcpad),
(gst_au_parse_remove_srcpad), (gst_au_parse_parse_header),
(gst_au_parse_chain), (gst_au_parse_src_convert),
(gst_au_parse_src_query), (gst_au_parse_handle_seek),
(gst_au_parse_sink_event), (gst_au_parse_src_event),
(gst_au_parse_change_state):
* gst/auparse/gstauparse.h:
Rewrite auparse to suck a little bit less: make source pad
dynamic, so decodebin/playbin work with non-raw formats
like alaw/mulaw; add query function for duration/position
queries; check whether we have enough data before attempting
to parse the header (instead of crashing when that is not the
case); work around audioconvert sucking by swapping endianness
to the native endianness ourselves for float formats; send
initial newsegment event. Fixes #161712.
2006-04-26 17:08:24 +00:00
|
|
|
static gboolean
|
2011-11-17 14:02:55 +00:00
|
|
|
gst_au_parse_sink_event (GstPad * pad, GstObject * parent, GstEvent * event)
|
gst/auparse/gstauparse.*: Rewrite auparse to suck a little bit less: make source pad dynamic, so decodebin/playbin wo...
Original commit message from CVS:
* gst/auparse/gstauparse.c: (gst_au_parse_base_init),
(gst_au_parse_class_init), (gst_au_parse_init),
(gst_au_parse_reset), (gst_au_parse_add_srcpad),
(gst_au_parse_remove_srcpad), (gst_au_parse_parse_header),
(gst_au_parse_chain), (gst_au_parse_src_convert),
(gst_au_parse_src_query), (gst_au_parse_handle_seek),
(gst_au_parse_sink_event), (gst_au_parse_src_event),
(gst_au_parse_change_state):
* gst/auparse/gstauparse.h:
Rewrite auparse to suck a little bit less: make source pad
dynamic, so decodebin/playbin work with non-raw formats
like alaw/mulaw; add query function for duration/position
queries; check whether we have enough data before attempting
to parse the header (instead of crashing when that is not the
case); work around audioconvert sucking by swapping endianness
to the native endianness ourselves for float formats; send
initial newsegment event. Fixes #161712.
2006-04-26 17:08:24 +00:00
|
|
|
{
|
|
|
|
GstAuParse *auparse;
|
2011-04-20 19:25:58 +00:00
|
|
|
gboolean ret = TRUE;
|
2001-12-22 23:22:05 +00:00
|
|
|
|
2011-11-17 14:02:55 +00:00
|
|
|
auparse = GST_AU_PARSE (parent);
|
2005-11-21 17:18:01 +00:00
|
|
|
|
gst/auparse/gstauparse.*: Rewrite auparse to suck a little bit less: make source pad dynamic, so decodebin/playbin wo...
Original commit message from CVS:
* gst/auparse/gstauparse.c: (gst_au_parse_base_init),
(gst_au_parse_class_init), (gst_au_parse_init),
(gst_au_parse_reset), (gst_au_parse_add_srcpad),
(gst_au_parse_remove_srcpad), (gst_au_parse_parse_header),
(gst_au_parse_chain), (gst_au_parse_src_convert),
(gst_au_parse_src_query), (gst_au_parse_handle_seek),
(gst_au_parse_sink_event), (gst_au_parse_src_event),
(gst_au_parse_change_state):
* gst/auparse/gstauparse.h:
Rewrite auparse to suck a little bit less: make source pad
dynamic, so decodebin/playbin work with non-raw formats
like alaw/mulaw; add query function for duration/position
queries; check whether we have enough data before attempting
to parse the header (instead of crashing when that is not the
case); work around audioconvert sucking by swapping endianness
to the native endianness ourselves for float formats; send
initial newsegment event. Fixes #161712.
2006-04-26 17:08:24 +00:00
|
|
|
switch (GST_EVENT_TYPE (event)) {
|
2011-07-07 09:22:26 +00:00
|
|
|
case GST_EVENT_CAPS:
|
|
|
|
{
|
|
|
|
/* discard, we'll come up with proper src caps */
|
|
|
|
gst_event_unref (event);
|
|
|
|
break;
|
|
|
|
}
|
2011-07-07 09:14:16 +00:00
|
|
|
case GST_EVENT_SEGMENT:
|
2011-04-20 19:25:58 +00:00
|
|
|
{
|
2011-07-07 09:14:16 +00:00
|
|
|
gint64 start, stop, offset = 0;
|
2011-04-20 19:25:58 +00:00
|
|
|
GstSegment segment;
|
|
|
|
GstEvent *new_event = NULL;
|
|
|
|
|
2011-07-07 09:14:16 +00:00
|
|
|
/* some debug output */
|
|
|
|
gst_event_copy_segment (event, &segment);
|
|
|
|
GST_DEBUG_OBJECT (auparse, "received newsegment %" GST_SEGMENT_FORMAT,
|
|
|
|
&segment);
|
2011-04-20 19:25:58 +00:00
|
|
|
|
2011-07-07 09:14:16 +00:00
|
|
|
start = segment.start;
|
|
|
|
stop = segment.stop;
|
2011-04-20 19:25:58 +00:00
|
|
|
if (auparse->sample_size > 0) {
|
|
|
|
if (start > 0) {
|
|
|
|
offset = start;
|
|
|
|
start -= auparse->offset;
|
|
|
|
start = MAX (start, 0);
|
|
|
|
}
|
|
|
|
if (stop > 0) {
|
|
|
|
stop -= auparse->offset;
|
|
|
|
stop = MAX (stop, 0);
|
|
|
|
}
|
|
|
|
gst_au_parse_src_convert (auparse, GST_FORMAT_BYTES, start,
|
|
|
|
GST_FORMAT_TIME, &start);
|
|
|
|
gst_au_parse_src_convert (auparse, GST_FORMAT_BYTES, stop,
|
|
|
|
GST_FORMAT_TIME, &stop);
|
|
|
|
}
|
|
|
|
|
2011-07-07 09:22:26 +00:00
|
|
|
GST_INFO_OBJECT (auparse,
|
|
|
|
"new segment: %" GST_TIME_FORMAT " ... %" GST_TIME_FORMAT,
|
|
|
|
GST_TIME_ARGS (start), GST_TIME_ARGS (stop));
|
2011-04-20 19:25:58 +00:00
|
|
|
|
2011-07-07 09:22:26 +00:00
|
|
|
gst_segment_init (&segment, GST_FORMAT_TIME);
|
|
|
|
segment.start = segment.time = start;
|
|
|
|
segment.stop = stop;
|
|
|
|
new_event = gst_event_new_segment (&segment);
|
2011-04-20 19:25:58 +00:00
|
|
|
|
2011-07-07 09:22:26 +00:00
|
|
|
ret = gst_pad_push_event (auparse->srcpad, new_event);
|
2011-04-20 19:25:58 +00:00
|
|
|
|
|
|
|
auparse->buffer_offset = offset;
|
|
|
|
|
|
|
|
gst_event_unref (event);
|
|
|
|
break;
|
|
|
|
}
|
2011-07-19 10:05:51 +00:00
|
|
|
case GST_EVENT_EOS:
|
|
|
|
if (!auparse->srcpad) {
|
|
|
|
GST_ELEMENT_ERROR (auparse, STREAM, WRONG_TYPE,
|
|
|
|
("No valid input found before end of stream"), (NULL));
|
|
|
|
}
|
|
|
|
/* fall-through */
|
gst/auparse/gstauparse.*: Rewrite auparse to suck a little bit less: make source pad dynamic, so decodebin/playbin wo...
Original commit message from CVS:
* gst/auparse/gstauparse.c: (gst_au_parse_base_init),
(gst_au_parse_class_init), (gst_au_parse_init),
(gst_au_parse_reset), (gst_au_parse_add_srcpad),
(gst_au_parse_remove_srcpad), (gst_au_parse_parse_header),
(gst_au_parse_chain), (gst_au_parse_src_convert),
(gst_au_parse_src_query), (gst_au_parse_handle_seek),
(gst_au_parse_sink_event), (gst_au_parse_src_event),
(gst_au_parse_change_state):
* gst/auparse/gstauparse.h:
Rewrite auparse to suck a little bit less: make source pad
dynamic, so decodebin/playbin work with non-raw formats
like alaw/mulaw; add query function for duration/position
queries; check whether we have enough data before attempting
to parse the header (instead of crashing when that is not the
case); work around audioconvert sucking by swapping endianness
to the native endianness ourselves for float formats; send
initial newsegment event. Fixes #161712.
2006-04-26 17:08:24 +00:00
|
|
|
default:
|
2011-11-17 14:02:55 +00:00
|
|
|
ret = gst_pad_event_default (pad, parent, event);
|
gst/auparse/gstauparse.*: Rewrite auparse to suck a little bit less: make source pad dynamic, so decodebin/playbin wo...
Original commit message from CVS:
* gst/auparse/gstauparse.c: (gst_au_parse_base_init),
(gst_au_parse_class_init), (gst_au_parse_init),
(gst_au_parse_reset), (gst_au_parse_add_srcpad),
(gst_au_parse_remove_srcpad), (gst_au_parse_parse_header),
(gst_au_parse_chain), (gst_au_parse_src_convert),
(gst_au_parse_src_query), (gst_au_parse_handle_seek),
(gst_au_parse_sink_event), (gst_au_parse_src_event),
(gst_au_parse_change_state):
* gst/auparse/gstauparse.h:
Rewrite auparse to suck a little bit less: make source pad
dynamic, so decodebin/playbin work with non-raw formats
like alaw/mulaw; add query function for duration/position
queries; check whether we have enough data before attempting
to parse the header (instead of crashing when that is not the
case); work around audioconvert sucking by swapping endianness
to the native endianness ourselves for float formats; send
initial newsegment event. Fixes #161712.
2006-04-26 17:08:24 +00:00
|
|
|
break;
|
2001-12-22 23:22:05 +00:00
|
|
|
}
|
|
|
|
|
2005-11-21 17:18:01 +00:00
|
|
|
return ret;
|
gst/auparse/gstauparse.*: Rewrite auparse to suck a little bit less: make source pad dynamic, so decodebin/playbin wo...
Original commit message from CVS:
* gst/auparse/gstauparse.c: (gst_au_parse_base_init),
(gst_au_parse_class_init), (gst_au_parse_init),
(gst_au_parse_reset), (gst_au_parse_add_srcpad),
(gst_au_parse_remove_srcpad), (gst_au_parse_parse_header),
(gst_au_parse_chain), (gst_au_parse_src_convert),
(gst_au_parse_src_query), (gst_au_parse_handle_seek),
(gst_au_parse_sink_event), (gst_au_parse_src_event),
(gst_au_parse_change_state):
* gst/auparse/gstauparse.h:
Rewrite auparse to suck a little bit less: make source pad
dynamic, so decodebin/playbin work with non-raw formats
like alaw/mulaw; add query function for duration/position
queries; check whether we have enough data before attempting
to parse the header (instead of crashing when that is not the
case); work around audioconvert sucking by swapping endianness
to the native endianness ourselves for float formats; send
initial newsegment event. Fixes #161712.
2006-04-26 17:08:24 +00:00
|
|
|
}
|
2006-03-30 15:37:05 +00:00
|
|
|
|
gst/auparse/gstauparse.*: Rewrite auparse to suck a little bit less: make source pad dynamic, so decodebin/playbin wo...
Original commit message from CVS:
* gst/auparse/gstauparse.c: (gst_au_parse_base_init),
(gst_au_parse_class_init), (gst_au_parse_init),
(gst_au_parse_reset), (gst_au_parse_add_srcpad),
(gst_au_parse_remove_srcpad), (gst_au_parse_parse_header),
(gst_au_parse_chain), (gst_au_parse_src_convert),
(gst_au_parse_src_query), (gst_au_parse_handle_seek),
(gst_au_parse_sink_event), (gst_au_parse_src_event),
(gst_au_parse_change_state):
* gst/auparse/gstauparse.h:
Rewrite auparse to suck a little bit less: make source pad
dynamic, so decodebin/playbin work with non-raw formats
like alaw/mulaw; add query function for duration/position
queries; check whether we have enough data before attempting
to parse the header (instead of crashing when that is not the
case); work around audioconvert sucking by swapping endianness
to the native endianness ourselves for float formats; send
initial newsegment event. Fixes #161712.
2006-04-26 17:08:24 +00:00
|
|
|
static gboolean
|
2011-11-17 14:02:55 +00:00
|
|
|
gst_au_parse_src_event (GstPad * pad, GstObject * parent, GstEvent * event)
|
gst/auparse/gstauparse.*: Rewrite auparse to suck a little bit less: make source pad dynamic, so decodebin/playbin wo...
Original commit message from CVS:
* gst/auparse/gstauparse.c: (gst_au_parse_base_init),
(gst_au_parse_class_init), (gst_au_parse_init),
(gst_au_parse_reset), (gst_au_parse_add_srcpad),
(gst_au_parse_remove_srcpad), (gst_au_parse_parse_header),
(gst_au_parse_chain), (gst_au_parse_src_convert),
(gst_au_parse_src_query), (gst_au_parse_handle_seek),
(gst_au_parse_sink_event), (gst_au_parse_src_event),
(gst_au_parse_change_state):
* gst/auparse/gstauparse.h:
Rewrite auparse to suck a little bit less: make source pad
dynamic, so decodebin/playbin work with non-raw formats
like alaw/mulaw; add query function for duration/position
queries; check whether we have enough data before attempting
to parse the header (instead of crashing when that is not the
case); work around audioconvert sucking by swapping endianness
to the native endianness ourselves for float formats; send
initial newsegment event. Fixes #161712.
2006-04-26 17:08:24 +00:00
|
|
|
{
|
|
|
|
GstAuParse *auparse;
|
|
|
|
gboolean ret;
|
|
|
|
|
2011-11-17 14:02:55 +00:00
|
|
|
auparse = GST_AU_PARSE (parent);
|
gst/auparse/gstauparse.*: Rewrite auparse to suck a little bit less: make source pad dynamic, so decodebin/playbin wo...
Original commit message from CVS:
* gst/auparse/gstauparse.c: (gst_au_parse_base_init),
(gst_au_parse_class_init), (gst_au_parse_init),
(gst_au_parse_reset), (gst_au_parse_add_srcpad),
(gst_au_parse_remove_srcpad), (gst_au_parse_parse_header),
(gst_au_parse_chain), (gst_au_parse_src_convert),
(gst_au_parse_src_query), (gst_au_parse_handle_seek),
(gst_au_parse_sink_event), (gst_au_parse_src_event),
(gst_au_parse_change_state):
* gst/auparse/gstauparse.h:
Rewrite auparse to suck a little bit less: make source pad
dynamic, so decodebin/playbin work with non-raw formats
like alaw/mulaw; add query function for duration/position
queries; check whether we have enough data before attempting
to parse the header (instead of crashing when that is not the
case); work around audioconvert sucking by swapping endianness
to the native endianness ourselves for float formats; send
initial newsegment event. Fixes #161712.
2006-04-26 17:08:24 +00:00
|
|
|
|
|
|
|
switch (GST_EVENT_TYPE (event)) {
|
|
|
|
case GST_EVENT_SEEK:
|
|
|
|
ret = gst_au_parse_handle_seek (auparse, event);
|
|
|
|
break;
|
|
|
|
default:
|
2011-11-17 14:02:55 +00:00
|
|
|
ret = gst_pad_event_default (pad, parent, event);
|
gst/auparse/gstauparse.*: Rewrite auparse to suck a little bit less: make source pad dynamic, so decodebin/playbin wo...
Original commit message from CVS:
* gst/auparse/gstauparse.c: (gst_au_parse_base_init),
(gst_au_parse_class_init), (gst_au_parse_init),
(gst_au_parse_reset), (gst_au_parse_add_srcpad),
(gst_au_parse_remove_srcpad), (gst_au_parse_parse_header),
(gst_au_parse_chain), (gst_au_parse_src_convert),
(gst_au_parse_src_query), (gst_au_parse_handle_seek),
(gst_au_parse_sink_event), (gst_au_parse_src_event),
(gst_au_parse_change_state):
* gst/auparse/gstauparse.h:
Rewrite auparse to suck a little bit less: make source pad
dynamic, so decodebin/playbin work with non-raw formats
like alaw/mulaw; add query function for duration/position
queries; check whether we have enough data before attempting
to parse the header (instead of crashing when that is not the
case); work around audioconvert sucking by swapping endianness
to the native endianness ourselves for float formats; send
initial newsegment event. Fixes #161712.
2006-04-26 17:08:24 +00:00
|
|
|
break;
|
2006-03-30 15:37:05 +00:00
|
|
|
}
|
gst/auparse/gstauparse.*: Rewrite auparse to suck a little bit less: make source pad dynamic, so decodebin/playbin wo...
Original commit message from CVS:
* gst/auparse/gstauparse.c: (gst_au_parse_base_init),
(gst_au_parse_class_init), (gst_au_parse_init),
(gst_au_parse_reset), (gst_au_parse_add_srcpad),
(gst_au_parse_remove_srcpad), (gst_au_parse_parse_header),
(gst_au_parse_chain), (gst_au_parse_src_convert),
(gst_au_parse_src_query), (gst_au_parse_handle_seek),
(gst_au_parse_sink_event), (gst_au_parse_src_event),
(gst_au_parse_change_state):
* gst/auparse/gstauparse.h:
Rewrite auparse to suck a little bit less: make source pad
dynamic, so decodebin/playbin work with non-raw formats
like alaw/mulaw; add query function for duration/position
queries; check whether we have enough data before attempting
to parse the header (instead of crashing when that is not the
case); work around audioconvert sucking by swapping endianness
to the native endianness ourselves for float formats; send
initial newsegment event. Fixes #161712.
2006-04-26 17:08:24 +00:00
|
|
|
|
|
|
|
return ret;
|
2001-12-22 23:22:05 +00:00
|
|
|
}
|
|
|
|
|
2005-09-02 15:44:50 +00:00
|
|
|
static GstStateChangeReturn
|
2005-12-12 10:30:20 +00:00
|
|
|
gst_au_parse_change_state (GstElement * element, GstStateChange transition)
|
2004-05-11 00:20:02 +00:00
|
|
|
{
|
2005-12-12 10:30:20 +00:00
|
|
|
GstAuParse *auparse = GST_AU_PARSE (element);
|
2005-10-31 19:08:27 +00:00
|
|
|
GstStateChangeReturn ret = GST_STATE_CHANGE_SUCCESS;
|
|
|
|
|
2011-06-07 09:23:55 +00:00
|
|
|
ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
|
2005-12-12 10:30:20 +00:00
|
|
|
if (ret == GST_STATE_CHANGE_FAILURE)
|
|
|
|
return ret;
|
2005-10-31 19:08:27 +00:00
|
|
|
|
|
|
|
switch (transition) {
|
gst/auparse/gstauparse.*: Rewrite auparse to suck a little bit less: make source pad dynamic, so decodebin/playbin wo...
Original commit message from CVS:
* gst/auparse/gstauparse.c: (gst_au_parse_base_init),
(gst_au_parse_class_init), (gst_au_parse_init),
(gst_au_parse_reset), (gst_au_parse_add_srcpad),
(gst_au_parse_remove_srcpad), (gst_au_parse_parse_header),
(gst_au_parse_chain), (gst_au_parse_src_convert),
(gst_au_parse_src_query), (gst_au_parse_handle_seek),
(gst_au_parse_sink_event), (gst_au_parse_src_event),
(gst_au_parse_change_state):
* gst/auparse/gstauparse.h:
Rewrite auparse to suck a little bit less: make source pad
dynamic, so decodebin/playbin work with non-raw formats
like alaw/mulaw; add query function for duration/position
queries; check whether we have enough data before attempting
to parse the header (instead of crashing when that is not the
case); work around audioconvert sucking by swapping endianness
to the native endianness ourselves for float formats; send
initial newsegment event. Fixes #161712.
2006-04-26 17:08:24 +00:00
|
|
|
case GST_STATE_CHANGE_PAUSED_TO_READY:
|
|
|
|
gst_au_parse_reset (auparse);
|
2005-10-31 19:08:27 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2004-05-11 00:20:02 +00:00
|
|
|
|
2005-10-31 19:08:27 +00:00
|
|
|
return ret;
|
2004-05-11 00:20:02 +00:00
|
|
|
}
|
2001-12-22 23:22:05 +00:00
|
|
|
|
|
|
|
static gboolean
|
2004-03-14 22:34:33 +00:00
|
|
|
plugin_init (GstPlugin * plugin)
|
2001-12-22 23:22:05 +00:00
|
|
|
{
|
2003-11-01 01:32:29 +00:00
|
|
|
if (!gst_element_register (plugin, "auparse", GST_RANK_SECONDARY,
|
2005-12-12 10:30:20 +00:00
|
|
|
GST_TYPE_AU_PARSE)) {
|
2003-11-01 01:32:29 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
2001-12-22 23:22:05 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
|
|
|
|
GST_VERSION_MINOR,
|
2012-04-05 15:36:38 +00:00
|
|
|
auparse,
|
2005-11-14 02:13:35 +00:00
|
|
|
"parses au streams", plugin_init, VERSION, "LGPL", GST_PACKAGE_NAME,
|
|
|
|
GST_PACKAGE_ORIGIN)
|