OSDN Git Service

7e0d35afd158179ca8decec8a875faceb11f05ea
[lamexp/LameXP.git] / src / Encoder_Abstract.h
1 ///////////////////////////////////////////////////////////////////////////////
2 // LameXP - Audio Encoder Front-End
3 // Copyright (C) 2004-2013 LoRd_MuldeR <MuldeR2@GMX.de>
4 //
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 2 of the License, or
8 // (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License along
16 // with this program; if not, write to the Free Software Foundation, Inc.,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 //
19 // http://www.gnu.org/licenses/gpl-2.0.txt
20 ///////////////////////////////////////////////////////////////////////////////
21
22 #pragma once
23
24 #include "Tool_Abstract.h"
25 #include "Model_AudioFile.h"
26
27 class QProcess;
28 class QStringList;
29 class QMutex;
30
31 class AbstractEncoderInfo
32 {
33 public:
34         typedef enum
35         {
36                 TYPE_BITRATE = 0,
37                 TYPE_APPROX_BITRATE = 1,
38                 TYPE_QUALITY_LEVEL = 2,
39                 TYPE_COMPRESSION_LEVEL = 3,
40                 TYPE_UNCOMPRESSED = 4
41         }
42         value_type_t;
43
44         virtual bool isModeSupported(int mode) const = 0;       //Returns whether the encoder does support the current RC mode
45         virtual int valueCount(int mode) const = 0;                     //The number of bitrate/quality values for current RC mode
46         virtual int valueAt(int mode, int index) const = 0;     //The bitrate/quality value at 'index' for the current RC mode
47         virtual int valueType(int mode) const = 0;                      //The display type of the values for the current RC mode
48 };
49
50 class AbstractEncoder : public AbstractTool
51 {
52         Q_OBJECT
53
54 public:
55         AbstractEncoder(void);
56         virtual ~AbstractEncoder(void);
57
58         //Internal encoder API
59         virtual bool encode(const QString &sourceFile, const AudioFileModel &metaInfo, const QString &outputFile, volatile bool *abortFlag) = 0;
60         virtual bool isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion) = 0;
61         virtual QString extension(void) = 0;
62         virtual const unsigned int *supportedSamplerates(void);
63         virtual const unsigned int *supportedChannelCount(void);
64         virtual const unsigned int *supportedBitdepths(void);
65         virtual const bool needsTimingInfo(void);
66
67         //Common setter methods
68         virtual void setBitrate(int bitrate);
69         virtual void setRCMode(int mode);
70         virtual void setCustomParams(const QString &customParams);
71
72         //Encoder info
73         static const AbstractEncoderInfo *getEncoderInfo(void)
74         {
75                 throw "This method is supposed to be re-implemented in derived classes!";
76                 return NULL;
77         }
78
79 protected:
80         int m_configBitrate;                    //Bitrate *or* VBR-quality-level
81         int m_configRCMode;                             //Rate-control mode
82         QString m_configCustomParams;   //Custom parameters, if any
83
84         //Helper functions
85         bool isUnicode(const QString &text);
86         QString cleanTag(const QString &text);
87 };