Tue, 06 Jan 2015 21:39:09 +0100
Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.
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 "DirectShowDecoder.h" |
michael@0 | 8 | #include "DirectShowReader.h" |
michael@0 | 9 | #include "MediaDecoderStateMachine.h" |
michael@0 | 10 | #include "mozilla/Preferences.h" |
michael@0 | 11 | #include "mozilla/WindowsVersion.h" |
michael@0 | 12 | |
michael@0 | 13 | namespace mozilla { |
michael@0 | 14 | |
michael@0 | 15 | MediaDecoderStateMachine* DirectShowDecoder::CreateStateMachine() |
michael@0 | 16 | { |
michael@0 | 17 | return new MediaDecoderStateMachine(this, new DirectShowReader(this)); |
michael@0 | 18 | } |
michael@0 | 19 | |
michael@0 | 20 | /* static */ |
michael@0 | 21 | bool |
michael@0 | 22 | DirectShowDecoder::GetSupportedCodecs(const nsACString& aType, |
michael@0 | 23 | char const *const ** aCodecList) |
michael@0 | 24 | { |
michael@0 | 25 | if (!IsEnabled()) { |
michael@0 | 26 | return false; |
michael@0 | 27 | } |
michael@0 | 28 | |
michael@0 | 29 | static char const *const mp3AudioCodecs[] = { |
michael@0 | 30 | "mp3", |
michael@0 | 31 | nullptr |
michael@0 | 32 | }; |
michael@0 | 33 | if (aType.EqualsASCII("audio/mpeg") || |
michael@0 | 34 | aType.EqualsASCII("audio/mp3")) { |
michael@0 | 35 | if (aCodecList) { |
michael@0 | 36 | *aCodecList = mp3AudioCodecs; |
michael@0 | 37 | } |
michael@0 | 38 | return true; |
michael@0 | 39 | } |
michael@0 | 40 | |
michael@0 | 41 | return false; |
michael@0 | 42 | } |
michael@0 | 43 | |
michael@0 | 44 | /* static */ |
michael@0 | 45 | bool |
michael@0 | 46 | DirectShowDecoder::IsEnabled() |
michael@0 | 47 | { |
michael@0 | 48 | return Preferences::GetBool("media.directshow.enabled"); |
michael@0 | 49 | } |
michael@0 | 50 | |
michael@0 | 51 | DirectShowDecoder::DirectShowDecoder() |
michael@0 | 52 | { |
michael@0 | 53 | MOZ_COUNT_CTOR(DirectShowDecoder); |
michael@0 | 54 | } |
michael@0 | 55 | |
michael@0 | 56 | DirectShowDecoder::~DirectShowDecoder() |
michael@0 | 57 | { |
michael@0 | 58 | MOZ_COUNT_DTOR(DirectShowDecoder); |
michael@0 | 59 | } |
michael@0 | 60 | |
michael@0 | 61 | } // namespace mozilla |
michael@0 | 62 |