svcore  1.9
OggVorbisFileReader.h
Go to the documentation of this file.
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
2 
3 /*
4  Sonic Visualiser
5  An audio file viewer and annotation editor.
6  Centre for Digital Music, Queen Mary, University of London.
7  This file copyright 2006 Chris Cannam.
8 
9  This program is free software; you can redistribute it and/or
10  modify it under the terms of the GNU General Public License as
11  published by the Free Software Foundation; either version 2 of the
12  License, or (at your option) any later version. See the file
13  COPYING included with this distribution for more information.
14 */
15 
16 #ifndef _OGG_VORBIS_FILE_READER_H_
17 #define _OGG_VORBIS_FILE_READER_H_
18 
19 #ifdef HAVE_OGGZ
20 #ifdef HAVE_FISHSOUND
21 
22 #include "CodedAudioFileReader.h"
23 
24 #include "base/Thread.h"
25 #include <oggz/oggz.h>
26 #include <fishsound/fishsound.h>
27 
28 #include <set>
29 
30 class ProgressReporter;
31 
33 {
34  Q_OBJECT
35 
36 public:
37  enum DecodeMode {
38  DecodeAtOnce, // decode the file on construction, with progress
39  DecodeThreaded // decode in a background thread after construction
40  };
41 
43  DecodeMode decodeMode,
44  CacheMode cacheMode,
45  int targetRate = 0,
46  bool normalised = false,
47  ProgressReporter *reporter = 0);
48  virtual ~OggVorbisFileReader();
49 
50  virtual QString getError() const { return m_error; }
51 
52  virtual QString getLocation() const { return m_source.getLocation(); }
53  virtual QString getTitle() const { return m_title; }
54  virtual QString getMaker() const { return m_maker; }
55  virtual TagMap getTags() const { return m_tags; }
56 
57  static void getSupportedExtensions(std::set<QString> &extensions);
58  static bool supportsExtension(QString ext);
59  static bool supportsContentType(QString type);
60  static bool supports(FileSource &source);
61 
62  virtual int getDecodeCompletion() const { return m_completion; }
63 
64  virtual bool isUpdating() const {
65  return m_decodeThread && m_decodeThread->isRunning();
66  }
67 
68 public slots:
69  void cancelled();
70 
71 protected:
73  QString m_path;
74  QString m_error;
75  QString m_title;
76  QString m_maker;
78 
79  OGGZ *m_oggz;
80  FishSound *m_fishSound;
87 
88  static int readPacket(OGGZ *, ogg_packet *, long, void *);
89  static int acceptFrames(FishSound *, float **, long, void *);
90 
91  class DecodeThread : public Thread
92  {
93  public:
94  DecodeThread(OggVorbisFileReader *reader) : m_reader(reader) { }
95  virtual void run();
96 
97  protected:
99  };
100 
102 };
103 
104 #endif
105 #endif
106 
107 #endif
virtual int getDecodeCompletion() const
virtual bool isUpdating() const
DecodeThread(OggVorbisFileReader *reader)
QString getLocation() const
Return the location filename or URL as passed to the constructor.
Definition: FileSource.cpp:595
OggVorbisFileReader(FileSource source, DecodeMode decodeMode, CacheMode cacheMode, int targetRate=0, bool normalised=false, ProgressReporter *reporter=0)
static void getSupportedExtensions(std::set< QString > &extensions)
DecodeThread * m_decodeThread
virtual QString getError() const
std::map< QString, QString > TagMap
virtual TagMap getTags() const
static int readPacket(OGGZ *, ogg_packet *, long, void *)
FileSource is a class used to refer to the contents of a file that may be either local or at a remote...
Definition: FileSource.h:59
virtual QString getTitle() const
Return the title of the work in the audio file, if known.
Definition: Thread.h:24
virtual QString getMaker() const
Return the "maker" of the work in the audio file, if known.
static bool supportsContentType(QString type)
static int acceptFrames(FishSound *, float **, long, void *)
ProgressReporter * m_reporter
static bool supports(FileSource &source)
virtual QString getLocation() const
Return the location of the audio data in the reader (as passed in to the FileSource constructor,...
static bool supportsExtension(QString ext)