blob: 112e96dce91090a8a081bf11f4011e937485945c (
plain)
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
|
/***************************************************************************
encodervorbis.h - vorbis encoder for mixxx
-------------------
copyright : (C) 2007 by Wesley Stessens
(C) 1994 by Xiph.org (encoder example)
(C) 1994 Tobias Rafreider (broadcast and recording fixes)
***************************************************************************/
#ifndef ENCODERVORBIS_H
#define ENCODERVORBIS_H
// this also includes vorbis/codec.h
#include <vorbis/vorbisenc.h>
#include <QFile>
#include "encoder/encoder.h"
#include "track/track_decl.h"
#include "util/types.h"
class EncoderCallback;
class EncoderVorbis : public Encoder {
public:
static const int MONO_BITRATE_THRESHOLD;
EncoderVorbis(EncoderCallback* pCallback = nullptr);
~EncoderVorbis() override;
int initEncoder(int samplerate, QString errorMessage) override;
void encodeBuffer(const CSAMPLE *samples, const int size) override;
void updateMetaData(const QString& artist, const QString& title, const QString& album) override;
void flush() override;
void setEncoderSettings(const EncoderSettings& settings) override;
private:
int getSerial();
void initStream();
bool metaDataHasChanged();
//Call this method in conjunction with broadcast streaming
void writePage();
bool m_bStreamInitialized;
ogg_stream_state m_oggs; /* take physical pages, weld into logical stream
of packets */
ogg_page m_oggpage; /* Ogg bitstream page: contains Vorbis packets */
ogg_packet m_oggpacket; /* raw packet of data */
vorbis_block m_vblock; /* local working space for packet-to-PCM */
vorbis_dsp_state m_vdsp; /* central working space for packet-to-PCM */
vorbis_info m_vinfo; /* stores all static vorbis bitstream settings */
vorbis_comment m_vcomment; /* stores all user comments */
bool m_header_write;
EncoderCallback* m_pCallback;
TrackPointer m_pMetaData;
QString m_metaDataTitle;
QString m_metaDataArtist;
QString m_metaDataAlbum;
int m_bitrate;
int m_channels;
QFile m_file;
};
#endif
|