Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 2 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 3 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 4 | |
michael@0 | 5 | #ifndef __AppleMP3Reader_h__ |
michael@0 | 6 | #define __AppleMP3Reader_h__ |
michael@0 | 7 | |
michael@0 | 8 | #include "MediaDecoderReader.h" |
michael@0 | 9 | #include "MP3FrameParser.h" |
michael@0 | 10 | #include "VideoUtils.h" |
michael@0 | 11 | |
michael@0 | 12 | #include <AudioToolbox/AudioToolbox.h> |
michael@0 | 13 | |
michael@0 | 14 | namespace mozilla { |
michael@0 | 15 | |
michael@0 | 16 | class AppleMP3Reader : public MediaDecoderReader |
michael@0 | 17 | { |
michael@0 | 18 | public: |
michael@0 | 19 | AppleMP3Reader(AbstractMediaDecoder *aDecoder); |
michael@0 | 20 | virtual ~AppleMP3Reader() MOZ_OVERRIDE; |
michael@0 | 21 | |
michael@0 | 22 | virtual nsresult Init(MediaDecoderReader* aCloneDonor) MOZ_OVERRIDE; |
michael@0 | 23 | |
michael@0 | 24 | nsresult PushDataToDemuxer(); |
michael@0 | 25 | |
michael@0 | 26 | virtual bool DecodeAudioData() MOZ_OVERRIDE; |
michael@0 | 27 | virtual bool DecodeVideoFrame(bool &aKeyframeSkip, |
michael@0 | 28 | int64_t aTimeThreshold) MOZ_OVERRIDE; |
michael@0 | 29 | |
michael@0 | 30 | virtual bool HasAudio() MOZ_OVERRIDE; |
michael@0 | 31 | virtual bool HasVideo() MOZ_OVERRIDE; |
michael@0 | 32 | |
michael@0 | 33 | virtual nsresult ReadMetadata(MediaInfo* aInfo, |
michael@0 | 34 | MetadataTags** aTags) MOZ_OVERRIDE; |
michael@0 | 35 | |
michael@0 | 36 | virtual nsresult Seek(int64_t aTime, |
michael@0 | 37 | int64_t aStartTime, |
michael@0 | 38 | int64_t aEndTime, |
michael@0 | 39 | int64_t aCurrentTime) MOZ_OVERRIDE; |
michael@0 | 40 | |
michael@0 | 41 | void AudioSampleCallback(UInt32 aNumBytes, |
michael@0 | 42 | UInt32 aNumPackets, |
michael@0 | 43 | const void *aData, |
michael@0 | 44 | AudioStreamPacketDescription *aPackets); |
michael@0 | 45 | |
michael@0 | 46 | void AudioMetadataCallback(AudioFileStreamID aFileStream, |
michael@0 | 47 | AudioFileStreamPropertyID aPropertyID, |
michael@0 | 48 | UInt32 *aFlags); |
michael@0 | 49 | |
michael@0 | 50 | virtual void NotifyDataArrived(const char* aBuffer, |
michael@0 | 51 | uint32_t aLength, |
michael@0 | 52 | int64_t aOffset) MOZ_OVERRIDE; |
michael@0 | 53 | |
michael@0 | 54 | private: |
michael@0 | 55 | void SetupDecoder(); |
michael@0 | 56 | nsresult Read(uint32_t *aNumBytes, char *aData); |
michael@0 | 57 | |
michael@0 | 58 | static OSStatus PassthroughInputDataCallback(AudioConverterRef aAudioConverter, |
michael@0 | 59 | UInt32 *aNumDataPackets, |
michael@0 | 60 | AudioBufferList *aData, |
michael@0 | 61 | AudioStreamPacketDescription **aPacketDesc, |
michael@0 | 62 | void *aUserData); |
michael@0 | 63 | |
michael@0 | 64 | // Initialisation has to be done in a callback, so we store the result here. |
michael@0 | 65 | bool mStreamReady; |
michael@0 | 66 | |
michael@0 | 67 | // Number of audio samples in an audio packet. Constant over all packets in a |
michael@0 | 68 | // stream. |
michael@0 | 69 | UInt32 mAudioFramesPerCompressedPacket; |
michael@0 | 70 | // Store the next audio frame to be played; so we can keep time when seeking. |
michael@0 | 71 | UInt64 mCurrentAudioFrame; |
michael@0 | 72 | UInt32 mAudioChannels; |
michael@0 | 73 | UInt32 mAudioSampleRate; |
michael@0 | 74 | |
michael@0 | 75 | uint64_t mDuration; |
michael@0 | 76 | |
michael@0 | 77 | AudioFileStreamID mAudioFileStream; |
michael@0 | 78 | AudioConverterRef mAudioConverter; |
michael@0 | 79 | |
michael@0 | 80 | MP3FrameParser mMP3FrameParser; |
michael@0 | 81 | }; |
michael@0 | 82 | |
michael@0 | 83 | } // namespace mozilla |
michael@0 | 84 | |
michael@0 | 85 | #endif // __AppleMP3Reader_h__ |