1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 #ifndef __AppleMP3Reader_h__
6 #define __AppleMP3Reader_h__
8 #include "MediaDecoderReader.h"
9 #include "MP3FrameParser.h"
10 #include "VideoUtils.h"
12 #include <AudioToolbox/AudioToolbox.h>
16 class AppleMP3Reader
: public MediaDecoderReader
19 AppleMP3Reader(AbstractMediaDecoder
*aDecoder
);
20 virtual ~AppleMP3Reader() MOZ_OVERRIDE
;
22 virtual nsresult
Init(MediaDecoderReader
* aCloneDonor
) MOZ_OVERRIDE
;
24 nsresult
PushDataToDemuxer();
26 virtual bool DecodeAudioData() MOZ_OVERRIDE
;
27 virtual bool DecodeVideoFrame(bool &aKeyframeSkip
,
28 int64_t aTimeThreshold
) MOZ_OVERRIDE
;
30 virtual bool HasAudio() MOZ_OVERRIDE
;
31 virtual bool HasVideo() MOZ_OVERRIDE
;
33 virtual nsresult
ReadMetadata(MediaInfo
* aInfo
,
34 MetadataTags
** aTags
) MOZ_OVERRIDE
;
36 virtual nsresult
Seek(int64_t aTime
,
39 int64_t aCurrentTime
) MOZ_OVERRIDE
;
41 void AudioSampleCallback(UInt32 aNumBytes
,
44 AudioStreamPacketDescription
*aPackets
);
46 void AudioMetadataCallback(AudioFileStreamID aFileStream
,
47 AudioFileStreamPropertyID aPropertyID
,
50 virtual void NotifyDataArrived(const char* aBuffer
,
52 int64_t aOffset
) MOZ_OVERRIDE
;
56 nsresult
Read(uint32_t *aNumBytes
, char *aData
);
58 static OSStatus
PassthroughInputDataCallback(AudioConverterRef aAudioConverter
,
59 UInt32
*aNumDataPackets
,
60 AudioBufferList
*aData
,
61 AudioStreamPacketDescription
**aPacketDesc
,
64 // Initialisation has to be done in a callback, so we store the result here.
67 // Number of audio samples in an audio packet. Constant over all packets in a
69 UInt32 mAudioFramesPerCompressedPacket
;
70 // Store the next audio frame to be played; so we can keep time when seeking.
71 UInt64 mCurrentAudioFrame
;
72 UInt32 mAudioChannels
;
73 UInt32 mAudioSampleRate
;
77 AudioFileStreamID mAudioFileStream
;
78 AudioConverterRef mAudioConverter
;
80 MP3FrameParser mMP3FrameParser
;
83 } // namespace mozilla
85 #endif // __AppleMP3Reader_h__