|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "tsound_io.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tconvert.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
DEFINE_CLASS_CODE(TSoundTrackReader, 13)
|
|
Toshihiro Shimizu |
890ddd |
DEFINE_CLASS_CODE(TSoundTrackWriter, 14)
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
std::map<qstring, *="" tsoundtrackreadercreateproc=""> SoundTrackReaderTable;</qstring,>
|
|
Toshihiro Shimizu |
890ddd |
std::map<qstring, *="" tsoundtrackwritercreateproc=""> SoundTrackWriterTable;</qstring,>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TSoundTrackReader::TSoundTrackReader(const TFilePath &fp)
|
|
Toshihiro Shimizu |
890ddd |
: TSmartObject(m_classCode), m_path(fp)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TSoundTrackReader::~TSoundTrackReader() {}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//===========================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TSoundTrackReaderP::TSoundTrackReaderP(const TFilePath &path)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
QString type = QString::fromStdString(toLower(path.getType()));
|
|
Toshihiro Shimizu |
890ddd |
std::map<qstring, *="" tsoundtrackreadercreateproc="">::iterator it;</qstring,>
|
|
Toshihiro Shimizu |
890ddd |
it = SoundTrackReaderTable.find(type);
|
|
Toshihiro Shimizu |
890ddd |
if (it != SoundTrackReaderTable.end()) {
|
|
Toshihiro Shimizu |
890ddd |
m_pointer = it->second(path);
|
|
Toshihiro Shimizu |
890ddd |
assert(m_pointer);
|
|
Toshihiro Shimizu |
890ddd |
m_pointer->addRef();
|
|
Toshihiro Shimizu |
890ddd |
} else {
|
|
Toshihiro Shimizu |
890ddd |
m_pointer = 0;
|
|
Toshihiro Shimizu |
890ddd |
throw TException(path.getWideString() + L": soundtrack reader not implemented");
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//===========================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TSoundTrackWriter::TSoundTrackWriter(const TFilePath &fp)
|
|
Toshihiro Shimizu |
890ddd |
: TSmartObject(m_classCode), m_path(fp)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TSoundTrackWriter::~TSoundTrackWriter() {}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//===========================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TSoundTrackWriterP::TSoundTrackWriterP(const TFilePath &path)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
QString type = QString::fromStdString(toLower(path.getType()));
|
|
Toshihiro Shimizu |
890ddd |
std::map<qstring, *="" tsoundtrackwritercreateproc="">::iterator it;</qstring,>
|
|
Toshihiro Shimizu |
890ddd |
it = SoundTrackWriterTable.find(type);
|
|
Toshihiro Shimizu |
890ddd |
if (it != SoundTrackWriterTable.end()) {
|
|
Toshihiro Shimizu |
890ddd |
m_pointer = it->second(path);
|
|
Toshihiro Shimizu |
890ddd |
assert(m_pointer);
|
|
Toshihiro Shimizu |
890ddd |
m_pointer->addRef();
|
|
Toshihiro Shimizu |
890ddd |
} else {
|
|
Toshihiro Shimizu |
890ddd |
m_pointer = 0;
|
|
Toshihiro Shimizu |
890ddd |
throw TException(path.getWideString() + L"soundtrack writer not implemented");
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//============================================================
|
|
Toshihiro Shimizu |
890ddd |
//
|
|
Toshihiro Shimizu |
890ddd |
// Helper functions statiche
|
|
Toshihiro Shimizu |
890ddd |
//
|
|
Toshihiro Shimizu |
890ddd |
//============================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
bool TSoundTrackReader::load(const TFilePath &path, TSoundTrackP &st)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
st = TSoundTrackReaderP(path)->load();
|
|
Toshihiro Shimizu |
890ddd |
return st;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void TSoundTrackReader::getSupportedFormats(QStringList &names)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
for (std::map<qstring, *="" tsoundtrackreadercreateproc="">::iterator it = SoundTrackReaderTable.begin();</qstring,>
|
|
Toshihiro Shimizu |
890ddd |
it != SoundTrackReaderTable.end();
|
|
Toshihiro Shimizu |
890ddd |
++it) {
|
|
Toshihiro Shimizu |
890ddd |
names.push_back(it->first);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
bool TSoundTrackWriter::save(const TFilePath &path, const TSoundTrackP &st)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return TSoundTrackWriterP(path)->save(st);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void TSoundTrackWriter::getSupportedFormats(QStringList &names)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
for (std::map<qstring, *="" tsoundtrackwritercreateproc="">::iterator it = SoundTrackWriterTable.begin();</qstring,>
|
|
Toshihiro Shimizu |
890ddd |
it != SoundTrackWriterTable.end();
|
|
Toshihiro Shimizu |
890ddd |
++it) {
|
|
Toshihiro Shimizu |
890ddd |
names.push_back(it->first);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//===========================================================
|
|
Toshihiro Shimizu |
890ddd |
//
|
|
Toshihiro Shimizu |
890ddd |
// funzioni per la registrazione dei formati (chiamate dal Plugin)
|
|
Toshihiro Shimizu |
890ddd |
//
|
|
Toshihiro Shimizu |
890ddd |
//===========================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void TSoundTrackReader::define(
|
|
Toshihiro Shimizu |
890ddd |
QString extension,
|
|
Toshihiro Shimizu |
890ddd |
TSoundTrackReaderCreateProc *proc)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
SoundTrackReaderTable[extension] = proc;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void TSoundTrackWriter::define(
|
|
Toshihiro Shimizu |
890ddd |
QString extension,
|
|
Toshihiro Shimizu |
890ddd |
TSoundTrackWriterCreateProc *proc)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
SoundTrackWriterTable[extension] = proc;
|
|
Toshihiro Shimizu |
890ddd |
}
|