Backed out 2 changesets (bug 1211339) for m3 test failures on a CLOSED TREE

Backed out changeset 91bff7bc67d7 (bug 1211339)
Backed out changeset d34f694b13cf (bug 1211339)
This commit is contained in:
Carsten "Tomcat" Book 2015-10-05 14:34:44 +02:00
Родитель 9a4e08328c
Коммит 239ba800f1
9 изменённых файлов: 122 добавлений и 127 удалений

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

@ -347,7 +347,9 @@ static bool
IsMP4SupportedType(const nsACString& aType,
const nsAString& aCodecs = EmptyString())
{
return MP4Decoder::CanHandleMediaType(aType, aCodecs);
// MP4Decoder/Reader is currently used for MSE and mp4 files local playback.
bool haveAAC, haveMP3, haveH264;
return MP4Decoder::CanHandleMediaType(aType, aCodecs, haveAAC, haveH264, haveMP3);
}
#endif

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

@ -469,15 +469,6 @@ LogToBrowserConsole(const nsAString& aMsg)
console->LogStringMessage(msg.get());
}
bool
IsAACCodecString(const nsAString& aCodec)
{
return
aCodec.EqualsLiteral("mp4a.40.2") || // MPEG4 AAC-LC
aCodec.EqualsLiteral("mp4a.40.5") || // MPEG4 HE-AAC
aCodec.EqualsLiteral("mp4a.67"); // MPEG2 AAC-LC}
}
bool
ParseCodecsString(const nsAString& aCodecs, nsTArray<nsString>& aOutCodecs)
{

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

@ -338,9 +338,6 @@ IsH264ContentType(const nsAString& aContentType);
bool
IsAACContentType(const nsAString& aContentType);
bool
IsAACCodecString(const nsAString& aCodec);
} // end namespace mozilla
#endif

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

