2003-10-29 23:50:00 +00:00
|
|
|
/* -*- Mode: C; tab-width: 2; indent-tabs-mode: t; c-basic-offset: 2 -*- */
|
2002-03-20 21:45:03 +00:00
|
|
|
/* GStreamer
|
2001-12-22 23:27:31 +00:00
|
|
|
* Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2003-06-29 19:46:12 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
2001-12-22 23:27:31 +00:00
|
|
|
#include <string.h>
|
|
|
|
|
2004-07-27 21:51:32 +00:00
|
|
|
#include "gstwavparse.h"
|
2004-05-08 00:33:39 +00:00
|
|
|
#include "gst/riff/riff-ids.h"
|
|
|
|
#include "gst/riff/riff-media.h"
|
2005-10-23 11:07:10 +00:00
|
|
|
#include <gst/gst-i18n-plugin.h>
|
2001-12-22 23:27:31 +00:00
|
|
|
|
2004-10-02 21:34:00 +00:00
|
|
|
#ifndef G_MAXUINT32
|
|
|
|
#define G_MAXUINT32 0xffffffff
|
|
|
|
#endif
|
|
|
|
|
configure.ac: Check for optional dependency on zlib for id3demux
Original commit message from CVS:
* configure.ac:
Check for optional dependency on zlib for id3demux
* gst/id3demux/Makefile.am:
* gst/id3demux/gstid3demux.c: (gst_gst_id3demux_get_type),
(gst_id3demux_base_init), (gst_id3demux_class_init),
(gst_id3demux_reset), (gst_id3demux_init), (gst_id3demux_dispose),
(gst_id3demux_add_srcpad), (gst_id3demux_remove_srcpad),
(gst_id3demux_trim_buffer), (gst_id3demux_chain),
(gst_id3demux_set_property), (gst_id3demux_get_property),
(id3demux_get_upstream_size), (gst_id3demux_srcpad_event),
(gst_id3demux_read_id3v1), (gst_id3demux_read_id3v2),
(gst_id3demux_sink_activate), (gst_id3demux_src_activate_pull),
(gst_id3demux_src_checkgetrange), (gst_id3demux_read_range),
(gst_id3demux_src_getrange), (gst_id3demux_change_state),
(gst_id3demux_pad_query), (gst_id3demux_get_query_types),
(simple_find_peek), (simple_find_suggest),
(gst_id3demux_do_typefind), (gst_id3demux_send_tag_event),
(plugin_init):
* gst/id3demux/gstid3demux.h:
* gst/id3demux/id3tags.c: (read_synch_uint),
(id3demux_read_id3v1_tag), (id3demux_read_id3v2_tag),
(id3demux_id3v2_frame_hdr_size), (convert_fid_to_v240),
(id3demux_id3v2_frames_to_tag_list):
* gst/id3demux/id3tags.h:
* gst/id3demux/id3v2.4.0-frames.txt:
* gst/id3demux/id3v2.4.0-structure.txt:
* gst/id3demux/id3v2frames.c: (id3demux_id3v2_parse_frame),
(parse_comment_frame), (parse_text_identification_frame),
(id3v2_tag_to_taglist), (parse_split_strings):
All new LGPL id3 demuxer. Can use zlib for compressed frames,
otherwise it discards them. Works on my test files.
* gst/wavparse/gstwavparse.c: (gst_wavparse_loop):
Don't send EOS to a non-existing srcpad
The debug category can be static
2005-12-18 15:14:44 +00:00
|
|
|
GST_DEBUG_CATEGORY_STATIC (wavparse_debug);
|
2004-10-01 16:01:51 +00:00
|
|
|
#define GST_CAT_DEFAULT (wavparse_debug)
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
static void gst_wavparse_base_init (gpointer g_class);
|
|
|
|
static void gst_wavparse_class_init (GstWavParseClass * klass);
|
|
|
|
static void gst_wavparse_init (GstWavParse * wavparse);
|
|
|
|
|
2005-07-20 11:26:05 +00:00
|
|
|
static gboolean gst_wavparse_sink_activate (GstPad * sinkpad);
|
|
|
|
static gboolean gst_wavparse_sink_activate_pull (GstPad * sinkpad,
|
|
|
|
gboolean active);
|
2005-09-02 15:44:50 +00:00
|
|
|
static GstStateChangeReturn gst_wavparse_change_state (GstElement * element,
|
|
|
|
GstStateChange transition);
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2005-07-20 11:26:05 +00:00
|
|
|
static gboolean gst_wavparse_pad_query (GstPad * pad, GstQuery * query);
|
2004-03-14 22:34:33 +00:00
|
|
|
static const GstQueryType *gst_wavparse_get_query_types (GstPad * pad);
|
|
|
|
static gboolean gst_wavparse_pad_convert (GstPad * pad,
|
|
|
|
GstFormat src_format,
|
|
|
|
gint64 src_value, GstFormat * dest_format, gint64 * dest_value);
|
|
|
|
|
2005-07-20 11:26:05 +00:00
|
|
|
static void gst_wavparse_loop (GstPad * pad);
|
2004-03-14 22:34:33 +00:00
|
|
|
static gboolean gst_wavparse_srcpad_event (GstPad * pad, GstEvent * event);
|
|
|
|
static void gst_wavparse_get_property (GObject * object, guint prop_id,
|
|
|
|
GValue * value, GParamSpec * pspec);
|
2001-12-22 23:27:31 +00:00
|
|
|
|
2003-12-22 01:47:09 +00:00
|
|
|
static GstStaticPadTemplate sink_template_factory =
|
2004-03-14 22:34:33 +00:00
|
|
|
GST_STATIC_PAD_TEMPLATE ("wavparse_sink",
|
|
|
|
GST_PAD_SINK,
|
|
|
|
GST_PAD_ALWAYS,
|
|
|
|
GST_STATIC_CAPS ("audio/x-wav")
|
|
|
|
);
|
2001-12-22 23:27:31 +00:00
|
|
|
|
2003-12-22 01:47:09 +00:00
|
|
|
static GstStaticPadTemplate src_template_factory =
|
2004-03-14 22:34:33 +00:00
|
|
|
GST_STATIC_PAD_TEMPLATE ("wavparse_src",
|
|
|
|
GST_PAD_SRC,
|
2004-04-18 23:40:34 +00:00
|
|
|
GST_PAD_SOMETIMES, /* FIXME: spider */
|
2004-03-14 22:34:33 +00:00
|
|
|
GST_STATIC_CAPS ("audio/x-raw-int, "
|
2004-03-15 19:32:27 +00:00
|
|
|
"endianness = (int) little_endian, "
|
|
|
|
"signed = (boolean) { true, false }, "
|
2005-08-10 12:12:31 +00:00
|
|
|
"width = (int) { 8, 16, 24, 32 }, "
|
|
|
|
"depth = (int) { 8, 16, 24, 32 }, "
|
gst/avi/gstavidemux.c: Construct index for indexless files.
Original commit message from CVS:
* gst/avi/gstavidemux.c: (gst_avi_demux_reset),
(gst_avi_demux_handle_src_event), (gst_avi_demux_parse_stream),
(gst_avi_demux_parse_odml), (gst_avi_demux_peek_tag),
(gst_avi_demux_next_data_buffer), (gst_avi_demux_stream_scan),
(gst_avi_demux_stream_header), (gst_avi_demux_loop):
Construct index for indexless files.
Make sure pad/buffers are correctly reset to NULL once we don't need
them anymore, else we get lovely segfaults/assertions.
* gst/wavparse/gstwavparse.c:
Yes, you can have 96KHz audio and wma in wav :(
2005-12-19 15:06:27 +00:00
|
|
|
"rate = (int) [ 8000, 96000 ], "
|
2004-03-15 19:32:27 +00:00
|
|
|
"channels = (int) [ 1, 2 ]; "
|
|
|
|
"audio/mpeg, "
|
|
|
|
"mpegversion = (int) 1, "
|
|
|
|
"layer = (int) [ 1, 3 ], "
|
|
|
|
"rate = (int) [ 8000, 48000 ], "
|
|
|
|
"channels = (int) [ 1, 2 ]; "
|
|
|
|
"audio/x-alaw, "
|
|
|
|
"rate = (int) [ 8000, 48000 ], "
|
|
|
|
"channels = (int) [ 1, 2 ]; "
|
|
|
|
"audio/x-mulaw, "
|
gst/: Add MS RLE support. I added some functions to read out strf chunks into strf chunks and the data behind it. Thi...
Original commit message from CVS:
reviewed by: <delete if not using a buddy>
* gst-libs/gst/riff/riff-media.c:
(gst_riff_create_video_caps_with_data),
(gst_riff_create_video_caps), (gst_riff_create_audio_caps),
(gst_riff_create_video_template_caps),
(gst_riff_create_audio_template_caps):
* gst-libs/gst/riff/riff-media.h:
* gst-libs/gst/riff/riff-read.c:
(gst_riff_read_strf_vids_with_data), (gst_riff_read_strf_vids):
* gst-libs/gst/riff/riff-read.h:
* gst/avi/gstavidemux.c: (gst_avi_demux_add_stream):
Add MS RLE support. I added some functions to read out strf chunks
into strf chunks and the data behind it. This is usually color
palettes (as in RLE, but also in 8-bit RGB). Also use those during
caps creation. Lastly, add ADPCM (similar to wavparse - which
should eventually be rifflib based).
* gst/matroska/matroska-demux.c: (gst_matroska_demux_class_init),
(gst_matroska_demux_init), (gst_matroska_demux_reset):
* gst/matroska/matroska-demux.h:
Remove placeholders for some prehistoric tagging system. Didn't add
support for any tag system really anyway.
* gst/qtdemux/qtdemux.c:
Add support for audio/x-m4a (MPEG-4) through spider.
* gst/wavparse/gstwavparse.c: (gst_wavparse_parse_fmt),
(gst_wavparse_loop):
ADPCM support (#135862). Increase max. buffer size because we
cannot split buffers for ADPCM (screws references) and I've seen
files with 2048 byte chunks. 4096 seems safe for now.
2004-04-16 01:20:44 +00:00
|
|
|
"rate = (int) [ 8000, 48000 ], " "channels = (int) [ 1, 2 ];"
|
|
|
|
"audio/x-adpcm, "
|
|
|
|
"layout = (string) microsoft, "
|
|
|
|
"block_align = (int) [ 1, 8192 ], "
|
2004-04-23 00:47:41 +00:00
|
|
|
"rate = (int) [ 8000, 48000 ], "
|
|
|
|
"channels = (int) [ 1, 2 ]; "
|
|
|
|
"audio/x-adpcm, "
|
|
|
|
"layout = (string) dvi, "
|
|
|
|
"block_align = (int) [ 1, 8192 ], "
|
2004-10-06 15:12:08 +00:00
|
|
|
"rate = (int) [ 8000, 48000 ], " "channels = (int) [ 1, 2 ];"
|
gst/avi/gstavidemux.c: Construct index for indexless files.
Original commit message from CVS:
* gst/avi/gstavidemux.c: (gst_avi_demux_reset),
(gst_avi_demux_handle_src_event), (gst_avi_demux_parse_stream),
(gst_avi_demux_parse_odml), (gst_avi_demux_peek_tag),
(gst_avi_demux_next_data_buffer), (gst_avi_demux_stream_scan),
(gst_avi_demux_stream_header), (gst_avi_demux_loop):
Construct index for indexless files.
Make sure pad/buffers are correctly reset to NULL once we don't need
them anymore, else we get lovely segfaults/assertions.
* gst/wavparse/gstwavparse.c:
Yes, you can have 96KHz audio and wma in wav :(
2005-12-19 15:06:27 +00:00
|
|
|
"audio/x-vnd.sony.atrac3;"
|
|
|
|
"audio/x-wma, " "wmaversion = (int) [ 1, 2 ]")
|
2004-03-14 22:34:33 +00:00
|
|
|
);
|
2001-12-22 23:27:31 +00:00
|
|
|
|
2002-01-30 10:20:58 +00:00
|
|
|
/* WavParse signals and args */
|
2004-03-14 22:34:33 +00:00
|
|
|
enum
|
|
|
|
{
|
2001-12-22 23:27:31 +00:00
|
|
|
/* FILL ME */
|
|
|
|
LAST_SIGNAL
|
|
|
|
};
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
enum
|
|
|
|
{
|
2004-05-21 22:39:30 +00:00
|
|
|
PROP_0
|
2001-12-22 23:27:31 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static GstElementClass *parent_class = NULL;
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2002-03-19 04:10:05 +00:00
|
|
|
/*static guint gst_wavparse_signals[LAST_SIGNAL] = { 0 }; */
|
2001-12-22 23:27:31 +00:00
|
|
|
|
|
|
|
GType
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_wavparse_get_type (void)
|
2001-12-22 23:27:31 +00:00
|
|
|
{
|
2002-01-30 10:20:58 +00:00
|
|
|
static GType wavparse_type = 0;
|
2001-12-22 23:27:31 +00:00
|
|
|
|
2002-01-30 10:20:58 +00:00
|
|
|
if (!wavparse_type) {
|
|
|
|
static const GTypeInfo wavparse_info = {
|
2004-03-14 22:34:33 +00:00
|
|
|
sizeof (GstWavParseClass),
|
2003-11-02 19:28:08 +00:00
|
|
|
gst_wavparse_base_init,
|
2001-12-22 23:27:31 +00:00
|
|
|
NULL,
|
2002-01-30 10:20:58 +00:00
|
|
|
(GClassInitFunc) gst_wavparse_class_init,
|
2001-12-22 23:27:31 +00:00
|
|
|
NULL,
|
|
|
|
NULL,
|
2004-03-14 22:34:33 +00:00
|
|
|
sizeof (GstWavParse),
|
2001-12-22 23:27:31 +00:00
|
|
|
0,
|
2002-01-30 10:20:58 +00:00
|
|
|
(GInstanceInitFunc) gst_wavparse_init,
|
2001-12-22 23:27:31 +00:00
|
|
|
};
|
2004-03-15 19:32:27 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
wavparse_type =
|
2005-07-20 11:26:05 +00:00
|
|
|
g_type_register_static (GST_TYPE_ELEMENT, "GstWavParse",
|
2004-05-08 00:33:39 +00:00
|
|
|
&wavparse_info, 0);
|
2001-12-22 23:27:31 +00:00
|
|
|
}
|
2002-01-30 10:20:58 +00:00
|
|
|
return wavparse_type;
|
2001-12-22 23:27:31 +00:00
|
|
|
}
|
|
|
|
|
2003-11-02 19:28:08 +00:00
|
|
|
|
|
|
|
static void
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_wavparse_base_init (gpointer g_class)
|
2003-11-02 19:28:08 +00:00
|
|
|
{
|
|
|
|
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
|
2005-12-07 11:40:46 +00:00
|
|
|
GstPadTemplate *templ;
|
2004-05-16 20:06:35 +00:00
|
|
|
static GstElementDetails gst_wavparse_details =
|
|
|
|
GST_ELEMENT_DETAILS (".wav demuxer",
|
|
|
|
"Codec/Demuxer/Audio",
|
|
|
|
"Parse a .wav file into raw audio",
|
|
|
|
"Erik Walthinsen <omega@cse.ogi.edu>");
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2003-11-02 19:28:08 +00:00
|
|
|
gst_element_class_set_details (element_class, &gst_wavparse_details);
|
|
|
|
|
|
|
|
/* register src pads */
|
2005-12-07 11:40:46 +00:00
|
|
|
templ = gst_static_pad_template_get (&sink_template_factory);
|
|
|
|
gst_element_class_add_pad_template (element_class, templ);
|
|
|
|
gst_object_unref (templ);
|
|
|
|
templ = gst_static_pad_template_get (&src_template_factory);
|
|
|
|
gst_element_class_add_pad_template (element_class, templ);
|
|
|
|
gst_object_unref (templ);
|
2003-11-02 19:28:08 +00:00
|
|
|
}
|
2004-05-08 00:33:39 +00:00
|
|
|
|
2001-12-22 23:27:31 +00:00
|
|
|
static void
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_wavparse_class_init (GstWavParseClass * klass)
|
2001-12-22 23:27:31 +00:00
|
|
|
{
|
|
|
|
GstElementClass *gstelement_class;
|
2003-10-17 00:29:44 +00:00
|
|
|
GObjectClass *object_class;
|
2004-03-14 22:34:33 +00:00
|
|
|
|
|
|
|
gstelement_class = (GstElementClass *) klass;
|
2003-10-17 00:29:44 +00:00
|
|
|
object_class = (GObjectClass *) klass;
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2005-07-20 11:26:05 +00:00
|
|
|
parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
|
2003-06-13 22:11:56 +00:00
|
|
|
|
2003-10-17 00:29:44 +00:00
|
|
|
object_class->get_property = gst_wavparse_get_property;
|
2003-06-13 22:11:56 +00:00
|
|
|
gstelement_class->change_state = gst_wavparse_change_state;
|
2004-10-01 16:01:51 +00:00
|
|
|
|
|
|
|
GST_DEBUG_CATEGORY_INIT (wavparse_debug, "wavparse", 0, "WAV parser");
|
2001-12-22 23:27:31 +00:00
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
static void
|
2005-07-20 11:26:05 +00:00
|
|
|
gst_wavparse_reset (GstWavParse * wavparse)
|
2001-12-22 23:27:31 +00:00
|
|
|
{
|
2004-05-08 00:33:39 +00:00
|
|
|
wavparse->state = GST_WAVPARSE_START;
|
|
|
|
|
|
|
|
/* These will all be set correctly in the fmt chunk */
|
|
|
|
wavparse->depth = 0;
|
|
|
|
wavparse->rate = 0;
|
|
|
|
wavparse->width = 0;
|
|
|
|
wavparse->channels = 0;
|
2005-07-20 11:26:05 +00:00
|
|
|
wavparse->blockalign = 0;
|
|
|
|
wavparse->bps = 0;
|
2005-12-16 19:32:53 +00:00
|
|
|
wavparse->offset = 0;
|
|
|
|
wavparse->end_offset = 0;
|
2005-07-20 11:26:05 +00:00
|
|
|
wavparse->dataleft = 0;
|
|
|
|
wavparse->datasize = 0;
|
|
|
|
wavparse->datastart = 0;
|
|
|
|
|
|
|
|
if (wavparse->seek_event)
|
|
|
|
gst_event_unref (wavparse->seek_event);
|
|
|
|
wavparse->seek_event = NULL;
|
gst/wavparse/gstwavparse.*: Fix wavparse some more.
Original commit message from CVS:
* gst/wavparse/gstwavparse.c: (gst_wavparse_reset),
(gst_wavparse_init), (gst_wavparse_parse_file_header),
(gst_wavparse_stream_init), (gst_wavparse_handle_seek),
(gst_wavparse_stream_headers), (gst_wavparse_stream_data),
(gst_wavparse_loop), (gst_wavparse_pad_convert),
(gst_wavparse_pad_query), (gst_wavparse_srcpad_event),
(gst_wavparse_change_state):
* gst/wavparse/gstwavparse.h:
Fix wavparse some more.
2005-09-19 16:26:30 +00:00
|
|
|
|
2005-12-16 19:32:53 +00:00
|
|
|
/* we keep the segment info in time */
|
|
|
|
gst_segment_init (&wavparse->segment, GST_FORMAT_TIME);
|
2005-07-20 11:26:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_wavparse_init (GstWavParse * wavparse)
|
|
|
|
{
|
|
|
|
/* sink */
|
|
|
|
wavparse->sinkpad =
|
|
|
|
gst_pad_new_from_template (gst_static_pad_template_get
|
|
|
|
(&sink_template_factory), "sink");
|
|
|
|
gst_element_add_pad (GST_ELEMENT (wavparse), wavparse->sinkpad);
|
2005-11-21 17:23:46 +00:00
|
|
|
gst_pad_set_activate_function (wavparse->sinkpad,
|
|
|
|
GST_DEBUG_FUNCPTR (gst_wavparse_sink_activate));
|
2005-07-20 11:26:05 +00:00
|
|
|
gst_pad_set_activatepull_function (wavparse->sinkpad,
|
2005-11-21 17:23:46 +00:00
|
|
|
GST_DEBUG_FUNCPTR (gst_wavparse_sink_activate_pull));
|
2005-07-20 11:26:05 +00:00
|
|
|
gst_wavparse_reset (wavparse);
|
2001-12-22 23:27:31 +00:00
|
|
|
}
|
|
|
|
|
2004-04-18 23:40:34 +00:00
|
|
|
static void
|
|
|
|
gst_wavparse_destroy_sourcepad (GstWavParse * wavparse)
|
|
|
|
{
|
2004-05-09 00:13:39 +00:00
|
|
|
if (wavparse->srcpad) {
|
|
|
|
gst_element_remove_pad (GST_ELEMENT (wavparse), wavparse->srcpad);
|
|
|
|
wavparse->srcpad = NULL;
|
|
|
|
}
|
2004-04-18 23:40:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_wavparse_create_sourcepad (GstWavParse * wavparse)
|
|
|
|
{
|
2005-12-07 11:40:46 +00:00
|
|
|
GstPadTemplate *templ;
|
|
|
|
|
2004-05-09 00:13:39 +00:00
|
|
|
gst_wavparse_destroy_sourcepad (wavparse);
|
2004-04-18 23:40:34 +00:00
|
|
|
|
|
|
|
/* source */
|
2005-12-07 11:40:46 +00:00
|
|
|
templ = gst_static_pad_template_get (&src_template_factory);
|
|
|
|
wavparse->srcpad = gst_pad_new_from_template (templ, "src");
|
|
|
|
gst_object_unref (templ);
|
2005-07-20 11:26:05 +00:00
|
|
|
gst_pad_use_fixed_caps (wavparse->srcpad);
|
2004-04-18 23:40:34 +00:00
|
|
|
gst_pad_set_query_type_function (wavparse->srcpad,
|
2005-11-21 17:23:46 +00:00
|
|
|
GST_DEBUG_FUNCPTR (gst_wavparse_get_query_types));
|
|
|
|
gst_pad_set_query_function (wavparse->srcpad,
|
|
|
|
GST_DEBUG_FUNCPTR (gst_wavparse_pad_query));
|
|
|
|
gst_pad_set_event_function (wavparse->srcpad,
|
|
|
|
GST_DEBUG_FUNCPTR (gst_wavparse_srcpad_event));
|
2004-04-18 23:40:34 +00:00
|
|
|
}
|
|
|
|
|
2003-10-17 00:29:44 +00:00
|
|
|
static void
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_wavparse_get_property (GObject * object,
|
|
|
|
guint prop_id, GValue * value, GParamSpec * pspec)
|
2003-10-17 00:29:44 +00:00
|
|
|
{
|
|
|
|
GstWavParse *wavparse;
|
|
|
|
|
|
|
|
wavparse = GST_WAVPARSE (object);
|
|
|
|
|
|
|
|
switch (prop_id) {
|
2004-03-14 22:34:33 +00:00
|
|
|
default:
|
|
|
|
break;
|
2003-10-17 00:29:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-12-22 01:47:09 +00:00
|
|
|
#if 0
|
2003-10-17 00:29:44 +00:00
|
|
|
static void
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_wavparse_parse_adtl (GstWavParse * wavparse, int len)
|
2003-10-17 00:29:44 +00:00
|
|
|
{
|
2003-10-29 23:50:00 +00:00
|
|
|
guint32 got_bytes;
|
|
|
|
GstByteStream *bs = wavparse->bs;
|
2003-10-17 00:29:44 +00:00
|
|
|
gst_riff_chunk *temp_chunk, chunk;
|
2003-10-29 23:50:00 +00:00
|
|
|
guint8 *tempdata;
|
|
|
|
struct _gst_riff_labl labl, *temp_labl;
|
|
|
|
struct _gst_riff_ltxt ltxt, *temp_ltxt;
|
|
|
|
struct _gst_riff_note note, *temp_note;
|
|
|
|
char *label_name;
|
2003-10-17 00:29:44 +00:00
|
|
|
GstProps *props;
|
2003-10-29 23:50:00 +00:00
|
|
|
GstPropsEntry *entry;
|
|
|
|
GstCaps *new_caps;
|
|
|
|
GList *caps = NULL;
|
2003-10-17 00:29:44 +00:00
|
|
|
|
2003-10-29 23:50:00 +00:00
|
|
|
props = wavparse->metadata->properties;
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2003-10-29 23:50:00 +00:00
|
|
|
while (len > 0) {
|
2004-03-14 22:34:33 +00:00
|
|
|
got_bytes =
|
2004-03-15 19:32:27 +00:00
|
|
|
gst_bytestream_peek_bytes (bs, &tempdata, sizeof (gst_riff_chunk));
|
2003-10-29 23:50:00 +00:00
|
|
|
if (got_bytes != sizeof (gst_riff_chunk)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
temp_chunk = (gst_riff_chunk *) tempdata;
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2003-10-29 23:50:00 +00:00
|
|
|
chunk.id = GUINT32_FROM_LE (temp_chunk->id);
|
|
|
|
chunk.size = GUINT32_FROM_LE (temp_chunk->size);
|
|
|
|
|
|
|
|
if (chunk.size == 0) {
|
|
|
|
gst_bytestream_flush (bs, sizeof (gst_riff_chunk));
|
|
|
|
len -= sizeof (gst_riff_chunk);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
switch (chunk.id) {
|
|
|
|
case GST_RIFF_adtl_labl:
|
2004-03-15 19:32:27 +00:00
|
|
|
got_bytes =
|
|
|
|
gst_bytestream_peek_bytes (bs, &tempdata,
|
|
|
|
sizeof (struct _gst_riff_labl));
|
|
|
|
if (got_bytes != sizeof (struct _gst_riff_labl)) {
|
|
|
|
return;
|
|
|
|
}
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2004-03-15 19:32:27 +00:00
|
|
|
temp_labl = (struct _gst_riff_labl *) tempdata;
|
|
|
|
labl.id = GUINT32_FROM_LE (temp_labl->id);
|
|
|
|
labl.size = GUINT32_FROM_LE (temp_labl->size);
|
|
|
|
labl.identifier = GUINT32_FROM_LE (temp_labl->identifier);
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2004-03-15 19:32:27 +00:00
|
|
|
gst_bytestream_flush (bs, sizeof (struct _gst_riff_labl));
|
|
|
|
len -= sizeof (struct _gst_riff_labl);
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2004-03-15 19:32:27 +00:00
|
|
|
got_bytes = gst_bytestream_peek_bytes (bs, &tempdata, labl.size - 4);
|
|
|
|
if (got_bytes != labl.size - 4) {
|
|
|
|
return;
|
|
|
|
}
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2004-03-15 19:32:27 +00:00
|
|
|
label_name = (char *) tempdata;
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2004-03-15 19:32:27 +00:00
|
|
|
gst_bytestream_flush (bs, ((labl.size - 4) + 1) & ~1);
|
|
|
|
len -= (((labl.size - 4) + 1) & ~1);
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2004-03-15 19:32:27 +00:00
|
|
|
new_caps = gst_caps_new ("label",
|
|
|
|
"application/x-gst-metadata",
|
|
|
|
gst_props_new ("identifier", G_TYPE_INT (labl.identifier),
|
|
|
|
"name", G_TYPE_STRING (label_name), NULL));
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2004-03-15 19:32:27 +00:00
|
|
|
if (gst_props_get (props, "labels", &caps, NULL)) {
|
|
|
|
caps = g_list_append (caps, new_caps);
|
|
|
|
} else {
|
|
|
|
caps = g_list_append (NULL, new_caps);
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2004-03-15 19:32:27 +00:00
|
|
|
entry = gst_props_entry_new ("labels", GST_PROPS_GLIST (caps));
|
|
|
|
gst_props_add_entry (props, entry);
|
|
|
|
}
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2004-03-15 19:32:27 +00:00
|
|
|
break;
|
2004-03-14 22:34:33 +00:00
|
|
|
|
|
|
|
case GST_RIFF_adtl_ltxt:
|
2004-03-15 19:32:27 +00:00
|
|
|
got_bytes =
|
|
|
|
gst_bytestream_peek_bytes (bs, &tempdata,
|
|
|
|
sizeof (struct _gst_riff_ltxt));
|
|
|
|
if (got_bytes != sizeof (struct _gst_riff_ltxt)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
temp_ltxt = (struct _gst_riff_ltxt *) tempdata;
|
|
|
|
ltxt.id = GUINT32_FROM_LE (temp_ltxt->id);
|
|
|
|
ltxt.size = GUINT32_FROM_LE (temp_ltxt->size);
|
|
|
|
ltxt.identifier = GUINT32_FROM_LE (temp_ltxt->identifier);
|
|
|
|
ltxt.length = GUINT32_FROM_LE (temp_ltxt->length);
|
|
|
|
ltxt.purpose = GUINT32_FROM_LE (temp_ltxt->purpose);
|
|
|
|
ltxt.country = GUINT16_FROM_LE (temp_ltxt->country);
|
|
|
|
ltxt.language = GUINT16_FROM_LE (temp_ltxt->language);
|
|
|
|
ltxt.dialect = GUINT16_FROM_LE (temp_ltxt->dialect);
|
|
|
|
ltxt.codepage = GUINT16_FROM_LE (temp_ltxt->codepage);
|
|
|
|
|
|
|
|
gst_bytestream_flush (bs, sizeof (struct _gst_riff_ltxt));
|
|
|
|
len -= sizeof (struct _gst_riff_ltxt);
|
|
|
|
|
|
|
|
if (ltxt.size - 20 > 0) {
|
|
|
|
got_bytes = gst_bytestream_peek_bytes (bs, &tempdata, ltxt.size - 20);
|
|
|
|
if (got_bytes != ltxt.size - 20) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
gst_bytestream_flush (bs, ((ltxt.size - 20) + 1) & ~1);
|
|
|
|
len -= (((ltxt.size - 20) + 1) & ~1);
|
|
|
|
|
|
|
|
label_name = (char *) tempdata;
|
|
|
|
} else {
|
|
|
|
label_name = "";
|
|
|
|
}
|
|
|
|
|
|
|
|
new_caps = gst_caps_new ("ltxt",
|
|
|
|
"application/x-gst-metadata",
|
|
|
|
gst_props_new ("identifier", G_TYPE_INT (ltxt.identifier),
|
|
|
|
"name", G_TYPE_STRING (label_name),
|
|
|
|
"length", G_TYPE_INT (ltxt.length), NULL));
|
|
|
|
|
|
|
|
if (gst_props_get (props, "ltxts", &caps, NULL)) {
|
|
|
|
caps = g_list_append (caps, new_caps);
|
|
|
|
} else {
|
|
|
|
caps = g_list_append (NULL, new_caps);
|
|
|
|
|
|
|
|
entry = gst_props_entry_new ("ltxts", GST_PROPS_GLIST (caps));
|
|
|
|
gst_props_add_entry (props, entry);
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
2004-03-14 22:34:33 +00:00
|
|
|
|
|
|
|
case GST_RIFF_adtl_note:
|
2004-03-15 19:32:27 +00:00
|
|
|
got_bytes =
|
|
|
|
gst_bytestream_peek_bytes (bs, &tempdata,
|
|
|
|
sizeof (struct _gst_riff_note));
|
|
|
|
if (got_bytes != sizeof (struct _gst_riff_note)) {
|
|
|
|
return;
|
|
|
|
}
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2004-03-15 19:32:27 +00:00
|
|
|
temp_note = (struct _gst_riff_note *) tempdata;
|
|
|
|
note.id = GUINT32_FROM_LE (temp_note->id);
|
|
|
|
note.size = GUINT32_FROM_LE (temp_note->size);
|
|
|
|
note.identifier = GUINT32_FROM_LE (temp_note->identifier);
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2004-03-15 19:32:27 +00:00
|
|
|
gst_bytestream_flush (bs, sizeof (struct _gst_riff_note));
|
|
|
|
len -= sizeof (struct _gst_riff_note);
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2004-03-15 19:32:27 +00:00
|
|
|
got_bytes = gst_bytestream_peek_bytes (bs, &tempdata, note.size - 4);
|
|
|
|
if (got_bytes != note.size - 4) {
|
|
|
|
return;
|
|
|
|
}
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2004-03-15 19:32:27 +00:00
|
|
|
gst_bytestream_flush (bs, ((note.size - 4) + 1) & ~1);
|
|
|
|
len -= (((note.size - 4) + 1) & ~1);
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2004-03-15 19:32:27 +00:00
|
|
|
label_name = (char *) tempdata;
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2004-03-15 19:32:27 +00:00
|
|
|
new_caps = gst_caps_new ("note",
|
|
|
|
"application/x-gst-metadata",
|
|
|
|
gst_props_new ("identifier", G_TYPE_INT (note.identifier),
|
|
|
|
"name", G_TYPE_STRING (label_name), NULL));
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2004-03-15 19:32:27 +00:00
|
|
|
if (gst_props_get (props, "notes", &caps, NULL)) {
|
|
|
|
caps = g_list_append (caps, new_caps);
|
|
|
|
} else {
|
|
|
|
caps = g_list_append (NULL, new_caps);
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2004-03-15 19:32:27 +00:00
|
|
|
entry = gst_props_entry_new ("notes", GST_PROPS_GLIST (caps));
|
|
|
|
gst_props_add_entry (props, entry);
|
|
|
|
}
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2004-03-15 19:32:27 +00:00
|
|
|
break;
|
2004-03-14 22:34:33 +00:00
|
|
|
|
|
|
|
default:
|
2005-11-21 13:38:24 +00:00
|
|
|
g_print ("Unknown chunk: %" GST_FOURCC_FORMAT "\n",
|
2004-03-15 19:32:27 +00:00
|
|
|
GST_FOURCC_ARGS (chunk.id));
|
|
|
|
return;
|
2003-10-29 23:50:00 +00:00
|
|
|
}
|
|
|
|
}
|
2003-11-14 15:02:42 +00:00
|
|
|
|
|
|
|
g_object_notify (G_OBJECT (wavparse), "metadata");
|
2003-10-29 23:50:00 +00:00
|
|
|
}
|
2004-01-02 08:12:12 +00:00
|
|
|
#endif
|
2003-10-29 23:50:00 +00:00
|
|
|
|
2004-01-02 08:12:12 +00:00
|
|
|
#if 0
|
2003-10-29 23:50:00 +00:00
|
|
|
static void
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_wavparse_parse_cues (GstWavParse * wavparse, int len)
|
2003-08-13 06:41:09 +00:00
|
|
|
{
|
2003-10-29 23:50:00 +00:00
|
|
|
guint32 got_bytes;
|
|
|
|
GstByteStream *bs = wavparse->bs;
|
|
|
|
struct _gst_riff_cue *temp_cue, cue;
|
|
|
|
struct _gst_riff_cuepoints *points;
|
|
|
|
guint8 *tempdata;
|
|
|
|
int i;
|
|
|
|
GList *cues = NULL;
|
|
|
|
GstPropsEntry *entry;
|
2003-08-13 06:41:09 +00:00
|
|
|
|
2003-10-29 23:50:00 +00:00
|
|
|
while (len > 0) {
|
2003-11-14 15:02:42 +00:00
|
|
|
int required;
|
2004-03-14 22:34:33 +00:00
|
|
|
|
|
|
|
got_bytes =
|
2004-03-15 19:32:27 +00:00
|
|
|
gst_bytestream_peek_bytes (bs, &tempdata,
|
|
|
|
sizeof (struct _gst_riff_cue));
|
2003-10-29 23:50:00 +00:00
|
|
|
temp_cue = (struct _gst_riff_cue *) tempdata;
|
2003-08-13 06:41:09 +00:00
|
|
|
|
2003-10-29 23:50:00 +00:00
|
|
|
/* fixup for our big endian friends */
|
|
|
|
cue.id = GUINT32_FROM_LE (temp_cue->id);
|
|
|
|
cue.size = GUINT32_FROM_LE (temp_cue->size);
|
|
|
|
cue.cuepoints = GUINT32_FROM_LE (temp_cue->cuepoints);
|
|
|
|
|
|
|
|
gst_bytestream_flush (bs, sizeof (struct _gst_riff_cue));
|
|
|
|
if (got_bytes != sizeof (struct _gst_riff_cue)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
len -= sizeof (struct _gst_riff_cue);
|
|
|
|
|
|
|
|
/* -4 because cue.size contains the cuepoints size
|
|
|
|
and we've already flushed that out of the system */
|
2003-11-14 15:02:42 +00:00
|
|
|
required = cue.size - 4;
|
|
|
|
got_bytes = gst_bytestream_peek_bytes (bs, &tempdata, required);
|
|
|
|
gst_bytestream_flush (bs, ((required) + 1) & ~1);
|
|
|
|
if (got_bytes != required) {
|
2003-10-29 23:50:00 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
len -= (((cue.size - 4) + 1) & ~1);
|
2003-10-29 23:50:00 +00:00
|
|
|
|
|
|
|
/* now we have an array of struct _gst_riff_cuepoints in tempdata */
|
|
|
|
points = (struct _gst_riff_cuepoints *) tempdata;
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2003-10-29 23:50:00 +00:00
|
|
|
for (i = 0; i < cue.cuepoints; i++) {
|
|
|
|
GstCaps *caps;
|
|
|
|
|
|
|
|
caps = gst_caps_new ("cues",
|
2004-03-15 19:32:27 +00:00
|
|
|
"application/x-gst-metadata",
|
|
|
|
gst_props_new ("identifier", G_TYPE_INT (points[i].identifier),
|
|
|
|
"position", G_TYPE_INT (points[i].offset), NULL));
|
2003-10-29 23:50:00 +00:00
|
|
|
cues = g_list_append (cues, caps);
|
|
|
|
}
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2003-10-29 23:50:00 +00:00
|
|
|
entry = gst_props_entry_new ("cues", GST_PROPS_GLIST (cues));
|
|
|
|
gst_props_add_entry (wavparse->metadata->properties, entry);
|
|
|
|
}
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2003-10-29 23:50:00 +00:00
|
|
|
g_object_notify (G_OBJECT (wavparse), "metadata");
|
|
|
|
}
|
2004-01-02 08:12:12 +00:00
|
|
|
#endif
|
2003-10-29 23:50:00 +00:00
|
|
|
|
2004-05-08 00:33:39 +00:00
|
|
|
static gboolean
|
2005-07-20 11:26:05 +00:00
|
|
|
gst_wavparse_parse_file_header (GstElement * element, GstBuffer * buf)
|
2001-12-22 23:27:31 +00:00
|
|
|
{
|
2004-05-08 00:33:39 +00:00
|
|
|
guint32 doctype;
|
2003-03-01 18:34:38 +00:00
|
|
|
|
2005-07-20 11:26:05 +00:00
|
|
|
if (!gst_riff_parse_file_header (element, buf, &doctype))
|
2004-05-08 00:33:39 +00:00
|
|
|
return FALSE;
|
2001-12-22 23:27:31 +00:00
|
|
|
|
gst/wavparse/gstwavparse.*: Fix wavparse some more.
Original commit message from CVS:
* gst/wavparse/gstwavparse.c: (gst_wavparse_reset),
(gst_wavparse_init), (gst_wavparse_parse_file_header),
(gst_wavparse_stream_init), (gst_wavparse_handle_seek),
(gst_wavparse_stream_headers), (gst_wavparse_stream_data),
(gst_wavparse_loop), (gst_wavparse_pad_convert),
(gst_wavparse_pad_query), (gst_wavparse_srcpad_event),
(gst_wavparse_change_state):
* gst/wavparse/gstwavparse.h:
Fix wavparse some more.
2005-09-19 16:26:30 +00:00
|
|
|
if (doctype != GST_RIFF_RIFF_WAVE)
|
|
|
|
goto not_wav;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
not_wav:
|
|
|
|
{
|
2005-07-20 11:26:05 +00:00
|
|
|
GST_ELEMENT_ERROR (element, STREAM, WRONG_TYPE, (NULL),
|
2005-11-21 13:38:24 +00:00
|
|
|
("File is not an WAVE file: %" GST_FOURCC_FORMAT,
|
2005-07-20 11:26:05 +00:00
|
|
|
GST_FOURCC_ARGS (doctype)));
|
2004-05-08 00:33:39 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2005-07-20 11:26:05 +00:00
|
|
|
static GstFlowReturn
|
|
|
|
gst_wavparse_stream_init (GstWavParse * wav)
|
|
|
|
{
|
|
|
|
GstFlowReturn res;
|
|
|
|
GstBuffer *buf = NULL;
|
|
|
|
|
|
|
|
if ((res = gst_pad_pull_range (wav->sinkpad,
|
|
|
|
wav->offset, 12, &buf)) != GST_FLOW_OK)
|
|
|
|
return res;
|
gst/wavparse/gstwavparse.*: Fix wavparse some more.
Original commit message from CVS:
* gst/wavparse/gstwavparse.c: (gst_wavparse_reset),
(gst_wavparse_init), (gst_wavparse_parse_file_header),
(gst_wavparse_stream_init), (gst_wavparse_handle_seek),
(gst_wavparse_stream_headers), (gst_wavparse_stream_data),
(gst_wavparse_loop), (gst_wavparse_pad_convert),
(gst_wavparse_pad_query), (gst_wavparse_srcpad_event),
(gst_wavparse_change_state):
* gst/wavparse/gstwavparse.h:
Fix wavparse some more.
2005-09-19 16:26:30 +00:00
|
|
|
|
2005-07-20 11:26:05 +00:00
|
|
|
else if (!gst_wavparse_parse_file_header (GST_ELEMENT (wav), buf))
|
|
|
|
return GST_FLOW_ERROR;
|
|
|
|
|
|
|
|
wav->offset += 12;
|
|
|
|
|
|
|
|
return GST_FLOW_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
#if 0
|
2004-05-08 00:33:39 +00:00
|
|
|
/* Read 'fmt ' header */
|
|
|
|
static gboolean
|
|
|
|
gst_wavparse_fmt (GstWavParse * wav)
|
|
|
|
{
|
2004-10-01 11:53:19 +00:00
|
|
|
gst_riff_strf_auds *header = NULL;
|
2004-05-08 00:33:39 +00:00
|
|
|
GstCaps *caps;
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2005-07-20 11:26:05 +00:00
|
|
|
if (!gst_riff_read_strf_auds (wav, &header)) {
|
2004-05-08 00:33:39 +00:00
|
|
|
g_warning ("Not fmt");
|
|
|
|
return FALSE;
|
2003-10-29 23:50:00 +00:00
|
|
|
}
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2004-05-08 00:33:39 +00:00
|
|
|
wav->format = header->format;
|
|
|
|
wav->rate = header->rate;
|
|
|
|
wav->channels = header->channels;
|
2005-07-20 11:26:05 +00:00
|
|
|
if (wav->channels == 0) {
|
|
|
|
GST_ELEMENT_ERROR (wav, STREAM, FAILED, (NULL),
|
|
|
|
("Stream claims to contain zero channels - invalid data"));
|
|
|
|
g_free (header);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2004-10-01 16:01:51 +00:00
|
|
|
wav->blockalign = header->blockalign;
|
2004-05-08 00:33:39 +00:00
|
|
|
wav->width = (header->blockalign * 8) / header->channels;
|
|
|
|
wav->depth = header->size;
|
2004-05-16 20:06:35 +00:00
|
|
|
wav->bps = header->av_bps;
|
2005-07-20 11:26:05 +00:00
|
|
|
if (wav->bps <= 0) {
|
|
|
|
GST_ELEMENT_ERROR (wav, STREAM, FAILED, (NULL),
|
|
|
|
("Stream claims to bitrate of <= zero - invalid data"));
|
|
|
|
g_free (header);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Note: gst_riff_create_audio_caps might nedd to fix values in
|
|
|
|
* the header header depending on the format, so call it first */
|
|
|
|
caps = gst_riff_create_audio_caps (header->format, NULL, header, NULL);
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2004-10-29 11:57:35 +00:00
|
|
|
g_free (header);
|
2003-10-29 23:50:00 +00:00
|
|
|
|
2004-05-08 00:33:39 +00:00
|
|
|
if (caps) {
|
2004-10-01 12:39:08 +00:00
|
|
|
gst_wavparse_create_sourcepad (wav);
|
2005-07-20 11:26:05 +00:00
|
|
|
gst_pad_use_fixed_caps (wav->srcpad);
|
|
|
|
gst_pad_set_active (wav->srcpad, TRUE);
|
|
|
|
gst_pad_set_caps (wav->srcpad, caps);
|
2004-05-08 00:33:39 +00:00
|
|
|
gst_caps_free (caps);
|
2004-10-01 12:39:08 +00:00
|
|
|
gst_element_add_pad (GST_ELEMENT (wav), wav->srcpad);
|
2005-01-04 11:09:19 +00:00
|
|
|
gst_element_no_more_pads (GST_ELEMENT (wav));
|
2004-10-01 12:39:08 +00:00
|
|
|
GST_DEBUG ("frequency %d, channels %d", wav->rate, wav->channels);
|
|
|
|
} else {
|
|
|
|
GST_ELEMENT_ERROR (wav, STREAM, TYPE_NOT_FOUND, (NULL), (NULL));
|
|
|
|
return FALSE;
|
2004-05-08 00:33:39 +00:00
|
|
|
}
|
2003-10-29 23:50:00 +00:00
|
|
|
|
2004-05-08 00:33:39 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
2003-10-29 23:50:00 +00:00
|
|
|
|
2004-05-08 00:33:39 +00:00
|
|
|
static gboolean
|
|
|
|
gst_wavparse_other (GstWavParse * wav)
|
|
|
|
{
|
|
|
|
guint32 tag, length;
|
2003-10-29 23:50:00 +00:00
|
|
|
|
2005-07-20 11:26:05 +00:00
|
|
|
if (!gst_riff_peek_head (wav, &tag, &length, NULL)) {
|
2004-10-01 16:01:51 +00:00
|
|
|
GST_WARNING_OBJECT (wav, "could not peek head");
|
2004-05-08 00:33:39 +00:00
|
|
|
return FALSE;
|
2003-11-14 15:02:42 +00:00
|
|
|
}
|
2004-10-01 16:01:51 +00:00
|
|
|
GST_DEBUG_OBJECT (wav, "got tag (%08x) %4.4s, length %d", tag,
|
|
|
|
(gchar *) & tag, length);
|
2003-10-29 23:50:00 +00:00
|
|
|
|
2004-05-08 00:33:39 +00:00
|
|
|
switch (tag) {
|
|
|
|
case GST_RIFF_TAG_LIST:
|
2005-07-20 11:26:05 +00:00
|
|
|
if (!(tag = gst_riff_peek_list (wav))) {
|
2004-10-01 16:01:51 +00:00
|
|
|
GST_WARNING_OBJECT (wav, "could not peek list");
|
2004-05-08 00:33:39 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2004-05-08 00:33:39 +00:00
|
|
|
switch (tag) {
|
|
|
|
case GST_RIFF_LIST_INFO:
|
2005-07-20 11:26:05 +00:00
|
|
|
if (!gst_riff_read_list (wav, &tag) || !gst_riff_read_info (wav)) {
|
2004-10-01 16:01:51 +00:00
|
|
|
GST_WARNING_OBJECT (wav, "could not read list");
|
2004-05-16 20:06:35 +00:00
|
|
|
return FALSE;
|
2004-10-01 16:01:51 +00:00
|
|
|
}
|
2004-05-08 00:33:39 +00:00
|
|
|
break;
|
2003-10-29 23:50:00 +00:00
|
|
|
|
2004-05-08 00:33:39 +00:00
|
|
|
case GST_RIFF_LIST_adtl:
|
2005-07-20 11:26:05 +00:00
|
|
|
if (!gst_riff_read_skip (wav)) {
|
2004-10-01 16:01:51 +00:00
|
|
|
GST_WARNING_OBJECT (wav, "could not read skip");
|
2004-05-16 20:06:35 +00:00
|
|
|
return FALSE;
|
2004-10-01 16:01:51 +00:00
|
|
|
}
|
2004-05-08 00:33:39 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2004-10-01 16:01:51 +00:00
|
|
|
GST_DEBUG_OBJECT (wav, "skipping tag (%08x) %4.4s", tag,
|
|
|
|
(gchar *) & tag);
|
2005-07-20 11:26:05 +00:00
|
|
|
if (!gst_riff_read_skip (wav)) {
|
2004-10-01 16:01:51 +00:00
|
|
|
GST_WARNING_OBJECT (wav, "could not read skip");
|
2004-05-16 20:06:35 +00:00
|
|
|
return FALSE;
|
2004-10-01 16:01:51 +00:00
|
|
|
}
|
2004-05-08 00:33:39 +00:00
|
|
|
break;
|
2003-03-01 18:34:38 +00:00
|
|
|
}
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2004-05-08 00:33:39 +00:00
|
|
|
break;
|
2003-03-01 18:34:38 +00:00
|
|
|
|
2004-05-08 00:33:39 +00:00
|
|
|
case GST_RIFF_TAG_data:
|
2005-07-20 11:26:05 +00:00
|
|
|
if (!gst_bytestream_flush (wav->bs, 8)) {
|
2004-10-01 16:01:51 +00:00
|
|
|
GST_WARNING_OBJECT (wav, "could not flush 8 bytes");
|
2004-05-16 20:06:35 +00:00
|
|
|
return FALSE;
|
2004-10-01 16:01:51 +00:00
|
|
|
}
|
2004-03-15 19:32:27 +00:00
|
|
|
|
2004-10-01 16:01:51 +00:00
|
|
|
GST_DEBUG_OBJECT (wav, "switching to data mode");
|
2004-05-08 00:33:39 +00:00
|
|
|
wav->state = GST_WAVPARSE_DATA;
|
2005-07-20 11:26:05 +00:00
|
|
|
wav->datastart = gst_bytestream_tell (wav->bs);
|
2004-10-01 16:01:51 +00:00
|
|
|
if (length == 0) {
|
|
|
|
guint64 file_length;
|
|
|
|
|
|
|
|
/* length is 0, data probably stretches to the end
|
|
|
|
* of file */
|
|
|
|
GST_DEBUG_OBJECT (wav, "length is 0 trying to find length");
|
|
|
|
/* get length of file */
|
2005-07-20 11:26:05 +00:00
|
|
|
file_length = gst_bytestream_length (wav->bs);
|
2004-10-01 16:01:51 +00:00
|
|
|
if (file_length == -1) {
|
|
|
|
GST_DEBUG_OBJECT (wav,
|
|
|
|
"could not get file length, assuming data to eof");
|
|
|
|
/* could not get length, assuming till eof */
|
|
|
|
length = G_MAXUINT32;
|
|
|
|
}
|
|
|
|
if (file_length > G_MAXUINT32) {
|
|
|
|
GST_DEBUG_OBJECT (wav, "file length %lld, clipping to 32 bits");
|
|
|
|
/* could not get length, assuming till eof */
|
|
|
|
length = G_MAXUINT32;
|
|
|
|
} else {
|
2005-07-20 11:26:05 +00:00
|
|
|
GST_DEBUG_OBJECT (wav, "file length %lld, datalength",
|
|
|
|
file_length, length);
|
2004-10-01 16:01:51 +00:00
|
|
|
/* substract offset of datastart from length */
|
|
|
|
length = file_length - wav->datastart;
|
|
|
|
GST_DEBUG_OBJECT (wav, "datalength %lld", length);
|
|
|
|
}
|
|
|
|
}
|
2005-12-16 19:32:53 +00:00
|
|
|
wav->datasize = (guint64) length;
|
2004-05-08 00:33:39 +00:00
|
|
|
break;
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2004-05-08 00:33:39 +00:00
|
|
|
case GST_RIFF_TAG_cue:
|
2005-07-20 11:26:05 +00:00
|
|
|
if (!gst_riff_read_skip (wav)) {
|
2004-10-01 16:01:51 +00:00
|
|
|
GST_WARNING_OBJECT (wav, "could not read skip");
|
2004-05-16 20:06:35 +00:00
|
|
|
return FALSE;
|
2004-10-01 16:01:51 +00:00
|
|
|
}
|
2004-05-08 00:33:39 +00:00
|
|
|
break;
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2004-05-08 00:33:39 +00:00
|
|
|
default:
|
2004-10-01 16:01:51 +00:00
|
|
|
GST_DEBUG_OBJECT (wav, "skipping tag (%08x) %4.4s", tag, (gchar *) & tag);
|
2005-07-20 11:26:05 +00:00
|
|
|
if (!gst_riff_read_skip (wav))
|
2004-05-16 20:06:35 +00:00
|
|
|
return FALSE;
|
2004-05-08 00:33:39 +00:00
|
|
|
break;
|
|
|
|
}
|
2001-12-22 23:27:31 +00:00
|
|
|
|
2004-05-08 00:33:39 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
2005-07-20 11:26:05 +00:00
|
|
|
#endif
|
2001-12-22 23:27:31 +00:00
|
|
|
|
2004-05-16 20:06:35 +00:00
|
|
|
static gboolean
|
2005-12-16 19:32:53 +00:00
|
|
|
gst_wavparse_perform_seek (GstWavParse * wav, GstEvent * event)
|
2004-05-16 20:06:35 +00:00
|
|
|
{
|
2005-12-16 19:32:53 +00:00
|
|
|
gboolean res;
|
|
|
|
gdouble rate;
|
|
|
|
GstFormat format;
|
|
|
|
GstSeekFlags flags;
|
|
|
|
GstSeekType cur_type, stop_type;
|
|
|
|
gint64 cur, stop;
|
gst/wavparse/gstwavparse.*: Fix wavparse some more.
Original commit message from CVS:
* gst/wavparse/gstwavparse.c: (gst_wavparse_reset),
(gst_wavparse_init), (gst_wavparse_parse_file_header),
(gst_wavparse_stream_init), (gst_wavparse_handle_seek),
(gst_wavparse_stream_headers), (gst_wavparse_stream_data),
(gst_wavparse_loop), (gst_wavparse_pad_convert),
(gst_wavparse_pad_query), (gst_wavparse_srcpad_event),
(gst_wavparse_change_state):
* gst/wavparse/gstwavparse.h:
Fix wavparse some more.
2005-09-19 16:26:30 +00:00
|
|
|
gboolean flush;
|
2005-12-16 19:32:53 +00:00
|
|
|
gboolean update;
|
|
|
|
GstSegment seeksegment;
|
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (wav, "doing seek");
|
|
|
|
|
|
|
|
if (event) {
|
|
|
|
gst_event_parse_seek (event, &rate, &format, &flags,
|
|
|
|
&cur_type, &cur, &stop_type, &stop);
|
|
|
|
|
|
|
|
/* we have to have a format as the segment format. Try to convert
|
|
|
|
* if not. */
|
|
|
|
if (format != GST_FORMAT_TIME) {
|
|
|
|
GstFormat fmt;
|
|
|
|
|
|
|
|
fmt = GST_FORMAT_TIME;
|
|
|
|
res = TRUE;
|
|
|
|
if (cur_type != GST_SEEK_TYPE_NONE)
|
|
|
|
res = gst_pad_query_convert (wav->srcpad, format, cur, &fmt, &cur);
|
|
|
|
if (res && stop_type != GST_SEEK_TYPE_NONE)
|
|
|
|
res = gst_pad_query_convert (wav->srcpad, format, stop, &fmt, &stop);
|
|
|
|
if (!res)
|
|
|
|
goto no_format;
|
|
|
|
|
|
|
|
format = fmt;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
flags = 0;
|
|
|
|
}
|
gst/wavparse/gstwavparse.*: Fix wavparse some more.
Original commit message from CVS:
* gst/wavparse/gstwavparse.c: (gst_wavparse_reset),
(gst_wavparse_init), (gst_wavparse_parse_file_header),
(gst_wavparse_stream_init), (gst_wavparse_handle_seek),
(gst_wavparse_stream_headers), (gst_wavparse_stream_data),
(gst_wavparse_loop), (gst_wavparse_pad_convert),
(gst_wavparse_pad_query), (gst_wavparse_srcpad_event),
(gst_wavparse_change_state):
* gst/wavparse/gstwavparse.h:
Fix wavparse some more.
2005-09-19 16:26:30 +00:00
|
|
|
|
2005-12-16 19:32:53 +00:00
|
|
|
flush = flags & GST_SEEK_FLAG_FLUSH;
|
gst/wavparse/gstwavparse.*: Fix wavparse some more.
Original commit message from CVS:
* gst/wavparse/gstwavparse.c: (gst_wavparse_reset),
(gst_wavparse_init), (gst_wavparse_parse_file_header),
(gst_wavparse_stream_init), (gst_wavparse_handle_seek),
(gst_wavparse_stream_headers), (gst_wavparse_stream_data),
(gst_wavparse_loop), (gst_wavparse_pad_convert),
(gst_wavparse_pad_query), (gst_wavparse_srcpad_event),
(gst_wavparse_change_state):
* gst/wavparse/gstwavparse.h:
Fix wavparse some more.
2005-09-19 16:26:30 +00:00
|
|
|
|
|
|
|
if (flush)
|
|
|
|
gst_pad_push_event (wav->srcpad, gst_event_new_flush_start ());
|
|
|
|
else
|
|
|
|
gst_pad_pause_task (wav->sinkpad);
|
2004-05-16 20:06:35 +00:00
|
|
|
|
2005-11-21 18:09:02 +00:00
|
|
|
GST_PAD_STREAM_LOCK (wav->sinkpad);
|
2004-05-16 20:06:35 +00:00
|
|
|
|
2005-12-16 19:32:53 +00:00
|
|
|
/* copy segment, we need this because we still need the old
|
|
|
|
* segment when we close the current segment. */
|
|
|
|
memcpy (&seeksegment, &wav->segment, sizeof (GstSegment));
|
|
|
|
|
|
|
|
if (event) {
|
|
|
|
gst_segment_set_seek (&seeksegment, rate, format, flags,
|
|
|
|
cur_type, cur, stop_type, stop, &update);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((stop = seeksegment.stop) == -1)
|
|
|
|
stop = seeksegment.duration;
|
|
|
|
|
|
|
|
if (cur_type != GST_SEEK_TYPE_NONE) {
|
|
|
|
wav->offset =
|
|
|
|
gst_util_uint64_scale_int (seeksegment.last_stop, wav->bps, GST_SECOND);
|
|
|
|
wav->offset += wav->datastart;
|
|
|
|
wav->offset -= wav->offset % wav->bytes_per_sample;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (stop != -1) {
|
|
|
|
wav->end_offset = gst_util_uint64_scale_int (stop, wav->bps, GST_SECOND);
|
|
|
|
wav->end_offset += wav->datastart;
|
|
|
|
wav->end_offset +=
|
|
|
|
wav->bytes_per_sample - (wav->end_offset % wav->bytes_per_sample);
|
gst/wavparse/gstwavparse.*: Fix wavparse some more.
Original commit message from CVS:
* gst/wavparse/gstwavparse.c: (gst_wavparse_reset),
(gst_wavparse_init), (gst_wavparse_parse_file_header),
(gst_wavparse_stream_init), (gst_wavparse_handle_seek),
(gst_wavparse_stream_headers), (gst_wavparse_stream_data),
(gst_wavparse_loop), (gst_wavparse_pad_convert),
(gst_wavparse_pad_query), (gst_wavparse_srcpad_event),
(gst_wavparse_change_state):
* gst/wavparse/gstwavparse.h:
Fix wavparse some more.
2005-09-19 16:26:30 +00:00
|
|
|
} else {
|
2005-12-16 19:32:53 +00:00
|
|
|
wav->end_offset = wav->datasize + wav->datastart;
|
gst/wavparse/gstwavparse.*: Fix wavparse some more.
Original commit message from CVS:
* gst/wavparse/gstwavparse.c: (gst_wavparse_reset),
(gst_wavparse_init), (gst_wavparse_parse_file_header),
(gst_wavparse_stream_init), (gst_wavparse_handle_seek),
(gst_wavparse_stream_headers), (gst_wavparse_stream_data),
(gst_wavparse_loop), (gst_wavparse_pad_convert),
(gst_wavparse_pad_query), (gst_wavparse_srcpad_event),
(gst_wavparse_change_state):
* gst/wavparse/gstwavparse.h:
Fix wavparse some more.
2005-09-19 16:26:30 +00:00
|
|
|
}
|
2005-12-16 19:32:53 +00:00
|
|
|
wav->offset = MIN (wav->offset, wav->end_offset);
|
|
|
|
wav->dataleft = wav->end_offset - wav->offset;
|
gst/wavparse/gstwavparse.*: Fix wavparse some more.
Original commit message from CVS:
* gst/wavparse/gstwavparse.c: (gst_wavparse_reset),
(gst_wavparse_init), (gst_wavparse_parse_file_header),
(gst_wavparse_stream_init), (gst_wavparse_handle_seek),
(gst_wavparse_stream_headers), (gst_wavparse_stream_data),
(gst_wavparse_loop), (gst_wavparse_pad_convert),
(gst_wavparse_pad_query), (gst_wavparse_srcpad_event),
(gst_wavparse_change_state):
* gst/wavparse/gstwavparse.h:
Fix wavparse some more.
2005-09-19 16:26:30 +00:00
|
|
|
|
2005-12-16 19:32:53 +00:00
|
|
|
GST_DEBUG ("seek: offset %" G_GUINT64_FORMAT ", end %" G_GUINT64_FORMAT
|
gst/wavparse/gstwavparse.*: Fix wavparse some more.
Original commit message from CVS:
* gst/wavparse/gstwavparse.c: (gst_wavparse_reset),
(gst_wavparse_init), (gst_wavparse_parse_file_header),
(gst_wavparse_stream_init), (gst_wavparse_handle_seek),
(gst_wavparse_stream_headers), (gst_wavparse_stream_data),
(gst_wavparse_loop), (gst_wavparse_pad_convert),
(gst_wavparse_pad_query), (gst_wavparse_srcpad_event),
(gst_wavparse_change_state):
* gst/wavparse/gstwavparse.h:
Fix wavparse some more.
2005-09-19 16:26:30 +00:00
|
|
|
", segment %" GST_TIME_FORMAT " -- %" GST_TIME_FORMAT,
|
2005-12-16 19:32:53 +00:00
|
|
|
wav->offset, wav->end_offset, GST_TIME_ARGS (seeksegment.start),
|
|
|
|
GST_TIME_ARGS (stop));
|
2004-05-16 20:06:35 +00:00
|
|
|
|
2005-12-16 19:32:53 +00:00
|
|
|
/* prepare for streaming again */
|
|
|
|
if (flush) {
|
gst/wavparse/gstwavparse.*: Fix wavparse some more.
Original commit message from CVS:
* gst/wavparse/gstwavparse.c: (gst_wavparse_reset),
(gst_wavparse_init), (gst_wavparse_parse_file_header),
(gst_wavparse_stream_init), (gst_wavparse_handle_seek),
(gst_wavparse_stream_headers), (gst_wavparse_stream_data),
(gst_wavparse_loop), (gst_wavparse_pad_convert),
(gst_wavparse_pad_query), (gst_wavparse_srcpad_event),
(gst_wavparse_change_state):
* gst/wavparse/gstwavparse.h:
Fix wavparse some more.
2005-09-19 16:26:30 +00:00
|
|
|
gst_pad_push_event (wav->srcpad, gst_event_new_flush_stop ());
|
2005-12-16 19:32:53 +00:00
|
|
|
} else if (wav->segment_running) {
|
|
|
|
/* we are running the current segment and doing a non-flushing seek,
|
|
|
|
* close the segment first based on the last_stop. */
|
|
|
|
GST_DEBUG_OBJECT (wav, "closing running segment %" G_GINT64_FORMAT
|
|
|
|
" to %" G_GINT64_FORMAT, wav->segment.start, wav->segment.last_stop);
|
|
|
|
|
|
|
|
gst_pad_push_event (wav->srcpad,
|
|
|
|
gst_event_new_new_segment (TRUE,
|
|
|
|
wav->segment.rate, wav->segment.format,
|
|
|
|
wav->segment.start, wav->segment.last_stop, wav->segment.time));
|
|
|
|
}
|
gst/wavparse/gstwavparse.*: Fix wavparse some more.
Original commit message from CVS:
* gst/wavparse/gstwavparse.c: (gst_wavparse_reset),
(gst_wavparse_init), (gst_wavparse_parse_file_header),
(gst_wavparse_stream_init), (gst_wavparse_handle_seek),
(gst_wavparse_stream_headers), (gst_wavparse_stream_data),
(gst_wavparse_loop), (gst_wavparse_pad_convert),
(gst_wavparse_pad_query), (gst_wavparse_srcpad_event),
(gst_wavparse_change_state):
* gst/wavparse/gstwavparse.h:
Fix wavparse some more.
2005-09-19 16:26:30 +00:00
|
|
|
|
2005-12-16 19:32:53 +00:00
|
|
|
memcpy (&wav->segment, &seeksegment, sizeof (GstSegment));
|
|
|
|
|
|
|
|
if (wav->segment.flags & GST_SEEK_FLAG_SEGMENT) {
|
gst/wavparse/gstwavparse.*: Fix wavparse some more.
Original commit message from CVS:
* gst/wavparse/gstwavparse.c: (gst_wavparse_reset),
(gst_wavparse_init), (gst_wavparse_parse_file_header),
(gst_wavparse_stream_init), (gst_wavparse_handle_seek),
(gst_wavparse_stream_headers), (gst_wavparse_stream_data),
(gst_wavparse_loop), (gst_wavparse_pad_convert),
(gst_wavparse_pad_query), (gst_wavparse_srcpad_event),
(gst_wavparse_change_state):
* gst/wavparse/gstwavparse.h:
Fix wavparse some more.
2005-09-19 16:26:30 +00:00
|
|
|
gst_element_post_message (GST_ELEMENT (wav),
|
2005-12-16 19:32:53 +00:00
|
|
|
gst_message_new_segment_start (GST_OBJECT (wav),
|
|
|
|
wav->segment.format, wav->segment.last_stop));
|
gst/wavparse/gstwavparse.*: Fix wavparse some more.
Original commit message from CVS:
* gst/wavparse/gstwavparse.c: (gst_wavparse_reset),
(gst_wavparse_init), (gst_wavparse_parse_file_header),
(gst_wavparse_stream_init), (gst_wavparse_handle_seek),
(gst_wavparse_stream_headers), (gst_wavparse_stream_data),
(gst_wavparse_loop), (gst_wavparse_pad_convert),
(gst_wavparse_pad_query), (gst_wavparse_srcpad_event),
(gst_wavparse_change_state):
* gst/wavparse/gstwavparse.h:
Fix wavparse some more.
2005-09-19 16:26:30 +00:00
|
|
|
}
|
2004-05-16 20:06:35 +00:00
|
|
|
|
2005-12-16 19:32:53 +00:00
|
|
|
/* now send the newsegment */
|
|
|
|
GST_DEBUG_OBJECT (wav, "Sending newsegment from %" G_GINT64_FORMAT
|
|
|
|
" to %" G_GINT64_FORMAT, wav->segment.start, stop);
|
|
|
|
|
|
|
|
gst_pad_push_event (wav->srcpad,
|
|
|
|
gst_event_new_new_segment (FALSE,
|
|
|
|
wav->segment.rate, wav->segment.format,
|
|
|
|
wav->segment.last_stop, stop, wav->segment.time));
|
|
|
|
|
|
|
|
wav->segment_running = TRUE;
|
2005-07-20 11:26:05 +00:00
|
|
|
gst_pad_start_task (wav->sinkpad, (GstTaskFunction) gst_wavparse_loop,
|
|
|
|
wav->sinkpad);
|
|
|
|
|
2005-11-21 18:09:02 +00:00
|
|
|
GST_PAD_STREAM_UNLOCK (wav->sinkpad);
|
2005-07-20 11:26:05 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
2005-12-16 19:32:53 +00:00
|
|
|
/* ERRORS */
|
|
|
|
no_format:
|
|
|
|
{
|
|
|
|
GST_DEBUG_OBJECT (wav, "unsupported format given, seek aborted.");
|
|
|
|
return FALSE;
|
|
|
|
}
|
2005-07-20 11:26:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static GstFlowReturn
|
|
|
|
gst_wavparse_stream_headers (GstWavParse * wav)
|
|
|
|
{
|
|
|
|
GstFlowReturn res;
|
|
|
|
GstBuffer *buf, *extra;
|
|
|
|
gst_riff_strf_auds *header = NULL;
|
|
|
|
guint32 tag;
|
|
|
|
gboolean gotdata = FALSE;
|
|
|
|
GstCaps *caps;
|
2005-12-16 19:32:53 +00:00
|
|
|
gint64 duration;
|
2005-07-20 11:26:05 +00:00
|
|
|
|
|
|
|
/* The header start with a 'fmt ' tag */
|
|
|
|
if ((res = gst_riff_read_chunk (GST_ELEMENT (wav), wav->sinkpad,
|
|
|
|
&wav->offset, &tag, &buf)) != GST_FLOW_OK)
|
|
|
|
return res;
|
gst/wavparse/gstwavparse.*: Fix wavparse some more.
Original commit message from CVS:
* gst/wavparse/gstwavparse.c: (gst_wavparse_reset),
(gst_wavparse_init), (gst_wavparse_parse_file_header),
(gst_wavparse_stream_init), (gst_wavparse_handle_seek),
(gst_wavparse_stream_headers), (gst_wavparse_stream_data),
(gst_wavparse_loop), (gst_wavparse_pad_convert),
(gst_wavparse_pad_query), (gst_wavparse_srcpad_event),
(gst_wavparse_change_state):
* gst/wavparse/gstwavparse.h:
Fix wavparse some more.
2005-09-19 16:26:30 +00:00
|
|
|
|
|
|
|
else if (tag != GST_RIFF_TAG_fmt)
|
|
|
|
goto invalid_wav;
|
|
|
|
|
|
|
|
if (!(gst_riff_parse_strf_auds (GST_ELEMENT (wav), buf, &header, &extra)))
|
|
|
|
goto parse_header_error;
|
2004-05-16 20:06:35 +00:00
|
|
|
|
2005-12-07 11:40:46 +00:00
|
|
|
if (extra)
|
|
|
|
gst_buffer_unref (extra);
|
|
|
|
|
2005-08-10 12:12:31 +00:00
|
|
|
/* Note: gst_riff_create_audio_caps might nedd to fix values in
|
|
|
|
* the header header depending on the format, so call it first */
|
2005-07-20 11:26:05 +00:00
|
|
|
caps =
|
|
|
|
gst_riff_create_audio_caps (header->format, NULL, header, NULL,
|
|
|
|
NULL, NULL);
|
2004-05-16 20:06:35 +00:00
|
|
|
|
2005-07-20 11:26:05 +00:00
|
|
|
wav->format = header->format;
|
|
|
|
wav->rate = header->rate;
|
|
|
|
wav->channels = header->channels;
|
gst/wavparse/gstwavparse.*: Fix wavparse some more.
Original commit message from CVS:
* gst/wavparse/gstwavparse.c: (gst_wavparse_reset),
(gst_wavparse_init), (gst_wavparse_parse_file_header),
(gst_wavparse_stream_init), (gst_wavparse_handle_seek),
(gst_wavparse_stream_headers), (gst_wavparse_stream_data),
(gst_wavparse_loop), (gst_wavparse_pad_convert),
(gst_wavparse_pad_query), (gst_wavparse_srcpad_event),
(gst_wavparse_change_state):
* gst/wavparse/gstwavparse.h:
Fix wavparse some more.
2005-09-19 16:26:30 +00:00
|
|
|
|
|
|
|
if (wav->channels == 0)
|
|
|
|
goto no_channels;
|
|
|
|
|
2005-07-20 11:26:05 +00:00
|
|
|
wav->blockalign = header->blockalign;
|
|
|
|
wav->width = (header->blockalign * 8) / header->channels;
|
|
|
|
wav->depth = header->size;
|
|
|
|
wav->bps = header->av_bps;
|
gst/wavparse/gstwavparse.*: Fix wavparse some more.
Original commit message from CVS:
* gst/wavparse/gstwavparse.c: (gst_wavparse_reset),
(gst_wavparse_init), (gst_wavparse_parse_file_header),
(gst_wavparse_stream_init), (gst_wavparse_handle_seek),
(gst_wavparse_stream_headers), (gst_wavparse_stream_data),
(gst_wavparse_loop), (gst_wavparse_pad_convert),
(gst_wavparse_pad_query), (gst_wavparse_srcpad_event),
(gst_wavparse_change_state):
* gst/wavparse/gstwavparse.h:
Fix wavparse some more.
2005-09-19 16:26:30 +00:00
|
|
|
|
|
|
|
if (wav->bps <= 0)
|
|
|
|
goto no_bitrate;
|
|
|
|
|
|
|
|
wav->bytes_per_sample = wav->channels * wav->width / 8;
|
|
|
|
if (wav->bytes_per_sample <= 0)
|
|
|
|
goto no_bytes_per_sample;
|
2004-05-16 20:06:35 +00:00
|
|
|
|
2005-07-20 11:26:05 +00:00
|
|
|
g_free (header);
|
|
|
|
|
gst/wavparse/gstwavparse.*: Fix wavparse some more.
Original commit message from CVS:
* gst/wavparse/gstwavparse.c: (gst_wavparse_reset),
(gst_wavparse_init), (gst_wavparse_parse_file_header),
(gst_wavparse_stream_init), (gst_wavparse_handle_seek),
(gst_wavparse_stream_headers), (gst_wavparse_stream_data),
(gst_wavparse_loop), (gst_wavparse_pad_convert),
(gst_wavparse_pad_query), (gst_wavparse_srcpad_event),
(gst_wavparse_change_state):
* gst/wavparse/gstwavparse.h:
Fix wavparse some more.
2005-09-19 16:26:30 +00:00
|
|
|
if (!caps)
|
|
|
|
goto unknown_format;
|
|
|
|
|
|
|
|
gst_wavparse_create_sourcepad (wav);
|
|
|
|
gst_pad_set_active (wav->srcpad, TRUE);
|
|
|
|
gst_pad_set_caps (wav->srcpad, caps);
|
|
|
|
gst_caps_unref (caps);
|
|
|
|
caps = NULL;
|
|
|
|
|
|
|
|
gst_element_add_pad (GST_ELEMENT (wav), wav->srcpad);
|
|
|
|
gst_element_no_more_pads (GST_ELEMENT (wav));
|
2005-07-20 11:26:05 +00:00
|
|
|
|
gst/wavparse/gstwavparse.*: Fix wavparse some more.
Original commit message from CVS:
* gst/wavparse/gstwavparse.c: (gst_wavparse_reset),
(gst_wavparse_init), (gst_wavparse_parse_file_header),
(gst_wavparse_stream_init), (gst_wavparse_handle_seek),
(gst_wavparse_stream_headers), (gst_wavparse_stream_data),
(gst_wavparse_loop), (gst_wavparse_pad_convert),
(gst_wavparse_pad_query), (gst_wavparse_srcpad_event),
(gst_wavparse_change_state):
* gst/wavparse/gstwavparse.h:
Fix wavparse some more.
2005-09-19 16:26:30 +00:00
|
|
|
GST_DEBUG ("frequency %d, channels %d", wav->rate, wav->channels);
|
2005-07-20 11:26:05 +00:00
|
|
|
|
|
|
|
/* loop headers until we get data */
|
|
|
|
while (!gotdata) {
|
|
|
|
guint size;
|
|
|
|
guint32 tag;
|
|
|
|
|
|
|
|
if ((res =
|
|
|
|
gst_pad_pull_range (wav->sinkpad, wav->offset, 8,
|
gst/wavparse/gstwavparse.*: Fix wavparse some more.
Original commit message from CVS:
* gst/wavparse/gstwavparse.c: (gst_wavparse_reset),
(gst_wavparse_init), (gst_wavparse_parse_file_header),
(gst_wavparse_stream_init), (gst_wavparse_handle_seek),
(gst_wavparse_stream_headers), (gst_wavparse_stream_data),
(gst_wavparse_loop), (gst_wavparse_pad_convert),
(gst_wavparse_pad_query), (gst_wavparse_srcpad_event),
(gst_wavparse_change_state):
* gst/wavparse/gstwavparse.h:
Fix wavparse some more.
2005-09-19 16:26:30 +00:00
|
|
|
&buf)) != GST_FLOW_OK)
|
|
|
|
goto header_read_error;
|
2005-07-20 11:26:05 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
wav is a st00pid format, we don't know for sure where data starts.
|
|
|
|
So we have to go bit by bit until we find the 'data' header
|
|
|
|
*/
|
|
|
|
tag = GST_READ_UINT32_LE (GST_BUFFER_DATA (buf));
|
|
|
|
size = GST_READ_UINT32_LE (GST_BUFFER_DATA (buf) + 4);
|
gst/wavparse/gstwavparse.*: Fix wavparse some more.
Original commit message from CVS:
* gst/wavparse/gstwavparse.c: (gst_wavparse_reset),
(gst_wavparse_init), (gst_wavparse_parse_file_header),
(gst_wavparse_stream_init), (gst_wavparse_handle_seek),
(gst_wavparse_stream_headers), (gst_wavparse_stream_data),
(gst_wavparse_loop), (gst_wavparse_pad_convert),
(gst_wavparse_pad_query), (gst_wavparse_srcpad_event),
(gst_wavparse_change_state):
* gst/wavparse/gstwavparse.h:
Fix wavparse some more.
2005-09-19 16:26:30 +00:00
|
|
|
|
2005-07-20 11:26:05 +00:00
|
|
|
switch (tag) {
|
|
|
|
/* TODO : Implement the various cases */
|
|
|
|
case GST_RIFF_TAG_data:
|
|
|
|
GST_DEBUG ("Got 'data' TAG, size : %d", size);
|
|
|
|
gotdata = TRUE;
|
|
|
|
wav->offset += 8;
|
|
|
|
wav->datastart = wav->offset;
|
|
|
|
wav->datasize = size;
|
2005-12-16 19:32:53 +00:00
|
|
|
wav->dataleft = size;
|
|
|
|
wav->end_offset = size + wav->datastart;
|
2005-07-20 11:26:05 +00:00
|
|
|
break;
|
|
|
|
default:
|
2005-11-21 13:38:24 +00:00
|
|
|
GST_DEBUG ("Ignoring tag %" GST_FOURCC_FORMAT, GST_FOURCC_ARGS (tag));
|
2005-07-20 11:26:05 +00:00
|
|
|
wav->offset += 8 + ((size + 1) & ~1);
|
|
|
|
}
|
|
|
|
gst_buffer_unref (buf);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_DEBUG ("Finished parsing headers");
|
gst/wavparse/gstwavparse.*: Fix wavparse some more.
Original commit message from CVS:
* gst/wavparse/gstwavparse.c: (gst_wavparse_reset),
(gst_wavparse_init), (gst_wavparse_parse_file_header),
(gst_wavparse_stream_init), (gst_wavparse_handle_seek),
(gst_wavparse_stream_headers), (gst_wavparse_stream_data),
(gst_wavparse_loop), (gst_wavparse_pad_convert),
(gst_wavparse_pad_query), (gst_wavparse_srcpad_event),
(gst_wavparse_change_state):
* gst/wavparse/gstwavparse.h:
Fix wavparse some more.
2005-09-19 16:26:30 +00:00
|
|
|
|
2005-12-16 19:32:53 +00:00
|
|
|
duration = gst_util_uint64_scale_int (wav->datasize, GST_SECOND, wav->bps);
|
|
|
|
gst_segment_set_duration (&wav->segment, GST_FORMAT_TIME, duration);
|
gst/wavparse/gstwavparse.*: Fix wavparse some more.
Original commit message from CVS:
* gst/wavparse/gstwavparse.c: (gst_wavparse_reset),
(gst_wavparse_init), (gst_wavparse_parse_file_header),
(gst_wavparse_stream_init), (gst_wavparse_handle_seek),
(gst_wavparse_stream_headers), (gst_wavparse_stream_data),
(gst_wavparse_loop), (gst_wavparse_pad_convert),
(gst_wavparse_pad_query), (gst_wavparse_srcpad_event),
(gst_wavparse_change_state):
* gst/wavparse/gstwavparse.h:
Fix wavparse some more.
2005-09-19 16:26:30 +00:00
|
|
|
|
2005-12-16 19:32:53 +00:00
|
|
|
gst_pad_push_event (wav->srcpad,
|
|
|
|
gst_event_new_new_segment (FALSE, wav->segment.rate,
|
|
|
|
wav->segment.format, wav->segment.start,
|
|
|
|
wav->segment.duration, wav->segment.start));
|
2005-07-20 11:26:05 +00:00
|
|
|
|
|
|
|
return GST_FLOW_OK;
|
gst/wavparse/gstwavparse.*: Fix wavparse some more.
Original commit message from CVS:
* gst/wavparse/gstwavparse.c: (gst_wavparse_reset),
(gst_wavparse_init), (gst_wavparse_parse_file_header),
(gst_wavparse_stream_init), (gst_wavparse_handle_seek),
(gst_wavparse_stream_headers), (gst_wavparse_stream_data),
(gst_wavparse_loop), (gst_wavparse_pad_convert),
(gst_wavparse_pad_query), (gst_wavparse_srcpad_event),
(gst_wavparse_change_state):
* gst/wavparse/gstwavparse.h:
Fix wavparse some more.
2005-09-19 16:26:30 +00:00
|
|
|
|
|
|
|
/* ERROR */
|
|
|
|
invalid_wav:
|
|
|
|
{
|
|
|
|
GST_ELEMENT_ERROR (wav, STREAM, DEMUX, (NULL),
|
2005-11-21 13:38:24 +00:00
|
|
|
("Invalid WAV header (no fmt at start): %"
|
gst/wavparse/gstwavparse.*: Fix wavparse some more.
Original commit message from CVS:
* gst/wavparse/gstwavparse.c: (gst_wavparse_reset),
(gst_wavparse_init), (gst_wavparse_parse_file_header),
(gst_wavparse_stream_init), (gst_wavparse_handle_seek),
(gst_wavparse_stream_headers), (gst_wavparse_stream_data),
(gst_wavparse_loop), (gst_wavparse_pad_convert),
(gst_wavparse_pad_query), (gst_wavparse_srcpad_event),
(gst_wavparse_change_state):
* gst/wavparse/gstwavparse.h:
Fix wavparse some more.
2005-09-19 16:26:30 +00:00
|
|
|
GST_FOURCC_FORMAT, GST_FOURCC_ARGS (tag)));
|
|
|
|
return GST_FLOW_ERROR;
|
|
|
|
}
|
|
|
|
parse_header_error:
|
|
|
|
{
|
|
|
|
GST_ELEMENT_ERROR (wav, STREAM, DEMUX, (NULL),
|
|
|
|
("Couldn't parse audio header"));
|
|
|
|
gst_buffer_unref (buf);
|
|
|
|
return GST_FLOW_ERROR;
|
|
|
|
}
|
|
|
|
no_channels:
|
|
|
|
{
|
|
|
|
GST_ELEMENT_ERROR (wav, STREAM, FAILED, (NULL),
|
|
|
|
("Stream claims to contain no channels - invalid data"));
|
|
|
|
g_free (header);
|
|
|
|
return GST_FLOW_ERROR;
|
|
|
|
}
|
|
|
|
no_bitrate:
|
|
|
|
{
|
|
|
|
GST_ELEMENT_ERROR (wav, STREAM, FAILED, (NULL),
|
|
|
|
("Stream claims to have a bitrate of <= zero - invalid data"));
|
|
|
|
g_free (header);
|
|
|
|
return GST_FLOW_ERROR;
|
|
|
|
}
|
|
|
|
no_bytes_per_sample:
|
|
|
|
{
|
|
|
|
GST_ELEMENT_ERROR (wav, STREAM, FAILED, (NULL),
|
|
|
|
("could not caluclate bytes per sample - invalid data"));
|
|
|
|
g_free (header);
|
|
|
|
return GST_FLOW_ERROR;
|
|
|
|
}
|
|
|
|
unknown_format:
|
|
|
|
{
|
|
|
|
GST_ELEMENT_ERROR (wav, STREAM, TYPE_NOT_FOUND, (NULL),
|
|
|
|
("No caps found for format 0x%x, %d channels, %d Hz",
|
|
|
|
wav->format, wav->channels, wav->rate));
|
|
|
|
return GST_FLOW_ERROR;
|
|
|
|
}
|
|
|
|
header_read_error:
|
|
|
|
{
|
|
|
|
GST_ELEMENT_ERROR (wav, STREAM, DEMUX, (NULL), ("Couldn't read in header"));
|
|
|
|
return GST_FLOW_ERROR;
|
|
|
|
}
|
2004-05-16 20:06:35 +00:00
|
|
|
}
|
|
|
|
|
2004-05-08 00:33:39 +00:00
|
|
|
#define MAX_BUFFER_SIZE 4096
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2005-07-20 11:26:05 +00:00
|
|
|
static GstFlowReturn
|
|
|
|
gst_wavparse_stream_data (GstWavParse * wav)
|
2004-05-08 00:33:39 +00:00
|
|
|
{
|
2005-07-20 11:26:05 +00:00
|
|
|
GstBuffer *buf = NULL;
|
|
|
|
GstFlowReturn res = GST_FLOW_OK;
|
|
|
|
guint64 desired, obtained;
|
2005-12-16 19:32:53 +00:00
|
|
|
GstClockTime timestamp, next_timestamp;
|
|
|
|
guint64 pos, nextpos;
|
2005-07-20 11:26:05 +00:00
|
|
|
|
2005-12-16 19:32:53 +00:00
|
|
|
GST_DEBUG ("offset : %lld , end : %lld", wav->offset, wav->end_offset);
|
2004-03-15 19:32:27 +00:00
|
|
|
|
gst/wavparse/gstwavparse.*: Fix wavparse some more.
Original commit message from CVS:
* gst/wavparse/gstwavparse.c: (gst_wavparse_reset),
(gst_wavparse_init), (gst_wavparse_parse_file_header),
(gst_wavparse_stream_init), (gst_wavparse_handle_seek),
(gst_wavparse_stream_headers), (gst_wavparse_stream_data),
(gst_wavparse_loop), (gst_wavparse_pad_convert),
(gst_wavparse_pad_query), (gst_wavparse_srcpad_event),
(gst_wavparse_change_state):
* gst/wavparse/gstwavparse.h:
Fix wavparse some more.
2005-09-19 16:26:30 +00:00
|
|
|
/* Get the next n bytes and output them */
|
|
|
|
if (wav->dataleft == 0)
|
|
|
|
goto found_eos;
|
|
|
|
|
2005-12-16 19:32:53 +00:00
|
|
|
desired = MIN (wav->dataleft, MAX_BUFFER_SIZE * ABS (wav->segment.rate));
|
2005-08-10 12:12:31 +00:00
|
|
|
if (desired >= wav->blockalign && wav->blockalign > 0)
|
|
|
|
desired -= (desired % wav->blockalign);
|
gst/wavparse/gstwavparse.*: Fix wavparse some more.
Original commit message from CVS:
* gst/wavparse/gstwavparse.c: (gst_wavparse_reset),
(gst_wavparse_init), (gst_wavparse_parse_file_header),
(gst_wavparse_stream_init), (gst_wavparse_handle_seek),
(gst_wavparse_stream_headers), (gst_wavparse_stream_data),
(gst_wavparse_loop), (gst_wavparse_pad_convert),
(gst_wavparse_pad_query), (gst_wavparse_srcpad_event),
(gst_wavparse_change_state):
* gst/wavparse/gstwavparse.h:
Fix wavparse some more.
2005-09-19 16:26:30 +00:00
|
|
|
|
2005-07-20 11:26:05 +00:00
|
|
|
GST_DEBUG ("Fetching %lld bytes of data from the sinkpad.", desired);
|
gst/wavparse/gstwavparse.*: Fix wavparse some more.
Original commit message from CVS:
* gst/wavparse/gstwavparse.c: (gst_wavparse_reset),
(gst_wavparse_init), (gst_wavparse_parse_file_header),
(gst_wavparse_stream_init), (gst_wavparse_handle_seek),
(gst_wavparse_stream_headers), (gst_wavparse_stream_data),
(gst_wavparse_loop), (gst_wavparse_pad_convert),
(gst_wavparse_pad_query), (gst_wavparse_srcpad_event),
(gst_wavparse_change_state):
* gst/wavparse/gstwavparse.h:
Fix wavparse some more.
2005-09-19 16:26:30 +00:00
|
|
|
|
2005-07-20 11:26:05 +00:00
|
|
|
if ((res = gst_pad_pull_range (wav->sinkpad, wav->offset,
|
gst/wavparse/gstwavparse.*: Fix wavparse some more.
Original commit message from CVS:
* gst/wavparse/gstwavparse.c: (gst_wavparse_reset),
(gst_wavparse_init), (gst_wavparse_parse_file_header),
(gst_wavparse_stream_init), (gst_wavparse_handle_seek),
(gst_wavparse_stream_headers), (gst_wavparse_stream_data),
(gst_wavparse_loop), (gst_wavparse_pad_convert),
(gst_wavparse_pad_query), (gst_wavparse_srcpad_event),
(gst_wavparse_change_state):
* gst/wavparse/gstwavparse.h:
Fix wavparse some more.
2005-09-19 16:26:30 +00:00
|
|
|
desired, &buf)) != GST_FLOW_OK)
|
|
|
|
goto pull_error;
|
2004-10-01 16:01:51 +00:00
|
|
|
|
2005-07-20 11:26:05 +00:00
|
|
|
obtained = GST_BUFFER_SIZE (buf);
|
2005-12-16 19:32:53 +00:00
|
|
|
|
|
|
|
/* our positions */
|
|
|
|
pos = wav->offset - wav->datastart;
|
|
|
|
nextpos = pos + obtained;
|
|
|
|
|
|
|
|
/* update offsets, does not overflow. */
|
|
|
|
GST_BUFFER_OFFSET (buf) = pos / wav->bytes_per_sample;
|
|
|
|
GST_BUFFER_OFFSET_END (buf) = nextpos / wav->bytes_per_sample;
|
|
|
|
|
|
|
|
/* and timestamps, be carefull for overflows */
|
|
|
|
timestamp = gst_util_uint64_scale_int (pos, GST_SECOND, wav->bps);
|
|
|
|
next_timestamp = gst_util_uint64_scale_int (nextpos, GST_SECOND, wav->bps);
|
|
|
|
|
|
|
|
GST_BUFFER_TIMESTAMP (buf) = timestamp;
|
|
|
|
GST_BUFFER_DURATION (buf) = next_timestamp - timestamp;
|
|
|
|
|
|
|
|
/* update current running segment position */
|
|
|
|
gst_segment_set_last_stop (&wav->segment, GST_FORMAT_TIME, next_timestamp);
|
|
|
|
|
|
|
|
/* don't forget to set the caps on the buffer */
|
2005-07-20 11:26:05 +00:00
|
|
|
gst_buffer_set_caps (buf, GST_PAD_CAPS (wav->srcpad));
|
2004-03-15 19:32:27 +00:00
|
|
|
|
gst/wavparse/gstwavparse.*: Fix wavparse some more.
Original commit message from CVS:
* gst/wavparse/gstwavparse.c: (gst_wavparse_reset),
(gst_wavparse_init), (gst_wavparse_parse_file_header),
(gst_wavparse_stream_init), (gst_wavparse_handle_seek),
(gst_wavparse_stream_headers), (gst_wavparse_stream_data),
(gst_wavparse_loop), (gst_wavparse_pad_convert),
(gst_wavparse_pad_query), (gst_wavparse_srcpad_event),
(gst_wavparse_change_state):
* gst/wavparse/gstwavparse.h:
Fix wavparse some more.
2005-09-19 16:26:30 +00:00
|
|
|
GST_DEBUG ("Got buffer. timestamp:%" GST_TIME_FORMAT " , duration:%"
|
|
|
|
GST_TIME_FORMAT ", size:%u",
|
|
|
|
GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buf)),
|
|
|
|
GST_TIME_ARGS (GST_BUFFER_DURATION (buf)), GST_BUFFER_SIZE (buf));
|
|
|
|
|
|
|
|
if ((res = gst_pad_push (wav->srcpad, buf)) != GST_FLOW_OK)
|
|
|
|
goto push_error;
|
2004-03-15 19:32:27 +00:00
|
|
|
|
2005-07-20 11:26:05 +00:00
|
|
|
if (obtained < wav->dataleft) {
|
|
|
|
wav->dataleft -= obtained;
|
|
|
|
wav->offset += obtained;
|
|
|
|
} else {
|
|
|
|
wav->dataleft = 0;
|
2004-05-08 00:33:39 +00:00
|
|
|
}
|
2005-07-20 11:26:05 +00:00
|
|
|
return res;
|
gst/wavparse/gstwavparse.*: Fix wavparse some more.
Original commit message from CVS:
* gst/wavparse/gstwavparse.c: (gst_wavparse_reset),
(gst_wavparse_init), (gst_wavparse_parse_file_header),
(gst_wavparse_stream_init), (gst_wavparse_handle_seek),
(gst_wavparse_stream_headers), (gst_wavparse_stream_data),
(gst_wavparse_loop), (gst_wavparse_pad_convert),
(gst_wavparse_pad_query), (gst_wavparse_srcpad_event),
(gst_wavparse_change_state):
* gst/wavparse/gstwavparse.h:
Fix wavparse some more.
2005-09-19 16:26:30 +00:00
|
|
|
|
|
|
|
/* ERROR */
|
|
|
|
found_eos:
|
|
|
|
{
|
|
|
|
GST_DEBUG ("found EOS");
|
2005-12-16 19:32:53 +00:00
|
|
|
/* we completed the segment */
|
|
|
|
wav->segment_running = FALSE;
|
|
|
|
if (wav->segment.flags & GST_SEEK_FLAG_SEGMENT) {
|
|
|
|
GstClockTime stop;
|
gst/wavparse/gstwavparse.*: Fix wavparse some more.
Original commit message from CVS:
* gst/wavparse/gstwavparse.c: (gst_wavparse_reset),
(gst_wavparse_init), (gst_wavparse_parse_file_header),
(gst_wavparse_stream_init), (gst_wavparse_handle_seek),
(gst_wavparse_stream_headers), (gst_wavparse_stream_data),
(gst_wavparse_loop), (gst_wavparse_pad_convert),
(gst_wavparse_pad_query), (gst_wavparse_srcpad_event),
(gst_wavparse_change_state):
* gst/wavparse/gstwavparse.h:
Fix wavparse some more.
2005-09-19 16:26:30 +00:00
|
|
|
|
2005-12-16 19:32:53 +00:00
|
|
|
if ((stop = wav->segment.stop) == -1)
|
|
|
|
stop = wav->segment.duration;
|
gst/wavparse/gstwavparse.*: Fix wavparse some more.
Original commit message from CVS:
* gst/wavparse/gstwavparse.c: (gst_wavparse_reset),
(gst_wavparse_init), (gst_wavparse_parse_file_header),
(gst_wavparse_stream_init), (gst_wavparse_handle_seek),
(gst_wavparse_stream_headers), (gst_wavparse_stream_data),
(gst_wavparse_loop), (gst_wavparse_pad_convert),
(gst_wavparse_pad_query), (gst_wavparse_srcpad_event),
(gst_wavparse_change_state):
* gst/wavparse/gstwavparse.h:
Fix wavparse some more.
2005-09-19 16:26:30 +00:00
|
|
|
|
|
|
|
gst_element_post_message (GST_ELEMENT (wav),
|
2005-10-18 13:21:18 +00:00
|
|
|
gst_message_new_segment_done (GST_OBJECT (wav), GST_FORMAT_TIME,
|
2005-12-16 19:32:53 +00:00
|
|
|
stop));
|
gst/wavparse/gstwavparse.*: Fix wavparse some more.
Original commit message from CVS:
* gst/wavparse/gstwavparse.c: (gst_wavparse_reset),
(gst_wavparse_init), (gst_wavparse_parse_file_header),
(gst_wavparse_stream_init), (gst_wavparse_handle_seek),
(gst_wavparse_stream_headers), (gst_wavparse_stream_data),
(gst_wavparse_loop), (gst_wavparse_pad_convert),
(gst_wavparse_pad_query), (gst_wavparse_srcpad_event),
(gst_wavparse_change_state):
* gst/wavparse/gstwavparse.h:
Fix wavparse some more.
2005-09-19 16:26:30 +00:00
|
|
|
} else {
|
|
|
|
gst_pad_push_event (wav->srcpad, gst_event_new_eos ());
|
|
|
|
}
|
|
|
|
return GST_FLOW_WRONG_STATE;
|
|
|
|
}
|
|
|
|
pull_error:
|
|
|
|
{
|
|
|
|
GST_DEBUG ("Error getting %ldd bytes from the sinkpad!", desired);
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
push_error:
|
|
|
|
{
|
|
|
|
GST_DEBUG ("Error pushing on srcpad");
|
|
|
|
return res;
|
|
|
|
}
|
2005-07-20 11:26:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_wavparse_loop (GstPad * pad)
|
|
|
|
{
|
|
|
|
GstFlowReturn ret;
|
|
|
|
GstWavParse *wav = GST_WAVPARSE (GST_PAD_PARENT (pad));
|
|
|
|
|
2004-05-08 00:33:39 +00:00
|
|
|
switch (wav->state) {
|
|
|
|
case GST_WAVPARSE_START:
|
2005-07-20 11:26:05 +00:00
|
|
|
if ((ret = gst_wavparse_stream_init (wav)) != GST_FLOW_OK)
|
|
|
|
goto pause;
|
2004-03-15 19:32:27 +00:00
|
|
|
|
2005-07-20 11:26:05 +00:00
|
|
|
wav->state = GST_WAVPARSE_HEADER;
|
2004-05-08 00:33:39 +00:00
|
|
|
/* fall-through */
|
2004-03-15 19:32:27 +00:00
|
|
|
|
2005-07-20 11:26:05 +00:00
|
|
|
case GST_WAVPARSE_HEADER:
|
gst/wavparse/gstwavparse.*: Fix wavparse some more.
Original commit message from CVS:
* gst/wavparse/gstwavparse.c: (gst_wavparse_reset),
(gst_wavparse_init), (gst_wavparse_parse_file_header),
(gst_wavparse_stream_init), (gst_wavparse_handle_seek),
(gst_wavparse_stream_headers), (gst_wavparse_stream_data),
(gst_wavparse_loop), (gst_wavparse_pad_convert),
(gst_wavparse_pad_query), (gst_wavparse_srcpad_event),
(gst_wavparse_change_state):
* gst/wavparse/gstwavparse.h:
Fix wavparse some more.
2005-09-19 16:26:30 +00:00
|
|
|
if ((ret = gst_wavparse_stream_headers (wav)) != GST_FLOW_OK)
|
2005-07-20 11:26:05 +00:00
|
|
|
goto pause;
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2005-07-20 11:26:05 +00:00
|
|
|
wav->state = GST_WAVPARSE_DATA;
|
2004-05-08 00:33:39 +00:00
|
|
|
/* fall-through */
|
2005-07-20 11:26:05 +00:00
|
|
|
case GST_WAVPARSE_DATA:
|
|
|
|
if ((ret = gst_wavparse_stream_data (wav)) != GST_FLOW_OK)
|
|
|
|
goto pause;
|
2004-05-08 00:33:39 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
g_assert_not_reached ();
|
2005-07-20 11:26:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
pause:
|
|
|
|
GST_LOG_OBJECT (wav, "pausing task %d", ret);
|
|
|
|
gst_pad_pause_task (wav->sinkpad);
|
|
|
|
if (GST_FLOW_IS_FATAL (ret)) {
|
|
|
|
/* for fatal errors we post an error message */
|
2005-10-23 11:07:10 +00:00
|
|
|
GST_ELEMENT_ERROR (wav, STREAM, FAILED,
|
|
|
|
(_("Internal data stream error.")),
|
2005-10-11 16:33:08 +00:00
|
|
|
("streaming stopped, reason %s", gst_flow_get_name (ret)));
|
configure.ac: Check for optional dependency on zlib for id3demux
Original commit message from CVS:
* configure.ac:
Check for optional dependency on zlib for id3demux
* gst/id3demux/Makefile.am:
* gst/id3demux/gstid3demux.c: (gst_gst_id3demux_get_type),
(gst_id3demux_base_init), (gst_id3demux_class_init),
(gst_id3demux_reset), (gst_id3demux_init), (gst_id3demux_dispose),
(gst_id3demux_add_srcpad), (gst_id3demux_remove_srcpad),
(gst_id3demux_trim_buffer), (gst_id3demux_chain),
(gst_id3demux_set_property), (gst_id3demux_get_property),
(id3demux_get_upstream_size), (gst_id3demux_srcpad_event),
(gst_id3demux_read_id3v1), (gst_id3demux_read_id3v2),
(gst_id3demux_sink_activate), (gst_id3demux_src_activate_pull),
(gst_id3demux_src_checkgetrange), (gst_id3demux_read_range),
(gst_id3demux_src_getrange), (gst_id3demux_change_state),
(gst_id3demux_pad_query), (gst_id3demux_get_query_types),
(simple_find_peek), (simple_find_suggest),
(gst_id3demux_do_typefind), (gst_id3demux_send_tag_event),
(plugin_init):
* gst/id3demux/gstid3demux.h:
* gst/id3demux/id3tags.c: (read_synch_uint),
(id3demux_read_id3v1_tag), (id3demux_read_id3v2_tag),
(id3demux_id3v2_frame_hdr_size), (convert_fid_to_v240),
(id3demux_id3v2_frames_to_tag_list):
* gst/id3demux/id3tags.h:
* gst/id3demux/id3v2.4.0-frames.txt:
* gst/id3demux/id3v2.4.0-structure.txt:
* gst/id3demux/id3v2frames.c: (id3demux_id3v2_parse_frame),
(parse_comment_frame), (parse_text_identification_frame),
(id3v2_tag_to_taglist), (parse_split_strings):
All new LGPL id3 demuxer. Can use zlib for compressed frames,
otherwise it discards them. Works on my test files.
* gst/wavparse/gstwavparse.c: (gst_wavparse_loop):
Don't send EOS to a non-existing srcpad
The debug category can be static
2005-12-18 15:14:44 +00:00
|
|
|
if (wav->srcpad != NULL)
|
|
|
|
gst_pad_push_event (wav->srcpad, gst_event_new_eos ());
|
2001-12-22 23:27:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-07-20 11:26:05 +00:00
|
|
|
#if 0
|
2002-11-03 13:59:35 +00:00
|
|
|
/* convert and query stuff */
|
|
|
|
static const GstFormat *
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_wavparse_get_formats (GstPad * pad)
|
2002-11-03 13:59:35 +00:00
|
|
|
{
|
|
|
|
static GstFormat formats[] = {
|
|
|
|
GST_FORMAT_TIME,
|
|
|
|
GST_FORMAT_BYTES,
|
2004-03-15 19:32:27 +00:00
|
|
|
GST_FORMAT_DEFAULT, /* a "frame", ie a set of samples per Hz */
|
2002-11-03 13:59:35 +00:00
|
|
|
0
|
|
|
|
};
|
2004-03-15 19:32:27 +00:00
|
|
|
|
2002-11-03 13:59:35 +00:00
|
|
|
return formats;
|
|
|
|
}
|
2005-07-20 11:26:05 +00:00
|
|
|
#endif
|
2002-11-03 13:59:35 +00:00
|
|
|
|
|
|
|
static gboolean
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_wavparse_pad_convert (GstPad * pad,
|
|
|
|
GstFormat src_format, gint64 src_value,
|
|
|
|
GstFormat * dest_format, gint64 * dest_value)
|
2002-11-03 13:59:35 +00:00
|
|
|
{
|
|
|
|
GstWavParse *wavparse;
|
gst/wavparse/gstwavparse.*: Fix wavparse some more.
Original commit message from CVS:
* gst/wavparse/gstwavparse.c: (gst_wavparse_reset),
(gst_wavparse_init), (gst_wavparse_parse_file_header),
(gst_wavparse_stream_init), (gst_wavparse_handle_seek),
(gst_wavparse_stream_headers), (gst_wavparse_stream_data),
(gst_wavparse_loop), (gst_wavparse_pad_convert),
(gst_wavparse_pad_query), (gst_wavparse_srcpad_event),
(gst_wavparse_change_state):
* gst/wavparse/gstwavparse.h:
Fix wavparse some more.
2005-09-19 16:26:30 +00:00
|
|
|
gboolean res = TRUE;
|
2002-11-03 13:59:35 +00:00
|
|
|
|
|
|
|
wavparse = GST_WAVPARSE (gst_pad_get_parent (pad));
|
2004-03-14 22:34:33 +00:00
|
|
|
|
gst/wavparse/gstwavparse.*: Fix wavparse some more.
Original commit message from CVS:
* gst/wavparse/gstwavparse.c: (gst_wavparse_reset),
(gst_wavparse_init), (gst_wavparse_parse_file_header),
(gst_wavparse_stream_init), (gst_wavparse_handle_seek),
(gst_wavparse_stream_headers), (gst_wavparse_stream_data),
(gst_wavparse_loop), (gst_wavparse_pad_convert),
(gst_wavparse_pad_query), (gst_wavparse_srcpad_event),
(gst_wavparse_change_state):
* gst/wavparse/gstwavparse.h:
Fix wavparse some more.
2005-09-19 16:26:30 +00:00
|
|
|
if (wavparse->bytes_per_sample == 0)
|
|
|
|
goto no_bytes_per_sample;
|
|
|
|
|
|
|
|
if (wavparse->bps == 0)
|
|
|
|
goto no_bps;
|
2002-11-03 13:59:35 +00:00
|
|
|
|
|
|
|
switch (src_format) {
|
|
|
|
case GST_FORMAT_BYTES:
|
2004-05-16 20:06:35 +00:00
|
|
|
switch (*dest_format) {
|
|
|
|
case GST_FORMAT_DEFAULT:
|
gst/wavparse/gstwavparse.*: Fix wavparse some more.
Original commit message from CVS:
* gst/wavparse/gstwavparse.c: (gst_wavparse_reset),
(gst_wavparse_init), (gst_wavparse_parse_file_header),
(gst_wavparse_stream_init), (gst_wavparse_handle_seek),
(gst_wavparse_stream_headers), (gst_wavparse_stream_data),
(gst_wavparse_loop), (gst_wavparse_pad_convert),
(gst_wavparse_pad_query), (gst_wavparse_srcpad_event),
(gst_wavparse_change_state):
* gst/wavparse/gstwavparse.h:
Fix wavparse some more.
2005-09-19 16:26:30 +00:00
|
|
|
*dest_value = src_value / wavparse->bytes_per_sample;
|
2004-05-16 20:06:35 +00:00
|
|
|
break;
|
|
|
|
case GST_FORMAT_TIME:
|
2005-12-16 19:32:53 +00:00
|
|
|
*dest_value =
|
|
|
|
gst_util_uint64_scale_int (src_value, GST_SECOND, wavparse->bps);
|
2004-05-16 20:06:35 +00:00
|
|
|
break;
|
|
|
|
default:
|
gst/wavparse/gstwavparse.*: Fix wavparse some more.
Original commit message from CVS:
* gst/wavparse/gstwavparse.c: (gst_wavparse_reset),
(gst_wavparse_init), (gst_wavparse_parse_file_header),
(gst_wavparse_stream_init), (gst_wavparse_handle_seek),
(gst_wavparse_stream_headers), (gst_wavparse_stream_data),
(gst_wavparse_loop), (gst_wavparse_pad_convert),
(gst_wavparse_pad_query), (gst_wavparse_srcpad_event),
(gst_wavparse_change_state):
* gst/wavparse/gstwavparse.h:
Fix wavparse some more.
2005-09-19 16:26:30 +00:00
|
|
|
res = FALSE;
|
|
|
|
goto done;
|
2004-03-06 00:13:19 +00:00
|
|
|
}
|
gst/wavparse/gstwavparse.*: Fix wavparse some more.
Original commit message from CVS:
* gst/wavparse/gstwavparse.c: (gst_wavparse_reset),
(gst_wavparse_init), (gst_wavparse_parse_file_header),
(gst_wavparse_stream_init), (gst_wavparse_handle_seek),
(gst_wavparse_stream_headers), (gst_wavparse_stream_data),
(gst_wavparse_loop), (gst_wavparse_pad_convert),
(gst_wavparse_pad_query), (gst_wavparse_srcpad_event),
(gst_wavparse_change_state):
* gst/wavparse/gstwavparse.h:
Fix wavparse some more.
2005-09-19 16:26:30 +00:00
|
|
|
*dest_value -= *dest_value % wavparse->bytes_per_sample;
|
2002-11-03 13:59:35 +00:00
|
|
|
break;
|
2004-05-16 20:06:35 +00:00
|
|
|
|
2003-05-24 10:41:21 +00:00
|
|
|
case GST_FORMAT_DEFAULT:
|
2004-05-16 20:06:35 +00:00
|
|
|
switch (*dest_format) {
|
|
|
|
case GST_FORMAT_BYTES:
|
gst/wavparse/gstwavparse.*: Fix wavparse some more.
Original commit message from CVS:
* gst/wavparse/gstwavparse.c: (gst_wavparse_reset),
(gst_wavparse_init), (gst_wavparse_parse_file_header),
(gst_wavparse_stream_init), (gst_wavparse_handle_seek),
(gst_wavparse_stream_headers), (gst_wavparse_stream_data),
(gst_wavparse_loop), (gst_wavparse_pad_convert),
(gst_wavparse_pad_query), (gst_wavparse_srcpad_event),
(gst_wavparse_change_state):
* gst/wavparse/gstwavparse.h:
Fix wavparse some more.
2005-09-19 16:26:30 +00:00
|
|
|
*dest_value = src_value * wavparse->bytes_per_sample;
|
2004-05-16 20:06:35 +00:00
|
|
|
break;
|
|
|
|
case GST_FORMAT_TIME:
|
2005-12-16 19:32:53 +00:00
|
|
|
*dest_value =
|
|
|
|
gst_util_uint64_scale_int (src_value, GST_SECOND, wavparse->rate);
|
2004-05-16 20:06:35 +00:00
|
|
|
break;
|
|
|
|
default:
|
gst/wavparse/gstwavparse.*: Fix wavparse some more.
Original commit message from CVS:
* gst/wavparse/gstwavparse.c: (gst_wavparse_reset),
(gst_wavparse_init), (gst_wavparse_parse_file_header),
(gst_wavparse_stream_init), (gst_wavparse_handle_seek),
(gst_wavparse_stream_headers), (gst_wavparse_stream_data),
(gst_wavparse_loop), (gst_wavparse_pad_convert),
(gst_wavparse_pad_query), (gst_wavparse_srcpad_event),
(gst_wavparse_change_state):
* gst/wavparse/gstwavparse.h:
Fix wavparse some more.
2005-09-19 16:26:30 +00:00
|
|
|
res = FALSE;
|
|
|
|
goto done;
|
2004-03-06 00:13:19 +00:00
|
|
|
}
|
2002-11-03 13:59:35 +00:00
|
|
|
break;
|
2004-05-16 20:06:35 +00:00
|
|
|
|
2002-11-03 13:59:35 +00:00
|
|
|
case GST_FORMAT_TIME:
|
2004-05-16 20:06:35 +00:00
|
|
|
switch (*dest_format) {
|
|
|
|
case GST_FORMAT_BYTES:
|
2004-10-01 16:01:51 +00:00
|
|
|
/* make sure we end up on a sample boundary */
|
|
|
|
*dest_value =
|
2006-01-18 19:08:08 +00:00
|
|
|
gst_util_uint64_scale_int (src_value, wavparse->bps, GST_SECOND);
|
|
|
|
*dest_value -= *dest_value % wavparse->blockalign;
|
2004-05-16 20:06:35 +00:00
|
|
|
break;
|
|
|
|
case GST_FORMAT_DEFAULT:
|
2005-12-16 19:32:53 +00:00
|
|
|
*dest_value =
|
|
|
|
gst_util_uint64_scale_int (src_value, wavparse->rate, GST_SECOND);
|
2004-05-16 20:06:35 +00:00
|
|
|
break;
|
|
|
|
default:
|
gst/wavparse/gstwavparse.*: Fix wavparse some more.
Original commit message from CVS:
* gst/wavparse/gstwavparse.c: (gst_wavparse_reset),
(gst_wavparse_init), (gst_wavparse_parse_file_header),
(gst_wavparse_stream_init), (gst_wavparse_handle_seek),
(gst_wavparse_stream_headers), (gst_wavparse_stream_data),
(gst_wavparse_loop), (gst_wavparse_pad_convert),
(gst_wavparse_pad_query), (gst_wavparse_srcpad_event),
(gst_wavparse_change_state):
* gst/wavparse/gstwavparse.h:
Fix wavparse some more.
2005-09-19 16:26:30 +00:00
|
|
|
res = FALSE;
|
|
|
|
goto done;
|
2004-03-06 00:13:19 +00:00
|
|
|
}
|
2002-11-03 13:59:35 +00:00
|
|
|
break;
|
2004-05-16 20:06:35 +00:00
|
|
|
|
2002-11-03 13:59:35 +00:00
|
|
|
default:
|
gst/wavparse/gstwavparse.*: Fix wavparse some more.
Original commit message from CVS:
* gst/wavparse/gstwavparse.c: (gst_wavparse_reset),
(gst_wavparse_init), (gst_wavparse_parse_file_header),
(gst_wavparse_stream_init), (gst_wavparse_handle_seek),
(gst_wavparse_stream_headers), (gst_wavparse_stream_data),
(gst_wavparse_loop), (gst_wavparse_pad_convert),
(gst_wavparse_pad_query), (gst_wavparse_srcpad_event),
(gst_wavparse_change_state):
* gst/wavparse/gstwavparse.h:
Fix wavparse some more.
2005-09-19 16:26:30 +00:00
|
|
|
res = FALSE;
|
|
|
|
goto done;
|
2002-11-03 13:59:35 +00:00
|
|
|
}
|
2004-05-16 20:06:35 +00:00
|
|
|
|
gst/wavparse/gstwavparse.*: Fix wavparse some more.
Original commit message from CVS:
* gst/wavparse/gstwavparse.c: (gst_wavparse_reset),
(gst_wavparse_init), (gst_wavparse_parse_file_header),
(gst_wavparse_stream_init), (gst_wavparse_handle_seek),
(gst_wavparse_stream_headers), (gst_wavparse_stream_data),
(gst_wavparse_loop), (gst_wavparse_pad_convert),
(gst_wavparse_pad_query), (gst_wavparse_srcpad_event),
(gst_wavparse_change_state):
* gst/wavparse/gstwavparse.h:
Fix wavparse some more.
2005-09-19 16:26:30 +00:00
|
|
|
done:
|
|
|
|
gst_object_unref (wavparse);
|
|
|
|
|
|
|
|
return res;
|
|
|
|
|
|
|
|
/* ERRORS */
|
|
|
|
no_bytes_per_sample:
|
|
|
|
{
|
|
|
|
GST_DEBUG
|
|
|
|
("bytes_per_sample 0, probably an mp3 - channels %d, width %d",
|
|
|
|
wavparse->channels, wavparse->width);
|
|
|
|
res = FALSE;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
no_bps:
|
|
|
|
{
|
|
|
|
g_warning ("bps is 0, internal error\n");
|
|
|
|
res = FALSE;
|
|
|
|
goto done;
|
|
|
|
}
|
2002-11-03 13:59:35 +00:00
|
|
|
}
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2002-12-30 17:53:18 +00:00
|
|
|
static const GstQueryType *
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_wavparse_get_query_types (GstPad * pad)
|
2002-11-03 13:59:35 +00:00
|
|
|
{
|
2002-12-30 17:53:18 +00:00
|
|
|
static const GstQueryType types[] = {
|
2003-01-14 21:10:53 +00:00
|
|
|
GST_QUERY_POSITION,
|
2006-02-06 12:18:45 +00:00
|
|
|
GST_QUERY_DURATION,
|
|
|
|
GST_QUERY_CONVERT,
|
2003-01-14 21:10:53 +00:00
|
|
|
0
|
2002-11-03 13:59:35 +00:00
|
|
|
};
|
2004-03-15 19:32:27 +00:00
|
|
|
|
2002-11-03 13:59:35 +00:00
|
|
|
return types;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* handle queries for location and length in requested format */
|
|
|
|
static gboolean
|
2005-07-20 11:26:05 +00:00
|
|
|
gst_wavparse_pad_query (GstPad * pad, GstQuery * query)
|
2002-11-03 13:59:35 +00:00
|
|
|
{
|
2005-07-20 11:26:05 +00:00
|
|
|
gboolean res = TRUE;
|
|
|
|
GstWavParse *wav = GST_WAVPARSE (GST_PAD_PARENT (pad));
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2004-05-16 20:06:35 +00:00
|
|
|
/* only if we know */
|
|
|
|
if (wav->state != GST_WAVPARSE_DATA)
|
2002-11-03 13:59:35 +00:00
|
|
|
return FALSE;
|
2004-05-16 20:06:35 +00:00
|
|
|
|
2005-07-20 11:26:05 +00:00
|
|
|
switch (GST_QUERY_TYPE (query)) {
|
2004-05-16 20:06:35 +00:00
|
|
|
case GST_QUERY_POSITION:
|
2005-07-20 11:26:05 +00:00
|
|
|
{
|
2005-10-19 15:57:04 +00:00
|
|
|
gint64 curb;
|
|
|
|
gint64 cur;
|
2005-07-20 11:26:05 +00:00
|
|
|
GstFormat format;
|
|
|
|
gboolean res = TRUE;
|
|
|
|
|
gst/wavparse/gstwavparse.*: Fix wavparse some more.
Original commit message from CVS:
* gst/wavparse/gstwavparse.c: (gst_wavparse_reset),
(gst_wavparse_init), (gst_wavparse_parse_file_header),
(gst_wavparse_stream_init), (gst_wavparse_handle_seek),
(gst_wavparse_stream_headers), (gst_wavparse_stream_data),
(gst_wavparse_loop), (gst_wavparse_pad_convert),
(gst_wavparse_pad_query), (gst_wavparse_srcpad_event),
(gst_wavparse_change_state):
* gst/wavparse/gstwavparse.h:
Fix wavparse some more.
2005-09-19 16:26:30 +00:00
|
|
|
curb = wav->offset - wav->datastart;
|
2005-10-19 15:57:04 +00:00
|
|
|
gst_query_parse_position (query, &format, NULL);
|
2005-07-20 11:26:05 +00:00
|
|
|
|
|
|
|
switch (format) {
|
|
|
|
case GST_FORMAT_TIME:
|
|
|
|
res &=
|
|
|
|
gst_wavparse_pad_convert (pad, GST_FORMAT_BYTES, curb,
|
|
|
|
&format, &cur);
|
2005-10-19 15:57:04 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
format = GST_FORMAT_BYTES;
|
|
|
|
cur = curb;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (res)
|
|
|
|
gst_query_set_position (query, format, cur);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case GST_QUERY_DURATION:
|
|
|
|
{
|
|
|
|
gint64 endb;
|
|
|
|
gint64 end;
|
|
|
|
GstFormat format;
|
|
|
|
gboolean res = TRUE;
|
|
|
|
|
|
|
|
endb = wav->datasize;
|
|
|
|
gst_query_parse_duration (query, &format, NULL);
|
|
|
|
|
|
|
|
switch (format) {
|
|
|
|
case GST_FORMAT_TIME:
|
2005-07-20 11:26:05 +00:00
|
|
|
res &=
|
|
|
|
gst_wavparse_pad_convert (pad, GST_FORMAT_BYTES, endb,
|
|
|
|
&format, &end);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
format = GST_FORMAT_BYTES;
|
|
|
|
end = endb;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (res)
|
2005-10-19 15:57:04 +00:00
|
|
|
gst_query_set_duration (query, format, end);
|
2004-05-16 20:06:35 +00:00
|
|
|
break;
|
2005-07-20 11:26:05 +00:00
|
|
|
}
|
|
|
|
case GST_QUERY_CONVERT:
|
|
|
|
{
|
|
|
|
gint64 srcvalue, dstvalue;
|
|
|
|
GstFormat srcformat, dstformat;
|
|
|
|
|
|
|
|
gst_query_parse_convert (query, &srcformat, &srcvalue,
|
|
|
|
&dstformat, &dstvalue);
|
|
|
|
res &=
|
|
|
|
gst_wavparse_pad_convert (pad, srcformat, srcvalue,
|
|
|
|
&dstformat, &dstvalue);
|
|
|
|
if (res)
|
|
|
|
gst_query_set_convert (query, srcformat, srcvalue, dstformat, dstvalue);
|
2004-05-16 20:06:35 +00:00
|
|
|
break;
|
2005-07-20 11:26:05 +00:00
|
|
|
}
|
2004-05-16 20:06:35 +00:00
|
|
|
default:
|
2006-02-06 12:18:45 +00:00
|
|
|
res = gst_pad_query_default (pad, query);
|
2005-07-20 11:26:05 +00:00
|
|
|
break;
|
2002-11-03 13:59:35 +00:00
|
|
|
}
|
2005-07-20 11:26:05 +00:00
|
|
|
return res;
|
2004-03-14 22:34:33 +00:00
|
|
|
}
|
2003-03-01 18:34:38 +00:00
|
|
|
|
|
|
|
static gboolean
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_wavparse_srcpad_event (GstPad * pad, GstEvent * event)
|
2003-03-01 18:34:38 +00:00
|
|
|
{
|
|
|
|
GstWavParse *wavparse = GST_WAVPARSE (GST_PAD_PARENT (pad));
|
2005-07-20 11:26:05 +00:00
|
|
|
gboolean res = TRUE;
|
2003-03-01 18:34:38 +00:00
|
|
|
|
2003-06-29 19:46:12 +00:00
|
|
|
GST_DEBUG ("event %d", GST_EVENT_TYPE (event));
|
2003-03-01 18:34:38 +00:00
|
|
|
|
|
|
|
switch (GST_EVENT_TYPE (event)) {
|
|
|
|
case GST_EVENT_SEEK:
|
|
|
|
{
|
2005-12-16 19:32:53 +00:00
|
|
|
res = gst_wavparse_perform_seek (wavparse, event);
|
2003-03-01 18:34:38 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
2005-07-20 11:26:05 +00:00
|
|
|
res = FALSE;
|
2003-03-01 18:34:38 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
gst_event_unref (event);
|
2004-05-16 20:06:35 +00:00
|
|
|
|
2003-03-01 18:34:38 +00:00
|
|
|
return res;
|
|
|
|
}
|
2001-12-22 23:27:31 +00:00
|
|
|
|
2005-07-20 11:26:05 +00:00
|
|
|
static gboolean
|
|
|
|
gst_wavparse_sink_activate (GstPad * sinkpad)
|
|
|
|
{
|
|
|
|
if (gst_pad_check_pull_range (sinkpad))
|
|
|
|
return gst_pad_activate_pull (sinkpad, TRUE);
|
|
|
|
|
2005-11-21 17:23:46 +00:00
|
|
|
GST_DEBUG ("pull_range not supported on sinkpad");
|
2005-07-20 11:26:05 +00:00
|
|
|
return FALSE;
|
|
|
|
};
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gst_wavparse_sink_activate_pull (GstPad * sinkpad, gboolean active)
|
|
|
|
{
|
2005-12-16 19:32:53 +00:00
|
|
|
GstWavParse *wav = GST_WAVPARSE (gst_pad_get_parent (sinkpad));
|
|
|
|
|
2005-07-20 11:26:05 +00:00
|
|
|
if (active) {
|
|
|
|
/* if we have a scheduler we can start the task */
|
2005-12-16 19:32:53 +00:00
|
|
|
wav->segment_running = TRUE;
|
2005-07-20 11:26:05 +00:00
|
|
|
gst_pad_start_task (sinkpad, (GstTaskFunction) gst_wavparse_loop, sinkpad);
|
|
|
|
} else {
|
|
|
|
gst_pad_stop_task (sinkpad);
|
|
|
|
}
|
2005-12-16 19:32:53 +00:00
|
|
|
gst_object_unref (wav);
|
2005-07-20 11:26:05 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
};
|
|
|
|
|
2005-09-02 15:44:50 +00:00
|
|
|
static GstStateChangeReturn
|
|
|
|
gst_wavparse_change_state (GstElement * element, GstStateChange transition)
|
2003-06-13 22:11:56 +00:00
|
|
|
{
|
gst/wavparse/gstwavparse.*: Fix wavparse some more.
Original commit message from CVS:
* gst/wavparse/gstwavparse.c: (gst_wavparse_reset),
(gst_wavparse_init), (gst_wavparse_parse_file_header),
(gst_wavparse_stream_init), (gst_wavparse_handle_seek),
(gst_wavparse_stream_headers), (gst_wavparse_stream_data),
(gst_wavparse_loop), (gst_wavparse_pad_convert),
(gst_wavparse_pad_query), (gst_wavparse_srcpad_event),
(gst_wavparse_change_state):
* gst/wavparse/gstwavparse.h:
Fix wavparse some more.
2005-09-19 16:26:30 +00:00
|
|
|
GstStateChangeReturn ret;
|
2004-05-08 00:33:39 +00:00
|
|
|
GstWavParse *wav = GST_WAVPARSE (element);
|
2003-06-13 22:11:56 +00:00
|
|
|
|
2005-09-02 15:44:50 +00:00
|
|
|
switch (transition) {
|
|
|
|
case GST_STATE_CHANGE_NULL_TO_READY:
|
2003-06-13 22:11:56 +00:00
|
|
|
break;
|
2005-09-02 15:44:50 +00:00
|
|
|
case GST_STATE_CHANGE_READY_TO_PAUSED:
|
2004-05-08 00:33:39 +00:00
|
|
|
wav->state = GST_WAVPARSE_START;
|
2003-06-13 22:11:56 +00:00
|
|
|
break;
|
2005-09-02 15:44:50 +00:00
|
|
|
case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
|
2003-06-13 22:11:56 +00:00
|
|
|
break;
|
gst/wavparse/gstwavparse.*: Fix wavparse some more.
Original commit message from CVS:
* gst/wavparse/gstwavparse.c: (gst_wavparse_reset),
(gst_wavparse_init), (gst_wavparse_parse_file_header),
(gst_wavparse_stream_init), (gst_wavparse_handle_seek),
(gst_wavparse_stream_headers), (gst_wavparse_stream_data),
(gst_wavparse_loop), (gst_wavparse_pad_convert),
(gst_wavparse_pad_query), (gst_wavparse_srcpad_event),
(gst_wavparse_change_state):
* gst/wavparse/gstwavparse.h:
Fix wavparse some more.
2005-09-19 16:26:30 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
|
2004-05-08 00:33:39 +00:00
|
|
|
|
gst/wavparse/gstwavparse.*: Fix wavparse some more.
Original commit message from CVS:
* gst/wavparse/gstwavparse.c: (gst_wavparse_reset),
(gst_wavparse_init), (gst_wavparse_parse_file_header),
(gst_wavparse_stream_init), (gst_wavparse_handle_seek),
(gst_wavparse_stream_headers), (gst_wavparse_stream_data),
(gst_wavparse_loop), (gst_wavparse_pad_convert),
(gst_wavparse_pad_query), (gst_wavparse_srcpad_event),
(gst_wavparse_change_state):
* gst/wavparse/gstwavparse.h:
Fix wavparse some more.
2005-09-19 16:26:30 +00:00
|
|
|
switch (transition) {
|
2005-09-02 15:44:50 +00:00
|
|
|
case GST_STATE_CHANGE_PLAYING_TO_PAUSED:
|
2003-06-13 22:11:56 +00:00
|
|
|
break;
|
2005-09-02 15:44:50 +00:00
|
|
|
case GST_STATE_CHANGE_PAUSED_TO_READY:
|
2004-05-08 00:33:39 +00:00
|
|
|
gst_wavparse_destroy_sourcepad (wav);
|
2005-07-20 11:26:05 +00:00
|
|
|
gst_wavparse_reset (wav);
|
2003-06-13 22:11:56 +00:00
|
|
|
break;
|
2005-09-02 15:44:50 +00:00
|
|
|
case GST_STATE_CHANGE_READY_TO_NULL:
|
2003-06-13 22:11:56 +00:00
|
|
|
break;
|
gst/wavparse/gstwavparse.*: Fix wavparse some more.
Original commit message from CVS:
* gst/wavparse/gstwavparse.c: (gst_wavparse_reset),
(gst_wavparse_init), (gst_wavparse_parse_file_header),
(gst_wavparse_stream_init), (gst_wavparse_handle_seek),
(gst_wavparse_stream_headers), (gst_wavparse_stream_data),
(gst_wavparse_loop), (gst_wavparse_pad_convert),
(gst_wavparse_pad_query), (gst_wavparse_srcpad_event),
(gst_wavparse_change_state):
* gst/wavparse/gstwavparse.h:
Fix wavparse some more.
2005-09-19 16:26:30 +00:00
|
|
|
default:
|
|
|
|
break;
|
2003-06-13 22:11:56 +00:00
|
|
|
}
|
gst/wavparse/gstwavparse.*: Fix wavparse some more.
Original commit message from CVS:
* gst/wavparse/gstwavparse.c: (gst_wavparse_reset),
(gst_wavparse_init), (gst_wavparse_parse_file_header),
(gst_wavparse_stream_init), (gst_wavparse_handle_seek),
(gst_wavparse_stream_headers), (gst_wavparse_stream_data),
(gst_wavparse_loop), (gst_wavparse_pad_convert),
(gst_wavparse_pad_query), (gst_wavparse_srcpad_event),
(gst_wavparse_change_state):
* gst/wavparse/gstwavparse.h:
Fix wavparse some more.
2005-09-19 16:26:30 +00:00
|
|
|
return ret;
|
2003-06-13 22:11:56 +00:00
|
|
|
}
|
|
|
|
|
2001-12-22 23:27:31 +00:00
|
|
|
static gboolean
|
2004-03-14 22:34:33 +00:00
|
|
|
plugin_init (GstPlugin * plugin)
|
2001-12-22 23:27:31 +00:00
|
|
|
{
|
2005-07-20 11:26:05 +00:00
|
|
|
gst_riff_init ();
|
2003-08-13 04:48:51 +00:00
|
|
|
|
2004-07-15 23:56:05 +00:00
|
|
|
return gst_element_register (plugin, "wavparse", GST_RANK_PRIMARY,
|
2004-03-14 22:34:33 +00:00
|
|
|
GST_TYPE_WAVPARSE);
|
2001-12-22 23:27:31 +00:00
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
|
|
|
|
GST_VERSION_MINOR,
|
|
|
|
"wavparse",
|
|
|
|
"Parse a .wav file into raw audio",
|
2005-11-14 02:13:35 +00:00
|
|
|
plugin_init, VERSION, GST_LICENSE, GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN)
|