Fri, 16 Jan 2015 04:50:19 +0100
Replace accessor implementation with direct member state manipulation, by
request https://trac.torproject.org/projects/tor/ticket/9701#comment:32
michael@0 | 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* vim:set ts=2 sw=2 sts=2 et cindent: */ |
michael@0 | 3 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 4 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 5 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 6 | |
michael@0 | 7 | #include "PlatformDecoderModule.h" |
michael@0 | 8 | #ifdef XP_WIN |
michael@0 | 9 | #include "WMFDecoderModule.h" |
michael@0 | 10 | #endif |
michael@0 | 11 | #ifdef MOZ_FFMPEG |
michael@0 | 12 | #include "FFmpegDecoderModule.h" |
michael@0 | 13 | #endif |
michael@0 | 14 | #include "mozilla/Preferences.h" |
michael@0 | 15 | |
michael@0 | 16 | namespace mozilla { |
michael@0 | 17 | |
michael@0 | 18 | extern PlatformDecoderModule* CreateBlankDecoderModule(); |
michael@0 | 19 | |
michael@0 | 20 | bool PlatformDecoderModule::sUseBlankDecoder = false; |
michael@0 | 21 | bool PlatformDecoderModule::sFFmpegDecoderEnabled = false; |
michael@0 | 22 | |
michael@0 | 23 | /* static */ |
michael@0 | 24 | void |
michael@0 | 25 | PlatformDecoderModule::Init() |
michael@0 | 26 | { |
michael@0 | 27 | MOZ_ASSERT(NS_IsMainThread()); |
michael@0 | 28 | static bool alreadyInitialized = false; |
michael@0 | 29 | if (alreadyInitialized) { |
michael@0 | 30 | return; |
michael@0 | 31 | } |
michael@0 | 32 | alreadyInitialized = true; |
michael@0 | 33 | |
michael@0 | 34 | Preferences::AddBoolVarCache(&sUseBlankDecoder, |
michael@0 | 35 | "media.fragmented-mp4.use-blank-decoder"); |
michael@0 | 36 | Preferences::AddBoolVarCache(&sFFmpegDecoderEnabled, |
michael@0 | 37 | "media.fragmented-mp4.ffmpeg.enabled", false); |
michael@0 | 38 | |
michael@0 | 39 | #ifdef XP_WIN |
michael@0 | 40 | WMFDecoderModule::Init(); |
michael@0 | 41 | #endif |
michael@0 | 42 | } |
michael@0 | 43 | |
michael@0 | 44 | /* static */ |
michael@0 | 45 | PlatformDecoderModule* |
michael@0 | 46 | PlatformDecoderModule::Create() |
michael@0 | 47 | { |
michael@0 | 48 | if (sUseBlankDecoder) { |
michael@0 | 49 | return CreateBlankDecoderModule(); |
michael@0 | 50 | } |
michael@0 | 51 | #ifdef XP_WIN |
michael@0 | 52 | nsAutoPtr<WMFDecoderModule> m(new WMFDecoderModule()); |
michael@0 | 53 | if (NS_SUCCEEDED(m->Startup())) { |
michael@0 | 54 | return m.forget(); |
michael@0 | 55 | } |
michael@0 | 56 | #endif |
michael@0 | 57 | #ifdef MOZ_FFMPEG |
michael@0 | 58 | if (sFFmpegDecoderEnabled) { |
michael@0 | 59 | return new FFmpegDecoderModule(); |
michael@0 | 60 | } |
michael@0 | 61 | #endif |
michael@0 | 62 | return nullptr; |
michael@0 | 63 | } |
michael@0 | 64 | |
michael@0 | 65 | } // namespace mozilla |