2010-01-23 19:44:49 +00:00
|
|
|
/**********************************************************************
|
|
|
|
|
|
|
|
Audacity: A Digital Audio Editor
|
|
|
|
|
|
|
|
ExportFFmpegDialogs.h
|
|
|
|
|
|
|
|
LRN
|
|
|
|
|
|
|
|
**********************************************************************/
|
|
|
|
|
|
|
|
#if !defined(__EXPORT_FFMPEG_DIALOGS_H__)
|
|
|
|
#define __EXPORT_FFMPEG_DIALOGS_H__
|
|
|
|
|
2019-03-22 15:01:05 +00:00
|
|
|
#include "../Audacity.h" // keep ffmpeg before wx because they interact // for USE_* macros
|
2010-01-23 19:44:49 +00:00
|
|
|
|
2019-03-22 15:01:05 +00:00
|
|
|
#if defined(USE_FFMPEG)
|
2018-11-11 02:40:37 +00:00
|
|
|
|
2010-01-23 19:44:49 +00:00
|
|
|
#include "../FFmpeg.h" // and Audacity.h before FFmpeg for config*.h
|
|
|
|
|
|
|
|
#include "../xml/XMLFileReader.h"
|
|
|
|
#include "../FileNames.h"
|
|
|
|
|
2018-01-08 21:38:52 +00:00
|
|
|
#include <unordered_map>
|
2019-02-28 17:22:25 +00:00
|
|
|
#include "audacity/Types.h"
|
2018-01-08 21:38:52 +00:00
|
|
|
|
2018-02-02 00:23:02 +00:00
|
|
|
class wxArrayStringEx;
|
2010-01-23 19:44:49 +00:00
|
|
|
|
2018-11-12 00:47:44 +00:00
|
|
|
class wxArrayString;
|
2018-11-11 22:30:55 +00:00
|
|
|
class wxCheckBox;
|
2018-11-11 21:41:45 +00:00
|
|
|
class wxStaticText;
|
2018-11-11 21:11:18 +00:00
|
|
|
class wxTextCtrl;
|
2018-11-12 00:47:44 +00:00
|
|
|
|
2010-01-23 19:44:49 +00:00
|
|
|
/// Identifiers for pre-set export types.
|
2014-06-03 20:30:19 +00:00
|
|
|
enum FFmpegExposedFormat
|
2010-01-23 19:44:49 +00:00
|
|
|
{
|
|
|
|
FMT_M4A,
|
|
|
|
FMT_AC3,
|
|
|
|
FMT_AMRNB,
|
2020-03-30 17:02:03 +00:00
|
|
|
FMT_OPUS,
|
2010-01-23 19:44:49 +00:00
|
|
|
FMT_WMA2,
|
|
|
|
FMT_OTHER,
|
|
|
|
FMT_LAST
|
|
|
|
};
|
|
|
|
|
2017-10-12 03:02:10 +00:00
|
|
|
#define AV_CANMETA (AV_VERSION_INT(255, 255, 255))
|
|
|
|
|
2010-01-23 19:44:49 +00:00
|
|
|
/// Describes export type
|
|
|
|
struct ExposedFormat
|
|
|
|
{
|
|
|
|
FFmpegExposedFormat fmtid; //!< one of the FFmpegExposedFormat
|
|
|
|
const wxChar *name; //!< format name (internal, should be unique; if not - export dialog may show unusual behaviour)
|
2019-12-27 21:14:25 +00:00
|
|
|
const FileExtension extension; //!< default extension for this format. More extensions may be added later via AddExtension.
|
2010-01-23 19:44:49 +00:00
|
|
|
const wxChar *shortname; //!< used to guess the format
|
2016-09-02 19:53:09 +00:00
|
|
|
unsigned maxchannels; //!< how many channels this format could handle
|
2017-10-12 03:02:10 +00:00
|
|
|
const int canmetadata; //!< !=0 if format supports metadata, AV_CANMETA any avformat version, otherwise version support added
|
2010-01-23 19:44:49 +00:00
|
|
|
bool canutf8; //!< true if format supports metadata in UTF-8, false otherwise
|
2018-03-29 20:26:31 +00:00
|
|
|
const TranslatableString description; //!< format description (will be shown in export dialog)
|
2014-05-23 20:25:50 +00:00
|
|
|
AVCodecID codecid; //!< codec ID (see libavcodec/avcodec.h)
|
2010-01-23 19:44:49 +00:00
|
|
|
bool compiledIn; //!< support for this codec/format is compiled in (checked at runtime)
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/// Describes format-codec compatibility
|
|
|
|
struct CompatibilityEntry
|
|
|
|
{
|
2021-01-12 11:56:09 +00:00
|
|
|
const wxChar *fmt; //!< format, recognizable by guess_format()
|
2014-05-23 20:25:50 +00:00
|
|
|
AVCodecID codec; //!< codec ID
|
2010-01-23 19:44:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/// AC3 export options dialog
|
2016-06-25 18:18:23 +00:00
|
|
|
class ExportFFmpegAC3Options final : public wxPanelWrapper
|
2010-01-23 19:44:49 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
2015-07-13 17:36:40 +00:00
|
|
|
ExportFFmpegAC3Options(wxWindow *parent, int format);
|
|
|
|
virtual ~ExportFFmpegAC3Options();
|
2015-08-05 07:28:42 +00:00
|
|
|
|
2010-01-23 19:44:49 +00:00
|
|
|
void PopulateOrExchange(ShuttleGui & S);
|
2017-10-01 17:28:04 +00:00
|
|
|
bool TransferDataToWindow() override;
|
|
|
|
bool TransferDataFromWindow() override;
|
2015-08-05 07:28:42 +00:00
|
|
|
|
2010-01-23 19:44:49 +00:00
|
|
|
/// Sample Rates supported by AC3 encoder (must end with zero-element)
|
|
|
|
/// It is not used in dialog anymore, but will be required later
|
|
|
|
static const int iAC3SampleRates[];
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
wxChoice *mBitRateChoice;
|
|
|
|
int mBitRateFromChoice;
|
|
|
|
};
|
|
|
|
|
2016-06-25 18:18:23 +00:00
|
|
|
class ExportFFmpegAACOptions final : public wxPanelWrapper
|
2010-01-23 19:44:49 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
2015-07-13 17:36:40 +00:00
|
|
|
ExportFFmpegAACOptions(wxWindow *parent, int format);
|
|
|
|
virtual ~ExportFFmpegAACOptions();
|
2015-08-05 07:28:42 +00:00
|
|
|
|
2010-01-23 19:44:49 +00:00
|
|
|
void PopulateOrExchange(ShuttleGui & S);
|
2017-10-01 17:28:04 +00:00
|
|
|
bool TransferDataToWindow() override;
|
|
|
|
bool TransferDataFromWindow() override;
|
2010-01-23 19:44:49 +00:00
|
|
|
};
|
|
|
|
|
2016-06-25 18:18:23 +00:00
|
|
|
class ExportFFmpegAMRNBOptions final : public wxPanelWrapper
|
2010-01-23 19:44:49 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
2015-07-13 17:36:40 +00:00
|
|
|
ExportFFmpegAMRNBOptions(wxWindow *parent, int format);
|
|
|
|
virtual ~ExportFFmpegAMRNBOptions();
|
2015-08-05 07:28:42 +00:00
|
|
|
|
2010-01-23 19:44:49 +00:00
|
|
|
void PopulateOrExchange(ShuttleGui & S);
|
2017-10-01 17:28:04 +00:00
|
|
|
bool TransferDataToWindow() override;
|
|
|
|
bool TransferDataFromWindow() override;
|
2010-01-23 19:44:49 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
wxChoice *mBitRateChoice;
|
|
|
|
int mBitRateFromChoice;
|
|
|
|
};
|
|
|
|
|
2020-03-30 17:02:03 +00:00
|
|
|
class ExportFFmpegOPUSOptions final : public wxPanelWrapper
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
ExportFFmpegOPUSOptions(wxWindow *parent, int format);
|
|
|
|
~ExportFFmpegOPUSOptions();
|
|
|
|
|
|
|
|
void PopulateOrExchange(ShuttleGui & S);
|
|
|
|
bool TransferDataToWindow() override;
|
|
|
|
bool TransferDataFromWindow() override;
|
|
|
|
|
|
|
|
static const int iOPUSSampleRates[];
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
wxSlider *mBitRateSlider;
|
|
|
|
int mBitRateFromSlider;
|
|
|
|
|
|
|
|
wxChoice *mVbrChoice;
|
|
|
|
int mVbrFromChoice;
|
|
|
|
|
|
|
|
wxSlider *mComplexitySlider;
|
|
|
|
int mComplexityFromSlider;
|
|
|
|
|
|
|
|
wxChoice *mFramesizeChoice;
|
|
|
|
int mFramesizeFromChoice;
|
|
|
|
|
|
|
|
wxChoice *mApplicationChoice;
|
|
|
|
int mApplicationFromChoice;
|
|
|
|
|
|
|
|
wxChoice *mCuttoffChoice;
|
|
|
|
int mCutoffFromChoice;
|
|
|
|
};
|
|
|
|
|
2016-06-25 18:18:23 +00:00
|
|
|
class ExportFFmpegWMAOptions final : public wxPanelWrapper
|
2010-01-23 19:44:49 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
2015-07-13 17:36:40 +00:00
|
|
|
ExportFFmpegWMAOptions(wxWindow *parent, int format);
|
|
|
|
~ExportFFmpegWMAOptions();
|
2015-08-05 07:28:42 +00:00
|
|
|
|
2010-01-23 19:44:49 +00:00
|
|
|
void PopulateOrExchange(ShuttleGui & S);
|
2017-10-01 17:28:04 +00:00
|
|
|
bool TransferDataToWindow() override;
|
|
|
|
bool TransferDataFromWindow() override;
|
2010-01-23 19:44:49 +00:00
|
|
|
|
|
|
|
static const int iWMASampleRates[];
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
wxChoice *mBitRateChoice;
|
|
|
|
int mBitRateFromChoice;
|
|
|
|
};
|
|
|
|
|
2016-06-25 18:18:23 +00:00
|
|
|
class ExportFFmpegCustomOptions final : public wxPanelWrapper
|
2015-08-05 07:28:42 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
ExportFFmpegCustomOptions(wxWindow *parent, int format);
|
|
|
|
~ExportFFmpegCustomOptions();
|
|
|
|
|
|
|
|
void PopulateOrExchange(ShuttleGui & S);
|
2017-10-01 17:28:04 +00:00
|
|
|
bool TransferDataToWindow() override;
|
|
|
|
bool TransferDataFromWindow() override;
|
2015-08-05 07:28:42 +00:00
|
|
|
|
|
|
|
void OnOpen(wxCommandEvent & evt);
|
|
|
|
|
|
|
|
private:
|
2020-03-31 00:37:06 +00:00
|
|
|
wxTextCtrl *mFormat;
|
|
|
|
wxTextCtrl *mCodec;
|
2015-08-05 07:28:42 +00:00
|
|
|
|
2016-09-18 14:26:29 +00:00
|
|
|
DECLARE_EVENT_TABLE()
|
2015-08-05 07:28:42 +00:00
|
|
|
};
|
|
|
|
|
2010-01-23 19:44:49 +00:00
|
|
|
/// Entry for the Applicability table
|
|
|
|
struct ApplicableFor
|
|
|
|
{
|
|
|
|
bool enable; //!< true if this control should be enabled, false otherwise
|
2010-02-13 01:39:38 +00:00
|
|
|
int control; //!< control ID
|
2014-05-23 20:25:50 +00:00
|
|
|
AVCodecID codec; //!< Codec ID
|
2010-01-23 19:44:49 +00:00
|
|
|
const char *format; //!< Format short name
|
|
|
|
};
|
|
|
|
|
|
|
|
class FFmpegPresets;
|
|
|
|
|
|
|
|
/// Custom FFmpeg export dialog
|
2016-07-10 21:10:50 +00:00
|
|
|
class ExportFFmpegOptions final : public wxDialogWrapper
|
2010-01-23 19:44:49 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
ExportFFmpegOptions(wxWindow *parent);
|
|
|
|
~ExportFFmpegOptions();
|
|
|
|
void PopulateOrExchange(ShuttleGui & S);
|
|
|
|
void OnOK(wxCommandEvent& event);
|
2019-07-15 09:52:22 +00:00
|
|
|
void OnGetURL(wxCommandEvent& event);
|
2010-01-23 19:44:49 +00:00
|
|
|
void OnFormatList(wxCommandEvent& event);
|
|
|
|
void DoOnFormatList();
|
|
|
|
void OnCodecList(wxCommandEvent& event);
|
|
|
|
void DoOnCodecList();
|
|
|
|
void OnAllFormats(wxCommandEvent& event);
|
|
|
|
void OnAllCodecs(wxCommandEvent& event);
|
|
|
|
void OnSavePreset(wxCommandEvent& event);
|
|
|
|
void OnLoadPreset(wxCommandEvent& event);
|
|
|
|
void OnDeletePreset(wxCommandEvent& event);
|
|
|
|
void OnImportPresets(wxCommandEvent& event);
|
|
|
|
void OnExportPresets(wxCommandEvent& event);
|
2019-07-15 09:52:22 +00:00
|
|
|
bool SavePreset( bool bCheckForOverwrite);
|
|
|
|
|
2010-01-23 19:44:49 +00:00
|
|
|
|
2010-02-13 01:39:38 +00:00
|
|
|
// Static tables
|
|
|
|
static CompatibilityEntry CompatibilityList[];
|
|
|
|
static ExposedFormat fmts[];
|
|
|
|
static const int iAACSampleRates[];
|
|
|
|
static ApplicableFor apptable[];
|
|
|
|
|
2010-01-23 19:44:49 +00:00
|
|
|
private:
|
|
|
|
|
|
|
|
wxArrayString mShownFormatNames;
|
|
|
|
wxArrayString mShownFormatLongNames;
|
|
|
|
wxArrayString mShownCodecNames;
|
|
|
|
wxArrayString mShownCodecLongNames;
|
2018-02-02 00:23:02 +00:00
|
|
|
wxArrayStringEx mFormatNames;
|
2010-01-23 19:44:49 +00:00
|
|
|
wxArrayString mFormatLongNames;
|
2018-02-02 00:23:02 +00:00
|
|
|
wxArrayStringEx mCodecNames;
|
2010-01-23 19:44:49 +00:00
|
|
|
wxArrayString mCodecLongNames;
|
|
|
|
|
|
|
|
wxListBox *mFormatList;
|
|
|
|
wxListBox *mCodecList;
|
|
|
|
|
|
|
|
wxStaticText *mFormatName;
|
|
|
|
wxStaticText *mCodecName;
|
|
|
|
|
|
|
|
wxComboBox *mPresetCombo;
|
2014-06-03 20:30:19 +00:00
|
|
|
|
2010-01-23 19:44:49 +00:00
|
|
|
int mBitRateFromChoice;
|
|
|
|
int mSampleRateFromChoice;
|
|
|
|
|
2016-04-09 20:09:19 +00:00
|
|
|
std::unique_ptr<FFmpegPresets> mPresets;
|
2010-01-23 19:44:49 +00:00
|
|
|
|
2018-02-02 00:23:02 +00:00
|
|
|
wxArrayStringEx mPresetNames;
|
2010-01-23 19:44:49 +00:00
|
|
|
|
2020-04-12 22:48:14 +00:00
|
|
|
/// Finds the format currently selected and returns its name and description
|
2010-01-23 19:44:49 +00:00
|
|
|
void FindSelectedFormat(wxString **name, wxString **longname);
|
2014-06-03 20:30:19 +00:00
|
|
|
|
2020-04-12 22:48:14 +00:00
|
|
|
/// Finds the codec currently selected and returns its name and description
|
2010-01-23 19:44:49 +00:00
|
|
|
void FindSelectedCodec(wxString **name, wxString **longname);
|
|
|
|
|
2020-04-11 07:08:33 +00:00
|
|
|
/// Retrieves format list from libavformat
|
2010-01-23 19:44:49 +00:00
|
|
|
void FetchFormatList();
|
|
|
|
|
2020-04-11 07:08:33 +00:00
|
|
|
/// Retrieves a list of formats compatible to codec
|
2010-01-23 19:44:49 +00:00
|
|
|
///\param id Codec ID
|
|
|
|
///\param selfmt format selected at the moment
|
2016-02-13 15:43:16 +00:00
|
|
|
///\return index of the selfmt in NEW format list or -1 if it is not in the list
|
2014-05-23 20:25:50 +00:00
|
|
|
int FetchCompatibleFormatList(AVCodecID id, wxString *selfmt);
|
2010-01-23 19:44:49 +00:00
|
|
|
|
2020-04-11 07:08:33 +00:00
|
|
|
/// Retrieves codec list from libavcodec
|
2010-01-23 19:44:49 +00:00
|
|
|
void FetchCodecList();
|
|
|
|
|
2020-04-11 07:08:33 +00:00
|
|
|
/// Retrieves a list of codecs compatible to format
|
2010-01-23 19:44:49 +00:00
|
|
|
///\param fmt Format short name
|
|
|
|
///\param id id of the codec selected at the moment
|
2016-02-13 15:43:16 +00:00
|
|
|
///\return index of the id in NEW codec list or -1 if it is not in the list
|
2014-05-23 20:25:50 +00:00
|
|
|
int FetchCompatibleCodecList(const wxChar *fmt, AVCodecID id);
|
2010-01-23 19:44:49 +00:00
|
|
|
|
2020-04-11 07:08:33 +00:00
|
|
|
/// Retrieves list of presets from configuration file
|
2010-01-23 19:44:49 +00:00
|
|
|
void FetchPresetList();
|
|
|
|
|
2019-09-01 11:41:24 +00:00
|
|
|
bool ReportIfBadCombination();
|
|
|
|
|
|
|
|
|
2010-01-23 19:44:49 +00:00
|
|
|
// Enables/disables controls based on format/codec combination,
|
|
|
|
// leaving only relevant controls enabled.
|
|
|
|
// Hiding the controls may have been a better idea,
|
2014-06-03 20:30:19 +00:00
|
|
|
// but it's hard to hide their text labels too
|
2010-01-23 19:44:49 +00:00
|
|
|
void EnableDisableControls(AVCodec *cdc, wxString *selfmt);
|
|
|
|
DECLARE_EVENT_TABLE()
|
|
|
|
};
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
// FFmpegPresets
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
class FFmpegPreset
|
|
|
|
{
|
|
|
|
public:
|
2015-08-26 16:18:55 +00:00
|
|
|
FFmpegPreset();
|
2010-01-23 19:44:49 +00:00
|
|
|
~FFmpegPreset();
|
|
|
|
|
2015-05-17 06:57:40 +00:00
|
|
|
wxString mPresetName;
|
|
|
|
wxArrayString mControlState;
|
2010-01-23 19:44:49 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
2018-01-08 21:38:52 +00:00
|
|
|
using FFmpegPresetMap = std::unordered_map<wxString, FFmpegPreset>;
|
2010-01-23 19:44:49 +00:00
|
|
|
|
|
|
|
class FFmpegPresets : XMLTagHandler
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
FFmpegPresets();
|
|
|
|
~FFmpegPresets();
|
|
|
|
|
2016-04-09 20:09:19 +00:00
|
|
|
void GetPresetList(wxArrayString &list);
|
2010-01-23 19:44:49 +00:00
|
|
|
void LoadPreset(ExportFFmpegOptions *parent, wxString &name);
|
2019-07-15 09:52:22 +00:00
|
|
|
bool SavePreset(ExportFFmpegOptions *parent, wxString &name);
|
2010-01-23 19:44:49 +00:00
|
|
|
void DeletePreset(wxString &name);
|
2019-07-15 09:52:22 +00:00
|
|
|
bool OverwriteIsOk( wxString &name );
|
2010-01-23 19:44:49 +00:00
|
|
|
FFmpegPreset *FindPreset(wxString &name);
|
|
|
|
|
|
|
|
void ImportPresets(wxString &filename);
|
|
|
|
void ExportPresets(wxString &filename);
|
|
|
|
|
2017-02-22 19:23:35 +00:00
|
|
|
bool HandleXMLTag(const wxChar *tag, const wxChar **attrs) override;
|
|
|
|
XMLTagHandler *HandleXMLChild(const wxChar *tag) override;
|
|
|
|
void WriteXMLHeader(XMLWriter &xmlFile) const;
|
|
|
|
void WriteXML(XMLWriter &xmlFile) const;
|
2010-01-23 19:44:49 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
|
2015-08-26 16:18:55 +00:00
|
|
|
FFmpegPresetMap mPresets;
|
2015-05-17 06:57:40 +00:00
|
|
|
FFmpegPreset *mPreset; // valid during XML parsing only
|
2015-08-26 16:18:55 +00:00
|
|
|
bool mAbortImport; // tells importer to ignore the rest of the import
|
2010-01-23 19:44:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif //__EXPORT_FFMPEG_DIALOGS_H__
|