mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-20 08:51:04 +00:00
Bug 1212670 - Implement GMPDecoderModule::SupportsMimeType() and EMEDecoderModule::SupportsMimeType(). r=jwwang
This commit is contained in:
parent
9475cc85a4
commit
4350c14ce1
@ -14,6 +14,7 @@
|
||||
#include "nsServiceManagerUtils.h"
|
||||
#include "MediaInfo.h"
|
||||
#include "nsClassHashtable.h"
|
||||
#include "GMPDecoderModule.h"
|
||||
|
||||
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
|
||||
|
@ -45,13 +45,7 @@ protected:
|
||||
DecoderNeedsConversion(const TrackInfo& aConfig) const override;
|
||||
|
||||
bool
|
||||
SupportsMimeType(const nsACString& aMimeType) override
|
||||
{
|
||||
// TODO Properly.
|
||||
return aMimeType.EqualsLiteral("audio/mp4a-latm") ||
|
||||
aMimeType.EqualsLiteral("video/mp4") ||
|
||||
aMimeType.EqualsLiteral("video/avc");
|
||||
}
|
||||
SupportsMimeType(const nsACString& aMimeType) override;
|
||||
|
||||
private:
|
||||
nsRefPtr<CDMProxy> mProxy;
|
||||
|
@ -11,6 +11,8 @@
|
||||
#include "mozIGeckoMediaPluginService.h"
|
||||
#include "nsServiceManagerUtils.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "gmp-audio-decode.h"
|
||||
#include "gmp-video-decode.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
@ -124,4 +126,41 @@ GMPDecoderModule::PreferredGMP(const nsACString& aMimeType)
|
||||
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
|
||||
|
@ -36,17 +36,15 @@ public:
|
||||
DecoderNeedsConversion(const TrackInfo& aConfig) const override;
|
||||
|
||||
bool
|
||||
SupportsMimeType(const nsACString& aMimeType) override
|
||||
{
|
||||
// TODO properly.
|
||||
return aMimeType.EqualsLiteral("audio/mp4a-latm") ||
|
||||
aMimeType.EqualsLiteral("video/avc");
|
||||
}
|
||||
SupportsMimeType(const nsACString& aMimeType) override;
|
||||
|
||||
static void Init();
|
||||
|
||||
static const Maybe<nsCString> PreferredGMP(const nsACString& aMimeType);
|
||||
|
||||
static bool SupportsMimeType(const nsACString& aMimeType,
|
||||
const Maybe<nsCString>& aGMP);
|
||||
|
||||
};
|
||||
|
||||
} // namespace mozilla
|
||||
|
Loading…
x
Reference in New Issue
Block a user