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