1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/content/media/gstreamer/GStreamerFormatHelper.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,78 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* vim:set ts=2 sw=2 sts=2 et cindent: */ 1.6 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this file, 1.8 + * You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.9 + 1.10 +#if !defined(GStreamerFormatHelper_h_) 1.11 +#define GStreamerFormatHelper_h_ 1.12 + 1.13 +#include <gst/gst.h> 1.14 +#include <mozilla/Types.h> 1.15 +#include "nsXPCOMStrings.h" 1.16 + 1.17 +namespace mozilla { 1.18 + 1.19 +class GStreamerFormatHelper { 1.20 + /* This class can be used to query the GStreamer registry for the required 1.21 + * demuxers/decoders from nsHTMLMediaElement::CanPlayType. 1.22 + * It implements looking at the GstRegistry to check if elements to 1.23 + * demux/decode the formats passed to CanPlayType() are actually installed. 1.24 + */ 1.25 + public: 1.26 + static GStreamerFormatHelper* Instance(); 1.27 + ~GStreamerFormatHelper(); 1.28 + 1.29 + bool CanHandleMediaType(const nsACString& aMIMEType, 1.30 + const nsAString* aCodecs); 1.31 + 1.32 + bool CanHandleContainerCaps(GstCaps* aCaps); 1.33 + bool CanHandleCodecCaps(GstCaps* aCaps); 1.34 + 1.35 + static GstCaps* ConvertFormatsToCaps(const char* aMIMEType, 1.36 + const nsAString* aCodecs); 1.37 + 1.38 + static void Shutdown(); 1.39 + 1.40 + private: 1.41 + GStreamerFormatHelper(); 1.42 + char* const *CodecListFromCaps(GstCaps* aCaps); 1.43 + bool HaveElementsToProcessCaps(GstCaps* aCaps); 1.44 + GList* GetFactories(); 1.45 + 1.46 + static GStreamerFormatHelper* gInstance; 1.47 + 1.48 + /* table to convert from container MIME types to GStreamer caps */ 1.49 + static char const *const mContainers[6][2]; 1.50 + 1.51 + /* table to convert from codec MIME types to GStreamer caps */ 1.52 + static char const *const mCodecs[9][2]; 1.53 + 1.54 + /* 1.55 + * True iff we were able to find the proper GStreamer libs and the functions 1.56 + * we need. 1.57 + */ 1.58 + static bool sLoadOK; 1.59 + 1.60 + /* whitelist of supported container/codec gst caps */ 1.61 + GstCaps* mSupportedContainerCaps; 1.62 + GstCaps* mSupportedCodecCaps; 1.63 + 1.64 + /* list of GStreamer element factories 1.65 + * Element factories are the basic types retrieved from the GStreamer 1.66 + * registry, they describe all plugins and elements that GStreamer can 1.67 + * create. 1.68 + * This means that element factories are useful for automated element 1.69 + * instancing, such as what autopluggers do, 1.70 + * and for creating lists of available elements. */ 1.71 + GList* mFactories; 1.72 + 1.73 + /* Storage for the default registrys feature list cookie. 1.74 + * It changes every time a feature is added to or removed from the 1.75 + * GStreamer registry. */ 1.76 + uint32_t mCookie; 1.77 +}; 1.78 + 1.79 +} //namespace mozilla 1.80 + 1.81 +#endif