|
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)
|
|
Shinya Kitaoka |
120a6e |
: TSmartObject(m_classCode), m_path(fp) {}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TSoundTrackReader::~TSoundTrackReader() {}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//===========================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TSoundTrackReaderP::TSoundTrackReaderP(const TFilePath &path) {
|
|
Shinya Kitaoka |
120a6e |
QString type = QString::fromStdString(toLower(path.getType()));
|
|
Shinya Kitaoka |
120a6e |
std::map<qstring, *="" tsoundtrackreadercreateproc="">::iterator it;</qstring,>
|
|
Shinya Kitaoka |
120a6e |
it = SoundTrackReaderTable.find(type);
|
|
Shinya Kitaoka |
120a6e |
if (it != SoundTrackReaderTable.end()) {
|
|
Shinya Kitaoka |
120a6e |
m_pointer = it->second(path);
|
|
Shinya Kitaoka |
120a6e |
assert(m_pointer);
|
|
Shinya Kitaoka |
120a6e |
m_pointer->addRef();
|
|
Shinya Kitaoka |
120a6e |
} else {
|
|
Shinya Kitaoka |
120a6e |
m_pointer = 0;
|
|
Shinya Kitaoka |
120a6e |
throw TException(path.getWideString() +
|
|
Shinya Kitaoka |
120a6e |
L": soundtrack reader not implemented");
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//===========================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TSoundTrackWriter::TSoundTrackWriter(const TFilePath &fp)
|
|
Shinya Kitaoka |
120a6e |
: TSmartObject(m_classCode), m_path(fp) {}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TSoundTrackWriter::~TSoundTrackWriter() {}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//===========================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TSoundTrackWriterP::TSoundTrackWriterP(const TFilePath &path) {
|
|
Shinya Kitaoka |
120a6e |
QString type = QString::fromStdString(toLower(path.getType()));
|
|
Shinya Kitaoka |
120a6e |
std::map<qstring, *="" tsoundtrackwritercreateproc="">::iterator it;</qstring,>
|
|
Shinya Kitaoka |
120a6e |
it = SoundTrackWriterTable.find(type);
|
|
Shinya Kitaoka |
120a6e |
if (it != SoundTrackWriterTable.end()) {
|
|
Shinya Kitaoka |
120a6e |
m_pointer = it->second(path);
|
|
Shinya Kitaoka |
120a6e |
assert(m_pointer);
|
|
Shinya Kitaoka |
120a6e |
m_pointer->addRef();
|
|
Shinya Kitaoka |
120a6e |
} else {
|
|
Shinya Kitaoka |
120a6e |
m_pointer = 0;
|
|
Shinya Kitaoka |
120a6e |
throw TException(path.getWideString() +
|
|
Shinya Kitaoka |
120a6e |
L"soundtrack writer not implemented");
|
|
Shinya Kitaoka |
120a6e |
}
|
|
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 |
|
|
Shinya Kitaoka |
120a6e |
bool TSoundTrackReader::load(const TFilePath &path, TSoundTrackP &st) {
|
|
Shinya Kitaoka |
120a6e |
st = TSoundTrackReaderP(path)->load();
|
|
Shinya Kitaoka |
120a6e |
return st;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void TSoundTrackReader::getSupportedFormats(QStringList &names) {
|
|
Shinya Kitaoka |
120a6e |
for (std::map<qstring, *="" tsoundtrackreadercreateproc="">::iterator it =</qstring,>
|
|
Shinya Kitaoka |
120a6e |
SoundTrackReaderTable.begin();
|
|
Shinya Kitaoka |
120a6e |
it != SoundTrackReaderTable.end(); ++it) {
|
|
Shinya Kitaoka |
120a6e |
names.push_back(it->first);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
bool TSoundTrackWriter::save(const TFilePath &path, const TSoundTrackP &st) {
|
|
Shinya Kitaoka |
120a6e |
return TSoundTrackWriterP(path)->save(st);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void TSoundTrackWriter::getSupportedFormats(QStringList &names) {
|
|
Shinya Kitaoka |
120a6e |
for (std::map<qstring, *="" tsoundtrackwritercreateproc="">::iterator it =</qstring,>
|
|
Shinya Kitaoka |
120a6e |
SoundTrackWriterTable.begin();
|
|
Shinya Kitaoka |
120a6e |
it != SoundTrackWriterTable.end(); ++it) {
|
|
Shinya Kitaoka |
120a6e |
names.push_back(it->first);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
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 |
|
|
Shinya Kitaoka |
120a6e |
void TSoundTrackReader::define(QString extension,
|
|
Shinya Kitaoka |
120a6e |
TSoundTrackReaderCreateProc *proc) {
|
|
Shinya Kitaoka |
120a6e |
SoundTrackReaderTable[extension] = proc;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void TSoundTrackWriter::define(QString extension,
|
|
Shinya Kitaoka |
120a6e |
TSoundTrackWriterCreateProc *proc) {
|
|
Shinya Kitaoka |
120a6e |
SoundTrackWriterTable[extension] = proc;
|
|
Toshihiro Shimizu |
890ddd |
}
|