content/media/directshow/DirectShowDecoder.cpp

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

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.

     1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     2 /* vim:set ts=2 sw=2 sts=2 et cindent: */
     3 /* This Source Code Form is subject to the terms of the Mozilla Public
     4  * License, v. 2.0. If a copy of the MPL was not distributed with this
     5  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     7 #include "DirectShowDecoder.h"
     8 #include "DirectShowReader.h"
     9 #include "MediaDecoderStateMachine.h"
    10 #include "mozilla/Preferences.h"
    11 #include "mozilla/WindowsVersion.h"
    13 namespace mozilla {
    15 MediaDecoderStateMachine* DirectShowDecoder::CreateStateMachine()
    16 {
    17   return new MediaDecoderStateMachine(this, new DirectShowReader(this));
    18 }
    20 /* static */
    21 bool
    22 DirectShowDecoder::GetSupportedCodecs(const nsACString& aType,
    23                                       char const *const ** aCodecList)
    24 {
    25   if (!IsEnabled()) {
    26     return false;
    27   }
    29   static char const *const mp3AudioCodecs[] = {
    30     "mp3",
    31     nullptr
    32   };
    33   if (aType.EqualsASCII("audio/mpeg") ||
    34       aType.EqualsASCII("audio/mp3")) {
    35     if (aCodecList) {
    36       *aCodecList = mp3AudioCodecs;
    37     }
    38     return true;
    39   }
    41   return false;
    42 }
    44 /* static */
    45 bool
    46 DirectShowDecoder::IsEnabled()
    47 {
    48   return Preferences::GetBool("media.directshow.enabled");
    49 }
    51 DirectShowDecoder::DirectShowDecoder()
    52 {
    53   MOZ_COUNT_CTOR(DirectShowDecoder);
    54 }
    56 DirectShowDecoder::~DirectShowDecoder()
    57 {
    58   MOZ_COUNT_DTOR(DirectShowDecoder);
    59 }
    61 } // namespace mozilla

mercurial