Bug 803287 - Don't use GStreamer (when enabled) for Ogg/WebM if builtin backends present. r=doublec

This commit is contained in:
Chris Pearce 2012-10-30 14:38:42 +13:00
Родитель 2f2c416342
Коммит 9c9d20378f
4 изменённых файлов: 55 добавлений и 57 удалений

Просмотреть файл

@ -6614,47 +6614,32 @@ nsContentUtils::FindInternalContentViewer(const char* aType,
#ifdef MOZ_MEDIA
#ifdef MOZ_OGG
if (nsHTMLMediaElement::IsOggEnabled()) {
for (unsigned int i = 0; i < ArrayLength(nsHTMLMediaElement::gOggTypes); ++i) {
const char* type = nsHTMLMediaElement::gOggTypes[i];
if (!strcmp(aType, type)) {
docFactory = do_GetService("@mozilla.org/content/document-loader-factory;1");
if (docFactory && aLoaderType) {
*aLoaderType = TYPE_CONTENT;
}
return docFactory.forget();
}
if (nsHTMLMediaElement::IsOggType(nsDependentCString(aType))) {
docFactory = do_GetService("@mozilla.org/content/document-loader-factory;1");
if (docFactory && aLoaderType) {
*aLoaderType = TYPE_CONTENT;
}
return docFactory.forget();
}
#endif
#ifdef MOZ_WEBM
if (nsHTMLMediaElement::IsWebMEnabled()) {
for (unsigned int i = 0; i < ArrayLength(nsHTMLMediaElement::gWebMTypes); ++i) {
const char* type = nsHTMLMediaElement::gWebMTypes[i];
if (!strcmp(aType, type)) {
docFactory = do_GetService("@mozilla.org/content/document-loader-factory;1");
if (docFactory && aLoaderType) {
*aLoaderType = TYPE_CONTENT;
}
return docFactory.forget();
}
if (nsHTMLMediaElement::IsWebMType(nsDependentCString(aType))) {
docFactory = do_GetService("@mozilla.org/content/document-loader-factory;1");
if (docFactory && aLoaderType) {
*aLoaderType = TYPE_CONTENT;
}
return docFactory.forget();
}
#endif
#ifdef MOZ_GSTREAMER
if (nsHTMLMediaElement::IsH264Enabled()) {
for (unsigned int i = 0; i < ArrayLength(nsHTMLMediaElement::gH264Types); ++i) {
const char* type = nsHTMLMediaElement::gH264Types[i];
if (!strcmp(aType, type)) {
docFactory = do_GetService("@mozilla.org/content/document-loader-factory;1");
if (docFactory && aLoaderType) {
*aLoaderType = TYPE_CONTENT;
}
return docFactory.forget();
}
if (nsHTMLMediaElement::IsGStreamerSupportedType(nsDependentCString(aType))) {
docFactory = do_GetService("@mozilla.org/content/document-loader-factory;1");
if (docFactory && aLoaderType) {
*aLoaderType = TYPE_CONTENT;
}
return docFactory.forget();
}
#endif
@ -6668,7 +6653,6 @@ nsContentUtils::FindInternalContentViewer(const char* aType,
return docFactory.forget();
}
#endif // MOZ_MEDIA_PLUGINS
#endif // MOZ_MEDIA
return NULL;

Просмотреть файл

@ -308,7 +308,8 @@ public:
#endif
#ifdef MOZ_GSTREAMER
static bool IsH264Enabled();
static bool IsGStreamerEnabled();
static bool IsGStreamerSupportedType(const nsACString& aType);
static bool IsH264Type(const nsACString& aType);
static const char gH264Types[3][16];
static char const *const gH264Codecs[7];

Просмотреть файл

@ -2153,24 +2153,19 @@ const char nsHTMLMediaElement::gH264Types[3][16] = {
};
bool
nsHTMLMediaElement::IsH264Enabled()
nsHTMLMediaElement::IsGStreamerEnabled()
{
return Preferences::GetBool("media.h264.enabled");
return Preferences::GetBool("media.gstreamer.enabled");
}
bool
nsHTMLMediaElement::IsH264Type(const nsACString& aType)
{
if (!IsH264Enabled()) {
return false;
}
for (uint32_t i = 0; i < ArrayLength(gH264Types); ++i) {
if (aType.EqualsASCII(gH264Types[i])) {
return true;
}
}
return false;
}
#endif
@ -2265,7 +2260,7 @@ nsHTMLMediaElement::IsDASHMPDType(const nsACString& aType)
#endif
/* static */
nsHTMLMediaElement::CanPlayStatus
nsHTMLMediaElement::CanPlayStatus
nsHTMLMediaElement::CanHandleMediaType(const char* aMIMEType,
char const *const ** aCodecList)
{
@ -2429,9 +2424,43 @@ nsHTMLMediaElement::CanPlayType(const nsAString& aType, nsAString& aResult)
return NS_OK;
}
#ifdef MOZ_GSTREAMER
bool
nsHTMLMediaElement::IsGStreamerSupportedType(const nsACString& aMimeType)
{
if (!IsGStreamerEnabled())
return false;
if (IsH264Type(aMimeType))
return true;
if (!Preferences::GetBool("media.prefer-gstreamer", false))
return false;
#ifdef MOZ_WEBM
if (IsWebMType(aMimeType))
return true;
#endif
#ifdef MOZ_OGG
if (IsOggType(aMimeType))
return true;
#endif
return false;
}
#endif
already_AddRefed<nsMediaDecoder>
nsHTMLMediaElement::CreateDecoder(const nsACString& aType)
{
#ifdef MOZ_GSTREAMER
// When enabled, use GStreamer for H.264, but not for codecs handled by our
// bundled decoders, unless the "media.prefer-gstreamer" pref is set.
if (IsGStreamerSupportedType(aType)) {
nsRefPtr<nsGStreamerDecoder> decoder = new nsGStreamerDecoder();
if (decoder->Init(this)) {
return decoder.forget();
}
}
#endif
#ifdef MOZ_RAW
if (IsRawType(aType)) {
nsRefPtr<nsRawDecoder> decoder = new nsRawDecoder();
@ -2442,11 +2471,7 @@ nsHTMLMediaElement::CreateDecoder(const nsACString& aType)
#endif
#ifdef MOZ_OGG
if (IsOggType(aType)) {
#ifdef MOZ_GSTREAMER
nsRefPtr<nsGStreamerDecoder> decoder = new nsGStreamerDecoder();
#else
nsRefPtr<nsOggDecoder> decoder = new nsOggDecoder();
#endif
if (decoder->Init(this)) {
return decoder.forget();
}
@ -2478,11 +2503,7 @@ nsHTMLMediaElement::CreateDecoder(const nsACString& aType)
#endif
#ifdef MOZ_WEBM
if (IsWebMType(aType)) {
#ifdef MOZ_GSTREAMER
nsRefPtr<nsGStreamerDecoder> decoder = new nsGStreamerDecoder();
#else
nsRefPtr<nsWebMDecoder> decoder = new nsWebMDecoder();
#endif
if (decoder->Init(this)) {
return decoder.forget();
}
@ -2498,14 +2519,6 @@ nsHTMLMediaElement::CreateDecoder(const nsACString& aType)
}
#endif
#ifdef MOZ_GSTREAMER
if (IsH264Type(aType)) {
nsRefPtr<nsGStreamerDecoder> decoder = new nsGStreamerDecoder();
if (decoder->Init(this)) {
return decoder.forget();
}
}
#endif
return nullptr;
}

Просмотреть файл

@ -169,7 +169,7 @@ pref("media.webm.enabled", true);
pref("media.dash.enabled", true);
#endif
#ifdef MOZ_GSTREAMER
pref("media.h264.enabled", true);
pref("media.gstreamer.enabled", true);
#endif
#ifdef MOZ_WEBRTC
pref("media.navigator.enabled", false);