svcore  1.9
QuickTimeFileReader.h
Go to the documentation of this file.
00001 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*-  vi:set ts=8 sts=4 sw=4: */
00002 
00003 /*
00004     Sonic Visualiser
00005     An audio file viewer and annotation editor.
00006     Centre for Digital Music, Queen Mary, University of London.
00007     This file copyright 2006-2007 Chris Cannam and QMUL.
00008 
00009     Based in part on QTAudioFile.h from SoundBite, copyright 2006
00010     Chris Sutton and Mark Levy.
00011     
00012     This program is free software; you can redistribute it and/or
00013     modify it under the terms of the GNU General Public License as
00014     published by the Free Software Foundation; either version 2 of the
00015     License, or (at your option) any later version.  See the file
00016     COPYING included with this distribution for more information.
00017 */
00018 
00019 #ifndef _QUICKTIME_FILE_READER_H_
00020 #define _QUICKTIME_FILE_READER_H_
00021 
00022 #ifdef HAVE_QUICKTIME
00023 
00024 #include "CodedAudioFileReader.h"
00025 
00026 #include "base/Thread.h"
00027 
00028 #include <set>
00029 
00030 class ProgressReporter;
00031 
00032 class QuickTimeFileReader : public CodedAudioFileReader
00033 {
00034     Q_OBJECT
00035 
00036 public:
00037     enum DecodeMode {
00038         DecodeAtOnce, // decode the file on construction, with progress
00039         DecodeThreaded // decode in a background thread after construction
00040     };
00041 
00042     QuickTimeFileReader(FileSource source,
00043                         DecodeMode decodeMode,
00044                         CacheMode cacheMode,
00045                         int targetRate = 0,
00046                         bool normalised = false,
00047                         ProgressReporter *reporter = 0);
00048     virtual ~QuickTimeFileReader();
00049 
00050     virtual QString getError() const { return m_error; }
00051     virtual QString getLocation() const { return m_source.getLocation(); }
00052     virtual QString getTitle() const { return m_title; }
00053     
00054     static void getSupportedExtensions(std::set<QString> &extensions);
00055     static bool supportsExtension(QString ext);
00056     static bool supportsContentType(QString type);
00057     static bool supports(FileSource &source);
00058 
00059     virtual int getDecodeCompletion() const { return m_completion; }
00060 
00061     virtual bool isUpdating() const {
00062         return m_decodeThread && m_decodeThread->isRunning();
00063     }
00064 
00065 public slots:
00066     void cancelled();
00067 
00068 protected:
00069     FileSource m_source;
00070     QString m_path;
00071     QString m_error;
00072     QString m_title;
00073 
00074     class D;
00075     D *m_d;
00076 
00077     ProgressReporter *m_reporter;
00078     bool m_cancelled;
00079     int m_completion;
00080 
00081     class DecodeThread : public Thread
00082     {
00083     public:
00084         DecodeThread(QuickTimeFileReader *reader) : m_reader(reader) { }
00085         virtual void run();
00086 
00087     protected:
00088         QuickTimeFileReader *m_reader; 
00089     };
00090 
00091     DecodeThread *m_decodeThread;
00092 };
00093 
00094 #endif
00095 
00096 #endif