Chris@1583: /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*-  vi:set ts=8 sts=4 sw=4: */
Chris@1583: 
Chris@1583: /*
Chris@1583:     Sonic Visualiser
Chris@1583:     An audio file viewer and annotation editor.
Chris@1583:     Centre for Digital Music, Queen Mary, University of London.
Chris@1583:     
Chris@1583:     This program is free software; you can redistribute it and/or
Chris@1583:     modify it under the terms of the GNU General Public License as
Chris@1583:     published by the Free Software Foundation; either version 2 of the
Chris@1583:     License, or (at your option) any later version.  See the file
Chris@1583:     COPYING included with this distribution for more information.
Chris@1583: */
Chris@1583: 
Chris@1583: #ifndef SV_BQA_FILE_READER_H
Chris@1583: #define SV_BQA_FILE_READER_H
Chris@1583: 
Chris@1583: #include <bqaudiostream/AudioReadStreamFactory.h>
Chris@1583: 
Chris@1583: #include "CodedAudioFileReader.h"
Chris@1583: #include "base/Thread.h"
Chris@1583: 
Chris@1583: #include <set>
Chris@1583: 
Chris@1583: class ProgressReporter;
Chris@1583: 
Chris@1583: /**
Chris@1583:  * Audio file reader using bqaudiostream library AudioReadStream
Chris@1583:  * classes.
Chris@1583:  */
Chris@1583: class BQAFileReader : public CodedAudioFileReader
Chris@1583: {
Chris@1583:     Q_OBJECT
Chris@1583: 
Chris@1583: public:
Chris@1583:     BQAFileReader(FileSource source,
Chris@1583:                   DecodeMode decodeMode,
Chris@1583:                   CacheMode cacheMode,
Chris@1583:                   sv_samplerate_t targetRate = 0,
Chris@1583:                   bool normalised = false,
Chris@1583:                   ProgressReporter *reporter = 0);
Chris@1583:     virtual ~BQAFileReader();
Chris@1583: 
Chris@1587:     QString getError() const override { return m_error; }
Chris@1587:     QString getLocation() const override { return m_source.getLocation(); }
Chris@1587:     QString getTitle() const override { return m_title; }
Chris@1587:     QString getMaker() const override { return m_maker; }
Chris@1583:     
Chris@1583:     static void getSupportedExtensions(std::set<QString> &extensions);
Chris@1583:     static bool supportsExtension(QString ext);
Chris@1583:     static bool supportsContentType(QString type);
Chris@1583:     static bool supports(FileSource &source);
Chris@1583: 
Chris@1587:     int getDecodeCompletion() const override { return m_completion; }
Chris@1583: 
Chris@1587:     bool isUpdating() const override {
Chris@1583:         return m_decodeThread && m_decodeThread->isRunning();
Chris@1583:     }
Chris@1583: 
Chris@1583: public slots:
Chris@1583:     void cancelled();
Chris@1583: 
Chris@1583: protected:
Chris@1583:     FileSource m_source;
Chris@1583:     QString m_path;
Chris@1583:     QString m_error;
Chris@1583:     QString m_title;
Chris@1583:     QString m_maker;
Chris@1583: 
Chris@1583:     breakfastquay::AudioReadStream *m_stream;
Chris@1583: 
Chris@1583:     bool m_cancelled;
Chris@1583:     int m_completion;
Chris@1583:     ProgressReporter *m_reporter;
Chris@1583:     
Chris@1583:     class DecodeThread : public Thread {
Chris@1583:     public:
Chris@1583:         DecodeThread(BQAFileReader *reader) : m_reader(reader) { }
Chris@1583:         virtual void run();
Chris@1583:     protected:
Chris@1583: 	BQAFileReader *m_reader;
Chris@1583:     };
Chris@1583:     DecodeThread *m_decodeThread;
Chris@1583: };
Chris@1583: 
Chris@1583: #endif
Chris@1583: