Audacity  2.2.0
ExportFFmpegDialogs.h
Go to the documentation of this file.
1 /**********************************************************************
2 
3 Audacity: A Digital Audio Editor
4 
5 ExportFFmpegDialogs.h
6 
7 LRN
8 
9 **********************************************************************/
10 
11 #if !defined(__EXPORT_FFMPEG_DIALOGS_H__)
12 #define __EXPORT_FFMPEG_DIALOGS_H__
13 
14 #if defined(USE_FFMPEG)
15 
16 #include "../Audacity.h" // keep ffmpeg before wx because they interact
17 #include "../FFmpeg.h" // and Audacity.h before FFmpeg for config*.h
18 
19 #include <wx/hashmap.h>
20 #include <wx/listimpl.cpp>
21 #include "../xml/XMLFileReader.h"
22 #include "../FileNames.h"
23 #include "../widgets/wxPanelWrapper.h"
24 
25 
27 enum FFmpegExposedFormat
28 {
29  FMT_M4A,
30  FMT_AC3,
31  FMT_AMRNB,
32  FMT_WMA2,
33  FMT_OTHER,
34  FMT_LAST
35 };
36 
38 struct ExposedFormat
39 {
40  FFmpegExposedFormat fmtid;
41  const wxChar *name;
42  const wxChar *extension;
43  const wxChar *shortname;
44  unsigned maxchannels;
45  int canmetadata;
46  bool canutf8;
47  const wxChar *description;
48  AVCodecID codecid;
49  bool compiledIn;
50 };
51 
52 
54 struct CompatibilityEntry
55 {
56  const wxChar *fmt;
57  AVCodecID codec;
58 };
59 
60 
62 class ExportFFmpegAC3Options final : public wxPanelWrapper
63 {
64 public:
65 
66  ExportFFmpegAC3Options(wxWindow *parent, int format);
67  virtual ~ExportFFmpegAC3Options();
68 
69  void PopulateOrExchange(ShuttleGui & S);
70  bool TransferDataToWindow();
71  bool TransferDataFromWindow();
72 
74  static const int iAC3BitRates[];
77  static const int iAC3SampleRates[];
78 
79 private:
80 
81  wxArrayString mBitRateNames;
82  wxArrayInt mBitRateLabels;
83 
84  wxChoice *mBitRateChoice;
85  int mBitRateFromChoice;
86 };
87 
88 class ExportFFmpegAACOptions final : public wxPanelWrapper
89 {
90 public:
91 
92  ExportFFmpegAACOptions(wxWindow *parent, int format);
93  virtual ~ExportFFmpegAACOptions();
94 
95  void PopulateOrExchange(ShuttleGui & S);
96  bool TransferDataToWindow();
97  bool TransferDataFromWindow();
98 
99 private:
100 
101  wxSpinCtrl *mQualitySpin;
102 };
103 
104 class ExportFFmpegAMRNBOptions final : public wxPanelWrapper
105 {
106 public:
107 
108  ExportFFmpegAMRNBOptions(wxWindow *parent, int format);
109  virtual ~ExportFFmpegAMRNBOptions();
110 
111  void PopulateOrExchange(ShuttleGui & S);
112  bool TransferDataToWindow();
113  bool TransferDataFromWindow();
114 
115  static int iAMRNBBitRate[];
116 
117 private:
118 
119  wxArrayString mBitRateNames;
120  wxArrayInt mBitRateLabels;
121 
122  wxChoice *mBitRateChoice;
123  int mBitRateFromChoice;
124 };
125 
126 class ExportFFmpegWMAOptions final : public wxPanelWrapper
127 {
128 public:
129 
130  ExportFFmpegWMAOptions(wxWindow *parent, int format);
132 
133  void PopulateOrExchange(ShuttleGui & S);
134  bool TransferDataToWindow();
135  bool TransferDataFromWindow();
136 
137  static const int iWMASampleRates[];
138  static const int iWMABitRate[];
139 
140 private:
141 
142  wxArrayString mBitRateNames;
143  wxArrayInt mBitRateLabels;
144 
145  wxChoice *mBitRateChoice;
146  int mBitRateFromChoice;
147 };
148 
149 class ExportFFmpegCustomOptions final : public wxPanelWrapper
150 {
151 public:
152 
153  ExportFFmpegCustomOptions(wxWindow *parent, int format);
154  ~ExportFFmpegCustomOptions();
155 
156  void PopulateOrExchange(ShuttleGui & S);
157  bool TransferDataToWindow();
158  bool TransferDataFromWindow();
159 
160  void OnOpen(wxCommandEvent & evt);
161 
162 private:
163 
164  DECLARE_EVENT_TABLE()
165 };
166 
168 struct ApplicableFor
169 {
170  bool enable;
171  int control;
172  AVCodecID codec;
173  const char *format;
174 };
175 
176 class FFmpegPresets;
177 
179 class ExportFFmpegOptions final : public wxDialogWrapper
180 {
181 public:
182 
183  ExportFFmpegOptions(wxWindow *parent);
185  void PopulateOrExchange(ShuttleGui & S);
186  void OnOK(wxCommandEvent& event);
187  void OnFormatList(wxCommandEvent& event);
188  void DoOnFormatList();
189  void OnCodecList(wxCommandEvent& event);
190  void DoOnCodecList();
191  void OnAllFormats(wxCommandEvent& event);
192  void OnAllCodecs(wxCommandEvent& event);
193  void OnSavePreset(wxCommandEvent& event);
194  void OnLoadPreset(wxCommandEvent& event);
195  void OnDeletePreset(wxCommandEvent& event);
196  void OnImportPresets(wxCommandEvent& event);
197  void OnExportPresets(wxCommandEvent& event);
198 
199  // Static tables
200  static CompatibilityEntry CompatibilityList[];
201  static int iAACProfileValues[];
202  static const wxChar *iAACProfileNames[];
203  static ExposedFormat fmts[];
204  static const int iAACSampleRates[];
205  static ApplicableFor apptable[];
206  static const wxChar *PredictionOrderMethodNames[];
207 
208 private:
209 
210  wxArrayString mShownFormatNames;
211  wxArrayString mShownFormatLongNames;
212  wxArrayString mShownCodecNames;
213  wxArrayString mShownCodecLongNames;
214  wxArrayString mFormatNames;
215  wxArrayString mFormatLongNames;
216  wxArrayString mCodecNames;
217  wxArrayString mCodecLongNames;
218  wxArrayString mProfileNames;
219  wxArrayInt mProfileLabels;
220  wxArrayString mPredictionOrderMethodNames;
221  wxArrayInt mPredictionOrderMethodLabels;
222 
223  wxChoice *mFormatChoice;
224  wxChoice *mCodecChoice;
225 
226  wxListBox *mFormatList;
227  wxListBox *mCodecList;
228 
229  wxStaticText *mFormatName;
230  wxStaticText *mCodecName;
231 
232  wxChoice *mPresetChoice;
233  wxComboBox *mPresetCombo;
234  wxSpinCtrl *mBitrateSpin;
235  wxSpinCtrl *mQualitySpin;
236  wxSpinCtrl *mSampleRateSpin;
237  wxTextCtrl *mLanguageText;
238  wxTextCtrl *mTag;
239  wxSpinCtrl *mCutoffSpin;
240  wxCheckBox *mBitReservoirCheck;
241  wxChoice *mProfileChoice;
242  //wxSpinCtrl *mTrellisSpin; //trellis is only applicable for ADPCM...scrap it.
243  wxSpinCtrl *mCompressionLevelSpin;
244  wxSpinCtrl *mFrameSizeSpin;
245  wxCheckBox *mUseLPCCheck;
246  wxSpinCtrl *mLPCCoeffsPrecisionSpin;
247  wxSpinCtrl *mMinPredictionOrderSpin;
248  wxSpinCtrl *mMaxPredictionOrderSpin;
249  wxChoice *mPredictionOrderMethodChoice;
250  wxSpinCtrl *mMinPartitionOrderSpin;
251  wxSpinCtrl *mMaxPartitionOrderSpin;
252  wxSpinCtrl *mMuxRate;
253  wxSpinCtrl *mPacketSize;
254 
255  wxButton *mOk;
256  wxButton *mSavePreset;
257  wxButton *mLoadPreset;
258  wxButton *mDeletePreset;
259  wxButton *mImportPresets;
260  wxButton *mExportPresets;
261 
262  int mBitRateFromChoice;
263  int mSampleRateFromChoice;
264 
265  std::unique_ptr<FFmpegPresets> mPresets;
266 
267  wxArrayString mPresetNames;
268 
270  void FindSelectedFormat(wxString **name, wxString **longname);
271 
273  void FindSelectedCodec(wxString **name, wxString **longname);
274 
276  void FetchFormatList();
277 
282  int FetchCompatibleFormatList(AVCodecID id, wxString *selfmt);
283 
285  void FetchCodecList();
286 
291  int FetchCompatibleCodecList(const wxChar *fmt, AVCodecID id);
292 
294  void FetchPresetList();
295 
296  // Enables/disables controls based on format/codec combination,
297  // leaving only relevant controls enabled.
298  // Hiding the controls may have been a better idea,
299  // but it's hard to hide their text labels too
300  void EnableDisableControls(AVCodec *cdc, wxString *selfmt);
301  DECLARE_EVENT_TABLE()
302 };
303 
304 //----------------------------------------------------------------------------
305 // FFmpegPresets
306 //----------------------------------------------------------------------------
307 
308 class FFmpegPreset
309 {
310 public:
311  FFmpegPreset();
312  ~FFmpegPreset();
313 
314  wxString mPresetName;
315  wxArrayString mControlState;
316 
317 };
318 
319 WX_DECLARE_STRING_HASH_MAP(FFmpegPreset, FFmpegPresetMap);
320 
321 class FFmpegPresets : XMLTagHandler
322 {
323 public:
324  FFmpegPresets();
325  ~FFmpegPresets();
326 
327  void GetPresetList(wxArrayString &list);
328  void LoadPreset(ExportFFmpegOptions *parent, wxString &name);
329  void SavePreset(ExportFFmpegOptions *parent, wxString &name);
330  void DeletePreset(wxString &name);
331  FFmpegPreset *FindPreset(wxString &name);
332 
333  void ImportPresets(wxString &filename);
334  void ExportPresets(wxString &filename);
335 
336  bool HandleXMLTag(const wxChar *tag, const wxChar **attrs) override;
337  XMLTagHandler *HandleXMLChild(const wxChar *tag) override;
338  void WriteXMLHeader(XMLWriter &xmlFile) const;
339  void WriteXML(XMLWriter &xmlFile) const;
340 
341 private:
342 
343  FFmpegPresetMap mPresets;
344  FFmpegPreset *mPreset; // valid during XML parsing only
345  bool mAbortImport; // tells importer to ignore the rest of the import
346 };
347 
348 #endif
349 
350 #endif //__EXPORT_FFMPEG_DIALOGS_H__
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI...
Definition: ShuttleGui.h:369
virtual XMLTagHandler * HandleXMLChild(const wxChar *tag)=0
Definition: wxPanelWrapper.h:19
Options dialog for FFmpeg exporting of AC3 format.
void OnOpen()
int format
Definition: ExportPCM.cpp:56
virtual bool HandleXMLTag(const wxChar *tag, const wxChar **attrs)=0
This class is an interface which should be implemented by classes which wish to be able to load and s...
Definition: XMLTagHandler.h:69
const wxChar * name
Definition: Distortion.cpp:93
Options dialog for FFmpeg exporting of AAC format.
WX_DECLARE_STRING_HASH_MAP(wxString, LangHash)
Options dialog for FFmpeg exporting of WMA format.
Base class for XMLFileWriter and XMLStringWriter that provides the general functionality for creating...
Definition: XMLWriter.h:22
Options dialog for Custom FFmpeg export format.
Options dialog for FFmpeg exporting of AMRNB format.