Audacity 3.2.0
ExportPlugin.h
Go to the documentation of this file.
1/**********************************************************************
2
3 Audacity: A Digital Audio Editor
4
5 ExportPlugin.h
6
7 Dominic Mazzoni
8
9**********************************************************************/
10#pragma once
11
12#include <memory>
13
14#include <rapidjson/fwd.h>
15
16#include <wx/string.h>
17
18#include "ExportOptionsEditor.h"
19#include "wxArrayStringEx.h"
20#include "Identifier.h"
21#include "TranslatableString.h"
22#include "wxFileNameWrapper.h"
23
24class wxFileName;
25class wxString;
26
27class AudacityProject;
28class Tags;
29
30namespace MixerOptions{ class Downmix; }
31
32
33struct IMPORT_EXPORT_API FormatInfo final
34{
35 wxString format;
38 unsigned maxChannels;
40};
41
42
43class IMPORT_EXPORT_API ExportException
44{
45 const wxString mMessage;
46public:
47
48 ExportException(const wxString& msg);
49
50 const wxString& What() const noexcept;
51};
52
53class IMPORT_EXPORT_API ExportErrorException
54{
56 wxString mHelpPageId;
57public:
61 ExportErrorException(const wxString& errorCode);
62 //
63 ExportErrorException(TranslatableString message, const wxString& helpPage);
64
65 const TranslatableString& GetMessage() const noexcept;
66 const wxString& GetHelpPageId() const noexcept;
67
68};
69
70class IMPORT_EXPORT_API ExportDiskFullError
71{
73public:
75
76 const wxFileNameWrapper& GetFileName() const noexcept;
77};
78
79class IMPORT_EXPORT_API ExportProcessorDelegate
80{
81public:
83
84 virtual bool IsCancelled() const = 0;
85 virtual bool IsStopped() const = 0;
86 virtual void SetStatusString(const TranslatableString& str) = 0;
87 virtual void OnProgress(double progress) = 0;
88};
89
90class IMPORT_EXPORT_API ExportProcessor
91{
92public:
93 using Parameters = std::vector<std::tuple<ExportOptionID, ExportValue>>;
94
97
98 ExportProcessor() = default;
100
115 const Parameters& parameters,
116 const wxFileNameWrapper& filename,
117 double t0, double t1, bool selectedOnly,
118 double rate, unsigned channels,
119 MixerOptions::Downmix* mixerSpec = nullptr,
120 const Tags* tags = nullptr) = 0;
121
123};
124
125//----------------------------------------------------------------------------
126// ExportPlugin
127//----------------------------------------------------------------------------
128class IMPORT_EXPORT_API ExportPlugin /* not final */
129{
130public:
131
133 virtual ~ExportPlugin();
134
135 virtual int GetFormatCount() const = 0;
143 virtual FormatInfo GetFormatInfo(int index) const = 0;
144
152 virtual std::unique_ptr<ExportOptionsEditor>
153 CreateOptionsEditor(int formatIndex, ExportOptionsEditor::Listener* listener) const = 0;
154
156 virtual std::vector<std::string> GetMimeTypes(int formatIndex) const;
157
167 virtual bool ParseConfig(int formatIndex, const rapidjson::Value& config, ExportProcessor::Parameters& parameters) const;
168
169 virtual bool CheckFileName(wxFileName &filename, int format = 0) const;
170
180 virtual std::unique_ptr<ExportProcessor> CreateProcessor(int format) const = 0;
181};
#define str(a)
ExportResult
Definition: ExportTypes.h:24
const auto project
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:90
wxFileNameWrapper mFileName
Definition: ExportPlugin.h:72
TranslatableString mMessage
Definition: ExportPlugin.h:55
const wxString mMessage
Definition: ExportPlugin.h:45
Listener object that is used to report on option changes.
virtual std::unique_ptr< ExportProcessor > CreateProcessor(int format) const =0
virtual FormatInfo GetFormatInfo(int index) const =0
Returns FormatInfo structure for given index if it's valid, or a default one. FormatInfo::format isn'...
virtual ~ExportPlugin()
virtual int GetFormatCount() const =0
virtual std::unique_ptr< ExportOptionsEditor > CreateOptionsEditor(int formatIndex, ExportOptionsEditor::Listener *listener) const =0
Creates format-dependent options editor, that is used to create a valid set of parameters to be used ...
virtual void SetStatusString(const TranslatableString &str)=0
virtual bool IsCancelled() const =0
virtual void OnProgress(double progress)=0
virtual bool IsStopped() const =0
virtual ~ExportProcessorDelegate()
virtual ~ExportProcessor()
ExportProcessor(const ExportProcessor &)=delete
virtual ExportResult Process(ExportProcessorDelegate &delegate)=0
ExportProcessor()=default
std::vector< std::tuple< ExportOptionID, ExportValue > > Parameters
Definition: ExportPlugin.h:93
virtual bool Initialize(AudacityProject &project, const Parameters &parameters, const wxFileNameWrapper &filename, double t0, double t1, bool selectedOnly, double rate, unsigned channels, MixerOptions::Downmix *mixerSpec=nullptr, const Tags *tags=nullptr)=0
Called before start processing.
ExportProcessor & operator=(const ExportProcessor &)=delete
A matrix of booleans, one row per input channel, column per output.
Definition: MixerOptions.h:32
ID3 Tags (for MP3)
Definition: Tags.h:73
Holds a msgid for the translation catalog; may also bind format arguments.
Extend wxArrayString with move operations and construction and insertion fromstd::initializer_list.
bool canMetaData
Definition: ExportPlugin.h:39
TranslatableString description
Definition: ExportPlugin.h:36
wxString format
Definition: ExportPlugin.h:35
FileExtensions extensions
Definition: ExportPlugin.h:37
unsigned maxChannels
Definition: ExportPlugin.h:38