michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* vim:set ts=2 sw=2 sts=2 et cindent: */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "FFmpegRuntimeLinker.h" michael@0: #include "FFmpegAACDecoder.h" michael@0: #include "FFmpegH264Decoder.h" michael@0: michael@0: #include "FFmpegDecoderModule.h" michael@0: michael@0: namespace mozilla michael@0: { michael@0: michael@0: PRLogModuleInfo* GetFFmpegDecoderLog() michael@0: { michael@0: static PRLogModuleInfo* sFFmpegDecoderLog = nullptr; michael@0: if (!sFFmpegDecoderLog) { michael@0: sFFmpegDecoderLog = PR_NewLogModule("FFmpegDecoderModule"); michael@0: } michael@0: return sFFmpegDecoderLog; michael@0: } michael@0: michael@0: bool FFmpegDecoderModule::sFFmpegLinkDone = false; michael@0: michael@0: FFmpegDecoderModule::FFmpegDecoderModule() michael@0: { michael@0: MOZ_COUNT_CTOR(FFmpegDecoderModule); michael@0: } michael@0: michael@0: FFmpegDecoderModule::~FFmpegDecoderModule() { michael@0: MOZ_COUNT_DTOR(FFmpegDecoderModule); michael@0: } michael@0: michael@0: bool michael@0: FFmpegDecoderModule::Link() michael@0: { michael@0: if (sFFmpegLinkDone) { michael@0: return true; michael@0: } michael@0: michael@0: if (!FFmpegRuntimeLinker::Link()) { michael@0: NS_WARNING("Failed to link FFmpeg shared libraries."); michael@0: return false; michael@0: } michael@0: michael@0: sFFmpegLinkDone = true; michael@0: michael@0: return true; michael@0: } michael@0: michael@0: nsresult michael@0: FFmpegDecoderModule::Shutdown() michael@0: { michael@0: // Nothing to do here. michael@0: return NS_OK; michael@0: } michael@0: michael@0: MediaDataDecoder* michael@0: FFmpegDecoderModule::CreateH264Decoder( michael@0: const mp4_demuxer::VideoDecoderConfig& aConfig, michael@0: mozilla::layers::LayersBackend aLayersBackend, michael@0: mozilla::layers::ImageContainer* aImageContainer, michael@0: MediaTaskQueue* aVideoTaskQueue, MediaDataDecoderCallback* aCallback) michael@0: { michael@0: FFMPEG_LOG("Creating FFmpeg H264 decoder."); michael@0: return new FFmpegH264Decoder(aVideoTaskQueue, aCallback, aConfig, michael@0: aImageContainer); michael@0: } michael@0: michael@0: MediaDataDecoder* michael@0: FFmpegDecoderModule::CreateAACDecoder( michael@0: const mp4_demuxer::AudioDecoderConfig& aConfig, michael@0: MediaTaskQueue* aAudioTaskQueue, MediaDataDecoderCallback* aCallback) michael@0: { michael@0: FFMPEG_LOG("Creating FFmpeg AAC decoder."); michael@0: return new FFmpegAACDecoder(aAudioTaskQueue, aCallback, aConfig); michael@0: } michael@0: michael@0: } // namespace mozilla