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 file, |
michael@0 | 5 | * You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 6 | |
michael@0 | 7 | #if !defined(GStreamerFormatHelper_h_) |
michael@0 | 8 | #define GStreamerFormatHelper_h_ |
michael@0 | 9 | |
michael@0 | 10 | #include <gst/gst.h> |
michael@0 | 11 | #include <mozilla/Types.h> |
michael@0 | 12 | #include "nsXPCOMStrings.h" |
michael@0 | 13 | |
michael@0 | 14 | namespace mozilla { |
michael@0 | 15 | |
michael@0 | 16 | class GStreamerFormatHelper { |
michael@0 | 17 | /* This class can be used to query the GStreamer registry for the required |
michael@0 | 18 | * demuxers/decoders from nsHTMLMediaElement::CanPlayType. |
michael@0 | 19 | * It implements looking at the GstRegistry to check if elements to |
michael@0 | 20 | * demux/decode the formats passed to CanPlayType() are actually installed. |
michael@0 | 21 | */ |
michael@0 | 22 | public: |
michael@0 | 23 | static GStreamerFormatHelper* Instance(); |
michael@0 | 24 | ~GStreamerFormatHelper(); |
michael@0 | 25 | |
michael@0 | 26 | bool CanHandleMediaType(const nsACString& aMIMEType, |
michael@0 | 27 | const nsAString* aCodecs); |
michael@0 | 28 | |
michael@0 | 29 | bool CanHandleContainerCaps(GstCaps* aCaps); |
michael@0 | 30 | bool CanHandleCodecCaps(GstCaps* aCaps); |
michael@0 | 31 | |
michael@0 | 32 | static GstCaps* ConvertFormatsToCaps(const char* aMIMEType, |
michael@0 | 33 | const nsAString* aCodecs); |
michael@0 | 34 | |
michael@0 | 35 | static void Shutdown(); |
michael@0 | 36 | |
michael@0 | 37 | private: |
michael@0 | 38 | GStreamerFormatHelper(); |
michael@0 | 39 | char* const *CodecListFromCaps(GstCaps* aCaps); |
michael@0 | 40 | bool HaveElementsToProcessCaps(GstCaps* aCaps); |
michael@0 | 41 | GList* GetFactories(); |
michael@0 | 42 | |
michael@0 | 43 | static GStreamerFormatHelper* gInstance; |
michael@0 | 44 | |
michael@0 | 45 | /* table to convert from container MIME types to GStreamer caps */ |
michael@0 | 46 | static char const *const mContainers[6][2]; |
michael@0 | 47 | |
michael@0 | 48 | /* table to convert from codec MIME types to GStreamer caps */ |
michael@0 | 49 | static char const *const mCodecs[9][2]; |
michael@0 | 50 | |
michael@0 | 51 | /* |
michael@0 | 52 | * True iff we were able to find the proper GStreamer libs and the functions |
michael@0 | 53 | * we need. |
michael@0 | 54 | */ |
michael@0 | 55 | static bool sLoadOK; |
michael@0 | 56 | |
michael@0 | 57 | /* whitelist of supported container/codec gst caps */ |
michael@0 | 58 | GstCaps* mSupportedContainerCaps; |
michael@0 | 59 | GstCaps* mSupportedCodecCaps; |
michael@0 | 60 | |
michael@0 | 61 | /* list of GStreamer element factories |
michael@0 | 62 | * Element factories are the basic types retrieved from the GStreamer |
michael@0 | 63 | * registry, they describe all plugins and elements that GStreamer can |
michael@0 | 64 | * create. |
michael@0 | 65 | * This means that element factories are useful for automated element |
michael@0 | 66 | * instancing, such as what autopluggers do, |
michael@0 | 67 | * and for creating lists of available elements. */ |
michael@0 | 68 | GList* mFactories; |
michael@0 | 69 | |
michael@0 | 70 | /* Storage for the default registrys feature list cookie. |
michael@0 | 71 | * It changes every time a feature is added to or removed from the |
michael@0 | 72 | * GStreamer registry. */ |
michael@0 | 73 | uint32_t mCookie; |
michael@0 | 74 | }; |
michael@0 | 75 | |
michael@0 | 76 | } //namespace mozilla |
michael@0 | 77 | |
michael@0 | 78 | #endif |