Merge pull request #2948 from ace20022/blu_lang_fix
[vuplus_xbmc] / xbmc / cdrip / Encoder.h
1 #ifndef _ENCODER_H
2 #define _ENCODER_H
3
4 /*
5  *      Copyright (C) 2005-2013 Team XBMC
6  *      http://www.xbmc.org
7  *
8  *  This Program is free software; you can redistribute it and/or modify
9  *  it under the terms of the GNU General Public License as published by
10  *  the Free Software Foundation; either version 2, or (at your option)
11  *  any later version.
12  *
13  *  This Program is distributed in the hope that it will be useful,
14  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  *  GNU General Public License for more details.
17  *
18  *  You should have received a copy of the GNU General Public License
19  *  along with XBMC; see the file COPYING.  If not, see
20  *  <http://www.gnu.org/licenses/>.
21  *
22  */
23
24 #include "utils/StdString.h"
25
26 #define ENC_ARTIST  11
27 #define ENC_TITLE   12
28 #define ENC_ALBUM   13
29 #define ENC_YEAR    14
30 #define ENC_COMMENT 15
31 #define ENC_TRACK   16
32 #define ENC_GENRE   17
33
34 #define WRITEBUFFER_SIZE 131072 // 128k buffer
35
36 enum CDDARipEncoder
37 {
38   CDDARIP_ENCODER_LAME    = 0,
39   CDDARIP_ENCODER_VORBIS,
40   CDDARIP_ENCODER_WAV,
41   CDDARIP_ENCODER_FLAC,
42   CDDARIP_ENCODER_FFMPEG_M4A,
43   CDDARIP_ENCODER_FFMPEG_WMA
44 };
45
46 enum CDDARipQuality
47 {
48   CDDARIP_QUALITY_CBR      = 0,
49   CDDARIP_QUALITY_MEDIUM,
50   CDDARIP_QUALITY_STANDARD,
51   CDDARIP_QUALITY_EXTREME
52 };
53
54 namespace XFILE { class CFile; }
55
56 class CEncoder
57 {
58 public:
59   CEncoder();
60   virtual ~CEncoder();
61   virtual bool Init(const char* strFile, int iInChannels, int iInRate, int iInBits) = 0;
62   virtual int Encode(int nNumBytesRead, uint8_t* pbtStream) = 0;
63   virtual bool Close() = 0;
64
65   void SetComment(const CStdString& str) { m_strComment = str; }
66   void SetArtist(const CStdString& str) { m_strArtist = str; }
67   void SetTitle(const CStdString& str) { m_strTitle = str; }
68   void SetAlbum(const CStdString& str) { m_strAlbum = str; }
69   void SetAlbumArtist(const CStdString& str) { m_strAlbumArtist = str; }
70   void SetGenre(const CStdString& str) { m_strGenre = str; }
71   void SetTrack(const CStdString& str) { m_strTrack = str; }
72   void SetTrackLength(int length) { m_iTrackLength = length; }
73   void SetYear(const CStdString& str) { m_strYear = str; }
74
75 protected:
76   bool FileCreate(const char* filename);
77   bool FileClose();
78   int FileWrite(const void *pBuffer, uint32_t iBytes);
79   int64_t FileSeek(int64_t iFilePosition, int iWhence = SEEK_SET);
80
81   int WriteStream(const void *pBuffer, uint32_t iBytes);
82   int FlushStream();
83
84   // tag info
85   CStdString m_strComment;
86   CStdString m_strArtist;
87   CStdString m_strAlbumArtist;
88   CStdString m_strTitle;
89   CStdString m_strAlbum;
90   CStdString m_strGenre;
91   CStdString m_strTrack;
92   CStdString m_strYear;
93   int m_iTrackLength;
94
95   CStdString m_strFile;
96
97   XFILE::CFile *m_file;
98   int m_iInChannels;
99   int m_iInSampleRate;
100   int m_iInBitsPerSample;
101
102   uint8_t m_btWriteBuffer[WRITEBUFFER_SIZE]; // 128k buffer for writing to disc
103   uint32_t m_dwWriteBufferPointer;
104 };
105
106 #endif // _ENCODER_H
107