@ -16,7 +16,6 @@
#include "mozilla/Logging.h"
#include "nsMimeTypes.h"
#include "nsContentTypeParser.h"
#include "VideoUtils.h"
#ifdef XP_WIN
#include "mozilla/WindowsVersion.h"
@ -54,7 +53,30 @@ MediaDecoderStateMachine* MP4Decoder::CreateStateMachine()
}
static bool
IsWhitelistedH264Codec(const nsAString& aCodec)
IsSupportedAudioCodec(const nsAString& aCodec,
bool& aOutContainsAAC,
bool& aOutContainsMP3)
{
// AAC-LC or HE-AAC in M4A.
aOutContainsAAC = aCodec.EqualsASCII("mp4a.40.2") // MPEG4 AAC-LC
|| aCodec.EqualsASCII("mp4a.40.5") // MPEG4 HE-AAC
|| aCodec.EqualsASCII("mp4a.67"); // MPEG2 AAC-LC
if (aOutContainsAAC) {
return true;
}
#ifndef MOZ_GONK_MEDIACODEC // B2G doesn't support MP3 in MP4 yet.
aOutContainsMP3 = aCodec.EqualsASCII("mp3");
if (aOutContainsMP3) {
return true;
}
#else
aOutContainsMP3 = false;
#endif
return false;
}
static bool
IsSupportedH264Codec(const nsAString& aCodec)
{
int16_t profile = 0, level = 0;
@ -88,74 +110,52 @@ IsWhitelistedH264Codec(const nsAString& aCodec)
/* static */
bool
MP4Decoder::CanHandleMediaType(const nsACString& aMIMETypeExcludingCodecs,
const nsAString& aCodecs)
MP4Decoder::CanHandleMediaType(const nsACString& aType,
const nsAString& aCodecs,
bool& aOutContainsAAC,
bool& aOutContainsH264,
bool& aOutContainsMP3)
{
if (!IsEnabled()) {
return false;
}
// Whitelist MP4 types, so they explicitly match what we encounter on
// the web, as opposed to what we use internally (i.e. what our demuxers
// etc output).
if (!aMIMETypeExcludingCodecs.EqualsASCII("audio/mp4") &&
!aMIMETypeExcludingCodecs.EqualsASCII("audio/x-m4a") &&
!aMIMETypeExcludingCodecs.EqualsASCII("video/mp4") &&
!aMIMETypeExcludingCodecs.EqualsASCII("video/x-m4v")) {
return false;
if (aType.EqualsASCII("audio/mp4") || aType.EqualsASCII("audio/x-m4a")) {
return MP4Decoder::CanCreateAACDecoder() &&
(aCodecs.IsEmpty() ||
IsSupportedAudioCodec(aCodecs,
aOutContainsAAC,
aOutContainsMP3));
}
#ifdef MOZ_GONK_MEDIACODEC
if (aMIMETypeExcludingCodecs.EqualsASCII(VIDEO_3GPP)) {
if (aType.EqualsASCII(VIDEO_3GPP)) {
return Preferences::GetBool("media.fragmented-mp4.gonk.enabled", false);
}
#endif
nsTArray<nsCString> codecMimes;
if (aCodecs.IsEmpty()) {
// No codecs specified. Assume AAC/H.264
if (aMIMETypeExcludingCodecs.EqualsLiteral("audio/mp4") ||
aMIMETypeExcludingCodecs.EqualsLiteral("audio/x-m4a")) {
codecMimes.AppendElement(NS_LITERAL_CSTRING("audio/mp4a-latm"));
} else if (aMIMETypeExcludingCodecs.EqualsLiteral("video/mp4") ||
aMIMETypeExcludingCodecs.EqualsLiteral("video/x-m4v")) {
codecMimes.AppendElement(NS_LITERAL_CSTRING("video/avc"));
}
} else {
// Verify that all the codecs specified are ones that we expect that
// we can play.
nsTArray<nsString> codecs;
if (!ParseCodecsString(aCodecs, codecs)) {
return false;
}
for (const nsString& codec : codecs) {
if (IsAACCodecString(codec)) {
codecMimes.AppendElement(NS_LITERAL_CSTRING("audio/mp4a-latm"));
continue;
}
if (codec.EqualsLiteral("mp3")) {
codecMimes.AppendElement(NS_LITERAL_CSTRING("audio/mpeg"));
continue;
}
if (IsWhitelistedH264Codec(codec)) {
codecMimes.AppendElement(NS_LITERAL_CSTRING("video/avc"));
continue;
}
// Some unsupported codec.
return false;
}
}
// Verify that we have a PDM that supports the whitelisted types.
PlatformDecoderModule::Init();
nsRefPtr<PlatformDecoderModule> platform = PlatformDecoderModule::Create();
if (!platform) {
if ((!aType.EqualsASCII("video/mp4") && !aType.EqualsASCII("video/x-m4v")) ||
!MP4Decoder::CanCreateH264Decoder()) {
return false;
}
for (const nsCString& codecMime : codecMimes) {
if (!platform->SupportsMimeType(codecMime)) {
return false;
// Verify that all the codecs specifed are ones that we expect that
// we can play.
nsTArray<nsString> codecs;
if (!ParseCodecsString(aCodecs, codecs)) {
return false;
}
for (const nsString& codec : codecs) {
if (IsSupportedAudioCodec(codec,
aOutContainsAAC,
aOutContainsMP3)) {
continue;
}
if (IsSupportedH264Codec(codec)) {
aOutContainsH264 = true;
continue;
}
// Some unsupported codec.
return false;
}
return true;
@ -173,7 +173,10 @@ MP4Decoder::CanHandleMediaType(const nsAString& aContentType)
nsString codecs;
parser.GetParameter("codecs", codecs);
return CanHandleMediaType(NS_ConvertUTF16toUTF8(mimeType), codecs);
bool ignoreAAC, ignoreH264, ignoreMP3;
return CanHandleMediaType(NS_ConvertUTF16toUTF8(mimeType),
codecs,
ignoreAAC, ignoreH264, ignoreMP3);
}
static bool

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

@ -29,8 +29,11 @@ public:
// a MP4 platform decoder backend. If aCodecs is non emtpy, it is filled
// with a comma-delimited list of codecs to check support for. Notes in
// out params wether the codecs string contains AAC or H.264.
static bool CanHandleMediaType(const nsACString& aMIMETypeExcludingCodecs,
const nsAString& aCodecs);
static bool CanHandleMediaType(const nsACString& aMIMEType,
const nsAString& aCodecs,
bool& aOutContainsAAC,
bool& aOutContainsH264,
bool& aOutContainsMP3);
static bool CanHandleMediaType(const nsAString& aMIMEType);

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

@ -12,9 +12,6 @@
#include "mozilla/RefPtr.h"
#include "WMFMediaDataDecoder.h"
extern const GUID CLSID_WebmMfVp8Dec;
extern const GUID CLSID_WebmMfVp9Dec;
namespace mozilla {
class WMFAudioMFTManager : public MFTManager {

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

@ -21,7 +21,6 @@
#include "gfxWindowsPlatform.h"
#include "MediaInfo.h"
#include "prsystem.h"
#include "mozilla/Maybe.h"
namespace mozilla {
@ -124,59 +123,16 @@ WMFDecoderModule::CreateAudioDecoder(const AudioInfo& aConfig,
return decoder.forget();
}
static bool
CanCreateMFTDecoder(const GUID& aGuid)
{
if (FAILED(wmf::MFStartup())) {
return false;
}
RefPtr<MFTDecoder> decoder(new MFTDecoder());
bool hasH264 = SUCCEEDED(decoder->Create(aGuid));
wmf::MFShutdown();
return hasH264;
}
template<const GUID& aGuid>
static bool
CanCreateWMFDecoder()
{
static Maybe<bool> result;
if (result.isNothing()) {
result.emplace(CanCreateMFTDecoder(aGuid));
}
return result.value();
}
bool
WMFDecoderModule::SupportsMimeType(const nsACString& aMimeType)
{
if ((aMimeType.EqualsLiteral("audio/mp4a-latm") ||
aMimeType.EqualsLiteral("audio/mp4")) &&
CanCreateWMFDecoder<CLSID_CMSAACDecMFT>()) {
return true;
}
if ((aMimeType.EqualsLiteral("video/avc") ||
aMimeType.EqualsLiteral("video/mp4")) &&
CanCreateWMFDecoder<CLSID_CMSH264DecoderMFT>()) {
return true;
}
if (aMimeType.EqualsLiteral("audio/mpeg") &&
CanCreateWMFDecoder<CLSID_CMP3DecMediaObject>()) {
return true;
}
if (sIsIntelDecoderEnabled) {
if (aMimeType.EqualsLiteral("video/webm; codecs=vp8") &&
CanCreateWMFDecoder<CLSID_WebmMfVp8Dec>()) {
return true;
}
if (aMimeType.EqualsLiteral("video/webm; codecs=vp9") &&
CanCreateWMFDecoder<CLSID_WebmMfVp9Dec>()) {
return true;
}
}
// Some unsupported codec.
return false;
return aMimeType.EqualsLiteral("video/mp4") ||
aMimeType.EqualsLiteral("video/avc") ||
aMimeType.EqualsLiteral("audio/mp4a-latm") ||
aMimeType.EqualsLiteral("audio/mpeg") ||
(sIsIntelDecoderEnabled &&
(aMimeType.EqualsLiteral("video/webm; codecs=vp8") ||
aMimeType.EqualsLiteral("video/webm; codecs=vp9")));
}
PlatformDecoderModule::ConversionRequired
@ -191,4 +147,43 @@ WMFDecoderModule::DecoderNeedsConversion(const TrackInfo& aConfig) const
}
}
static bool
ClassesRootRegKeyExists(const nsAString& aRegKeyPath)
{
nsresult rv;
nsCOMPtr<nsIWindowsRegKey> regKey =
do_CreateInstance("@mozilla.org/windows-registry-key;1", &rv);
if (NS_WARN_IF(NS_FAILED(rv))) {
return false;
}
rv = regKey->Open(nsIWindowsRegKey::ROOT_KEY_CLASSES_ROOT,
aRegKeyPath,
nsIWindowsRegKey::ACCESS_READ);
if (NS_FAILED(rv)) {
return false;
}
regKey->Close();
return true;
}
/* static */ bool
WMFDecoderModule::HasH264()
{
// CLSID_CMSH264DecoderMFT
return ClassesRootRegKeyExists(
NS_LITERAL_STRING("CLSID\\{32D186A7-218F-4C75-8876-DD77273A8999}"));
}
/* static */ bool
WMFDecoderModule::HasAAC()
{
// CLSID_CMSAACDecMFT
return ClassesRootRegKeyExists(
NS_LITERAL_STRING("CLSID\\{62CE7E72-4C71-4D20-B15D-452831A87D9D}"));
}
} // namespace mozilla

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

@ -36,6 +36,13 @@ public:
ConversionRequired
DecoderNeedsConversion(const TrackInfo& aConfig) const override;
// Accessors that report whether we have the required MFTs available
// on the system to play various codecs. Windows Vista doesn't have the
// H.264/AAC decoders if the "Platform Update Supplement for Windows Vista"
// is not installed.
static bool HasAAC();
static bool HasH264();
// Called on main thread.
static void Init();

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

@ -168,7 +168,7 @@ WMFVideoMFTManager::InitializeDXVA(bool aForceD3D9)
}
// The DXVA manager must be created on the main thread.
nsRefPtr<CreateDXVAManagerEvent> event =
nsRefPtr<CreateDXVAManagerEvent> event =
new CreateDXVAManagerEvent(aForceD3D9 ? LayersBackend::LAYERS_D3D9 : mLayersBackend, mDXVAFailureReason);
if (NS_IsMainThread()) {