bool
QuickTimeFileReader::supportsExtension(QString extension)
{
    std::set<QString> extensions;
    getSupportedExtensions(extensions);
    return (extensions.find(extension.toLower()) != extensions.end());
}
Example #2
0
const QStringList& ContentFactory::getSupportedFilesFilter()
{
    static QStringList filters;

    if (filters.empty())
    {
        for (const auto& ext : getSupportedExtensions())
            filters.append("*." + ext);
    }

    return filters;
}
Example #3
0
void rspfGdalFactory::getImageHandlersBySuffix(rspfImageHandlerFactoryBase::ImageHandlerList& result, const rspfString& ext)const
{
   rspfImageHandlerFactoryBase::UniqueStringList extList;
   getSupportedExtensions(extList);
   
   rspfString testExt = ext.downcase();
   
   if(std::find(extList.getList().begin(),
                extList.getList().end(), testExt) != extList.getList().end())
   {
      result.push_back(new rspfGdalTileSource);
   }
}
namespace breakfastquay
{

static vector<string>
getSupportedExtensions()
{
    vector<string> extensions;
    int count;
    
    if (sf_command(0, SFC_GET_FORMAT_MAJOR_COUNT, &count, sizeof(count))) {
        extensions.push_back("wav");
        extensions.push_back("aiff");
        extensions.push_back("aifc");
        extensions.push_back("aif");
        return extensions;
    }

    SF_FORMAT_INFO info;
    for (int i = 0; i < count; ++i) {
        info.format = i;
        if (!sf_command(0, SFC_GET_FORMAT_MAJOR, &info, sizeof(info))) {
            extensions.push_back(string(info.extension));
        }
    }

    return extensions;
}

static
AudioReadStreamBuilder<WavFileReadStream>
wavbuilder(
    string("http://breakfastquay.com/rdf/turbot/audiostream/WavFileReadStream"),
    getSupportedExtensions()
    );

WavFileReadStream::WavFileReadStream(string path) :
    m_file(0),
    m_path(path),
    m_offset(0)
{
    m_channelCount = 0;
    m_sampleRate = 0;

    m_fileInfo.format = 0;
    m_fileInfo.frames = 0;
    m_file = sf_open(m_path.c_str(), SFM_READ, &m_fileInfo);

    if (!m_file || m_fileInfo.frames <= 0 || m_fileInfo.channels <= 0) {
	cerr << "WavFileReadStream::initialize: Failed to open file \""
                  << path << "\" (" << sf_strerror(m_file) << ")" << endl;
        if (sf_error(m_file) == SF_ERR_SYSTEM) {
	    m_error = string("Couldn't load audio file '") +
                m_path + "':\n" + sf_strerror(m_file);
            throw FileNotFound(m_path);
        }
	if (m_file) {
	    m_error = string("Couldn't load audio file '") +
                m_path + "':\n" + sf_strerror(m_file);
	} else {
	    m_error = string("Failed to open audio file '") +
		m_path + "'";
	}
        throw InvalidFileFormat(m_path, m_error);
    }

    m_channelCount = m_fileInfo.channels;
    m_sampleRate = m_fileInfo.samplerate;

    sf_seek(m_file, 0, SEEK_SET);
}

WavFileReadStream::~WavFileReadStream()
{
    if (m_file) sf_close(m_file);
}

size_t
WavFileReadStream::getFrames(size_t count, float *frames)
{
    if (!m_file || !m_channelCount) return 0;
    if (count == 0) return 0;

    if ((long)m_offset >= m_fileInfo.frames) {
	return 0;
    }

    sf_count_t readCount = 0;

    if ((readCount = sf_readf_float(m_file, frames, count)) < 0) {
        return 0;
    }

    m_offset = m_offset + readCount;

    return readCount;
}

}