ScummVM API documentation
quicktime_intern.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
29 #ifndef AUDIO_QUICKTIME_INTERN_H
30 #define AUDIO_QUICKTIME_INTERN_H
31 
32 #include "common/formats/quicktime.h"
33 #include "common/scummsys.h"
34 #include "common/types.h"
35 
36 #include "audio/audiostream.h"
37 
38 namespace Common {
39  class SeekableReadStream;
40  class String;
41 }
42 
43 namespace Audio {
44 
45 class Codec;
46 
48 public:
50  virtual ~QuickTimeAudioDecoder();
51 
56  bool loadAudioFile(const Common::Path &filename);
57 
62  bool loadAudioStream(Common::SeekableReadStream *stream, DisposeAfterUse::Flag disposeFileHandle);
63 
64 protected:
66  public:
67  QuickTimeAudioTrack(QuickTimeAudioDecoder *decoder, Track *parentTrack);
69 
70  // AudioStream API
71  int readBuffer(int16 *buffer, const int numSamples);
72  bool isStereo() const { return _queue->isStereo(); }
73  int getRate() const { return _queue->getRate(); }
74  bool endOfData() const;
75 
76  // SeekableAudioStream API
77  bool seek(const Timestamp &where);
78  Timestamp getLength() const;
79 
80  // Queue *at least* "length" audio
81  // If length is zero, it queues the next logical block of audio whether
82  // that be a whole edit or just one chunk within an edit
83  void queueAudio(const Timestamp &length = Timestamp());
84  Track *getParent() const { return _parentTrack; }
85  void queueRemainingAudio();
86  bool hasDataInQueue() const { return _samplesQueued != 0; }
87 
88  private:
89  QuickTimeAudioDecoder *_decoder;
90  Track *_parentTrack;
91  QueuingAudioStream *_queue;
92  uint _curChunk;
93  Timestamp _curMediaPos, _skipSamples;
94  uint32 _curEdit, _samplesQueued;
95  bool _skipAACPrimer;
96 
97  QueuingAudioStream *createStream() const;
98  AudioStream *readAudioChunk(uint chunk);
99  bool isOldDemuxing() const;
100  void skipSamples(const Timestamp &length, AudioStream *stream);
101  void findEdit(const Timestamp &position);
102  bool allDataRead() const;
103  void enterNewEdit(const Timestamp &position);
104  void queueStream(AudioStream *stream, const Timestamp &length);
105  uint32 getAudioChunkSampleCount(uint chunk) const;
106  Timestamp getChunkLength(uint chunk, bool skipAACPrimer = false) const;
107  uint32 getAACSampleTime(uint32 totalSampleCount, bool skipAACPrimer = false) const;
108  Timestamp getCurrentTrackTime() const;
109  };
110 
112  public:
113  AudioSampleDesc(Common::QuickTimeParser::Track *parentTrack, uint32 codecTag);
114  ~AudioSampleDesc();
115 
116  bool isAudioCodecSupported() const;
117 
118  AudioStream *createAudioStream(Common::SeekableReadStream *stream) const;
119  void initCodec();
120 
121  // TODO: Make private in the long run
122  uint16 _bitsPerSample;
123  uint16 _channels;
124  uint32 _sampleRate;
125  uint32 _samplesPerFrame;
126  uint32 _bytesPerFrame;
127 
128  private:
129  Codec *_codec;
130  };
131 
132  // Common::QuickTimeParser API
133  virtual Common::QuickTimeParser::SampleDesc *readSampleDesc(Track *track, uint32 format, uint32 descSize);
134 
135  void init();
136 
138 };
139 
140 } // End of namespace Audio
141 
142 #endif
Definition: quicktime_intern.h:65
bool isStereo() const
Definition: quicktime_intern.h:72
Definition: array.h:52
Definition: quicktime.h:132
Definition: path.h:52
Definition: timestamp.h:83
Definition: stream.h:745
int getRate() const
Definition: quicktime_intern.h:73
Definition: quicktime.h:58
Definition: quicktime.h:276
Definition: audiostream.h:212
Definition: quicktime_intern.h:47
Definition: codec.h:40
Definition: algorithm.h:29
Definition: audiostream.h:50
Definition: audiostream.h:370
Definition: quicktime_intern.h:111
Definition: system.h:38