content/media/apple/AppleMP3Reader.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/content/media/apple/AppleMP3Reader.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,85 @@
     1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.7 +
     1.8 +#ifndef __AppleMP3Reader_h__
     1.9 +#define __AppleMP3Reader_h__
    1.10 +
    1.11 +#include "MediaDecoderReader.h"
    1.12 +#include "MP3FrameParser.h"
    1.13 +#include "VideoUtils.h"
    1.14 +
    1.15 +#include <AudioToolbox/AudioToolbox.h>
    1.16 +
    1.17 +namespace mozilla {
    1.18 +
    1.19 +class AppleMP3Reader : public MediaDecoderReader
    1.20 +{
    1.21 +public:
    1.22 +  AppleMP3Reader(AbstractMediaDecoder *aDecoder);
    1.23 +  virtual ~AppleMP3Reader() MOZ_OVERRIDE;
    1.24 +
    1.25 +  virtual nsresult Init(MediaDecoderReader* aCloneDonor) MOZ_OVERRIDE;
    1.26 +
    1.27 +  nsresult PushDataToDemuxer();
    1.28 +
    1.29 +  virtual bool DecodeAudioData() MOZ_OVERRIDE;
    1.30 +  virtual bool DecodeVideoFrame(bool &aKeyframeSkip,
    1.31 +                                int64_t aTimeThreshold) MOZ_OVERRIDE;
    1.32 +
    1.33 +  virtual bool HasAudio() MOZ_OVERRIDE;
    1.34 +  virtual bool HasVideo() MOZ_OVERRIDE;
    1.35 +
    1.36 +  virtual nsresult ReadMetadata(MediaInfo* aInfo,
    1.37 +                                MetadataTags** aTags) MOZ_OVERRIDE;
    1.38 +
    1.39 +  virtual nsresult Seek(int64_t aTime,
    1.40 +                        int64_t aStartTime,
    1.41 +                        int64_t aEndTime,
    1.42 +                        int64_t aCurrentTime) MOZ_OVERRIDE;
    1.43 +
    1.44 +  void AudioSampleCallback(UInt32 aNumBytes,
    1.45 +                           UInt32 aNumPackets,
    1.46 +                           const void *aData,
    1.47 +                           AudioStreamPacketDescription *aPackets);
    1.48 +
    1.49 +  void AudioMetadataCallback(AudioFileStreamID aFileStream,
    1.50 +                             AudioFileStreamPropertyID aPropertyID,
    1.51 +                             UInt32 *aFlags);
    1.52 +
    1.53 +  virtual void NotifyDataArrived(const char* aBuffer,
    1.54 +                                 uint32_t aLength,
    1.55 +                                 int64_t aOffset) MOZ_OVERRIDE;
    1.56 +
    1.57 +private:
    1.58 +  void SetupDecoder();
    1.59 +  nsresult Read(uint32_t *aNumBytes, char *aData);
    1.60 +
    1.61 +  static OSStatus PassthroughInputDataCallback(AudioConverterRef aAudioConverter,
    1.62 +                                               UInt32 *aNumDataPackets,
    1.63 +                                               AudioBufferList *aData,
    1.64 +                                               AudioStreamPacketDescription **aPacketDesc,
    1.65 +                                               void *aUserData);
    1.66 +
    1.67 +  // Initialisation has to be done in a callback, so we store the result here.
    1.68 +  bool mStreamReady;
    1.69 +
    1.70 +  // Number of audio samples in an audio packet. Constant over all packets in a
    1.71 +  // stream.
    1.72 +  UInt32 mAudioFramesPerCompressedPacket;
    1.73 +  // Store the next audio frame to be played; so we can keep time when seeking.
    1.74 +  UInt64 mCurrentAudioFrame;
    1.75 +  UInt32 mAudioChannels;
    1.76 +  UInt32 mAudioSampleRate;
    1.77 +
    1.78 +  uint64_t mDuration;
    1.79 +
    1.80 +  AudioFileStreamID mAudioFileStream;
    1.81 +  AudioConverterRef mAudioConverter;
    1.82 +
    1.83 +  MP3FrameParser mMP3FrameParser;
    1.84 +};
    1.85 +
    1.86 +} // namespace mozilla
    1.87 +
    1.88 +#endif // __AppleMP3Reader_h__

mercurial