/
Encoder.h
88 lines (73 loc) · 2.52 KB
/
Encoder.h
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
#ifndef _ENCODER_H
#define _ENCODER_H
/*
* Copyright (C) 2005-2012 Team XBMC
* http://www.xbmc.org
*
* 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, or (at your option)
* any later version.
*
* This Program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with XBMC; see the file COPYING. If not, see
* <http://www.gnu.org/licenses/>.
*
*/
#include "utils/StdString.h"
#define ENC_ARTIST 11
#define ENC_TITLE 12
#define ENC_ALBUM 13
#define ENC_YEAR 14
#define ENC_COMMENT 15
#define ENC_TRACK 16
#define ENC_GENRE 17
#define WRITEBUFFER_SIZE 131072 // 128k buffer
namespace XFILE { class CFile; }
class CEncoder
{
public:
CEncoder();
virtual ~CEncoder();
virtual bool Init(const char* strFile, int iInChannels, int iInRate, int iInBits) = 0;
virtual int Encode(int nNumBytesRead, uint8_t* pbtStream) = 0;
virtual bool Close() = 0;
void SetComment(const CStdString& str) { m_strComment = str; }
void SetArtist(const CStdString& str) { m_strArtist = str; }
void SetTitle(const CStdString& str) { m_strTitle = str; }
void SetAlbum(const CStdString& str) { m_strAlbum = str; }
void SetAlbumArtist(const CStdString& str) { m_strAlbumArtist = str; }
void SetGenre(const CStdString& str) { m_strGenre = str; }
void SetTrack(const CStdString& str) { m_strTrack = str; }
void SetTrackLength(int length) { m_iTrackLength = length; }
void SetYear(const CStdString& str) { m_strYear = str; }
protected:
bool FileCreate(const char* filename);
bool FileClose();
int FileWrite(const void *pBuffer, uint32_t iBytes);
int WriteStream(const void *pBuffer, uint32_t iBytes);
int FlushStream();
// tag info
CStdString m_strComment;
CStdString m_strArtist;
CStdString m_strAlbumArtist;
CStdString m_strTitle;
CStdString m_strAlbum;
CStdString m_strGenre;
CStdString m_strTrack;
CStdString m_strYear;
int m_iTrackLength;
CStdString m_strFile;
XFILE::CFile *m_file;
int m_iInChannels;
int m_iInSampleRate;
int m_iInBitsPerSample;
uint8_t m_btWriteBuffer[WRITEBUFFER_SIZE]; // 128k buffer for writing to disc
uint32_t m_dwWriteBufferPointer;
};
#endif // _ENCODER_H