2002-04-21 12:04:54 +00:00
|
|
|
/* GStreamer
|
|
|
|
* Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
|
|
|
|
* 2000 Wim Taymans <wtay@chello.be>
|
|
|
|
*
|
|
|
|
* gstafparse.c:
|
|
|
|
*
|
|
|
|
* 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:13 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
2002-04-21 12:04:54 +00:00
|
|
|
#include <gst/gst.h>
|
|
|
|
#include <gst/audio/audio.h>
|
2002-04-22 18:50:01 +00:00
|
|
|
#include <string.h>
|
2002-04-21 12:04:54 +00:00
|
|
|
#include "gstafparse.h"
|
|
|
|
|
2002-09-18 19:02:52 +00:00
|
|
|
/* elementfactory information */
|
2006-04-25 21:56:38 +00:00
|
|
|
static const GstElementDetails afparse_details =
|
2006-04-06 11:35:26 +00:00
|
|
|
GST_ELEMENT_DETAILS ("Audiofile demuxer",
|
|
|
|
"Codec/Demuxer/Audio",
|
|
|
|
"Audiofile parser for audio/raw",
|
|
|
|
"Steve Baker <stevebaker_org@yahoo.co.uk>");
|
2002-04-21 12:04:54 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* AFParse signals and args */
|
2004-03-14 22:34:33 +00:00
|
|
|
enum
|
|
|
|
{
|
2002-04-21 12:04:54 +00:00
|
|
|
/* FILL ME */
|
|
|
|
SIGNAL_HANDOFF,
|
|
|
|
LAST_SIGNAL
|
|
|
|
};
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
enum
|
|
|
|
{
|
2004-05-21 23:28:57 +00:00
|
|
|
ARG_0
|
2002-04-21 12:04:54 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* added a src factory function to force audio/raw MIME type */
|
2003-12-22 01:47:09 +00:00
|
|
|
static GstStaticPadTemplate afparse_src_factory =
|
2004-03-14 22:34:33 +00:00
|
|
|
GST_STATIC_PAD_TEMPLATE ("src",
|
|
|
|
GST_PAD_SRC,
|
|
|
|
GST_PAD_ALWAYS,
|
|
|
|
GST_STATIC_CAPS ("audio/x-raw-int, "
|
2004-03-15 19:32:27 +00:00
|
|
|
"rate = (int) [ 1, MAX ], "
|
|
|
|
"channels = (int) [ 1, MAX ], "
|
|
|
|
"endianness = (int) BYTE_ORDER, "
|
|
|
|
"width = (int) { 8, 16 }, "
|
2004-11-09 06:08:22 +00:00
|
|
|
"depth = (int) { 8, 16 }, " "signed = (boolean) { true, false }")
|
2004-03-14 22:34:33 +00:00
|
|
|
);
|
2002-04-21 12:04:54 +00:00
|
|
|
|
2003-12-22 01:47:09 +00:00
|
|
|
static GstStaticPadTemplate afparse_sink_factory =
|
2004-03-14 22:34:33 +00:00
|
|
|
GST_STATIC_PAD_TEMPLATE ("sink",
|
|
|
|
GST_PAD_SINK,
|
|
|
|
GST_PAD_ALWAYS,
|
|
|
|
GST_STATIC_CAPS ("audio/x-aiff; " "audio/x-wav; " "audio/x-au")
|
|
|
|
);
|
2002-04-21 12:04:54 +00:00
|
|
|
|
2003-11-01 14:04:20 +00:00
|
|
|
static void gst_afparse_base_init (gpointer g_class);
|
2004-03-14 22:34:33 +00:00
|
|
|
static void gst_afparse_class_init (GstAFParseClass * klass);
|
|
|
|
static void gst_afparse_init (GstAFParse * afparse);
|
|
|
|
|
|
|
|
static gboolean gst_afparse_open_file (GstAFParse * afparse);
|
|
|
|
static void gst_afparse_close_file (GstAFParse * afparse);
|
|
|
|
|
|
|
|
static void gst_afparse_loop (GstElement * element);
|
|
|
|
static void gst_afparse_set_property (GObject * object, guint prop_id,
|
|
|
|
const GValue * value, GParamSpec * pspec);
|
|
|
|
static void gst_afparse_get_property (GObject * object, guint prop_id,
|
|
|
|
GValue * value, GParamSpec * pspec);
|
|
|
|
static ssize_t gst_afparse_vf_read (AFvirtualfile * vfile, void *data,
|
|
|
|
size_t nbytes);
|
|
|
|
static long gst_afparse_vf_length (AFvirtualfile * vfile);
|
|
|
|
static ssize_t gst_afparse_vf_write (AFvirtualfile * vfile, const void *data,
|
|
|
|
size_t nbytes);
|
|
|
|
static void gst_afparse_vf_destroy (AFvirtualfile * vfile);
|
|
|
|
static long gst_afparse_vf_seek (AFvirtualfile * vfile, long offset,
|
|
|
|
int is_relative);
|
|
|
|
static long gst_afparse_vf_tell (AFvirtualfile * vfile);
|
2002-04-21 12:04:54 +00:00
|
|
|
|
|
|
|
GType
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_afparse_get_type (void)
|
2002-04-21 12:04:54 +00:00
|
|
|
{
|
|
|
|
static GType afparse_type = 0;
|
|
|
|
|
|
|
|
if (!afparse_type) {
|
|
|
|
static const GTypeInfo afparse_info = {
|
2003-11-01 14:04:20 +00:00
|
|
|
sizeof (GstAFParseClass),
|
|
|
|
gst_afparse_base_init,
|
2002-04-21 12:04:54 +00:00
|
|
|
NULL,
|
|
|
|
(GClassInitFunc) gst_afparse_class_init,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
sizeof (GstAFParse),
|
|
|
|
0,
|
|
|
|
(GInstanceInitFunc) gst_afparse_init,
|
|
|
|
};
|
2004-03-15 19:32:27 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
afparse_type =
|
2004-03-15 19:32:27 +00:00
|
|
|
g_type_register_static (GST_TYPE_ELEMENT, "GstAFParse", &afparse_info,
|
|
|
|
0);
|
2002-04-21 12:04:54 +00:00
|
|
|
}
|
|
|
|
return afparse_type;
|
|
|
|
}
|
|
|
|
|
2003-11-01 14:04:20 +00:00
|
|
|
static void
|
|
|
|
gst_afparse_base_init (gpointer g_class)
|
|
|
|
{
|
|
|
|
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
|
|
|
|
|
2003-12-22 01:47:09 +00:00
|
|
|
gst_element_class_add_pad_template (element_class,
|
|
|
|
gst_static_pad_template_get (&afparse_src_factory));
|
|
|
|
gst_element_class_add_pad_template (element_class,
|
|
|
|
gst_static_pad_template_get (&afparse_sink_factory));
|
2003-11-01 14:04:20 +00:00
|
|
|
|
|
|
|
gst_element_class_set_details (element_class, &afparse_details);
|
|
|
|
}
|
|
|
|
|
2002-04-21 12:04:54 +00:00
|
|
|
static void
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_afparse_class_init (GstAFParseClass * klass)
|
2002-04-21 12:04:54 +00:00
|
|
|
{
|
|
|
|
GObjectClass *gobject_class;
|
|
|
|
GstElementClass *gstelement_class;
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
gobject_class = (GObjectClass *) klass;
|
|
|
|
gstelement_class = (GstElementClass *) klass;
|
2002-04-21 12:04:54 +00:00
|
|
|
|
|
|
|
gobject_class->set_property = gst_afparse_set_property;
|
|
|
|
gobject_class->get_property = gst_afparse_get_property;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
static void
|
|
|
|
gst_afparse_init (GstAFParse * afparse)
|
2002-04-21 12:04:54 +00:00
|
|
|
{
|
2004-03-14 22:34:33 +00:00
|
|
|
afparse->srcpad =
|
|
|
|
gst_pad_new_from_template (gst_element_get_pad_template (GST_ELEMENT
|
2004-03-15 19:32:27 +00:00
|
|
|
(afparse), "src"), "src");
|
2004-01-02 07:09:23 +00:00
|
|
|
gst_pad_use_explicit_caps (afparse->srcpad);
|
2002-04-21 12:04:54 +00:00
|
|
|
gst_element_add_pad (GST_ELEMENT (afparse), afparse->srcpad);
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
afparse->sinkpad =
|
|
|
|
gst_pad_new_from_template (gst_element_get_pad_template (GST_ELEMENT
|
2004-03-15 19:32:27 +00:00
|
|
|
(afparse), "sink"), "sink");
|
2002-04-21 12:04:54 +00:00
|
|
|
gst_element_add_pad (GST_ELEMENT (afparse), afparse->sinkpad);
|
|
|
|
|
|
|
|
gst_element_set_loop_function (GST_ELEMENT (afparse), gst_afparse_loop);
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
afparse->vfile = af_virtual_file_new ();
|
2002-04-21 12:04:54 +00:00
|
|
|
afparse->vfile->closure = NULL;
|
|
|
|
afparse->vfile->read = gst_afparse_vf_read;
|
|
|
|
afparse->vfile->length = gst_afparse_vf_length;
|
|
|
|
afparse->vfile->write = gst_afparse_vf_write;
|
|
|
|
afparse->vfile->destroy = gst_afparse_vf_destroy;
|
|
|
|
afparse->vfile->seek = gst_afparse_vf_seek;
|
|
|
|
afparse->vfile->tell = gst_afparse_vf_tell;
|
|
|
|
|
2002-04-24 10:19:41 +00:00
|
|
|
afparse->frames_per_read = 1024;
|
2002-04-21 12:04:54 +00:00
|
|
|
afparse->curoffset = 0;
|
|
|
|
afparse->seq = 0;
|
|
|
|
|
|
|
|
afparse->file = NULL;
|
|
|
|
/* default values, should never be needed */
|
|
|
|
afparse->channels = 2;
|
|
|
|
afparse->width = 16;
|
|
|
|
afparse->rate = 44100;
|
|
|
|
afparse->type = AF_FILE_WAVE;
|
|
|
|
afparse->endianness_data = 1234;
|
|
|
|
afparse->endianness_wanted = 1234;
|
|
|
|
afparse->timestamp = 0LL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_afparse_loop (GstElement * element)
|
2002-04-21 12:04:54 +00:00
|
|
|
{
|
|
|
|
GstAFParse *afparse;
|
|
|
|
GstBuffer *buf;
|
2002-05-26 21:59:21 +00:00
|
|
|
gint numframes = 0, frames_to_bytes, frames_per_read, bytes_per_read;
|
2002-04-21 12:04:54 +00:00
|
|
|
guint8 *data;
|
2002-04-22 18:50:01 +00:00
|
|
|
gboolean bypass_afread = TRUE;
|
|
|
|
GstByteStream *bs;
|
2002-04-24 10:19:41 +00:00
|
|
|
int s_format, v_format, s_width, v_width;
|
2002-04-21 12:04:54 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
afparse = GST_AFPARSE (element);
|
2002-04-21 12:04:54 +00:00
|
|
|
|
2002-09-09 23:27:38 +00:00
|
|
|
afparse->vfile->closure = bs = gst_bytestream_new (afparse->sinkpad);
|
2002-04-22 18:50:01 +00:00
|
|
|
|
|
|
|
/* just stop if we cannot open the file */
|
2004-03-14 22:34:33 +00:00
|
|
|
if (!gst_afparse_open_file (afparse)) {
|
2002-09-09 23:27:38 +00:00
|
|
|
gst_bytestream_destroy ((GstByteStream *) afparse->vfile->closure);
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_pad_push (afparse->srcpad, GST_DATA (gst_event_new (GST_EVENT_EOS)));
|
2002-04-22 18:50:01 +00:00
|
|
|
gst_element_set_eos (GST_ELEMENT (afparse));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* if audiofile changes the data in any way, we have to access
|
|
|
|
* the audio data via afReadFrames. Otherwise we can just access
|
|
|
|
* the data directly. */
|
2004-03-14 22:34:33 +00:00
|
|
|
afGetSampleFormat (afparse->file, AF_DEFAULT_TRACK, &s_format, &s_width);
|
|
|
|
afGetVirtualSampleFormat (afparse->file, AF_DEFAULT_TRACK, &v_format,
|
|
|
|
&v_width);
|
|
|
|
if (afGetCompression != AF_COMPRESSION_NONE
|
|
|
|
|| afGetByteOrder (afparse->file,
|
2004-03-15 19:32:27 +00:00
|
|
|
AF_DEFAULT_TRACK) != afGetVirtualByteOrder (afparse->file,
|
|
|
|
AF_DEFAULT_TRACK) || s_format != v_format || s_width != v_width) {
|
2002-04-24 10:19:41 +00:00
|
|
|
bypass_afread = FALSE;
|
2002-04-22 18:50:01 +00:00
|
|
|
}
|
2002-04-24 10:19:41 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
if (bypass_afread) {
|
|
|
|
GST_DEBUG ("will bypass afReadFrames\n");
|
2002-04-22 18:50:01 +00:00
|
|
|
}
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2002-04-22 18:50:01 +00:00
|
|
|
frames_to_bytes = afparse->channels * afparse->width / 8;
|
|
|
|
frames_per_read = afparse->frames_per_read;
|
|
|
|
bytes_per_read = frames_per_read * frames_to_bytes;
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
afSeekFrame (afparse->file, AF_DEFAULT_TRACK, 0);
|
|
|
|
|
|
|
|
if (bypass_afread) {
|
|
|
|
GstEvent *event = NULL;
|
|
|
|
guint32 waiting;
|
|
|
|
guint32 got_bytes;
|
2002-05-15 19:08:49 +00:00
|
|
|
|
2002-04-22 18:50:01 +00:00
|
|
|
do {
|
|
|
|
|
2002-05-15 19:08:49 +00:00
|
|
|
got_bytes = gst_bytestream_read (bs, &buf, bytes_per_read);
|
|
|
|
if (got_bytes == 0) {
|
2004-03-15 19:32:27 +00:00
|
|
|
/* we need to check for an event. */
|
|
|
|
gst_bytestream_get_status (bs, &waiting, &event);
|
|
|
|
if (event && GST_EVENT_TYPE (event) == GST_EVENT_EOS) {
|
|
|
|
gst_pad_push (afparse->srcpad,
|
|
|
|
GST_DATA (gst_event_new (GST_EVENT_EOS)));
|
|
|
|
gst_element_set_eos (GST_ELEMENT (afparse));
|
|
|
|
break;
|
|
|
|
}
|
2004-03-14 22:34:33 +00:00
|
|
|
} else {
|
2004-03-15 19:32:27 +00:00
|
|
|
GST_BUFFER_TIMESTAMP (buf) = afparse->timestamp;
|
|
|
|
gst_pad_push (afparse->srcpad, GST_DATA (buf));
|
|
|
|
if (got_bytes != bytes_per_read) {
|
|
|
|
/* this shouldn't happen very often */
|
|
|
|
/* FIXME calculate the timestamps based on the fewer bytes received */
|
|
|
|
|
|
|
|
} else {
|
|
|
|
afparse->timestamp += frames_per_read * 1E9 / afparse->rate;
|
|
|
|
}
|
2002-04-24 10:19:41 +00:00
|
|
|
}
|
2002-04-22 18:50:01 +00:00
|
|
|
}
|
|
|
|
while (TRUE);
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
} else {
|
2002-04-21 15:12:34 +00:00
|
|
|
do {
|
2003-12-22 01:47:09 +00:00
|
|
|
buf = gst_buffer_new_and_alloc (bytes_per_read);
|
2004-03-14 22:34:33 +00:00
|
|
|
GST_BUFFER_TIMESTAMP (buf) = afparse->timestamp;
|
|
|
|
data = GST_BUFFER_DATA (buf);
|
|
|
|
numframes =
|
2004-03-15 19:32:27 +00:00
|
|
|
afReadFrames (afparse->file, AF_DEFAULT_TRACK, data, frames_per_read);
|
2002-04-21 15:12:34 +00:00
|
|
|
|
|
|
|
/* events are handled in gst_afparse_vf_read so if there are no
|
|
|
|
* frames it must be EOS */
|
2004-03-14 22:34:33 +00:00
|
|
|
if (numframes < 1) {
|
2004-03-15 19:32:27 +00:00
|
|
|
gst_buffer_unref (buf);
|
2002-04-21 15:12:34 +00:00
|
|
|
|
2004-03-15 19:32:27 +00:00
|
|
|
gst_pad_push (afparse->srcpad,
|
|
|
|
GST_DATA (gst_event_new (GST_EVENT_EOS)));
|
|
|
|
gst_element_set_eos (GST_ELEMENT (afparse));
|
|
|
|
break;
|
2002-04-21 15:12:34 +00:00
|
|
|
}
|
2004-03-14 22:34:33 +00:00
|
|
|
GST_BUFFER_SIZE (buf) = numframes * frames_to_bytes;
|
2003-10-08 16:08:19 +00:00
|
|
|
gst_pad_push (afparse->srcpad, GST_DATA (buf));
|
2002-04-21 15:12:34 +00:00
|
|
|
afparse->timestamp += numframes * 1E9 / afparse->rate;
|
|
|
|
}
|
|
|
|
while (TRUE);
|
2002-04-21 12:04:54 +00:00
|
|
|
}
|
2002-04-22 18:50:01 +00:00
|
|
|
gst_afparse_close_file (afparse);
|
2004-03-14 22:34:33 +00:00
|
|
|
|
|
|
|
gst_bytestream_destroy ((GstByteStream *) afparse->vfile->closure);
|
2002-04-21 12:04:54 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_afparse_set_property (GObject * object, guint prop_id,
|
|
|
|
const GValue * value, GParamSpec * pspec)
|
2002-04-21 12:04:54 +00:00
|
|
|
{
|
|
|
|
GstAFParse *afparse;
|
|
|
|
|
|
|
|
afparse = GST_AFPARSE (object);
|
|
|
|
|
|
|
|
switch (prop_id) {
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
static void
|
|
|
|
gst_afparse_get_property (GObject * object, guint prop_id,
|
|
|
|
GValue * value, GParamSpec * pspec)
|
2002-04-21 12:04:54 +00:00
|
|
|
{
|
|
|
|
GstAFParse *afparse;
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2002-04-21 12:04:54 +00:00
|
|
|
g_return_if_fail (GST_IS_AFPARSE (object));
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2002-04-21 12:04:54 +00:00
|
|
|
afparse = GST_AFPARSE (object);
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2002-04-21 12:04:54 +00:00
|
|
|
switch (prop_id) {
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-05-26 21:59:21 +00:00
|
|
|
gboolean
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_afparse_plugin_init (GstPlugin * plugin)
|
2002-04-21 12:04:54 +00:00
|
|
|
{
|
2004-03-14 22:34:33 +00:00
|
|
|
/* load audio support library */
|
2002-04-21 12:04:54 +00:00
|
|
|
if (!gst_library_load ("gstaudio"))
|
|
|
|
return FALSE;
|
2003-10-01 13:14:50 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
if (!gst_element_register (plugin, "afparse", GST_RANK_NONE,
|
2004-03-15 19:32:27 +00:00
|
|
|
GST_TYPE_AFPARSE))
|
2003-11-01 14:04:20 +00:00
|
|
|
return FALSE;
|
|
|
|
|
2002-04-21 12:04:54 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* this is where we open the audiofile */
|
|
|
|
static gboolean
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_afparse_open_file (GstAFParse * afparse)
|
2002-04-21 12:04:54 +00:00
|
|
|
{
|
renamed GST_FLAGS macros to GST_OBJECT_FLAGS moved bitshift from macro to enum definition
Original commit message from CVS:
* examples/indexing/indexmpeg.c: (main):
* ext/artsd/gstartsdsink.c: (gst_artsdsink_open_audio),
(gst_artsdsink_close_audio), (gst_artsdsink_change_state):
* ext/artsd/gstartsdsink.h:
* ext/audiofile/gstafparse.c: (gst_afparse_open_file),
(gst_afparse_close_file):
* ext/audiofile/gstafparse.h:
* ext/audiofile/gstafsink.c: (gst_afsink_open_file),
(gst_afsink_close_file), (gst_afsink_chain),
(gst_afsink_change_state):
* ext/audiofile/gstafsink.h:
* ext/audiofile/gstafsrc.c: (gst_afsrc_open_file),
(gst_afsrc_close_file), (gst_afsrc_change_state):
* ext/audiofile/gstafsrc.h:
* ext/cdaudio/gstcdaudio.c: (gst_cdaudio_init):
* ext/directfb/directfbvideosink.c: (gst_directfbvideosink_init):
* ext/dts/gstdtsdec.c: (gst_dtsdec_init):
* ext/jack/gstjack.h:
* ext/jack/gstjackbin.c: (gst_jack_bin_init),
(gst_jack_bin_change_state):
* ext/musepack/gstmusepackdec.c: (gst_musepackdec_init):
* ext/musicbrainz/gsttrm.c: (gst_musicbrainz_init):
* ext/nas/nassink.c: (gst_nassink_open_audio),
(gst_nassink_close_audio), (gst_nassink_change_state):
* ext/nas/nassink.h:
* ext/polyp/polypsink.c: (gst_polypsink_init):
* ext/sdl/sdlvideosink.c: (gst_sdlvideosink_change_state):
* ext/sdl/sdlvideosink.h:
* ext/smoothwave/gstsmoothwave.c: (gst_smoothwave_init):
* ext/sndfile/gstsf.c: (gst_sf_set_property),
(gst_sf_change_state), (gst_sf_release_request_pad),
(gst_sf_open_file), (gst_sf_close_file), (gst_sf_loop):
* ext/sndfile/gstsf.h:
* ext/swfdec/gstswfdec.c: (gst_swfdec_init):
* ext/tarkin/gsttarkindec.c: (gst_tarkindec_init):
* gst/apetag/apedemux.c: (gst_ape_demux_init):
* gst/cdxaparse/gstcdxaparse.c: (gst_cdxaparse_init):
* gst/cdxaparse/gstcdxastrip.c: (gst_cdxastrip_init):
* gst/festival/gstfestival.c: (gst_festival_change_state):
* gst/festival/gstfestival.h:
* gst/mpeg2sub/gstmpeg2subt.c: (gst_mpeg2subt_init):
* gst/multifilesink/gstmultifilesink.c: (gst_multifilesink_init),
(gst_multifilesink_set_location), (gst_multifilesink_open_file),
(gst_multifilesink_close_file), (gst_multifilesink_next_file),
(gst_multifilesink_pad_query), (gst_multifilesink_handle_event),
(gst_multifilesink_chain), (gst_multifilesink_change_state):
* gst/multifilesink/gstmultifilesink.h:
* gst/videodrop/gstvideodrop.c: (gst_videodrop_init):
* sys/cdrom/gstcdplayer.c: (cdplayer_init):
* sys/dxr3/dxr3audiosink.c: (dxr3audiosink_init),
(dxr3audiosink_open), (dxr3audiosink_close),
(dxr3audiosink_chain_pcm), (dxr3audiosink_chain_ac3),
(dxr3audiosink_change_state):
* sys/dxr3/dxr3audiosink.h:
* sys/dxr3/dxr3spusink.c: (dxr3spusink_init), (dxr3spusink_open),
(dxr3spusink_close), (dxr3spusink_chain),
(dxr3spusink_change_state):
* sys/dxr3/dxr3spusink.h:
* sys/dxr3/dxr3videosink.c: (dxr3videosink_init),
(dxr3videosink_open), (dxr3videosink_close),
(dxr3videosink_write_data), (dxr3videosink_change_state):
* sys/dxr3/dxr3videosink.h:
* sys/glsink/glimagesink.c: (gst_glimagesink_init):
* sys/qcam/gstqcamsrc.c: (gst_qcamsrc_change_state),
(gst_qcamsrc_open), (gst_qcamsrc_close):
* sys/qcam/gstqcamsrc.h:
* sys/v4l2/gstv4l2src.c: (gst_v4l2src_init):
* sys/vcd/vcdsrc.c: (gst_vcdsrc_set_property), (gst_vcdsrc_get),
(gst_vcdsrc_open_file), (gst_vcdsrc_close_file),
(gst_vcdsrc_change_state), (gst_vcdsrc_recalculate):
* sys/vcd/vcdsrc.h:
renamed GST_FLAGS macros to GST_OBJECT_FLAGS
moved bitshift from macro to enum definition
2005-10-12 14:29:55 +00:00
|
|
|
g_return_val_if_fail (!GST_OBJECT_FLAG_IS_SET (afparse, GST_AFPARSE_OPEN),
|
|
|
|
FALSE);
|
2002-04-21 12:04:54 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* open the file */
|
2004-03-14 22:34:33 +00:00
|
|
|
GST_DEBUG ("opening vfile %p\n", afparse->vfile);
|
2002-04-21 12:04:54 +00:00
|
|
|
afparse->file = afOpenVirtualFile (afparse->vfile, "r", AF_NULL_FILESETUP);
|
2004-03-14 22:34:33 +00:00
|
|
|
if (afparse->file == AF_NULL_FILEHANDLE) {
|
2002-04-21 12:04:54 +00:00
|
|
|
/* this should never happen */
|
|
|
|
g_warning ("ERROR: gstafparse: Could not open virtual file for reading\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
GST_DEBUG ("vfile opened\n");
|
2002-04-21 12:04:54 +00:00
|
|
|
/* get the audiofile audio parameters */
|
|
|
|
{
|
|
|
|
int sampleFormat, sampleWidth;
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2002-04-21 12:04:54 +00:00
|
|
|
afparse->channels = afGetChannels (afparse->file, AF_DEFAULT_TRACK);
|
2004-03-14 22:34:33 +00:00
|
|
|
afGetSampleFormat (afparse->file, AF_DEFAULT_TRACK,
|
2004-03-15 19:32:27 +00:00
|
|
|
&sampleFormat, &sampleWidth);
|
2004-03-14 22:34:33 +00:00
|
|
|
switch (sampleFormat) {
|
2002-04-21 12:04:54 +00:00
|
|
|
case AF_SAMPFMT_TWOSCOMP:
|
2004-03-15 19:32:27 +00:00
|
|
|
afparse->is_signed = TRUE;
|
|
|
|
break;
|
2002-04-21 12:04:54 +00:00
|
|
|
case AF_SAMPFMT_UNSIGNED:
|
2004-03-15 19:32:27 +00:00
|
|
|
afparse->is_signed = FALSE;
|
|
|
|
break;
|
2002-04-21 12:04:54 +00:00
|
|
|
case AF_SAMPFMT_FLOAT:
|
|
|
|
case AF_SAMPFMT_DOUBLE:
|
2004-03-15 19:32:27 +00:00
|
|
|
GST_DEBUG ("ERROR: float data not supported yet !\n");
|
2002-04-21 12:04:54 +00:00
|
|
|
}
|
|
|
|
afparse->rate = (guint) afGetRate (afparse->file, AF_DEFAULT_TRACK);
|
|
|
|
afparse->width = sampleWidth;
|
2004-03-14 22:34:33 +00:00
|
|
|
GST_DEBUG ("input file: %d channels, %d width, %d rate, signed %s\n",
|
2004-03-15 19:32:27 +00:00
|
|
|
afparse->channels, afparse->width, afparse->rate,
|
|
|
|
afparse->is_signed ? "yes" : "no");
|
2002-04-21 12:04:54 +00:00
|
|
|
}
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2002-04-21 12:04:54 +00:00
|
|
|
/* set caps on src */
|
2004-03-14 22:34:33 +00:00
|
|
|
/*FIXME: add all the possible formats, especially float ! */
|
|
|
|
gst_pad_set_explicit_caps (afparse->srcpad,
|
|
|
|
gst_caps_new_simple ("audio/x-raw-int",
|
2004-03-15 19:32:27 +00:00
|
|
|
"endianness", G_TYPE_INT, G_BYTE_ORDER,
|
|
|
|
"signed", G_TYPE_BOOLEAN, afparse->is_signed,
|
|
|
|
"width", G_TYPE_INT, afparse->width,
|
|
|
|
"depth", G_TYPE_INT, afparse->width,
|
|
|
|
"rate", G_TYPE_INT, afparse->rate,
|
|
|
|
"channels", G_TYPE_INT, afparse->channels, NULL));
|
2002-04-21 12:04:54 +00:00
|
|
|
|
renamed GST_FLAGS macros to GST_OBJECT_FLAGS moved bitshift from macro to enum definition
Original commit message from CVS:
* examples/indexing/indexmpeg.c: (main):
* ext/artsd/gstartsdsink.c: (gst_artsdsink_open_audio),
(gst_artsdsink_close_audio), (gst_artsdsink_change_state):
* ext/artsd/gstartsdsink.h:
* ext/audiofile/gstafparse.c: (gst_afparse_open_file),
(gst_afparse_close_file):
* ext/audiofile/gstafparse.h:
* ext/audiofile/gstafsink.c: (gst_afsink_open_file),
(gst_afsink_close_file), (gst_afsink_chain),
(gst_afsink_change_state):
* ext/audiofile/gstafsink.h:
* ext/audiofile/gstafsrc.c: (gst_afsrc_open_file),
(gst_afsrc_close_file), (gst_afsrc_change_state):
* ext/audiofile/gstafsrc.h:
* ext/cdaudio/gstcdaudio.c: (gst_cdaudio_init):
* ext/directfb/directfbvideosink.c: (gst_directfbvideosink_init):
* ext/dts/gstdtsdec.c: (gst_dtsdec_init):
* ext/jack/gstjack.h:
* ext/jack/gstjackbin.c: (gst_jack_bin_init),
(gst_jack_bin_change_state):
* ext/musepack/gstmusepackdec.c: (gst_musepackdec_init):
* ext/musicbrainz/gsttrm.c: (gst_musicbrainz_init):
* ext/nas/nassink.c: (gst_nassink_open_audio),
(gst_nassink_close_audio), (gst_nassink_change_state):
* ext/nas/nassink.h:
* ext/polyp/polypsink.c: (gst_polypsink_init):
* ext/sdl/sdlvideosink.c: (gst_sdlvideosink_change_state):
* ext/sdl/sdlvideosink.h:
* ext/smoothwave/gstsmoothwave.c: (gst_smoothwave_init):
* ext/sndfile/gstsf.c: (gst_sf_set_property),
(gst_sf_change_state), (gst_sf_release_request_pad),
(gst_sf_open_file), (gst_sf_close_file), (gst_sf_loop):
* ext/sndfile/gstsf.h:
* ext/swfdec/gstswfdec.c: (gst_swfdec_init):
* ext/tarkin/gsttarkindec.c: (gst_tarkindec_init):
* gst/apetag/apedemux.c: (gst_ape_demux_init):
* gst/cdxaparse/gstcdxaparse.c: (gst_cdxaparse_init):
* gst/cdxaparse/gstcdxastrip.c: (gst_cdxastrip_init):
* gst/festival/gstfestival.c: (gst_festival_change_state):
* gst/festival/gstfestival.h:
* gst/mpeg2sub/gstmpeg2subt.c: (gst_mpeg2subt_init):
* gst/multifilesink/gstmultifilesink.c: (gst_multifilesink_init),
(gst_multifilesink_set_location), (gst_multifilesink_open_file),
(gst_multifilesink_close_file), (gst_multifilesink_next_file),
(gst_multifilesink_pad_query), (gst_multifilesink_handle_event),
(gst_multifilesink_chain), (gst_multifilesink_change_state):
* gst/multifilesink/gstmultifilesink.h:
* gst/videodrop/gstvideodrop.c: (gst_videodrop_init):
* sys/cdrom/gstcdplayer.c: (cdplayer_init):
* sys/dxr3/dxr3audiosink.c: (dxr3audiosink_init),
(dxr3audiosink_open), (dxr3audiosink_close),
(dxr3audiosink_chain_pcm), (dxr3audiosink_chain_ac3),
(dxr3audiosink_change_state):
* sys/dxr3/dxr3audiosink.h:
* sys/dxr3/dxr3spusink.c: (dxr3spusink_init), (dxr3spusink_open),
(dxr3spusink_close), (dxr3spusink_chain),
(dxr3spusink_change_state):
* sys/dxr3/dxr3spusink.h:
* sys/dxr3/dxr3videosink.c: (dxr3videosink_init),
(dxr3videosink_open), (dxr3videosink_close),
(dxr3videosink_write_data), (dxr3videosink_change_state):
* sys/dxr3/dxr3videosink.h:
* sys/glsink/glimagesink.c: (gst_glimagesink_init):
* sys/qcam/gstqcamsrc.c: (gst_qcamsrc_change_state),
(gst_qcamsrc_open), (gst_qcamsrc_close):
* sys/qcam/gstqcamsrc.h:
* sys/v4l2/gstv4l2src.c: (gst_v4l2src_init):
* sys/vcd/vcdsrc.c: (gst_vcdsrc_set_property), (gst_vcdsrc_get),
(gst_vcdsrc_open_file), (gst_vcdsrc_close_file),
(gst_vcdsrc_change_state), (gst_vcdsrc_recalculate):
* sys/vcd/vcdsrc.h:
renamed GST_FLAGS macros to GST_OBJECT_FLAGS
moved bitshift from macro to enum definition
2005-10-12 14:29:55 +00:00
|
|
|
GST_OBJECT_FLAG_SET (afparse, GST_AFPARSE_OPEN);
|
2002-04-21 12:04:54 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_afparse_close_file (GstAFParse * afparse)
|
2002-04-21 12:04:54 +00:00
|
|
|
{
|
renamed GST_FLAGS macros to GST_OBJECT_FLAGS moved bitshift from macro to enum definition
Original commit message from CVS:
* examples/indexing/indexmpeg.c: (main):
* ext/artsd/gstartsdsink.c: (gst_artsdsink_open_audio),
(gst_artsdsink_close_audio), (gst_artsdsink_change_state):
* ext/artsd/gstartsdsink.h:
* ext/audiofile/gstafparse.c: (gst_afparse_open_file),
(gst_afparse_close_file):
* ext/audiofile/gstafparse.h:
* ext/audiofile/gstafsink.c: (gst_afsink_open_file),
(gst_afsink_close_file), (gst_afsink_chain),
(gst_afsink_change_state):
* ext/audiofile/gstafsink.h:
* ext/audiofile/gstafsrc.c: (gst_afsrc_open_file),
(gst_afsrc_close_file), (gst_afsrc_change_state):
* ext/audiofile/gstafsrc.h:
* ext/cdaudio/gstcdaudio.c: (gst_cdaudio_init):
* ext/directfb/directfbvideosink.c: (gst_directfbvideosink_init):
* ext/dts/gstdtsdec.c: (gst_dtsdec_init):
* ext/jack/gstjack.h:
* ext/jack/gstjackbin.c: (gst_jack_bin_init),
(gst_jack_bin_change_state):
* ext/musepack/gstmusepackdec.c: (gst_musepackdec_init):
* ext/musicbrainz/gsttrm.c: (gst_musicbrainz_init):
* ext/nas/nassink.c: (gst_nassink_open_audio),
(gst_nassink_close_audio), (gst_nassink_change_state):
* ext/nas/nassink.h:
* ext/polyp/polypsink.c: (gst_polypsink_init):
* ext/sdl/sdlvideosink.c: (gst_sdlvideosink_change_state):
* ext/sdl/sdlvideosink.h:
* ext/smoothwave/gstsmoothwave.c: (gst_smoothwave_init):
* ext/sndfile/gstsf.c: (gst_sf_set_property),
(gst_sf_change_state), (gst_sf_release_request_pad),
(gst_sf_open_file), (gst_sf_close_file), (gst_sf_loop):
* ext/sndfile/gstsf.h:
* ext/swfdec/gstswfdec.c: (gst_swfdec_init):
* ext/tarkin/gsttarkindec.c: (gst_tarkindec_init):
* gst/apetag/apedemux.c: (gst_ape_demux_init):
* gst/cdxaparse/gstcdxaparse.c: (gst_cdxaparse_init):
* gst/cdxaparse/gstcdxastrip.c: (gst_cdxastrip_init):
* gst/festival/gstfestival.c: (gst_festival_change_state):
* gst/festival/gstfestival.h:
* gst/mpeg2sub/gstmpeg2subt.c: (gst_mpeg2subt_init):
* gst/multifilesink/gstmultifilesink.c: (gst_multifilesink_init),
(gst_multifilesink_set_location), (gst_multifilesink_open_file),
(gst_multifilesink_close_file), (gst_multifilesink_next_file),
(gst_multifilesink_pad_query), (gst_multifilesink_handle_event),
(gst_multifilesink_chain), (gst_multifilesink_change_state):
* gst/multifilesink/gstmultifilesink.h:
* gst/videodrop/gstvideodrop.c: (gst_videodrop_init):
* sys/cdrom/gstcdplayer.c: (cdplayer_init):
* sys/dxr3/dxr3audiosink.c: (dxr3audiosink_init),
(dxr3audiosink_open), (dxr3audiosink_close),
(dxr3audiosink_chain_pcm), (dxr3audiosink_chain_ac3),
(dxr3audiosink_change_state):
* sys/dxr3/dxr3audiosink.h:
* sys/dxr3/dxr3spusink.c: (dxr3spusink_init), (dxr3spusink_open),
(dxr3spusink_close), (dxr3spusink_chain),
(dxr3spusink_change_state):
* sys/dxr3/dxr3spusink.h:
* sys/dxr3/dxr3videosink.c: (dxr3videosink_init),
(dxr3videosink_open), (dxr3videosink_close),
(dxr3videosink_write_data), (dxr3videosink_change_state):
* sys/dxr3/dxr3videosink.h:
* sys/glsink/glimagesink.c: (gst_glimagesink_init):
* sys/qcam/gstqcamsrc.c: (gst_qcamsrc_change_state),
(gst_qcamsrc_open), (gst_qcamsrc_close):
* sys/qcam/gstqcamsrc.h:
* sys/v4l2/gstv4l2src.c: (gst_v4l2src_init):
* sys/vcd/vcdsrc.c: (gst_vcdsrc_set_property), (gst_vcdsrc_get),
(gst_vcdsrc_open_file), (gst_vcdsrc_close_file),
(gst_vcdsrc_change_state), (gst_vcdsrc_recalculate):
* sys/vcd/vcdsrc.h:
renamed GST_FLAGS macros to GST_OBJECT_FLAGS
moved bitshift from macro to enum definition
2005-10-12 14:29:55 +00:00
|
|
|
g_return_if_fail (GST_OBJECT_FLAG_IS_SET (afparse, GST_AFPARSE_OPEN));
|
2004-03-14 22:34:33 +00:00
|
|
|
if (afCloseFile (afparse->file) != 0) {
|
2002-04-21 12:04:54 +00:00
|
|
|
g_warning ("afparse: oops, error closing !\n");
|
2004-03-14 22:34:33 +00:00
|
|
|
} else {
|
renamed GST_FLAGS macros to GST_OBJECT_FLAGS moved bitshift from macro to enum definition
Original commit message from CVS:
* examples/indexing/indexmpeg.c: (main):
* ext/artsd/gstartsdsink.c: (gst_artsdsink_open_audio),
(gst_artsdsink_close_audio), (gst_artsdsink_change_state):
* ext/artsd/gstartsdsink.h:
* ext/audiofile/gstafparse.c: (gst_afparse_open_file),
(gst_afparse_close_file):
* ext/audiofile/gstafparse.h:
* ext/audiofile/gstafsink.c: (gst_afsink_open_file),
(gst_afsink_close_file), (gst_afsink_chain),
(gst_afsink_change_state):
* ext/audiofile/gstafsink.h:
* ext/audiofile/gstafsrc.c: (gst_afsrc_open_file),
(gst_afsrc_close_file), (gst_afsrc_change_state):
* ext/audiofile/gstafsrc.h:
* ext/cdaudio/gstcdaudio.c: (gst_cdaudio_init):
* ext/directfb/directfbvideosink.c: (gst_directfbvideosink_init):
* ext/dts/gstdtsdec.c: (gst_dtsdec_init):
* ext/jack/gstjack.h:
* ext/jack/gstjackbin.c: (gst_jack_bin_init),
(gst_jack_bin_change_state):
* ext/musepack/gstmusepackdec.c: (gst_musepackdec_init):
* ext/musicbrainz/gsttrm.c: (gst_musicbrainz_init):
* ext/nas/nassink.c: (gst_nassink_open_audio),
(gst_nassink_close_audio), (gst_nassink_change_state):
* ext/nas/nassink.h:
* ext/polyp/polypsink.c: (gst_polypsink_init):
* ext/sdl/sdlvideosink.c: (gst_sdlvideosink_change_state):
* ext/sdl/sdlvideosink.h:
* ext/smoothwave/gstsmoothwave.c: (gst_smoothwave_init):
* ext/sndfile/gstsf.c: (gst_sf_set_property),
(gst_sf_change_state), (gst_sf_release_request_pad),
(gst_sf_open_file), (gst_sf_close_file), (gst_sf_loop):
* ext/sndfile/gstsf.h:
* ext/swfdec/gstswfdec.c: (gst_swfdec_init):
* ext/tarkin/gsttarkindec.c: (gst_tarkindec_init):
* gst/apetag/apedemux.c: (gst_ape_demux_init):
* gst/cdxaparse/gstcdxaparse.c: (gst_cdxaparse_init):
* gst/cdxaparse/gstcdxastrip.c: (gst_cdxastrip_init):
* gst/festival/gstfestival.c: (gst_festival_change_state):
* gst/festival/gstfestival.h:
* gst/mpeg2sub/gstmpeg2subt.c: (gst_mpeg2subt_init):
* gst/multifilesink/gstmultifilesink.c: (gst_multifilesink_init),
(gst_multifilesink_set_location), (gst_multifilesink_open_file),
(gst_multifilesink_close_file), (gst_multifilesink_next_file),
(gst_multifilesink_pad_query), (gst_multifilesink_handle_event),
(gst_multifilesink_chain), (gst_multifilesink_change_state):
* gst/multifilesink/gstmultifilesink.h:
* gst/videodrop/gstvideodrop.c: (gst_videodrop_init):
* sys/cdrom/gstcdplayer.c: (cdplayer_init):
* sys/dxr3/dxr3audiosink.c: (dxr3audiosink_init),
(dxr3audiosink_open), (dxr3audiosink_close),
(dxr3audiosink_chain_pcm), (dxr3audiosink_chain_ac3),
(dxr3audiosink_change_state):
* sys/dxr3/dxr3audiosink.h:
* sys/dxr3/dxr3spusink.c: (dxr3spusink_init), (dxr3spusink_open),
(dxr3spusink_close), (dxr3spusink_chain),
(dxr3spusink_change_state):
* sys/dxr3/dxr3spusink.h:
* sys/dxr3/dxr3videosink.c: (dxr3videosink_init),
(dxr3videosink_open), (dxr3videosink_close),
(dxr3videosink_write_data), (dxr3videosink_change_state):
* sys/dxr3/dxr3videosink.h:
* sys/glsink/glimagesink.c: (gst_glimagesink_init):
* sys/qcam/gstqcamsrc.c: (gst_qcamsrc_change_state),
(gst_qcamsrc_open), (gst_qcamsrc_close):
* sys/qcam/gstqcamsrc.h:
* sys/v4l2/gstv4l2src.c: (gst_v4l2src_init):
* sys/vcd/vcdsrc.c: (gst_vcdsrc_set_property), (gst_vcdsrc_get),
(gst_vcdsrc_open_file), (gst_vcdsrc_close_file),
(gst_vcdsrc_change_state), (gst_vcdsrc_recalculate):
* sys/vcd/vcdsrc.h:
renamed GST_FLAGS macros to GST_OBJECT_FLAGS
moved bitshift from macro to enum definition
2005-10-12 14:29:55 +00:00
|
|
|
GST_OBJECT_FLAG_UNSET (afparse, GST_AFPARSE_OPEN);
|
2002-04-21 12:04:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
static ssize_t
|
|
|
|
gst_afparse_vf_read (AFvirtualfile * vfile, void *data, size_t nbytes)
|
2002-04-21 12:04:54 +00:00
|
|
|
{
|
2004-03-14 22:34:33 +00:00
|
|
|
GstByteStream *bs = (GstByteStream *) vfile->closure;
|
|
|
|
guint8 *bytes = NULL;
|
|
|
|
GstEvent *event = NULL;
|
|
|
|
guint32 waiting;
|
|
|
|
guint32 got_bytes;
|
|
|
|
|
|
|
|
/*gchar *debug_str; */
|
|
|
|
|
|
|
|
got_bytes = gst_bytestream_peek_bytes (bs, &bytes, nbytes);
|
|
|
|
|
|
|
|
while (got_bytes != nbytes) {
|
2002-04-21 12:04:54 +00:00
|
|
|
/* handle events */
|
2002-04-21 15:12:34 +00:00
|
|
|
gst_bytestream_get_status (bs, &waiting, &event);
|
2002-04-21 12:04:54 +00:00
|
|
|
|
2002-05-15 19:08:49 +00:00
|
|
|
/* FIXME this event handling isn't right yet */
|
2004-03-14 22:34:33 +00:00
|
|
|
if (!event) {
|
|
|
|
/*g_print("no event found with %u bytes\n", got_bytes); */
|
2002-05-15 19:08:49 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2004-03-14 22:34:33 +00:00
|
|
|
switch (GST_EVENT_TYPE (event)) {
|
2003-07-06 20:49:52 +00:00
|
|
|
case GST_EVENT_EOS:
|
2004-03-15 19:32:27 +00:00
|
|
|
return 0;
|
2003-07-06 20:49:52 +00:00
|
|
|
case GST_EVENT_FLUSH:
|
2004-03-15 19:32:27 +00:00
|
|
|
GST_DEBUG ("flush");
|
|
|
|
break;
|
2003-07-06 20:49:52 +00:00
|
|
|
case GST_EVENT_DISCONTINUOUS:
|
2004-03-15 19:32:27 +00:00
|
|
|
GST_DEBUG ("seek done");
|
|
|
|
got_bytes = gst_bytestream_peek_bytes (bs, &bytes, nbytes);
|
|
|
|
break;
|
2003-07-06 20:49:52 +00:00
|
|
|
default:
|
2004-03-15 19:32:27 +00:00
|
|
|
g_warning ("unknown event %d", GST_EVENT_TYPE (event));
|
|
|
|
got_bytes = gst_bytestream_peek_bytes (bs, &bytes, nbytes);
|
2002-04-21 15:12:34 +00:00
|
|
|
}
|
2002-04-21 12:04:54 +00:00
|
|
|
}
|
2004-03-14 22:34:33 +00:00
|
|
|
|
|
|
|
memcpy (data, bytes, got_bytes);
|
|
|
|
gst_bytestream_flush_fast (bs, got_bytes);
|
2002-04-21 15:12:34 +00:00
|
|
|
|
2002-05-15 19:08:49 +00:00
|
|
|
/* debug_str = g_strndup((gchar*)bytes, got_bytes);
|
2004-03-14 22:34:33 +00:00
|
|
|
g_print("read %u bytes: %s\n", got_bytes, debug_str);
|
|
|
|
*/
|
2002-05-15 19:08:49 +00:00
|
|
|
return got_bytes;
|
2002-04-21 12:04:54 +00:00
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
static long
|
|
|
|
gst_afparse_vf_seek (AFvirtualfile * vfile, long offset, int is_relative)
|
2002-04-21 12:04:54 +00:00
|
|
|
{
|
2004-03-14 22:34:33 +00:00
|
|
|
GstByteStream *bs = (GstByteStream *) vfile->closure;
|
2002-05-26 21:59:21 +00:00
|
|
|
GstSeekType method;
|
2004-03-14 22:34:33 +00:00
|
|
|
guint64 current_offset = gst_bytestream_tell (bs);
|
2002-04-21 15:12:34 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
if (!is_relative) {
|
|
|
|
if ((guint64) offset == current_offset) {
|
2002-04-21 15:12:34 +00:00
|
|
|
/* this seems to happen before every read - bad audiofile */
|
|
|
|
return offset;
|
|
|
|
}
|
|
|
|
|
2002-05-26 21:59:21 +00:00
|
|
|
method = GST_SEEK_METHOD_SET;
|
2004-03-14 22:34:33 +00:00
|
|
|
} else {
|
|
|
|
if (offset == 0)
|
|
|
|
return current_offset;
|
|
|
|
method = GST_SEEK_METHOD_CUR;
|
2002-04-21 15:12:34 +00:00
|
|
|
}
|
2004-03-14 22:34:33 +00:00
|
|
|
|
|
|
|
if (gst_bytestream_seek (bs, (gint64) offset, method)) {
|
|
|
|
GST_DEBUG ("doing seek to %d", (gint) offset);
|
2002-04-21 12:04:54 +00:00
|
|
|
return offset;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
static long
|
|
|
|
gst_afparse_vf_length (AFvirtualfile * vfile)
|
2002-04-21 12:04:54 +00:00
|
|
|
{
|
2004-03-14 22:34:33 +00:00
|
|
|
GstByteStream *bs = (GstByteStream *) vfile->closure;
|
2003-07-06 20:49:52 +00:00
|
|
|
guint64 length;
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
length = gst_bytestream_length (bs);
|
|
|
|
GST_DEBUG ("doing length: %" G_GUINT64_FORMAT, length);
|
2003-07-06 20:49:52 +00:00
|
|
|
return length;
|
2002-04-21 12:04:54 +00:00
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
static ssize_t
|
|
|
|
gst_afparse_vf_write (AFvirtualfile * vfile, const void *data, size_t nbytes)
|
2002-04-21 12:04:54 +00:00
|
|
|
{
|
2004-03-14 22:34:33 +00:00
|
|
|
/* GstByteStream *bs = (GstByteStream*)vfile->closure; */
|
|
|
|
g_warning ("shouldn't write to a readonly pad");
|
2002-04-21 12:04:54 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
static void
|
|
|
|
gst_afparse_vf_destroy (AFvirtualfile * vfile)
|
2002-04-21 12:04:54 +00:00
|
|
|
{
|
2004-03-14 22:34:33 +00:00
|
|
|
/* GstByteStream *bs = (GstByteStream*)vfile->closure; */
|
2002-04-21 12:04:54 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
GST_DEBUG ("doing destroy");
|
2002-04-21 12:04:54 +00:00
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
static long
|
|
|
|
gst_afparse_vf_tell (AFvirtualfile * vfile)
|
2002-04-21 12:04:54 +00:00
|
|
|
{
|
2004-03-14 22:34:33 +00:00
|
|
|
GstByteStream *bs = (GstByteStream *) vfile->closure;
|
2002-04-21 15:12:34 +00:00
|
|
|
guint64 offset;
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
offset = gst_bytestream_tell (bs);
|
|
|
|
GST_DEBUG ("doing tell: %" G_GUINT64_FORMAT, offset);
|
2002-04-21 15:12:34 +00:00
|
|
|
return offset;
|
2002-04-21 12:04:54 +00:00
|
|
|
}
|