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