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  wxString Description() const; // get translation
52 };
53 
54 
56 struct CompatibilityEntry
57 {
58  const wxChar *fmt;
59  AVCodecID codec;
60 };
61 
62 
64 class ExportFFmpegAC3Options final : public wxPanelWrapper
65 {
66 public:
67 
68  ExportFFmpegAC3Options(wxWindow *parent, int format);
69  virtual ~ExportFFmpegAC3Options();
70 
71  void PopulateOrExchange(ShuttleGui & S);
72  bool TransferDataToWindow();
73  bool TransferDataFromWindow();
74 
76  static const int iAC3BitRates[];
79  static const int iAC3SampleRates[];
80 
81 private:
82 
83  wxArrayString mBitRateNames;
84  wxArrayInt mBitRateLabels;
85 
86  wxChoice *mBitRateChoice;
87  int mBitRateFromChoice;
88 };
89 
90 class ExportFFmpegAACOptions final : public wxPanelWrapper
91 {
92 public:
93 
94  ExportFFmpegAACOptions(wxWindow *parent, int format);
95  virtual ~ExportFFmpegAACOptions();
96 
97  void PopulateOrExchange(ShuttleGui & S);
98  bool TransferDataToWindow();
99  bool TransferDataFromWindow();
100 
101 private:
102 
103  wxSpinCtrl *mQualitySpin;
104 };
105 
106 class ExportFFmpegAMRNBOptions final : public wxPanelWrapper
107 {
108 public:
109 
110  ExportFFmpegAMRNBOptions(wxWindow *parent, int format);
111  virtual ~ExportFFmpegAMRNBOptions();
112 
113  void PopulateOrExchange(ShuttleGui & S);
114  bool TransferDataToWindow();
115  bool TransferDataFromWindow();
116 
117  static int iAMRNBBitRate[];
118 
119 private:
120 
121  wxArrayString mBitRateNames;
122  wxArrayInt mBitRateLabels;
123 
124  wxChoice *mBitRateChoice;
125  int mBitRateFromChoice;
126 };
127 
128 class ExportFFmpegWMAOptions final : public wxPanelWrapper
129 {
130 public:
131 
132  ExportFFmpegWMAOptions(wxWindow *parent, int format);
134 
135  void PopulateOrExchange(ShuttleGui & S);
136  bool TransferDataToWindow();
137  bool TransferDataFromWindow();
138 
139  static const int iWMASampleRates[];
140  static const int iWMABitRate[];
141 
142 private:
143 
144  wxArrayString mBitRateNames;
145  wxArrayInt mBitRateLabels;
146 
147  wxChoice *mBitRateChoice;
148  int mBitRateFromChoice;
149 };
150 
151 class ExportFFmpegCustomOptions final : public wxPanelWrapper
152 {
153 public:
154 
155  ExportFFmpegCustomOptions(wxWindow *parent, int format);
156  ~ExportFFmpegCustomOptions();
157 
158  void PopulateOrExchange(ShuttleGui & S);
159  bool TransferDataToWindow();
160  bool TransferDataFromWindow();
161 
162  void OnOpen(wxCommandEvent & evt);
163 
164 private:
165 
166  DECLARE_EVENT_TABLE()
167 };
168 
170 struct ApplicableFor
171 {
172  bool enable;
173  int control;
174  AVCodecID codec;
175  const char *format;
176 };
177 
178 class FFmpegPresets;
179 
181 class ExportFFmpegOptions final : public wxDialogWrapper
182 {
183 public:
184 
185  ExportFFmpegOptions(wxWindow *parent);
187  void PopulateOrExchange(ShuttleGui & S);
188  void OnOK(wxCommandEvent& event);
189  void OnFormatList(wxCommandEvent& event);
190  void DoOnFormatList();
191  void OnCodecList(wxCommandEvent& event);
192  void DoOnCodecList();
193  void OnAllFormats(wxCommandEvent& event);
194  void OnAllCodecs(wxCommandEvent& event);
195  void OnSavePreset(wxCommandEvent& event);
196  void OnLoadPreset(wxCommandEvent& event);
197  void OnDeletePreset(wxCommandEvent& event);
198  void OnImportPresets(wxCommandEvent& event);
199  void OnExportPresets(wxCommandEvent& event);
200 
201  // Static tables
202  static CompatibilityEntry CompatibilityList[];
203  static int iAACProfileValues[];
204  static ExposedFormat fmts[];
205  static const int iAACSampleRates[];
206  static ApplicableFor apptable[];
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:94
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.