зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1212670 - Implement GMPDecoderModule::SupportsMimeType() and EMEDecoderModule::SupportsMimeType(). r=jwwang
This commit is contained in:
Родитель
9475cc85a4
Коммит
4350c14ce1
|
@ -14,6 +14,7 @@
|
||||||
#include "nsServiceManagerUtils.h"
|
#include "nsServiceManagerUtils.h"
|
||||||
#include "MediaInfo.h"
|
#include "MediaInfo.h"
|
||||||
#include "nsClassHashtable.h"
|
#include "nsClassHashtable.h"
|
||||||
|
#include "GMPDecoderModule.h"
|
||||||
|
|
||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
|
|
||||||
|
@ -301,4 +302,12 @@ EMEDecoderModule::DecoderNeedsConversion(const TrackInfo& aConfig) const
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
EMEDecoderModule::SupportsMimeType(const nsACString& aMimeType)
|
||||||
|
{
|
||||||
|
Maybe<nsCString> gmp;
|
||||||
|
gmp.emplace(NS_ConvertUTF16toUTF8(mProxy->KeySystem()));
|
||||||
|
return GMPDecoderModule::SupportsMimeType(aMimeType, gmp);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace mozilla
|
} // namespace mozilla
|
||||||
|
|
|
@ -45,13 +45,7 @@ protected:
|
||||||
DecoderNeedsConversion(const TrackInfo& aConfig) const override;
|
DecoderNeedsConversion(const TrackInfo& aConfig) const override;
|
||||||
|
|
||||||
bool
|
bool
|
||||||
SupportsMimeType(const nsACString& aMimeType) override
|
SupportsMimeType(const nsACString& aMimeType) override;
|
||||||
{
|
|
||||||
// TODO Properly.
|
|
||||||
return aMimeType.EqualsLiteral("audio/mp4a-latm") ||
|
|
||||||
aMimeType.EqualsLiteral("video/mp4") ||
|
|
||||||
aMimeType.EqualsLiteral("video/avc");
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
nsRefPtr<CDMProxy> mProxy;
|
nsRefPtr<CDMProxy> mProxy;
|
||||||
|
|
|
@ -11,6 +11,8 @@
|
||||||
#include "mozIGeckoMediaPluginService.h"
|
#include "mozIGeckoMediaPluginService.h"
|
||||||
#include "nsServiceManagerUtils.h"
|
#include "nsServiceManagerUtils.h"
|
||||||
#include "mozilla/Preferences.h"
|
#include "mozilla/Preferences.h"
|
||||||
|
#include "gmp-audio-decode.h"
|
||||||
|
#include "gmp-video-decode.h"
|
||||||
|
|
||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
|
|
||||||
|
@ -124,4 +126,41 @@ GMPDecoderModule::PreferredGMP(const nsACString& aMimeType)
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
GMPDecoderModule::SupportsMimeType(const nsACString& aMimeType,
|
||||||
|
const Maybe<nsCString>& aGMP)
|
||||||
|
{
|
||||||
|
nsTArray<nsCString> tags;
|
||||||
|
nsCString api;
|
||||||
|
if (aMimeType.EqualsLiteral("audio/mp4a-latm")) {
|
||||||
|
tags.AppendElement(NS_LITERAL_CSTRING("aac"));
|
||||||
|
api = NS_LITERAL_CSTRING(GMP_API_AUDIO_DECODER);
|
||||||
|
} else if (aMimeType.EqualsLiteral("video/avc") ||
|
||||||
|
aMimeType.EqualsLiteral("video/mp4")) {
|
||||||
|
tags.AppendElement(NS_LITERAL_CSTRING("h264"));
|
||||||
|
api = NS_LITERAL_CSTRING(GMP_API_VIDEO_DECODER);
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (aGMP.isSome()) {
|
||||||
|
tags.AppendElement(aGMP.value());
|
||||||
|
}
|
||||||
|
nsCOMPtr<mozIGeckoMediaPluginService> mps =
|
||||||
|
do_GetService("@mozilla.org/gecko-media-plugin-service;1");
|
||||||
|
if (NS_WARN_IF(!mps)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
bool hasPlugin = false;
|
||||||
|
if (NS_FAILED(mps->HasPluginForAPI(api, &tags, &hasPlugin))) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return hasPlugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
GMPDecoderModule::SupportsMimeType(const nsACString& aMimeType)
|
||||||
|
{
|
||||||
|
return SupportsMimeType(aMimeType, PreferredGMP(aMimeType));
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace mozilla
|
} // namespace mozilla
|
||||||
|
|
|
@ -36,17 +36,15 @@ public:
|
||||||
DecoderNeedsConversion(const TrackInfo& aConfig) const override;
|
DecoderNeedsConversion(const TrackInfo& aConfig) const override;
|
||||||
|
|
||||||
bool
|
bool
|
||||||
SupportsMimeType(const nsACString& aMimeType) override
|
SupportsMimeType(const nsACString& aMimeType) override;
|
||||||
{
|
|
||||||
// TODO properly.
|
|
||||||
return aMimeType.EqualsLiteral("audio/mp4a-latm") ||
|
|
||||||
aMimeType.EqualsLiteral("video/avc");
|
|
||||||
}
|
|
||||||
|
|
||||||
static void Init();
|
static void Init();
|
||||||
|
|
||||||
static const Maybe<nsCString> PreferredGMP(const nsACString& aMimeType);
|
static const Maybe<nsCString> PreferredGMP(const nsACString& aMimeType);
|
||||||
|
|
||||||
|
static bool SupportsMimeType(const nsACString& aMimeType,
|
||||||
|
const Maybe<nsCString>& aGMP);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace mozilla
|
} // namespace mozilla
|
||||||
|
|
Загрузка…
Ссылка в новой задаче