content/media/apple/AppleMP3Reader.h

branch
TOR_BUG_9701
changeset 8
97036ab72558
equal deleted inserted replaced
-1:000000000000 0:a337cf13ef8f
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/. */
4
5 #ifndef __AppleMP3Reader_h__
6 #define __AppleMP3Reader_h__
7
8 #include "MediaDecoderReader.h"
9 #include "MP3FrameParser.h"
10 #include "VideoUtils.h"
11
12 #include <AudioToolbox/AudioToolbox.h>
13
14 namespace mozilla {
15
16 class AppleMP3Reader : public MediaDecoderReader
17 {
18 public:
19 AppleMP3Reader(AbstractMediaDecoder *aDecoder);
20 virtual ~AppleMP3Reader() MOZ_OVERRIDE;
21
22 virtual nsresult Init(MediaDecoderReader* aCloneDonor) MOZ_OVERRIDE;
23
24 nsresult PushDataToDemuxer();
25
26 virtual bool DecodeAudioData() MOZ_OVERRIDE;
27 virtual bool DecodeVideoFrame(bool &aKeyframeSkip,
28 int64_t aTimeThreshold) MOZ_OVERRIDE;
29
30 virtual bool HasAudio() MOZ_OVERRIDE;
31 virtual bool HasVideo() MOZ_OVERRIDE;
32
33 virtual nsresult ReadMetadata(MediaInfo* aInfo,
34 MetadataTags** aTags) MOZ_OVERRIDE;
35
36 virtual nsresult Seek(int64_t aTime,
37 int64_t aStartTime,
38 int64_t aEndTime,
39 int64_t aCurrentTime) MOZ_OVERRIDE;
40
41 void AudioSampleCallback(UInt32 aNumBytes,
42 UInt32 aNumPackets,
43 const void *aData,
44 AudioStreamPacketDescription *aPackets);
45
46 void AudioMetadataCallback(AudioFileStreamID aFileStream,
47 AudioFileStreamPropertyID aPropertyID,
48 UInt32 *aFlags);
49
50 virtual void NotifyDataArrived(const char* aBuffer,
51 uint32_t aLength,
52 int64_t aOffset) MOZ_OVERRIDE;
53
54 private:
55 void SetupDecoder();
56 nsresult Read(uint32_t *aNumBytes, char *aData);
57
58 static OSStatus PassthroughInputDataCallback(AudioConverterRef aAudioConverter,
59 UInt32 *aNumDataPackets,
60 AudioBufferList *aData,
61 AudioStreamPacketDescription **aPacketDesc,
62 void *aUserData);
63
64 // Initialisation has to be done in a callback, so we store the result here.
65 bool mStreamReady;
66
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;
74
75 uint64_t mDuration;
76
77 AudioFileStreamID mAudioFileStream;
78 AudioConverterRef mAudioConverter;
79
80 MP3FrameParser mMP3FrameParser;
81 };
82
83 } // namespace mozilla
84
85 #endif // __AppleMP3Reader_h__

mercurial