QuickTimeAudioFileReader.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 #ifdef WIN32
00029 #include <QTML.h>
00030 #include <Movies.h>
00031 #else
00032 #include <QuickTime/QuickTime.h>
00033 #endif
00034 
00035 #include <set>
00036 
00037 class QProgressDialog;
00038 
00039 class QuickTimeFileReader : public CodedAudioFileReader
00040 {
00041 public:
00042     enum DecodeMode {
00043         DecodeAtOnce, // decode the file on construction, with progress dialog
00044         DecodeThreaded // decode in a background thread after construction
00045     };
00046 
00047     OggVorbisFileReader(QString path, DecodeMode decodeMode,
00048                         CacheMode cacheMode);
00049     virtual ~OggVorbisFileReader();
00050 
00051     virtual QString getError() const { return m_error; }
00052 
00053     virtual QString getTitle() const { return m_title; }
00054     
00055     static void getSupportedExtensions(std::set<QString> &extensions);
00056 
00057     virtual int getDecodeCompletion() const { return m_completion; }
00058 
00059     virtual bool isUpdating() const {
00060         return m_decodeThread && m_decodeThread->isRunning();
00061     }
00062 
00063 protected:
00064     QString m_path;
00065     QString m_error;
00066     QString m_title;
00067 
00068     MovieAudioExtractionRef m_extractionSessionRef;
00069     AudioBufferList* m_buffer;
00070     OSErr m_qtError; 
00071     AudioStreamBasicDescription m_asbd;
00072     Movie m_movie;
00073 
00074     bool m_cancelled;
00075     int m_completion;
00076 
00077     class DecodeThread : public Thread
00078     {
00079     public:
00080         DecodeThread(OggVorbisFileReader *reader) : m_reader(reader) { }
00081         virtual void run();
00082 
00083     protected:
00084         OggVorbisFileReader *m_reader; 
00085     };
00086 
00087     DecodeThread *m_decodeThread;
00088 };
00089 
00090 #endif
00091 #endif
00092 
00093 #endif

Generated on Wed Feb 20 15:45:27 2008 for SonicVisualiser by  doxygen 1.5.1