michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* vim:set ts=2 sw=2 sts=2 et cindent: */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this file, michael@0: * You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #if !defined(GStreamerFormatHelper_h_) michael@0: #define GStreamerFormatHelper_h_ michael@0: michael@0: #include michael@0: #include michael@0: #include "nsXPCOMStrings.h" michael@0: michael@0: namespace mozilla { michael@0: michael@0: class GStreamerFormatHelper { michael@0: /* This class can be used to query the GStreamer registry for the required michael@0: * demuxers/decoders from nsHTMLMediaElement::CanPlayType. michael@0: * It implements looking at the GstRegistry to check if elements to michael@0: * demux/decode the formats passed to CanPlayType() are actually installed. michael@0: */ michael@0: public: michael@0: static GStreamerFormatHelper* Instance(); michael@0: ~GStreamerFormatHelper(); michael@0: michael@0: bool CanHandleMediaType(const nsACString& aMIMEType, michael@0: const nsAString* aCodecs); michael@0: michael@0: bool CanHandleContainerCaps(GstCaps* aCaps); michael@0: bool CanHandleCodecCaps(GstCaps* aCaps); michael@0: michael@0: static GstCaps* ConvertFormatsToCaps(const char* aMIMEType, michael@0: const nsAString* aCodecs); michael@0: michael@0: static void Shutdown(); michael@0: michael@0: private: michael@0: GStreamerFormatHelper(); michael@0: char* const *CodecListFromCaps(GstCaps* aCaps); michael@0: bool HaveElementsToProcessCaps(GstCaps* aCaps); michael@0: GList* GetFactories(); michael@0: michael@0: static GStreamerFormatHelper* gInstance; michael@0: michael@0: /* table to convert from container MIME types to GStreamer caps */ michael@0: static char const *const mContainers[6][2]; michael@0: michael@0: /* table to convert from codec MIME types to GStreamer caps */ michael@0: static char const *const mCodecs[9][2]; michael@0: michael@0: /* michael@0: * True iff we were able to find the proper GStreamer libs and the functions michael@0: * we need. michael@0: */ michael@0: static bool sLoadOK; michael@0: michael@0: /* whitelist of supported container/codec gst caps */ michael@0: GstCaps* mSupportedContainerCaps; michael@0: GstCaps* mSupportedCodecCaps; michael@0: michael@0: /* list of GStreamer element factories michael@0: * Element factories are the basic types retrieved from the GStreamer michael@0: * registry, they describe all plugins and elements that GStreamer can michael@0: * create. michael@0: * This means that element factories are useful for automated element michael@0: * instancing, such as what autopluggers do, michael@0: * and for creating lists of available elements. */ michael@0: GList* mFactories; michael@0: michael@0: /* Storage for the default registrys feature list cookie. michael@0: * It changes every time a feature is added to or removed from the michael@0: * GStreamer registry. */ michael@0: uint32_t mCookie; michael@0: }; michael@0: michael@0: } //namespace mozilla michael@0: michael@0: #endif