Audacity 3.2.0
ExportFFmpegDialogs.h
Go to the documentation of this file.
1/**********************************************************************
2
3Audacity: A Digital Audio Editor
4
5ExportFFmpegDialogs.h
6
7LRN
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 "../FFmpeg.h"
17#include "FFmpegFunctions.h"
18
19#include "XMLFileReader.h"
20#include "FileNames.h"
21
22#include <unordered_map>
23#include "Identifier.h"
24
25class wxArrayStringEx;
26
27class wxArrayString;
28class wxCheckBox;
29class wxStaticText;
30class wxTextCtrl;
31
34{
42};
43
44#define AV_CANMETA (AV_VERSION_INT(255, 255, 255))
45
48{
50 const wxChar *name;
52 const wxChar *shortname;
53 unsigned maxchannels;
54 const int canmetadata;
55 bool canutf8;
59};
60
61
64{
65 const wxChar *fmt;
67};
68
69
72{
73public:
74
75 ExportFFmpegAC3Options(wxWindow *parent, int format);
77
79 bool TransferDataToWindow() override;
80 bool TransferDataFromWindow() override;
81
84 static const int iAC3SampleRates[];
85
86private:
87
88 wxChoice *mBitRateChoice;
90};
91
93{
94public:
95
96 ExportFFmpegAACOptions(wxWindow *parent, int format);
98
100 bool TransferDataToWindow() override;
101 bool TransferDataFromWindow() override;
102};
103
105{
106public:
107
108 ExportFFmpegAMRNBOptions(wxWindow *parent, int format);
110
112 bool TransferDataToWindow() override;
113 bool TransferDataFromWindow() override;
114
115private:
116
117 wxChoice *mBitRateChoice;
119};
120
122{
123public:
124
125 ExportFFmpegOPUSOptions(wxWindow *parent, int format);
127
129 bool TransferDataToWindow() override;
130 bool TransferDataFromWindow() override;
131
132 static const int iOPUSSampleRates[];
133
134private:
135
136 wxSlider *mBitRateSlider;
138
139 wxChoice *mVbrChoice;
141
144
147
150
151 wxChoice *mCuttoffChoice;
153};
154
156{
157public:
158
159 ExportFFmpegWMAOptions(wxWindow *parent, int format);
161
163 bool TransferDataToWindow() override;
164 bool TransferDataFromWindow() override;
165
166 static const int iWMASampleRates[];
167
168private:
169
170 wxChoice *mBitRateChoice;
172};
173
175{
176public:
177
178 ExportFFmpegCustomOptions(wxWindow *parent, int format);
180
182 bool TransferDataToWindow() override;
183 bool TransferDataFromWindow() override;
184
185 void OnOpen(wxCommandEvent & evt);
186
187private:
188 wxTextCtrl *mFormat;
189 wxTextCtrl *mCodec;
190
191 DECLARE_EVENT_TABLE()
192};
193
196{
197 bool enable;
200 const char *format;
201};
202
203class FFmpegPresets;
204
207{
208public:
209
210 ExportFFmpegOptions(wxWindow *parent);
213 void OnOK(wxCommandEvent& event);
214 void OnGetURL(wxCommandEvent& event);
215 void OnFormatList(wxCommandEvent& event);
216 void DoOnFormatList();
217 void OnCodecList(wxCommandEvent& event);
218 void DoOnCodecList();
219 void OnAllFormats(wxCommandEvent& event);
220 void OnAllCodecs(wxCommandEvent& event);
221 void OnSavePreset(wxCommandEvent& event);
222 void OnLoadPreset(wxCommandEvent& event);
223 void OnDeletePreset(wxCommandEvent& event);
224 void OnImportPresets(wxCommandEvent& event);
225 void OnExportPresets(wxCommandEvent& event);
226 bool SavePreset( bool bCheckForOverwrite);
227
228
229 // Static tables
232 static const int iAACSampleRates[];
234
235private:
236
237 wxArrayString mShownFormatNames;
239 wxArrayString mShownCodecNames;
240 wxArrayString mShownCodecLongNames;
242 wxArrayString mFormatLongNames;
244 wxArrayString mCodecLongNames;
245
246 wxListBox *mFormatList;
247 wxListBox *mCodecList;
248
249 wxStaticText *mFormatName;
250 wxStaticText *mCodecName;
251
252 wxComboBox *mPresetCombo;
253
256
257 std::unique_ptr<FFmpegPresets> mPresets;
258
260
261 std::shared_ptr<FFmpegFunctions> mFFmpeg;
262
264 void FindSelectedFormat(wxString **name, wxString **longname);
265
267 void FindSelectedCodec(wxString **name, wxString **longname);
268
270 void FetchFormatList();
271
276 int FetchCompatibleFormatList(AudacityAVCodecID id, wxString* selfmt);
277
279 void FetchCodecList();
280
285 int FetchCompatibleCodecList(const wxChar* fmt, AudacityAVCodecID id);
286
289
291
292
293 // Enables/disables controls based on format/codec combination,
294 // leaving only relevant controls enabled.
295 // Hiding the controls may have been a better idea,
296 // but it's hard to hide their text labels too
297 void EnableDisableControls(AVCodecWrapper *cdc, wxString *selfmt);
298 DECLARE_EVENT_TABLE()
299};
300
301//----------------------------------------------------------------------------
302// FFmpegPresets
303//----------------------------------------------------------------------------
304
306{
307public:
308 FFmpegPreset();
310
311 wxString mPresetName;
312 wxArrayString mControlState;
313
314};
315
316using FFmpegPresetMap = std::unordered_map<wxString, FFmpegPreset>;
317
319{
320public:
323
324 void GetPresetList(wxArrayString &list);
325 void LoadPreset(ExportFFmpegOptions *parent, wxString &name);
326 bool SavePreset(ExportFFmpegOptions *parent, wxString &name);
327 void DeletePreset(wxString &name);
328 bool OverwriteIsOk( wxString &name );
329 FFmpegPreset *FindPreset(wxString &name);
330
331 void ImportPresets(wxString &filename);
332 void ExportPresets(wxString &filename);
333
334 bool HandleXMLTag(const std::string_view& tag, const AttributesList &attrs) override;
335 XMLTagHandler *HandleXMLChild(const std::string_view& tag) override;
336 void WriteXMLHeader(XMLWriter &xmlFile) const;
337 void WriteXML(XMLWriter &xmlFile) const;
338
339private:
340
342 FFmpegPreset *mPreset; // valid during XML parsing only
343 bool mAbortImport; // tells importer to ignore the rest of the import
344};
345
346#endif
347
348#endif //__EXPORT_FFMPEG_DIALOGS_H__
const TranslatableString name
Definition: Distortion.cpp:82
std::unordered_map< wxString, FFmpegPreset > FFmpegPresetMap
FFmpegExposedFormat
Identifiers for pre-set export types.
@ FMT_OPUS
@ FMT_M4A
@ FMT_OTHER
@ FMT_AC3
@ FMT_WMA2
@ FMT_AMRNB
@ FMT_LAST
int format
Definition: ExportPCM.cpp:56
wxString FileExtension
File extension, not including any leading dot.
Definition: Identifier.h:224
#define S(N)
Definition: ToChars.cpp:64
std::vector< Attribute > AttributesList
Definition: XMLTagHandler.h:40
Options dialog for FFmpeg exporting of AAC format.
bool TransferDataToWindow() override
bool TransferDataFromWindow() override
ExportFFmpegAACOptions(wxWindow *parent, int format)
void PopulateOrExchange(ShuttleGui &S)
AC3 export options dialog.
static const int iAC3SampleRates[]
ExportFFmpegAC3Options(wxWindow *parent, int format)
bool TransferDataToWindow() override
bool TransferDataFromWindow() override
void PopulateOrExchange(ShuttleGui &S)
Options dialog for FFmpeg exporting of AMRNB format.
ExportFFmpegAMRNBOptions(wxWindow *parent, int format)
void PopulateOrExchange(ShuttleGui &S)
bool TransferDataFromWindow() override
void OnOpen(wxCommandEvent &evt)
ExportFFmpegCustomOptions(wxWindow *parent, int format)
void PopulateOrExchange(ShuttleGui &S)
Options dialog for FFmpeg exporting of OPUS format.
bool TransferDataToWindow() override
bool TransferDataFromWindow() override
ExportFFmpegOPUSOptions(wxWindow *parent, int format)
static const int iOPUSSampleRates[]
void PopulateOrExchange(ShuttleGui &S)
Custom FFmpeg export dialog.
void OnExportPresets(wxCommandEvent &event)
void OnSavePreset(wxCommandEvent &event)
static const int iAACSampleRates[]
void OnImportPresets(wxCommandEvent &event)
void FetchPresetList()
Retrieves list of presets from configuration file.
void FindSelectedCodec(wxString **name, wxString **longname)
Finds the codec currently selected and returns its name and description.
wxArrayStringEx mCodecNames
void OnDeletePreset(wxCommandEvent &event)
wxArrayString mShownFormatLongNames
void FetchCodecList()
Retrieves codec list from libavcodec.
static CompatibilityEntry CompatibilityList[]
std::unique_ptr< FFmpegPresets > mPresets
int FetchCompatibleFormatList(AudacityAVCodecID id, wxString *selfmt)
void OnCodecList(wxCommandEvent &event)
void PopulateOrExchange(ShuttleGui &S)
void FindSelectedFormat(wxString **name, wxString **longname)
Finds the format currently selected and returns its name and description.
void OnLoadPreset(wxCommandEvent &event)
wxArrayStringEx mFormatNames
wxArrayString mShownCodecLongNames
wxArrayString mShownCodecNames
int FetchCompatibleCodecList(const wxChar *fmt, AudacityAVCodecID id)
wxArrayString mCodecLongNames
void OnFormatList(wxCommandEvent &event)
void OnAllFormats(wxCommandEvent &event)
wxStaticText * mFormatName
void OnOK(wxCommandEvent &event)
ExportFFmpegOptions(wxWindow *parent)
void OnAllCodecs(wxCommandEvent &event)
bool SavePreset(bool bCheckForOverwrite)
void FetchFormatList()
Retrieves format list from libavformat.
static ExposedFormat fmts[]
List of export types.
static ApplicableFor apptable[]
wxArrayString mShownFormatNames
void OnGetURL(wxCommandEvent &event)
wxArrayStringEx mPresetNames
void EnableDisableControls(AVCodecWrapper *cdc, wxString *selfmt)
std::shared_ptr< FFmpegFunctions > mFFmpeg
wxArrayString mFormatLongNames
Options dialog for FFmpeg exporting of WMA format.
bool TransferDataFromWindow() override
void PopulateOrExchange(ShuttleGui &S)
bool TransferDataToWindow() override
static const int iWMASampleRates[]
ExportFFmpegWMAOptions(wxWindow *parent, int format)
wxArrayString mControlState
void LoadPreset(ExportFFmpegOptions *parent, wxString &name)
FFmpegPresetMap mPresets
bool SavePreset(ExportFFmpegOptions *parent, wxString &name)
void ImportPresets(wxString &filename)
bool OverwriteIsOk(wxString &name)
XMLTagHandler * HandleXMLChild(const std::string_view &tag) override
void DeletePreset(wxString &name)
FFmpegPreset * mPreset
bool HandleXMLTag(const std::string_view &tag, const AttributesList &attrs) override
void WriteXMLHeader(XMLWriter &xmlFile) const
void GetPresetList(wxArrayString &list)
void WriteXML(XMLWriter &xmlFile) const
void ExportPresets(wxString &filename)
FFmpegPreset * FindPreset(wxString &name)
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
Definition: ShuttleGui.h:628
Holds a msgid for the translation catalog; may also bind format arguments.
This class is an interface which should be implemented by classes which wish to be able to load and s...
Definition: XMLTagHandler.h:42
Base class for XMLFileWriter and XMLStringWriter that provides the general functionality for creating...
Definition: XMLWriter.h:26
Extend wxArrayString with move operations and construction and insertion fromstd::initializer_list.
Entry for the Applicability table.
int control
control ID
AudacityAVCodecID codec
Codec ID.
bool enable
true if this control should be enabled, false otherwise
const char * format
Format short name.
Describes format-codec compatibility.
const wxChar * fmt
format, recognizable by guess_format()
AudacityAVCodecID codec
codec ID
Describes export type.
FFmpegExposedFormat fmtid
one of the FFmpegExposedFormat
bool compiledIn
support for this codec/format is compiled in (checked at runtime)
const wxChar * shortname
used to guess the format
const int canmetadata
!=0 if format supports metadata, AV_CANMETA any avformat version, otherwise version support added
const TranslatableString description
format description (will be shown in export dialog)
const FileExtension extension
default extension for this format. More extensions may be added later via AddExtension.
const wxChar * name
format name (internal, should be unique; if not - export dialog may show unusual behaviour)
bool canutf8
true if format supports metadata in UTF-8, false otherwise
AudacityAVCodecID codecid
codec ID (see libavcodec/avcodec.h)
unsigned maxchannels
how many channels this format could handle