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
|
/*************************************************************************
VorbisEncoder.h - sub encoder base class for Vorbis in an Ogg container
-------------------
begin : Thu Jan 03 2013
copyright : (C) 2013 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_ENCODER_H
#define VORBIS_ENCODER_H
#include "config.h"
#include <vorbis/vorbisenc.h>
#include "libkwave/FileInfo.h"
#include "libkwave/VorbisCommentMap.h"
#include "OggSubEncoder.h"
class QIODevice;
class QWidget;
namespace Kwave
{
class FileInfo;
class MultiTrackReader;
class VorbisEncoder: public Kwave::OggSubEncoder
{
public:
/**
* Constructor
*/
VorbisEncoder();
/** Destructor */
~VorbisEncoder() 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
* @param src MultiTrackReader used as source of the audio data
* @return true if succeeded, false if failed
*/
virtual bool open(QWidget *widget,
const Kwave::FileInfo &info,
Kwave::MultiTrackReader &src) override;
/**
* write the header information
* @param dst a QIODevice that receives the raw data
* @return true if succeeded, false if failed
*/
bool writeHeader(QIODevice &dst) override;
/**
* encode received ogg data
* @param src MultiTrackReader used as source of the audio data
* @param dst a QIODevice that receives the raw data
* @return true if succeeded, false if failed
*/
virtual bool encode(Kwave::MultiTrackReader &src,
QIODevice &dst) override;
/**
* finished the encoding, clean up
*/
void close() override;
private:
/** Encodes all file properties into a vorbis comment */
void encodeProperties(const Kwave::FileInfo &info);
private:
/** map for translating Vorbis comments to Kwave FileInfo */
Kwave::VorbisCommentMap m_comments_map;
/** file info, set in open(...) */
Kwave::FileInfo m_info;
/** 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 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 /* VORBIS_ENCODER_H */
//***************************************************************************
//***************************************************************************
|