2010-01-23 19:44:49 +00:00
|
|
|
/**********************************************************************
|
|
|
|
|
|
|
|
Audacity: A Digital Audio Editor
|
|
|
|
|
|
|
|
ImportPlugin.h
|
|
|
|
|
|
|
|
Joshua Haberman
|
|
|
|
Leland Lucius
|
|
|
|
|
|
|
|
*******************************************************************//**
|
|
|
|
|
|
|
|
\file ImportPlugin.h
|
|
|
|
\brief
|
|
|
|
The interface that all file import "plugins" (if you want to call
|
|
|
|
them that) must implement. Defines ImportFileHandle, ImportPlugin,
|
|
|
|
UnusableImportPlugin, ImportPluginList and UnusableImportPluginList.
|
|
|
|
|
|
|
|
Since this is part of libaudacity, it must not use any GUI parts
|
|
|
|
of wxWidgets.
|
|
|
|
|
|
|
|
*//****************************************************************//**
|
|
|
|
|
|
|
|
\class ImportFileHandle
|
|
|
|
\brief Base class for FlacImportFileHandle, LOFImportFileHandle,
|
2014-06-03 20:30:19 +00:00
|
|
|
MP3ImportFileHandle, OggImportFileHandle and PCMImportFileHandle.
|
2010-01-23 19:44:49 +00:00
|
|
|
Gives API for sound file import.
|
|
|
|
|
|
|
|
*//****************************************************************//**
|
|
|
|
|
|
|
|
\class ImportPlugin
|
|
|
|
\brief Base class for FlacImportPlugin, LOFImportPlugin,
|
2014-06-03 20:30:19 +00:00
|
|
|
MP3ImportPlugin, OggImportPlugin and PCMImportPlugin.
|
2010-01-23 19:44:49 +00:00
|
|
|
Gives API for sound file import.
|
|
|
|
|
|
|
|
*//****************************************************************//**
|
|
|
|
|
|
|
|
\class UnusableImportPlugin
|
|
|
|
\brief Used in place of a real plug in for plug ins that have not
|
|
|
|
been compiled or are not available in this version of Audacity. Has
|
2014-06-03 20:30:19 +00:00
|
|
|
enough information to identify the file extensions that would be used,
|
2010-01-23 19:44:49 +00:00
|
|
|
but little else.
|
|
|
|
|
|
|
|
*//****************************************************************//**
|
|
|
|
|
|
|
|
\class ImportPluginList
|
|
|
|
\brief An ImportPlugin list.
|
|
|
|
|
|
|
|
*//****************************************************************//**
|
|
|
|
|
|
|
|
\class UnusableImportPluginList
|
|
|
|
\brief An UnusableImportPlugin list.
|
|
|
|
|
|
|
|
*//*******************************************************************/
|
|
|
|
|
|
|
|
#ifndef __AUDACITY_IMPORTER__
|
|
|
|
#define __AUDACITY_IMPORTER__
|
|
|
|
|
2016-02-14 18:23:08 +00:00
|
|
|
#include "../Audacity.h"
|
2010-01-23 19:44:49 +00:00
|
|
|
#include <wx/arrstr.h>
|
|
|
|
#include <wx/filename.h>
|
|
|
|
#include <wx/string.h>
|
2016-02-14 18:23:08 +00:00
|
|
|
#include "../MemoryX.h"
|
2010-01-23 19:44:49 +00:00
|
|
|
|
|
|
|
#include "../widgets/ProgressDialog.h"
|
|
|
|
|
2016-03-02 17:52:13 +00:00
|
|
|
#include "ImportRaw.h" // defines TrackHolders
|
|
|
|
|
2010-01-23 19:44:49 +00:00
|
|
|
class TrackFactory;
|
|
|
|
class Track;
|
|
|
|
class Tags;
|
|
|
|
|
|
|
|
class ImportFileHandle;
|
|
|
|
|
2016-02-24 06:06:39 +00:00
|
|
|
class ImportPlugin /* not final */
|
2010-01-23 19:44:49 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
2010-04-04 08:19:53 +00:00
|
|
|
// Get unique string ID of this plugin, usually it corresponds
|
|
|
|
// to the underlying library, i.e. "libsndfile", "libflac", "libav"
|
2016-02-13 15:43:16 +00:00
|
|
|
// These MUST NOT change across Audacity versions (but NEW IDs can
|
2010-04-04 08:19:53 +00:00
|
|
|
// be added).
|
|
|
|
virtual wxString GetPluginStringID() = 0;
|
|
|
|
|
2010-01-23 19:44:49 +00:00
|
|
|
// Get a description of the file type this importer can import.
|
|
|
|
// Examples: "Ogg Vorbis", "MP3", "Uncompressed PCM"
|
|
|
|
virtual wxString GetPluginFormatDescription() = 0;
|
|
|
|
|
|
|
|
// Get a list of extensions this plugin expects to be able to
|
|
|
|
// import. If a filename matches any of these extensions,
|
|
|
|
// this importer will get first dibs on importing it.
|
|
|
|
virtual wxArrayString GetSupportedExtensions()
|
|
|
|
{
|
|
|
|
return mExtensions;
|
|
|
|
}
|
|
|
|
|
2016-02-23 02:16:39 +00:00
|
|
|
bool SupportsExtension(const wxString &extension)
|
2010-01-23 19:44:49 +00:00
|
|
|
{
|
|
|
|
// Case-insensitive check if extension is supported
|
|
|
|
return mExtensions.Index(extension, false) != wxNOT_FOUND;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Open the given file, returning true if it is in a recognized
|
|
|
|
// format, false otherwise. This puts the importer into the open
|
|
|
|
// state.
|
2016-03-31 05:23:51 +00:00
|
|
|
virtual std::unique_ptr<ImportFileHandle> Open(const wxString &Filename) = 0;
|
2010-01-23 19:44:49 +00:00
|
|
|
|
|
|
|
virtual ~ImportPlugin() { }
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
ImportPlugin(wxArrayString supportedExtensions):
|
|
|
|
mExtensions(supportedExtensions)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
wxArrayString mExtensions;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2016-02-24 06:06:39 +00:00
|
|
|
class ImportFileHandle /* not final */
|
2010-01-23 19:44:49 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
ImportFileHandle(const wxString & filename)
|
|
|
|
: mFilename(filename),
|
2016-02-18 17:57:40 +00:00
|
|
|
mProgress{}
|
2010-01-23 19:44:49 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual ~ImportFileHandle()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
// The importer should call this to create the progress dialog and
|
|
|
|
// identify the filename being imported.
|
|
|
|
void CreateProgress()
|
|
|
|
{
|
2016-02-22 04:21:11 +00:00
|
|
|
wxFileName ff(mFilename);
|
2010-01-23 19:44:49 +00:00
|
|
|
wxString title;
|
|
|
|
|
|
|
|
title.Printf(_("Importing %s"), GetFileDescription().c_str());
|
2016-02-22 04:21:11 +00:00
|
|
|
mProgress.create(title, ff.GetFullName());
|
2010-01-23 19:44:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// This is similar to GetImporterDescription, but if possible the
|
|
|
|
// importer will return a more specific description of the
|
|
|
|
// specific file that is open.
|
|
|
|
virtual wxString GetFileDescription() = 0;
|
|
|
|
|
|
|
|
// Return an estimate of how many bytes the file will occupy once
|
2016-09-05 18:59:03 +00:00
|
|
|
// imported. In principle this may exceed main memory, so don't use
|
|
|
|
// size_t.
|
|
|
|
using ByteCount = unsigned long long;
|
|
|
|
virtual ByteCount GetFileUncompressedBytes() = 0;
|
2010-01-23 19:44:49 +00:00
|
|
|
|
|
|
|
// do the actual import, creating whatever tracks are necessary with
|
|
|
|
// the TrackFactory and calling the progress callback every iteration
|
|
|
|
// through the importing loop
|
2016-12-24 15:43:25 +00:00
|
|
|
virtual ProgressResult Import(TrackFactory *trackFactory, TrackHolders &outTracks,
|
2016-03-02 17:52:13 +00:00
|
|
|
Tags *tags) = 0;
|
2010-01-23 19:44:49 +00:00
|
|
|
|
|
|
|
// Return number of elements in stream list
|
|
|
|
virtual wxInt32 GetStreamCount() = 0;
|
|
|
|
|
|
|
|
// Return stream descriptions list
|
2016-04-09 20:08:33 +00:00
|
|
|
virtual const wxArrayString &GetStreamInfo() = 0;
|
2010-01-23 19:44:49 +00:00
|
|
|
|
|
|
|
// Set stream "import/don't import" flag
|
|
|
|
virtual void SetStreamUsage(wxInt32 StreamID, bool Use) = 0;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
wxString mFilename;
|
2016-02-18 17:57:40 +00:00
|
|
|
Maybe<ProgressDialog> mProgress;
|
2010-01-23 19:44:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class UnusableImportPlugin
|
|
|
|
{
|
|
|
|
public:
|
2016-02-23 02:16:39 +00:00
|
|
|
UnusableImportPlugin(const wxString &formatName, wxArrayString extensions):
|
2010-01-23 19:44:49 +00:00
|
|
|
mFormatName(formatName),
|
|
|
|
mExtensions(extensions)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
wxString GetPluginFormatDescription()
|
|
|
|
{
|
|
|
|
return mFormatName;
|
|
|
|
}
|
|
|
|
|
2016-02-23 02:16:39 +00:00
|
|
|
bool SupportsExtension(const wxString &extension)
|
2010-01-23 19:44:49 +00:00
|
|
|
{
|
|
|
|
return mExtensions.Index(extension, false) != wxNOT_FOUND;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
wxString mFormatName;
|
|
|
|
wxArrayString mExtensions;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|