svcore  1.9
QuickTimeFileReader.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-2007 Chris Cannam and QMUL.
8 
9  Based in part on QTAudioFile.h from SoundBite, copyright 2006
10  Chris Sutton and Mark Levy.
11 
12  This program is free software; you can redistribute it and/or
13  modify it under the terms of the GNU General Public License as
14  published by the Free Software Foundation; either version 2 of the
15  License, or (at your option) any later version. See the file
16  COPYING included with this distribution for more information.
17 */
18 
19 #ifndef _QUICKTIME_FILE_READER_H_
20 #define _QUICKTIME_FILE_READER_H_
21 
22 #ifdef HAVE_QUICKTIME
23 
24 #include "CodedAudioFileReader.h"
25 
26 #include "base/Thread.h"
27 
28 #include <set>
29 
30 class ProgressReporter;
31 
32 class QuickTimeFileReader : public CodedAudioFileReader
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 
42  QuickTimeFileReader(FileSource source,
43  DecodeMode decodeMode,
44  CacheMode cacheMode,
45  int targetRate = 0,
46  bool normalised = false,
47  ProgressReporter *reporter = 0);
48  virtual ~QuickTimeFileReader();
49 
50  virtual QString getError() const { return m_error; }
51  virtual QString getLocation() const { return m_source.getLocation(); }
52  virtual QString getTitle() const { return m_title; }
53 
54  static void getSupportedExtensions(std::set<QString> &extensions);
55  static bool supportsExtension(QString ext);
56  static bool supportsContentType(QString type);
57  static bool supports(FileSource &source);
58 
59  virtual int getDecodeCompletion() const { return m_completion; }
60 
61  virtual bool isUpdating() const {
62  return m_decodeThread && m_decodeThread->isRunning();
63  }
64 
65 public slots:
66  void cancelled();
67 
68 protected:
69  FileSource m_source;
70  QString m_path;
71  QString m_error;
72  QString m_title;
73 
74  class D;
75  D *m_d;
76 
77  ProgressReporter *m_reporter;
78  bool m_cancelled;
79  int m_completion;
80 
81  class DecodeThread : public Thread
82  {
83  public:
84  DecodeThread(QuickTimeFileReader *reader) : m_reader(reader) { }
85  virtual void run();
86 
87  protected:
88  QuickTimeFileReader *m_reader;
89  };
90 
91  DecodeThread *m_decodeThread;
92 };
93 
94 #endif
95 
96 #endif
virtual QString getError() const
virtual QString getLocation() const
Return the location of the audio data in the reader (as passed in to the FileSource constructor,...
virtual int getDecodeCompletion() const
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
Definition: Thread.h:24
virtual bool isUpdating() const
virtual QString getTitle() const
Return the title of the work in the audio file, if known.