Audacity  3.0.3
ImporterInterface.h
Go to the documentation of this file.
1 /**********************************************************************
2 
3  Audacity: A Digital Audio Editor
4 
5  ImporterInterface.h
6 
7  Leland Lucius
8 
9  Copyright (c) 2014, Audacity Team
10  All rights reserved.
11 
12  Redistribution and use in source and binary forms, with or without
13  modification, are permitted provided that the following conditions
14  are met:
15 
16  1. Redistributions of source code must retain the above copyright
17  notice, this list of conditions and the following disclaimer.
18 
19  2. Redistributions in binary form must reproduce the above copyright
20  notice, this list of conditions and the following disclaimer in the
21  documentation and/or other materials provided with the distribution.
22 
23  3. Neither the name of the copyright holder nor the names of its
24  contributors may be used to endorse or promote products derived from
25  this software without specific prior written permission.
26 
27  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
28  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
29  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
30  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
31  COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
32  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
33  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
34  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
35  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
36  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
37  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
38  POSSIBILITY OF SUCH DAMAGE.
39 
40 **********************************************************************/
41 
42 #ifndef __AUDACITY_IMPORTERINTERFACE_H__
43 #define __AUDACITY_IMPORTERINTERFACE_H__
44 
45 #include "Identifier.h"
48 
49 // ============================================================================
50 //
51 // ImporterInterface class
52 //
53 // ============================================================================
54 
58 {
59 public:
60  virtual ~ImporterInterface() {};
61 
62  // Get unique string ID of this plugin, usually it corresponds
63  // to the underlying library, i.e. "libsndfile", "libflac", "libav"
64  // These MUST NOT change across Audacity versions (but new IDs can
65  // be added).
66  virtual wxString GetPluginStringID() = 0;
67 
68  // Get a description of the file type this importer can import.
69  // Examples: "Ogg Vorbis", "MP3", "Uncompressed PCM"
71 
72  // Get a list of extensions this plugin expects to be able to
73  // import. If a filename matches any of these extensions,
74  // this importer will get first dibs on importing it.
76  virtual bool SupportsExtension(const FileExtension & extension) = 0;
77 
78  // Create the client that will be used to import a file.
80 };
81 
82 
83 // ============================================================================
84 //
85 // ImporterHostInterface class
86 //
87 // ============================================================================
88 
90 {
91 public:
92  virtual ~ImporterHostInterface() {};
93 
94  // Called by the client to add a new stream to the import.
95  virtual bool AddStream(int stream,
96  sampleFormat sampleformat,
97  float sampleRate,
98  int numChannels,
99  ChannelName *channelMap) = 0;
100 
101  // Accepts interleaved samples from the client.
102  virtual bool PutSamples(int stream, size_t numSamples, samplePtr inBuffer) = 0;
103 
104  // Accepts non-interleaved samples from the client.
105  virtual bool PutSamples(int stream, int channel, size_t numSamples, samplePtr inBuffer) = 0;
106 
107  // The client will call this as the import progresses.
108  virtual bool UpdateProgress(float current, float total) = 0;
109 };
110 
111 // ============================================================================
112 //
113 // ImporterClientInterface class
114 //
115 // ============================================================================
116 
118 {
119 public:
121 
122  // Provides a pointer to the associated host for this importer.
123  virtual void SetHost(ImporterHostInterface *host) = 0;
124 
125  // Open the given file, returning true if it is a recognized
126  // format, false otherwise. This puts the importer into the open
127  // state.
128  virtual bool Open(const wxString & fileName) = 0;
129 
130  // Do any processing necessary to close the file and release resources.
131  // This will be called only if Open() succeeded.
132  virtual void Close() = 0;
133 
134  // This is similar to GetImporterDescription, but if possible the
135  // importer will return a more specific description of the
136  // specific file that is open.
138 
139  // Return stream descriptions list
140  virtual void GetStreamInfo(wxArrayString & streamInfo) = 0;
141 
142  // Set stream "import/don't import" flag
143  virtual void SetStreamUsage(int streamID, bool use) = 0;
144 
145  // do the actual import, creating whatever tracks are necessary with
146  // the WaveTrackFactory and calling the progress callback every iteration
147  // through the importing loop
148  virtual bool Import() = 0;
149 };
150 
151 #endif // __AUDACITY_IMPORTERINTERFACE_H__
TranslatableString
Holds a msgid for the translation catalog; may also bind format arguments.
Definition: TranslatableString.h:32
ImporterHostInterface::~ImporterHostInterface
virtual ~ImporterHostInterface()
Definition: ImporterInterface.h:92
ImporterHostInterface::UpdateProgress
virtual bool UpdateProgress(float current, float total)=0
ImporterClientInterface::SetHost
virtual void SetHost(ImporterHostInterface *host)=0
ImporterClientInterface::Close
virtual void Close()=0
ImporterHostInterface::AddStream
virtual bool AddStream(int stream, sampleFormat sampleformat, float sampleRate, int numChannels, ChannelName *channelMap)=0
ImporterInterface::SupportsExtension
virtual bool SupportsExtension(const FileExtension &extension)=0
wxArrayStringEx
Extend wxArrayString with move operations and construction and insertion fromstd::initializer_list.
Definition: wxArrayStringEx.h:18
ImporterHostInterface
Definition: ImporterInterface.h:90
ImporterInterface::GetPluginStringID
virtual wxString GetPluginStringID()=0
ImporterClientInterface::GetFileDescription
virtual TranslatableString GetFileDescription()=0
ImporterHostInterface::PutSamples
virtual bool PutSamples(int stream, size_t numSamples, samplePtr inBuffer)=0
FileExtension
wxString FileExtension
File extension, not including any leading dot.
Definition: Identifier.h:224
ChannelName
ChannelName
Definition: Types.h:227
samplePtr
char * samplePtr
Definition: Types.h:214
sampleFormat
sampleFormat
Definition: Types.h:194
ComponentInterface.h
ImporterClientInterface::~ImporterClientInterface
virtual ~ImporterClientInterface()
Definition: ImporterInterface.h:120
ImporterClientInterface
Definition: ImporterInterface.h:118
Identifier.h
ImporterInterface
Definition: ImporterInterface.h:58
ImporterInterface::CreateClient
virtual ImporterClientInterface * CreateClient()=0
ConfigInterface.h
ImporterInterface::GetSupportedExtensions
virtual FileExtensions GetSupportedExtensions()=0
ComponentInterface
ComponentInterface provides name / vendor / version functions to identify plugins....
Definition: ComponentInterface.h:122
ImporterInterface::GetPluginFormatDescription
virtual TranslatableString GetPluginFormatDescription()=0
ImporterClientInterface::Import
virtual bool Import()=0
ImporterClientInterface::GetStreamInfo
virtual void GetStreamInfo(wxArrayString &streamInfo)=0
ImporterClientInterface::SetStreamUsage
virtual void SetStreamUsage(int streamID, bool use)=0
ImporterInterface::~ImporterInterface
virtual ~ImporterInterface()
Definition: ImporterInterface.h:60
ImporterClientInterface::Open
virtual bool Open(const wxString &fileName)=0
ImporterHostInterface::PutSamples
virtual bool PutSamples(int stream, int channel, size_t numSamples, samplePtr inBuffer)=0