Commit 72bc1ba4 authored by Sebastian Dröge's avatar Sebastian Dröge 🍵 Committed by Tim-Philipp Müller

configure.ac: Check for wavpack version and define WAVPACK_OLD_API if necessary.

Original commit message from CVS:
Patch by: Sebastian Dröge <slomo at circular-chaos.org>
* configure.ac:
Check for wavpack version and define WAVPACK_OLD_API if
necessary.
* ext/wavpack/Makefile.am:
* ext/wavpack/gstwavpackcommon.c: (gst_wavpack_read_header),
(gst_wavpack_read_metadata):
* ext/wavpack/gstwavpackcommon.h:
* ext/wavpack/gstwavpackdec.c: (gst_wavpack_dec_base_init),
(gst_wavpack_dec_class_init), (gst_wavpack_dec_init),
(gst_wavpack_dec_finalize), (gst_wavpack_dec_format_samples),
(gst_wavpack_dec_clip_outgoing_buffer), (gst_wavpack_dec_chain),
(gst_wavpack_dec_sink_event), (gst_wavpack_dec_change_state),
(gst_wavpack_dec_request_new_pad), (gst_wavpack_dec_plugin_init):
* ext/wavpack/gstwavpackdec.h:
* ext/wavpack/gstwavpackenc.c: (gst_wavpack_enc_class_init),
(gst_wavpack_enc_init), (gst_wavpack_enc_finalize),
(gst_wavpack_enc_set_wp_config):
* ext/wavpack/gstwavpackparse.c: (gst_wavpack_parse_base_init),
(gst_wavpack_parse_finalize), (gst_wavpack_parse_class_init),
(gst_wavpack_parse_index_get_entry_from_sample),
(gst_wavpack_parse_scan_to_find_sample),
(gst_wavpack_parse_handle_seek_event),
(gst_wavpack_parse_create_src_pad):
* ext/wavpack/gstwavpackstreamreader.c:
* ext/wavpack/gstwavpackstreamreader.h:
Port to new/official wavpack API, don't use API that was exported
in wavpack header files and in the lib but meant to be private, at
least not for recent wavpack versions; misc. 'cleanups' (#347443).
parent ae5b1206
......@@ -7,10 +7,11 @@ libgstwavpack_la_SOURCES = \
gstwavpackparse.c \
gstwavpackdec.c \
gstwavpackenc.c \
gstwavpackstreamreader.c \
md5.c
libgstwavpack_la_CFLAGS = $(GST_CFLAGS) $(WAVPACK_CFLAGS)
libgstwavpack_la_LIBADD = $(GST_LIBS) $(WAVPACK_LIBS)
libgstwavpack_la_CFLAGS = $(GST_CFLAGS) $(GST_PLUGINS_BASE_CFLAGS) $(WAVPACK_CFLAGS)
libgstwavpack_la_LIBADD = $(GST_LIBS) $(GST_PLUGINS_BASE_LIBS) -lgstaudio-$(GST_MAJORMINOR) $(WAVPACK_LIBS)
libgstwavpack_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
noinst_HEADERS = \
......@@ -18,5 +19,6 @@ noinst_HEADERS = \
gstwavpackdec.h \
gstwavpackenc.h \
gstwavpackcommon.h \
gstwavpackstreamreader.h \
md5.h
/* GStreamer Wavpack plugin
* Copyright (c) 2005 Arwed v. Merkatz <v.merkatz@gmx.net>
* Copyright (c) 1998 - 2005 Conifer Software
* Copyright (c) 2006 Sebastian Dröge <slomo@circular-chaos.org>
*
* gstwavpackcommon.c: common helper functions
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "gstwavpackcommon.h"
#include <string.h>
......@@ -5,10 +32,64 @@ gboolean
gst_wavpack_read_header (WavpackHeader * header, guint8 * buf)
{
g_memmove (header, buf, sizeof (WavpackHeader));
#ifndef WAVPACK_OLD_API
WavpackLittleEndianToNative (header, WavpackHeaderFormat);
#else
little_endian_to_native (header, WavpackHeaderFormat);
#endif
return (memcmp (header->ckID, "wvpk", 4) == 0);
}
if (strncmp (header->ckID, "wvpk", 4))
/* inspired by the original one in wavpack */
gboolean
gst_wavpack_read_metadata (GstWavpackMetadata * wpmd, guint8 * header_data,
guint8 ** p_data)
{
WavpackHeader hdr;
guint8 *end;
gst_wavpack_read_header (&hdr, header_data);
end = header_data + hdr.ckSize + 8;
if (end - *p_data < 2)
return FALSE;
else
return TRUE;
wpmd->id = GST_READ_UINT8 (*p_data);
wpmd->byte_length = 2 * (guint) GST_READ_UINT8 (*p_data + 1);
*p_data += 2;
if ((wpmd->id & ID_LARGE) == ID_LARGE) {
guint extra;
wpmd->id &= ~ID_LARGE;
if (end - *p_data < 2)
return FALSE;
extra = GST_READ_UINT16_LE (*p_data);
wpmd->byte_length += (extra << 9);
*p_data += 2;
}
if ((wpmd->id & ID_ODD_SIZE) == ID_ODD_SIZE) {
wpmd->id &= ~ID_ODD_SIZE;
--wpmd->byte_length;
}
if (wpmd->byte_length > 0) {
if (end - *p_data < wpmd->byte_length + (wpmd->byte_length & 1)) {
wpmd->data = NULL;
return FALSE;
}
wpmd->data = *p_data;
*p_data += wpmd->byte_length + (wpmd->byte_length & 1);
} else {
wpmd->data = NULL;
}
return TRUE;
}
/* GStreamer Wavpack plugin
* Copyright (c) 2005 Arwed v. Merkatz <v.merkatz@gmx.net>
* Copyright (c) 2006 Sebastian Dröge <slomo@circular-chaos.org>
*
* gstwavpackcommon.h: common helper functions
*
* 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.
*/
#ifndef __GST_WAVPACK_COMMON_H__
#define __GST_WAVPACK_COMMON_H__
#include <gst/gst.h>
#include <wavpack/wavpack.h>
typedef struct
{
guint32 byte_length;
guint8 *data;
guint8 id;
} GstWavpackMetadata;
#define ID_UNIQUE 0x3f
#define ID_OPTIONAL_DATA 0x20
#define ID_ODD_SIZE 0x40
#define ID_LARGE 0x80
#define ID_DUMMY 0x0
#define ID_ENCODER_INFO 0x1
#define ID_DECORR_TERMS 0x2
#define ID_DECORR_WEIGHTS 0x3
#define ID_DECORR_SAMPLES 0x4
#define ID_ENTROPY_VARS 0x5
#define ID_HYBRID_PROFILE 0x6
#define ID_SHAPING_WEIGHTS 0x7
#define ID_FLOAT_INFO 0x8
#define ID_INT32_INFO 0x9
#define ID_WV_BITSTREAM 0xa
#define ID_WVC_BITSTREAM 0xb
#define ID_WVX_BITSTREAM 0xc
#define ID_CHANNEL_INFO 0xd
#define ID_RIFF_HEADER (ID_OPTIONAL_DATA | 0x1)
#define ID_RIFF_TRAILER (ID_OPTIONAL_DATA | 0x2)
#define ID_REPLAY_GAIN (ID_OPTIONAL_DATA | 0x3)
#define ID_CUESHEET (ID_OPTIONAL_DATA | 0x4)
#define ID_CONFIG_BLOCK (ID_OPTIONAL_DATA | 0x5)
#define ID_MD5_CHECKSUM (ID_OPTIONAL_DATA | 0x6)
#define ID_SAMPLE_RATE (ID_OPTIONAL_DATA | 0x7)
gboolean gst_wavpack_read_header (WavpackHeader * header, guint8 * buf);
gboolean gst_wavpack_read_metadata (GstWavpackMetadata * meta,
guint8 * header_data, guint8 ** p_data);
#endif
This diff is collapsed.
/* GStreamer Wavpack plugin
* (c) 2004 Arwed v. Merkatz <v.merkatz@gmx.net>
* Copyright (c) 2004 Arwed v. Merkatz <v.merkatz@gmx.net>
* Copyright (c) 2006 Sebastian Dröge <slomo@circular-chaos.org>
*
* gstwavpackdec.h: raw Wavpack bitstream decoder
*
......@@ -26,8 +27,9 @@
#include <wavpack/wavpack.h>
G_BEGIN_DECLS
#include "gstwavpackstreamreader.h"
G_BEGIN_DECLS
/* #define's don't like whitespacey bits */
#define GST_TYPE_WAVPACK_DEC \
(gst_wavpack_dec_get_type())
......@@ -39,48 +41,40 @@ G_BEGIN_DECLS
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_WAVPACK_DEC))
#define GST_IS_WAVPACK_DEC_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_WAVPACK_DEC))
typedef struct _GstWavpackDec GstWavpackDec;
typedef struct _GstWavpackDec GstWavpackDec;
typedef struct _GstWavpackDecClass GstWavpackDecClass;
struct _GstWavpackDec
{
GstElement element;
GstPad *sinkpad, *srcpad;
#if 0
GstPad *wvcsinkpad;
#endif
/* GstPad *wvcsinkpad; */
GstPad *sinkpad;
GstPad *srcpad;
WavpackContext *context;
WavpackContext *context;
WavpackStreamReader *stream_reader;
int32_t *decodebuf;
guint decodebuf_size;
read_id wv_id;
/* read_id wvc_id; */
WavpackStream *stream;
GstSegment segment; /* used for clipping, TIME format */
guint32 samplerate;
guint channels;
guint width;
long frame_length;
guint sample_rate;
guint width;
guint channels;
guint64 wvcflushed_bytes;
guint64 duration;
guint64 wvcduration;
guchar *decdata;
long *cache;
gint error_count;
};
struct _GstWavpackDecClass
struct _GstWavpackDecClass
{
GstElementClass parent;
};
GType gst_wavpack_dec_get_type (void);
gboolean gst_wavpack_dec_plugin_init (GstPlugin *plugin);
gboolean gst_wavpack_dec_plugin_init (GstPlugin * plugin);
G_END_DECLS
#endif /* __GST_WAVPACK_DEC_H__ */
......@@ -52,7 +52,7 @@ static int gst_wavpack_enc_push_block (void *id, void *data, int32_t count);
static gboolean gst_wavpack_enc_sink_event (GstPad * pad, GstEvent * event);
static GstStateChangeReturn gst_wavpack_enc_change_state (GstElement * element,
GstStateChange transition);
static void gst_wavpack_enc_dispose (GObject * object);
static void gst_wavpack_enc_finalize (GObject * object);
static void gst_wavpack_enc_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec);
static void gst_wavpack_enc_get_property (GObject * object, guint prop_id,
......@@ -214,7 +214,7 @@ gst_wavpack_enc_class_init (GstWavpackEncClass * klass)
/* set state change handler */
gstelement_class->change_state =
GST_DEBUG_FUNCPTR (gst_wavpack_enc_change_state);
gobject_class->dispose = GST_DEBUG_FUNCPTR (gst_wavpack_enc_dispose);
gobject_class->finalize = GST_DEBUG_FUNCPTR (gst_wavpack_enc_finalize);
/* set property handlers */
gobject_class->set_property =
......@@ -270,15 +270,13 @@ gst_wavpack_enc_init (GstWavpackEnc * wavpack_enc, GstWavpackEncClass * gclass)
GST_DEBUG_FUNCPTR (gst_wavpack_enc_chain));
gst_pad_set_event_function (wavpack_enc->sinkpad,
GST_DEBUG_FUNCPTR (gst_wavpack_enc_sink_event));
gst_element_add_pad (GST_ELEMENT (wavpack_enc),
GST_DEBUG_FUNCPTR (wavpack_enc->sinkpad));
gst_element_add_pad (GST_ELEMENT (wavpack_enc), wavpack_enc->sinkpad);
/* setup src pad */
wavpack_enc->srcpad =
gst_pad_new_from_template (gst_element_class_get_pad_template (klass,
"src"), "src");
gst_element_add_pad (GST_ELEMENT (wavpack_enc),
GST_DEBUG_FUNCPTR (wavpack_enc->srcpad));
gst_element_add_pad (GST_ELEMENT (wavpack_enc), wavpack_enc->srcpad);
/* initialize object attributes */
wavpack_enc->wp_config = NULL;
......@@ -307,7 +305,7 @@ gst_wavpack_enc_init (GstWavpackEnc * wavpack_enc, GstWavpackEncClass * gclass)
}
static void
gst_wavpack_enc_dispose (GObject * object)
gst_wavpack_enc_finalize (GObject * object)
{
GstWavpackEnc *wavpack_enc = GST_WAVPACK_ENC (object);
......@@ -315,7 +313,7 @@ gst_wavpack_enc_dispose (GObject * object)
g_free (wavpack_enc->wv_id);
g_free (wavpack_enc->wvc_id);
G_OBJECT_CLASS (parent_class)->dispose (object);
G_OBJECT_CLASS (parent_class)->finalize (object);
}
static gboolean
......@@ -410,29 +408,31 @@ gst_wavpack_enc_set_wp_config (GstWavpackEnc * wavpack_enc)
(GST_ELEMENT_GET_CLASS (wavpack_enc), "wvcsrc"), "wvcsrc");
/* try to add correction src pad, don't set correction mode on failure */
if (gst_element_add_pad (GST_ELEMENT (wavpack_enc),
GST_DEBUG_FUNCPTR (wavpack_enc->wvcsrcpad))) {
GstCaps *caps = gst_caps_new_simple ("audio/x-wavpack-correction",
"framed", G_TYPE_BOOLEAN, FALSE, NULL);
GstCaps *caps = gst_caps_new_simple ("audio/x-wavpack-correction",
"framed", G_TYPE_BOOLEAN, FALSE, NULL);
gst_element_no_more_pads (GST_ELEMENT (wavpack_enc));
gst_element_no_more_pads (GST_ELEMENT (wavpack_enc));
if (!gst_pad_set_caps (wavpack_enc->wvcsrcpad, caps)) {
wavpack_enc->correction_mode = 0;
GST_ELEMENT_WARNING (wavpack_enc, LIBRARY, INIT, (NULL),
("setting correction caps failed: %", GST_PTR_FORMAT, caps));
} else {
gst_pad_use_fixed_caps (wavpack_enc->wvcsrcpad);
if (gst_element_add_pad (GST_ELEMENT (wavpack_enc),
wavpack_enc->wvcsrcpad)) {
if (!gst_pad_set_caps (wavpack_enc->wvcsrcpad, caps)) {
wavpack_enc->correction_mode = 0;
GST_ELEMENT_WARNING (wavpack_enc, LIBRARY, INIT, (NULL),
("setting correction caps failed: %", GST_PTR_FORMAT, caps));
} else {
gst_pad_use_fixed_caps (wavpack_enc->wvcsrcpad);
wavpack_enc->wp_config->flags |= CONFIG_CREATE_WVC;
if (wavpack_enc->correction_mode == 2) {
wavpack_enc->wp_config->flags |= CONFIG_OPTIMIZE_WVC;
}
} else {
wavpack_enc->correction_mode = 0;
GST_ELEMENT_WARNING (wavpack_enc, LIBRARY, INIT, (NULL),
("add correction pad failed. no correction file will be created."));
}
gst_caps_unref (caps);
} else {
wavpack_enc->correction_mode = 0;
GST_ELEMENT_WARNING (wavpack_enc, LIBRARY, INIT, (NULL),
("add correction pad failed. no correction file will be created."));
}
}
} else {
......@@ -442,6 +442,7 @@ gst_wavpack_enc_set_wp_config (GstWavpackEnc * wavpack_enc)
("settings correction mode only has effect if a bitrate is provided."));
}
}
gst_element_no_more_pads (GST_ELEMENT (wavpack_enc));
/* MD5, setup MD5 context */
if ((wavpack_enc->md5) && !(wavpack_enc->md5_context)) {
......
/* GStreamer wavpack plugin
* (c) 2005 Arwed v. Merkatz <v.merkatz@gmx.net>
* (c) 2006 Tim-Philipp Müller <tim centricular net>
* Copyright (c) 2005 Arwed v. Merkatz <v.merkatz@gmx.net>
* Copyright (c) 2006 Tim-Philipp Müller <tim centricular net>
* Copyright (c) 2006 Sebastian Dröge <slomo@circular-chaos.org>
*
* gstwavpackparse.c: wavpack file parser
*
......@@ -27,6 +28,7 @@
#include <wavpack/wavpack.h>
#include "gstwavpackparse.h"
#include "gstwavpackstreamreader.h"
#include "gstwavpackcommon.h"
GST_DEBUG_CATEGORY_STATIC (gst_wavpack_parse_debug);
......@@ -45,7 +47,7 @@ static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SOMETIMES,
GST_STATIC_CAPS ("audio/x-wavpack, "
"width = (int) { 8, 16, 24, 32 }, "
"channels = (int) { 1, 2 }, "
"channels = (int) [ 1, 2 ], "
"rate = (int) [ 6000, 192000 ], " "framed = (boolean) true")
);
......@@ -77,7 +79,7 @@ gst_wavpack_parse_base_init (gpointer klass)
GST_ELEMENT_DETAILS ("WavePack parser",
"Codec/Demuxer/Audio",
"Parses Wavpack files",
"Arwed v. Merkatz <v.merkatz@gmx.net>");
"Sebastian Dröge <slomo@circular-chaos.org>");
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
gst_element_class_add_pad_template (element_class,
......@@ -90,10 +92,11 @@ gst_wavpack_parse_base_init (gpointer klass)
}
static void
gst_wavpack_parse_dispose (GObject * object)
gst_wavpack_parse_finalize (GObject * object)
{
gst_wavpack_parse_reset (GST_WAVPACK_PARSE (object));
G_OBJECT_CLASS (parent_class)->dispose (object);
G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
......@@ -105,7 +108,7 @@ gst_wavpack_parse_class_init (GstWavpackParseClass * klass)
gobject_class = (GObjectClass *) klass;
gstelement_class = (GstElementClass *) klass;
gobject_class->dispose = gst_wavpack_parse_dispose;
gobject_class->finalize = gst_wavpack_parse_finalize;
gstelement_class->change_state =
GST_DEBUG_FUNCPTR (gst_wavpack_parse_change_state);
}
......@@ -137,13 +140,19 @@ gst_wavpack_parse_index_get_entry_from_sample (GstWavpackParse * wvparse,
entry = &g_array_index (wvparse->entries, GstWavpackParseIndexEntry, i);
GST_LOG_OBJECT (wvparse, "Index entry %03u: sample %" G_GINT64_FORMAT " @"
" byte %" G_GINT64_FORMAT, entry->sample_offset, entry->byte_offset);
" byte %" G_GINT64_FORMAT, i, entry->sample_offset, entry->byte_offset);
if (entry->sample_offset <= sample_offset &&
sample_offset < entry->sample_offset_end) {
GST_LOG_OBJECT (wvparse, "found match");
return entry;
}
/* as the list is sorted and we first look at the latest entry
* we can abort searching for an entry if the sample we want is
* after the latest one */
if (sample_offset >= entry->sample_offset_end)
break;
}
GST_LOG_OBJECT (wvparse, "no match in index");
return NULL;
......@@ -331,9 +340,7 @@ gst_wavpack_parse_scan_to_find_sample (GstWavpackParse * parse,
/* now scan forward until we find the chunk we're looking for or hit EOS */
do {
WavpackHeader header = { {0,}
, 0,
};
WavpackHeader header;
GstBuffer *buf;
buf = gst_wavpack_parse_pull_buffer (parse, off, sizeof (WavpackHeader),
......@@ -451,6 +458,11 @@ gst_wavpack_parse_handle_seek_event (GstWavpackParse * wvparse,
stop = gst_util_uint64_scale_int (stop, rate, GST_SECOND);
}
/* if seek is to something after the end of the stream seek only
* to the end. this can be caused by rounding errors */
if (start >= wvparse->total_samples)
start = wvparse->total_samples;
flush = ((seek_flags & GST_SEEK_FLAG_FLUSH) != 0);
if (start < 0) {
......@@ -628,7 +640,7 @@ static gboolean
gst_wavpack_parse_create_src_pad (GstWavpackParse * wvparse, GstBuffer * buf,
WavpackHeader * header)
{
WavpackMetadata meta;
GstWavpackMetadata meta;
GstCaps *caps = NULL;
guchar *bufptr;
......@@ -636,7 +648,7 @@ gst_wavpack_parse_create_src_pad (GstWavpackParse * wvparse, GstBuffer * buf,
bufptr = GST_BUFFER_DATA (buf) + sizeof (WavpackHeader);
while (read_metadata_buff (&meta, GST_BUFFER_DATA (buf), &bufptr)) {
while (gst_wavpack_read_metadata (&meta, GST_BUFFER_DATA (buf), &bufptr)) {
switch (meta.id) {
case ID_WVC_BITSTREAM:{
caps = gst_caps_new_simple ("audio/x-wavpack-correction",
......@@ -646,23 +658,41 @@ gst_wavpack_parse_create_src_pad (GstWavpackParse * wvparse, GstBuffer * buf,
(GST_ELEMENT_GET_CLASS (wvparse), "wvcsrc"), "wvcsrc");
break;
}
case ID_RIFF_HEADER:{
WaveHeader wheader;
/* skip RiffChunkHeader and ChunkHeader */
g_memmove (&wheader, meta.data + 20, sizeof (WaveHeader));
little_endian_to_native (&wheader, WaveHeaderFormat);
wvparse->samplerate = wheader.SampleRate;
wvparse->channels = wheader.NumChannels;
case ID_WV_BITSTREAM:
case ID_WVX_BITSTREAM:{
WavpackStreamReader *stream_reader = gst_wavpack_stream_reader_new ();
WavpackContext *wpc;
gchar error_msg[80];
read_id rid;
rid.buffer = GST_BUFFER_DATA (buf);
rid.length = GST_BUFFER_SIZE (buf);
rid.position = 0;
wpc =
WavpackOpenFileInputEx (stream_reader, &rid, NULL, error_msg, 0, 0);
if (!wpc)
return FALSE;
wvparse->samplerate = WavpackGetSampleRate (wpc);
wvparse->channels = WavpackGetNumChannels (wpc);
wvparse->total_samples = header->total_samples;
if (wvparse->total_samples == (int32_t) - 1)
wvparse->total_samples = 0;
else
wvparse->total_samples--;
caps = gst_caps_new_simple ("audio/x-wavpack",
"width", G_TYPE_INT, wheader.BitsPerSample,
"width", G_TYPE_INT, WavpackGetBitsPerSample (wpc),
"channels", G_TYPE_INT, wvparse->channels,
"rate", G_TYPE_INT, wvparse->samplerate,
"framed", G_TYPE_BOOLEAN, TRUE, NULL);
wvparse->srcpad =
gst_pad_new_from_template (gst_element_class_get_pad_template
(GST_ELEMENT_GET_CLASS (wvparse), "src"), "src");
WavpackCloseFile (wpc);
g_free (stream_reader);
break;
}
default:{
......@@ -685,6 +715,7 @@ gst_wavpack_parse_create_src_pad (GstWavpackParse * wvparse, GstBuffer * buf,
GST_DEBUG_FUNCPTR (gst_wavpack_parse_src_event));
gst_pad_set_caps (wvparse->srcpad, caps);
gst_caps_unref (caps);
gst_pad_use_fixed_caps (wvparse->srcpad);
gst_object_ref (wvparse->srcpad);
......
/* GStreamer Wavpack plugin
* Copyright (c) 2006 Sebastian Dröge <slomo@circular-chaos.org>
*
* gstwavpackstreamreader.c: stream reader used for decoding
*
* 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.
*/
#include <string.h>
#include <math.h>
#include <gst/gst.h>
#include "gstwavpackstreamreader.h"
static int32_t
gst_wavpack_stream_reader_read_bytes (void *id, void *data, int32_t bcount)
{
read_id *rid = (read_id *) id;
uint32_t left = rid->length - rid->position;
uint32_t to_read = MIN (left, bcount);
if (to_read > 0) {
g_memmove (data, rid->buffer + rid->position, to_read);
rid->position += to_read;
return to_read;
} else {
return 0;
}
}
static uint32_t
gst_wavpack_stream_reader_get_pos (void *id)
{
return ((read_id *) id)->position;
}
static int
gst_wavpack_stream_reader_set_pos_abs (void *id, uint32_t pos)
{
return -1;
}
static int
gst_wavpack_stream_reader_set_pos_rel (void *id, int32_t delta, int mode)
{
return -1;
}
static int
gst_wavpack_stream_reader_push_back_byte (void *id, int c)
{
read_id *rid = (read_id *) id;
rid->position -= 1;
if (rid->position < 0)
rid->position = 0;
return rid->position;
}
static uint32_t
gst_wavpack_stream_reader_get_length (void *id)
{
return ((read_id *) id)->length;
}
static int
gst_wavpack_stream_reader_can_seek (void *id)
{
return FALSE;
}
static int32_t
gst_wavpack_stream_reader_write_bytes (void *id, void *data, int32_t bcount)
{
return 0;
}
WavpackStreamReader *
gst_wavpack_stream_reader_new ()
{
WavpackStreamReader *stream_reader =
(WavpackStreamReader *) g_malloc0 (sizeof (WavpackStreamReader));
stream_reader->read_bytes = gst_wavpack_stream_reader_read_bytes;
<