Backout a74bd5095902, Bug 959405 - Please update the Buri Moz-central, 1.3, 1.2 with...
[gecko.git] / content / media / apple / AppleMP3Reader.h
blob67beec2b6a7494b5fa9ec87f83d050176a59f976
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>
14 namespace mozilla {
16 class AppleMP3Reader : public MediaDecoderReader
18 public:
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,
37 int64_t aStartTime,
38 int64_t aEndTime,
39 int64_t aCurrentTime) MOZ_OVERRIDE;
41 void AudioSampleCallback(UInt32 aNumBytes,
42 UInt32 aNumPackets,
43 const void *aData,
44 AudioStreamPacketDescription *aPackets);
46 void AudioMetadataCallback(AudioFileStreamID aFileStream,
47 AudioFileStreamPropertyID aPropertyID,
48 UInt32 *aFlags);
50 virtual void NotifyDataArrived(const char* aBuffer,
51 uint32_t aLength,
52 int64_t aOffset) MOZ_OVERRIDE;
54 private:
55 void SetupDecoder();
56 nsresult Read(uint32_t *aNumBytes, char *aData);
58 static OSStatus PassthroughInputDataCallback(AudioConverterRef aAudioConverter,
59 UInt32 *aNumDataPackets,
60 AudioBufferList *aData,
61 AudioStreamPacketDescription **aPacketDesc,
62 void *aUserData);
64 // Initialisation has to be done in a callback, so we store the result here.
65 bool mStreamReady;
67 // Number of audio samples in an audio packet. Constant over all packets in a
68 // stream.
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;
75 uint64_t mDuration;
77 AudioFileStreamID mAudioFileStream;
78 AudioConverterRef mAudioConverter;
80 MP3FrameParser mMP3FrameParser;
83 } // namespace mozilla
85 #endif // __AppleMP3Reader_h__