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 "PlatformDecoderModule.h" michael@0: #ifdef XP_WIN michael@0: #include "WMFDecoderModule.h" michael@0: #endif michael@0: #ifdef MOZ_FFMPEG michael@0: #include "FFmpegDecoderModule.h" michael@0: #endif michael@0: #include "mozilla/Preferences.h" michael@0: michael@0: namespace mozilla { michael@0: michael@0: extern PlatformDecoderModule* CreateBlankDecoderModule(); michael@0: michael@0: bool PlatformDecoderModule::sUseBlankDecoder = false; michael@0: bool PlatformDecoderModule::sFFmpegDecoderEnabled = false; michael@0: michael@0: /* static */ michael@0: void michael@0: PlatformDecoderModule::Init() michael@0: { michael@0: MOZ_ASSERT(NS_IsMainThread()); michael@0: static bool alreadyInitialized = false; michael@0: if (alreadyInitialized) { michael@0: return; michael@0: } michael@0: alreadyInitialized = true; michael@0: michael@0: Preferences::AddBoolVarCache(&sUseBlankDecoder, michael@0: "media.fragmented-mp4.use-blank-decoder"); michael@0: Preferences::AddBoolVarCache(&sFFmpegDecoderEnabled, michael@0: "media.fragmented-mp4.ffmpeg.enabled", false); michael@0: michael@0: #ifdef XP_WIN michael@0: WMFDecoderModule::Init(); michael@0: #endif michael@0: } michael@0: michael@0: /* static */ michael@0: PlatformDecoderModule* michael@0: PlatformDecoderModule::Create() michael@0: { michael@0: if (sUseBlankDecoder) { michael@0: return CreateBlankDecoderModule(); michael@0: } michael@0: #ifdef XP_WIN michael@0: nsAutoPtr m(new WMFDecoderModule()); michael@0: if (NS_SUCCEEDED(m->Startup())) { michael@0: return m.forget(); michael@0: } michael@0: #endif michael@0: #ifdef MOZ_FFMPEG michael@0: if (sFFmpegDecoderEnabled) { michael@0: return new FFmpegDecoderModule(); michael@0: } michael@0: #endif michael@0: return nullptr; michael@0: } michael@0: michael@0: } // namespace mozilla