ResidualVM logo ResidualVM website - Forums - Contact us BuildBot - Doxygen - Wiki curved edge

quicktime_intern.h

Go to the documentation of this file.
00001 /* ScummVM - Graphic Adventure Engine
00002  *
00003  * ScummVM is the legal property of its developers, whose names
00004  * are too numerous to list here. Please refer to the COPYRIGHT
00005  * file distributed with this source distribution.
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * as published by the Free Software Foundation; either version 2
00010  * of the License, or (at your option) any later version.
00011  *
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00020  *
00021  */
00022 
00030 #ifndef AUDIO_QUICKTIME_INTERN_H
00031 #define AUDIO_QUICKTIME_INTERN_H
00032 
00033 #include "common/quicktime.h"
00034 #include "common/scummsys.h"
00035 #include "common/types.h"
00036 
00037 #include "audio/audiostream.h"
00038 
00039 namespace Common {
00040     class SeekableReadStream;
00041     class String;
00042 }
00043 
00044 namespace Audio {
00045 
00046 class Codec;
00047 
00048 class QuickTimeAudioDecoder : public Common::QuickTimeParser {
00049 public:
00050     QuickTimeAudioDecoder();
00051     virtual ~QuickTimeAudioDecoder();
00052 
00057     bool loadAudioFile(const Common::String &filename);
00058 
00063     bool loadAudioStream(Common::SeekableReadStream *stream, DisposeAfterUse::Flag disposeFileHandle);
00064 
00065 protected:
00066     class QuickTimeAudioTrack : public SeekableAudioStream {
00067     public:
00068         QuickTimeAudioTrack(QuickTimeAudioDecoder *decoder, Track *parentTrack);
00069         ~QuickTimeAudioTrack();
00070 
00071         // AudioStream API
00072         int readBuffer(int16 *buffer, const int numSamples);
00073         bool isStereo() const { return _queue->isStereo(); }
00074         int getRate() const { return _queue->getRate(); }
00075         bool endOfData() const;
00076 
00077         // SeekableAudioStream API
00078         bool seek(const Timestamp &where);
00079         Timestamp getLength() const;
00080 
00081         // Queue *at least* "length" audio
00082         // If length is zero, it queues the next logical block of audio whether
00083         // that be a whole edit or just one chunk within an edit
00084         void queueAudio(const Timestamp &length = Timestamp());
00085         Track *getParent() const { return _parentTrack; }
00086         void queueRemainingAudio();
00087         bool hasDataInQueue() const { return _samplesQueued != 0; }
00088 
00089     private:
00090         QuickTimeAudioDecoder *_decoder;
00091         Track *_parentTrack;
00092         QueuingAudioStream *_queue;
00093         uint _curChunk;
00094         Timestamp _curMediaPos, _skipSamples;
00095         uint32 _curEdit, _samplesQueued;
00096         bool _skipAACPrimer;
00097 
00098         QueuingAudioStream *createStream() const;
00099         AudioStream *readAudioChunk(uint chunk);
00100         bool isOldDemuxing() const;
00101         void skipSamples(const Timestamp &length, AudioStream *stream);
00102         void findEdit(const Timestamp &position);
00103         bool allDataRead() const;
00104         void enterNewEdit(const Timestamp &position);
00105         void queueStream(AudioStream *stream, const Timestamp &length);
00106         uint32 getAudioChunkSampleCount(uint chunk) const;
00107         Timestamp getChunkLength(uint chunk, bool skipAACPrimer = false) const;
00108         uint32 getAACSampleTime(uint32 totalSampleCount, bool skipAACPrimer = false) const;
00109         Timestamp getCurrentTrackTime() const;
00110     };
00111 
00112     class AudioSampleDesc : public Common::QuickTimeParser::SampleDesc {
00113     public:
00114         AudioSampleDesc(Common::QuickTimeParser::Track *parentTrack, uint32 codecTag);
00115         ~AudioSampleDesc();
00116 
00117         bool isAudioCodecSupported() const;
00118 
00119         AudioStream *createAudioStream(Common::SeekableReadStream *stream) const;
00120         void initCodec();
00121 
00122         // TODO: Make private in the long run
00123         uint16 _bitsPerSample;
00124         uint16 _channels;
00125         uint32 _sampleRate;
00126         uint32 _samplesPerFrame;
00127         uint32 _bytesPerFrame;
00128 
00129     private:
00130         Codec *_codec;
00131     };
00132 
00133     // Common::QuickTimeParser API
00134     virtual Common::QuickTimeParser::SampleDesc *readSampleDesc(Track *track, uint32 format, uint32 descSize);
00135 
00136     void init();
00137 
00138     Common::Array<QuickTimeAudioTrack *> _audioTracks;
00139 };
00140 
00141 } // End of namespace Audio
00142 
00143 #endif


Generated on Sat Oct 19 2019 05:00:47 for ResidualVM by doxygen 1.7.1
curved edge   curved edge