Bug 834172 - Implement IsSupportedTypeInVideo in DecoderTraits. r=cpearce

This change moves the policy of supported media types in the element
nsHTMLMediaElement to the DecoderTraits class. The codec-specific code
has been removed from the media element.
This commit is contained in:
Thomas Zimmermann 2013-03-04 10:24:44 -05:00
parent bad04aa1d2
commit d634135a54
3 changed files with 33 additions and 65 deletions

View File

@ -6335,77 +6335,13 @@ nsContentUtils::FindInternalContentViewer(const char* aType,
}
#ifdef MOZ_MEDIA
#ifdef MOZ_OGG
if (DecoderTraits::IsOggType(nsDependentCString(aType))) {
if (DecoderTraits::IsSupportedInVideoDocument(nsDependentCString(aType))) {
docFactory = do_GetService("@mozilla.org/content/document-loader-factory;1");
if (docFactory && aLoaderType) {
*aLoaderType = TYPE_CONTENT;
}
return docFactory.forget();
}
#endif
#ifdef MOZ_WIDGET_GONK
if (DecoderTraits::IsOmxSupportedType(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 (DecoderTraits::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_DASH
if (DecoderTraits::IsDASHMPDType(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 (DecoderTraits::IsGStreamerSupportedType(nsDependentCString(aType))) {
docFactory = do_GetService("@mozilla.org/content/document-loader-factory;1");
if (docFactory && aLoaderType) {
*aLoaderType = TYPE_CONTENT;
}
return docFactory.forget();
}
#endif
#ifdef MOZ_MEDIA_PLUGINS
if (mozilla::MediaDecoder::IsMediaPluginsEnabled() &&
DecoderTraits::IsMediaPluginsType(nsDependentCString(aType))) {
docFactory = do_GetService("@mozilla.org/content/document-loader-factory;1");
if (docFactory && aLoaderType) {
*aLoaderType = TYPE_CONTENT;
}
return docFactory.forget();
}
#endif // MOZ_MEDIA_PLUGINS
#ifdef MOZ_WMF
if (DecoderTraits::IsWMFSupportedType(nsDependentCString(aType))) {
docFactory = do_GetService("@mozilla.org/content/document-loader-factory;1");
if (docFactory && aLoaderType) {
*aLoaderType = TYPE_CONTENT;
}
return docFactory.forget();
}
#endif
#endif // MOZ_MEDIA
return NULL;

View File

@ -440,5 +440,32 @@ DecoderTraits::CreateDecoder(const nsACString& aType, MediaDecoderOwner* aOwner)
return decoder.forget();
}
/* static */
bool DecoderTraits::IsSupportedInVideoDocument(const nsACString& aType)
{
return
#ifdef MOZ_OGG
IsOggType(aType) ||
#endif
#ifdef MOZ_WIDGET_GONK
IsOmxSupportedType(aType) ||
#endif
#ifdef MOZ_WEBM
IsWebMType(aType) ||
#endif
#ifdef MOZ_DASH
IsDASHMPDType(aType) ||
#endif
#ifdef MOZ_GSTREAMER
IsGStreamerSupportedType(aType) ||
#endif
#ifdef MOZ_MEDIA_PLUGINS
(mozilla::MediaDecoder::IsMediaPluginsEnabled() && IsMediaPluginsType(aType)) ||
#endif
#ifdef MOZ_WMF
IsWMFSupportedType(aType) ||
#endif
false;
}
}

View File

@ -83,6 +83,11 @@ public:
// were unable to create the decoder.
static already_AddRefed<MediaDecoder> CreateDecoder(const nsACString& aType,
MediaDecoderOwner* aOwner);
// Returns true if MIME type aType is supported in video documents,
// or false otherwise. Not all platforms support all MIME types, and
// vice versa.
static bool IsSupportedInVideoDocument(const nsACString& aType);
};
}