1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/content/media/fmp4/ffmpeg/FFmpegDecoderModule.cpp Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,81 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* vim:set ts=2 sw=2 sts=2 et cindent: */ 1.6 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.9 + 1.10 +#include "FFmpegRuntimeLinker.h" 1.11 +#include "FFmpegAACDecoder.h" 1.12 +#include "FFmpegH264Decoder.h" 1.13 + 1.14 +#include "FFmpegDecoderModule.h" 1.15 + 1.16 +namespace mozilla 1.17 +{ 1.18 + 1.19 +PRLogModuleInfo* GetFFmpegDecoderLog() 1.20 +{ 1.21 + static PRLogModuleInfo* sFFmpegDecoderLog = nullptr; 1.22 + if (!sFFmpegDecoderLog) { 1.23 + sFFmpegDecoderLog = PR_NewLogModule("FFmpegDecoderModule"); 1.24 + } 1.25 + return sFFmpegDecoderLog; 1.26 +} 1.27 + 1.28 +bool FFmpegDecoderModule::sFFmpegLinkDone = false; 1.29 + 1.30 +FFmpegDecoderModule::FFmpegDecoderModule() 1.31 +{ 1.32 + MOZ_COUNT_CTOR(FFmpegDecoderModule); 1.33 +} 1.34 + 1.35 +FFmpegDecoderModule::~FFmpegDecoderModule() { 1.36 + MOZ_COUNT_DTOR(FFmpegDecoderModule); 1.37 +} 1.38 + 1.39 +bool 1.40 +FFmpegDecoderModule::Link() 1.41 +{ 1.42 + if (sFFmpegLinkDone) { 1.43 + return true; 1.44 + } 1.45 + 1.46 + if (!FFmpegRuntimeLinker::Link()) { 1.47 + NS_WARNING("Failed to link FFmpeg shared libraries."); 1.48 + return false; 1.49 + } 1.50 + 1.51 + sFFmpegLinkDone = true; 1.52 + 1.53 + return true; 1.54 +} 1.55 + 1.56 +nsresult 1.57 +FFmpegDecoderModule::Shutdown() 1.58 +{ 1.59 + // Nothing to do here. 1.60 + return NS_OK; 1.61 +} 1.62 + 1.63 +MediaDataDecoder* 1.64 +FFmpegDecoderModule::CreateH264Decoder( 1.65 + const mp4_demuxer::VideoDecoderConfig& aConfig, 1.66 + mozilla::layers::LayersBackend aLayersBackend, 1.67 + mozilla::layers::ImageContainer* aImageContainer, 1.68 + MediaTaskQueue* aVideoTaskQueue, MediaDataDecoderCallback* aCallback) 1.69 +{ 1.70 + FFMPEG_LOG("Creating FFmpeg H264 decoder."); 1.71 + return new FFmpegH264Decoder(aVideoTaskQueue, aCallback, aConfig, 1.72 + aImageContainer); 1.73 +} 1.74 + 1.75 +MediaDataDecoder* 1.76 +FFmpegDecoderModule::CreateAACDecoder( 1.77 + const mp4_demuxer::AudioDecoderConfig& aConfig, 1.78 + MediaTaskQueue* aAudioTaskQueue, MediaDataDecoderCallback* aCallback) 1.79 +{ 1.80 + FFMPEG_LOG("Creating FFmpeg AAC decoder."); 1.81 + return new FFmpegAACDecoder(aAudioTaskQueue, aCallback, aConfig); 1.82 +} 1.83 + 1.84 +} // namespace mozilla