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