00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef _OGG_VORBIS_FILE_READER_H_
00017 #define _OGG_VORBIS_FILE_READER_H_
00018
00019 #ifdef HAVE_OGGZ
00020 #ifdef HAVE_FISHSOUND
00021
00022 #include "CodedAudioFileReader.h"
00023
00024 #include "base/Thread.h"
00025 #include <oggz/oggz.h>
00026 #include <fishsound/fishsound.h>
00027
00028 #include <set>
00029
00030 class QProgressDialog;
00031
00032 class OggVorbisFileReader : public CodedAudioFileReader
00033 {
00034 public:
00035 enum DecodeMode {
00036 DecodeAtOnce,
00037 DecodeThreaded
00038 };
00039
00040 OggVorbisFileReader(FileSource source,
00041 DecodeMode decodeMode,
00042 CacheMode cacheMode,
00043 size_t targetRate = 0);
00044 virtual ~OggVorbisFileReader();
00045
00046 virtual QString getError() const { return m_error; }
00047
00048 virtual QString getLocation() const { return m_source.getLocation(); }
00049 virtual QString getTitle() const { return m_title; }
00050 virtual QString getMaker() const { return m_maker; }
00051
00052 static void getSupportedExtensions(std::set<QString> &extensions);
00053 static bool supportsExtension(QString ext);
00054 static bool supportsContentType(QString type);
00055 static bool supports(FileSource &source);
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 FileSource m_source;
00065 QString m_path;
00066 QString m_error;
00067 QString m_title;
00068 QString m_maker;
00069
00070 OGGZ *m_oggz;
00071 FishSound *m_fishSound;
00072 QProgressDialog *m_progress;
00073 size_t m_fileSize;
00074 size_t m_bytesRead;
00075 bool m_commentsRead;
00076 bool m_cancelled;
00077 int m_completion;
00078
00079 static int readPacket(OGGZ *, ogg_packet *, long, void *);
00080 static int acceptFrames(FishSound *, float **, long, void *);
00081
00082 class DecodeThread : public Thread
00083 {
00084 public:
00085 DecodeThread(OggVorbisFileReader *reader) : m_reader(reader) { }
00086 virtual void run();
00087
00088 protected:
00089 OggVorbisFileReader *m_reader;
00090 };
00091
00092 DecodeThread *m_decodeThread;
00093 };
00094
00095 #endif
00096 #endif
00097
00098 #endif