1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136
|
/*************************************************************************
VorbisDecoder.h - sub decoder for Vorbis in an Ogg container
-------------------
begin : Wed Dec 26 2012
copyright : (C) 2012 by Thomas Eschenbacher
email : Thomas.Eschenbacher@gmx.de
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef VORBIS_DECODER_H
#define VORBIS_DECODER_H
#ifdef HAVE_OGG_VORBIS
#include "config.h"
#include <vorbis/codec.h>
#include "libkwave/FileInfo.h"
#include "libkwave/Sample.h"
#include "OggSubDecoder.h"
class QIODevice;
class QWidget;
namespace Kwave
{
class VorbisDecoder: public Kwave::OggSubDecoder
{
public:
/**
* Constructor
*
* @param source pointer to a QIODevice to read from, must not be null
* @param oy sync and verify incoming physical bitstream
* @param os take physical pages, weld into a logical stream of packets
* @param og one Ogg bitstream page, Vorbis packets are inside
* @param op one raw packet of data for decode
*/
explicit VorbisDecoder(QIODevice *source,
ogg_sync_state &oy,
ogg_stream_state &os,
ogg_page &og,
ogg_packet &op);
/** destructor */
~VorbisDecoder() override {}
/**
* parse the header of the stream and initialize the decoder
* @param widget a QWidget to be used as parent for error messages
* @param info reference to a FileInfo to fill
* @return -1 if failed or +1 if succeeded
*/
virtual int open(QWidget *widget, Kwave::FileInfo &info)
override;
/**
* decode received ogg data
* @param dst a MultiWriter to be used as sink
* @return -1 if failed or >= 0 if succeeded
*/
int decode(Kwave::MultiWriter &dst) override;
/** reset the stream info */
void reset() override;
/**
* finish the decoding, last chance to fix up some file info
* @param info reference to a FileInfo to fill
*/
void close(Kwave::FileInfo &info) override;
protected:
/**
* Searches for a vorbis comment and renders it into Kwave's FileInfo.
* If more than one occurrence is found, they are concatenated as a
* semicolon separated list.
* @param info the file info object to add the tag value
* @param tag name of the field to search for
* @param property specifies the FileProperty for storing the result
*/
void parseTag(Kwave::FileInfo &info, const char *tag,
Kwave::FileProperty property);
private:
/** IO device to read from */
QIODevice *m_source;
/** first stream with audio data */
qint64 m_stream_start_pos;
/** last known position in the output stream [samples] */
sample_index_t m_samples_written;
/** sync and verify incoming physical bitstream */
ogg_sync_state &m_oy;
/** take physical pages, weld into a logical stream of packets */
ogg_stream_state &m_os;
/** one Ogg bitstream page. Vorbis packets are inside */
ogg_page &m_og;
/** one raw packet of data for decode */
ogg_packet &m_op;
/** struct that stores all the static vorbis bitstream settings */
vorbis_info m_vi;
/** struct that stores all the bitstream user comments */
vorbis_comment m_vc;
/** central working state for the packet->PCM decoder */
vorbis_dsp_state m_vd;
/** local working space for packet->PCM decode */
vorbis_block m_vb;
};
}
#endif /* HAVE_OGG_VORBIS */
#endif /* VORBIS_DECODER_H */
//***************************************************************************
//***************************************************************************
|