michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef __AppleMP3Reader_h__ michael@0: #define __AppleMP3Reader_h__ michael@0: michael@0: #include "MediaDecoderReader.h" michael@0: #include "MP3FrameParser.h" michael@0: #include "VideoUtils.h" michael@0: michael@0: #include michael@0: michael@0: namespace mozilla { michael@0: michael@0: class AppleMP3Reader : public MediaDecoderReader michael@0: { michael@0: public: michael@0: AppleMP3Reader(AbstractMediaDecoder *aDecoder); michael@0: virtual ~AppleMP3Reader() MOZ_OVERRIDE; michael@0: michael@0: virtual nsresult Init(MediaDecoderReader* aCloneDonor) MOZ_OVERRIDE; michael@0: michael@0: nsresult PushDataToDemuxer(); michael@0: michael@0: virtual bool DecodeAudioData() MOZ_OVERRIDE; michael@0: virtual bool DecodeVideoFrame(bool &aKeyframeSkip, michael@0: int64_t aTimeThreshold) MOZ_OVERRIDE; michael@0: michael@0: virtual bool HasAudio() MOZ_OVERRIDE; michael@0: virtual bool HasVideo() MOZ_OVERRIDE; michael@0: michael@0: virtual nsresult ReadMetadata(MediaInfo* aInfo, michael@0: MetadataTags** aTags) MOZ_OVERRIDE; michael@0: michael@0: virtual nsresult Seek(int64_t aTime, michael@0: int64_t aStartTime, michael@0: int64_t aEndTime, michael@0: int64_t aCurrentTime) MOZ_OVERRIDE; michael@0: michael@0: void AudioSampleCallback(UInt32 aNumBytes, michael@0: UInt32 aNumPackets, michael@0: const void *aData, michael@0: AudioStreamPacketDescription *aPackets); michael@0: michael@0: void AudioMetadataCallback(AudioFileStreamID aFileStream, michael@0: AudioFileStreamPropertyID aPropertyID, michael@0: UInt32 *aFlags); michael@0: michael@0: virtual void NotifyDataArrived(const char* aBuffer, michael@0: uint32_t aLength, michael@0: int64_t aOffset) MOZ_OVERRIDE; michael@0: michael@0: private: michael@0: void SetupDecoder(); michael@0: nsresult Read(uint32_t *aNumBytes, char *aData); michael@0: michael@0: static OSStatus PassthroughInputDataCallback(AudioConverterRef aAudioConverter, michael@0: UInt32 *aNumDataPackets, michael@0: AudioBufferList *aData, michael@0: AudioStreamPacketDescription **aPacketDesc, michael@0: void *aUserData); michael@0: michael@0: // Initialisation has to be done in a callback, so we store the result here. michael@0: bool mStreamReady; michael@0: michael@0: // Number of audio samples in an audio packet. Constant over all packets in a michael@0: // stream. michael@0: UInt32 mAudioFramesPerCompressedPacket; michael@0: // Store the next audio frame to be played; so we can keep time when seeking. michael@0: UInt64 mCurrentAudioFrame; michael@0: UInt32 mAudioChannels; michael@0: UInt32 mAudioSampleRate; michael@0: michael@0: uint64_t mDuration; michael@0: michael@0: AudioFileStreamID mAudioFileStream; michael@0: AudioConverterRef mAudioConverter; michael@0: michael@0: MP3FrameParser mMP3FrameParser; michael@0: }; michael@0: michael@0: } // namespace mozilla michael@0: michael@0: #endif // __AppleMP3Reader_h__