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