FFmpegAudioDecoder.h (2156B)
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* vim:set ts=2 sw=2 sts=2 et cindent: */ 3 /* This Source Code Form is subject to the terms of the Mozilla Public 4 * License, v. 2.0. If a copy of the MPL was not distributed with this 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 7 #ifndef __FFmpegAACDecoder_h__ 8 #define __FFmpegAACDecoder_h__ 9 10 #include "FFmpegDataDecoder.h" 11 #include "FFmpegLibWrapper.h" 12 13 namespace mozilla { 14 15 template <int V> 16 class FFmpegAudioDecoder {}; 17 18 template <> 19 class FFmpegAudioDecoder<LIBAV_VER>; 20 DDLoggedTypeNameAndBase(FFmpegAudioDecoder<LIBAV_VER>, 21 FFmpegDataDecoder<LIBAV_VER>); 22 23 template <> 24 class FFmpegAudioDecoder<LIBAV_VER> 25 : public FFmpegDataDecoder<LIBAV_VER>, 26 public DecoderDoctorLifeLogger<FFmpegAudioDecoder<LIBAV_VER>> { 27 public: 28 FFmpegAudioDecoder(const FFmpegLibWrapper* aLib, 29 const CreateDecoderParams& aDecoderParams); 30 virtual ~FFmpegAudioDecoder(); 31 32 RefPtr<InitPromise> Init() override; 33 void InitCodecContext() MOZ_REQUIRES(sMutex) override; 34 static AVCodecID GetCodecId(const nsACString& aMimeType, 35 const AudioInfo& aInfo); 36 nsCString GetDescriptionName() const override { 37 #ifdef USING_MOZFFVPX 38 return "ffvpx audio decoder"_ns; 39 #else 40 return "ffmpeg audio decoder"_ns; 41 #endif 42 } 43 nsCString GetCodecName() const override; 44 45 private: 46 MediaResult DoDecode(MediaRawData* aSample, uint8_t* aData, int aSize, 47 bool* aGotFrame, DecodedData& aResults) override; 48 MediaResult DecodeUsingFFmpeg(AVPacket* aPacket, bool& aDecoded, 49 MediaRawData* aSample, DecodedData& aResults, 50 bool* aGotFrame); 51 MediaResult PostProcessOutput(bool aDecoded, MediaRawData* aSample, 52 DecodedData& aResults, bool* aGotFrame, 53 int32_t aSubmitted); 54 const AudioInfo mAudioInfo; 55 // True if the audio will be downmixed and rendered in mono. 56 bool mDefaultPlaybackDeviceMono; 57 }; 58 59 } // namespace mozilla 60 61 #endif // __FFmpegAACDecoder_h__