2013-09-14 01:14:42 +00:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#ifndef __AppleMP3Reader_h__
|
|
|
|
#define __AppleMP3Reader_h__
|
|
|
|
|
|
|
|
#include "MediaDecoderReader.h"
|
|
|
|
#include "MP3FrameParser.h"
|
|
|
|
#include "VideoUtils.h"
|
|
|
|
|
|
|
|
#include <AudioToolbox/AudioToolbox.h>
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
|
|
|
|
class AppleMP3Reader : public MediaDecoderReader
|
|
|
|
{
|
|
|
|
public:
|
2014-09-01 03:50:23 +00:00
|
|
|
explicit AppleMP3Reader(AbstractMediaDecoder *aDecoder);
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual ~AppleMP3Reader() override;
|
2013-09-14 01:14:42 +00:00
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual nsresult Init(MediaDecoderReader* aCloneDonor) override;
|
2013-09-14 01:14:42 +00:00
|
|
|
|
|
|
|
nsresult PushDataToDemuxer();
|
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual bool DecodeAudioData() override;
|
2013-09-14 01:14:42 +00:00
|
|
|
virtual bool DecodeVideoFrame(bool &aKeyframeSkip,
|
2015-03-21 16:28:04 +00:00
|
|
|
int64_t aTimeThreshold) override;
|
2013-09-14 01:14:42 +00:00
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual bool HasAudio() override;
|
|
|
|
virtual bool HasVideo() override;
|
2013-09-14 01:14:42 +00:00
|
|
|
|
2013-09-27 05:22:38 +00:00
|
|
|
virtual nsresult ReadMetadata(MediaInfo* aInfo,
|
2015-03-21 16:28:04 +00:00
|
|
|
MetadataTags** aTags) override;
|
2013-09-14 01:14:42 +00:00
|
|
|
|
2014-12-16 09:52:57 +00:00
|
|
|
virtual nsRefPtr<SeekPromise>
|
2015-03-21 16:28:04 +00:00
|
|
|
Seek(int64_t aTime, int64_t aEndTime) override;
|
2013-09-14 01:14:42 +00:00
|
|
|
|
|
|
|
void AudioSampleCallback(UInt32 aNumBytes,
|
|
|
|
UInt32 aNumPackets,
|
|
|
|
const void *aData,
|
|
|
|
AudioStreamPacketDescription *aPackets);
|
|
|
|
|
|
|
|
void AudioMetadataCallback(AudioFileStreamID aFileStream,
|
|
|
|
AudioFileStreamPropertyID aPropertyID,
|
|
|
|
UInt32 *aFlags);
|
|
|
|
|
2013-12-02 21:25:27 +00:00
|
|
|
virtual void NotifyDataArrived(const char* aBuffer,
|
|
|
|
uint32_t aLength,
|
2015-03-21 16:28:04 +00:00
|
|
|
int64_t aOffset) override;
|
2013-12-02 21:25:27 +00:00
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual bool IsMediaSeekable() override;
|
2014-06-23 10:08:34 +00:00
|
|
|
|
2013-09-14 01:14:42 +00:00
|
|
|
private:
|
|
|
|
void SetupDecoder();
|
2013-12-02 21:25:27 +00:00
|
|
|
nsresult Read(uint32_t *aNumBytes, char *aData);
|
2013-09-14 01:14:42 +00:00
|
|
|
|
|
|
|
static OSStatus PassthroughInputDataCallback(AudioConverterRef aAudioConverter,
|
|
|
|
UInt32 *aNumDataPackets,
|
|
|
|
AudioBufferList *aData,
|
|
|
|
AudioStreamPacketDescription **aPacketDesc,
|
|
|
|
void *aUserData);
|
|
|
|
|
|
|
|
// Initialisation has to be done in a callback, so we store the result here.
|
|
|
|
bool mStreamReady;
|
|
|
|
|
|
|
|
// Number of audio samples in an audio packet. Constant over all packets in a
|
|
|
|
// stream.
|
|
|
|
UInt32 mAudioFramesPerCompressedPacket;
|
|
|
|
// Store the next audio frame to be played; so we can keep time when seeking.
|
|
|
|
UInt64 mCurrentAudioFrame;
|
|
|
|
UInt32 mAudioChannels;
|
|
|
|
UInt32 mAudioSampleRate;
|
|
|
|
|
2013-09-23 05:23:56 +00:00
|
|
|
uint64_t mDuration;
|
2013-09-14 01:14:42 +00:00
|
|
|
|
|
|
|
AudioFileStreamID mAudioFileStream;
|
|
|
|
AudioConverterRef mAudioConverter;
|
|
|
|
|
|
|
|
MP3FrameParser mMP3FrameParser;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // __AppleMP3Reader_h__
|