зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1278198 - Implement "Get Supported Configuration" algorithm in MediaKeySystemAccess. r=gerald
MozReview-Commit-ID: KiJMOm5HgHe --HG-- extra : rebase_source : 0c60b76ad38cb9c5513e6618c8d8f4bc6f43b168
This commit is contained in:
Родитель
e7b5f0ede0
Коммит
1ec646af14
|
@ -406,16 +406,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
|
||||
aCodec.EqualsLiteral("mp4a.40.29"); // MPEG4 HE-AACv2
|
||||
}
|
||||
|
||||
bool
|
||||
ParseCodecsString(const nsAString& aCodecs, nsTArray<nsString>& aOutCodecs)
|
||||
{
|
||||
|
@ -434,97 +424,52 @@ ParseCodecsString(const nsAString& aCodecs, nsTArray<nsString>& aOutCodecs)
|
|||
return true;
|
||||
}
|
||||
|
||||
static bool
|
||||
CheckContentType(const nsAString& aContentType,
|
||||
mozilla::function<bool(const nsAString&)> aSubtypeFilter,
|
||||
mozilla::function<bool(const nsAString&)> aCodecFilter)
|
||||
bool
|
||||
ParseMIMETypeString(const nsAString& aMIMEType,
|
||||
nsString& aOutContainerType,
|
||||
nsTArray<nsString>& aOutCodecs)
|
||||
{
|
||||
nsContentTypeParser parser(aContentType);
|
||||
nsAutoString mimeType;
|
||||
nsresult rv = parser.GetType(mimeType);
|
||||
if (NS_FAILED(rv) || !aSubtypeFilter(mimeType)) {
|
||||
nsContentTypeParser parser(aMIMEType);
|
||||
nsresult rv = parser.GetType(aOutContainerType);
|
||||
if (NS_FAILED(rv)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
nsString codecsStr;
|
||||
parser.GetParameter("codecs", codecsStr);
|
||||
nsTArray<nsString> codecs;
|
||||
if (!ParseCodecsString(codecsStr, codecs)) {
|
||||
return false;
|
||||
}
|
||||
for (const nsString& codec : codecs) {
|
||||
if (!aCodecFilter(codec)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
return ParseCodecsString(codecsStr, aOutCodecs);
|
||||
}
|
||||
|
||||
bool
|
||||
IsH264ContentType(const nsAString& aContentType)
|
||||
IsH264CodecString(const nsAString& aCodec)
|
||||
{
|
||||
return CheckContentType(aContentType,
|
||||
[](const nsAString& type) {
|
||||
return type.EqualsLiteral("video/mp4");
|
||||
},
|
||||
[](const nsAString& codec) {
|
||||
int16_t profile = 0;
|
||||
int16_t level = 0;
|
||||
return ExtractH264CodecDetails(codec, profile, level);
|
||||
}
|
||||
);
|
||||
int16_t profile = 0;
|
||||
int16_t level = 0;
|
||||
return ExtractH264CodecDetails(aCodec, profile, level);
|
||||
}
|
||||
|
||||
bool
|
||||
IsAACContentType(const nsAString& aContentType)
|
||||
IsAACCodecString(const nsAString& aCodec)
|
||||
{
|
||||
return CheckContentType(aContentType,
|
||||
[](const nsAString& type) {
|
||||
return type.EqualsLiteral("audio/mp4") ||
|
||||
type.EqualsLiteral("audio/x-m4a");
|
||||
},
|
||||
[](const nsAString& codec) {
|
||||
return codec.EqualsLiteral("mp4a.40.2") || // MPEG4 AAC-LC
|
||||
codec.EqualsLiteral("mp4a.40.5") || // MPEG4 HE-AAC
|
||||
codec.EqualsLiteral("mp4a.67"); // MPEG2 AAC-LC
|
||||
});
|
||||
return
|
||||
aCodec.EqualsLiteral("mp4a.40.2") || // MPEG4 AAC-LC
|
||||
aCodec.EqualsLiteral("mp4a.40.5") || // MPEG4 HE-AAC
|
||||
aCodec.EqualsLiteral("mp4a.67") || // MPEG2 AAC-LC
|
||||
aCodec.EqualsLiteral("mp4a.40.29"); // MPEG4 HE-AACv2
|
||||
}
|
||||
|
||||
bool
|
||||
IsVorbisContentType(const nsAString& aContentType)
|
||||
IsVP8CodecString(const nsAString& aCodec)
|
||||
{
|
||||
return CheckContentType(aContentType,
|
||||
[](const nsAString& type) {
|
||||
return type.EqualsLiteral("audio/webm") ||
|
||||
type.EqualsLiteral("audio/ogg");
|
||||
},
|
||||
[](const nsAString& codec) {
|
||||
return codec.EqualsLiteral("vorbis");
|
||||
});
|
||||
return aCodec.EqualsLiteral("vp8") ||
|
||||
aCodec.EqualsLiteral("vp8.0");
|
||||
}
|
||||
|
||||
bool
|
||||
IsVP8ContentType(const nsAString& aContentType)
|
||||
IsVP9CodecString(const nsAString& aCodec)
|
||||
{
|
||||
return CheckContentType(aContentType,
|
||||
[](const nsAString& type) {
|
||||
return type.EqualsLiteral("video/webm");
|
||||
},
|
||||
[](const nsAString& codec) {
|
||||
return codec.EqualsLiteral("vp8");
|
||||
});
|
||||
}
|
||||
|
||||
bool
|
||||
IsVP9ContentType(const nsAString& aContentType)
|
||||
{
|
||||
return CheckContentType(aContentType,
|
||||
[](const nsAString& type) {
|
||||
return type.EqualsLiteral("video/webm");
|
||||
},
|
||||
[](const nsAString& codec) {
|
||||
return codec.EqualsLiteral("vp9");
|
||||
});
|
||||
return aCodec.EqualsLiteral("vp9") ||
|
||||
aCodec.EqualsLiteral("vp9.0");
|
||||
}
|
||||
|
||||
} // end namespace mozilla
|
||||
|
|
|
@ -322,18 +322,26 @@ private:
|
|||
void
|
||||
LogToBrowserConsole(const nsAString& aMsg);
|
||||
|
||||
bool
|
||||
ParseMIMETypeString(const nsAString& aMIMEType,
|
||||
nsString& aOutContainerType,
|
||||
nsTArray<nsString>& aOutCodecs);
|
||||
|
||||
bool
|
||||
ParseCodecsString(const nsAString& aCodecs, nsTArray<nsString>& aOutCodecs);
|
||||
|
||||
bool
|
||||
IsH264ContentType(const nsAString& aContentType);
|
||||
|
||||
bool
|
||||
IsAACContentType(const nsAString& aContentType);
|
||||
IsH264CodecString(const nsAString& aCodec);
|
||||
|
||||
bool
|
||||
IsAACCodecString(const nsAString& aCodec);
|
||||
|
||||
bool
|
||||
IsVP8CodecString(const nsAString& aCodec);
|
||||
|
||||
bool
|
||||
IsVP9CodecString(const nsAString& aCodec);
|
||||
|
||||
template <typename String>
|
||||
class StringListRange
|
||||
{
|
||||
|
@ -447,15 +455,6 @@ StringListContains(const ListString& aList, const ItemString& aItem)
|
|||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
IsVorbisContentType(const nsAString& aContentType);
|
||||
|
||||
bool
|
||||
IsVP8ContentType(const nsAString& aContentType);
|
||||
|
||||
bool
|
||||
IsVP9ContentType(const nsAString& aContentType);
|
||||
|
||||
} // end namespace mozilla
|
||||
|
||||
#endif
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -81,6 +81,21 @@ MediaKeySystemAccessManager::Request(DetailedPromise* aPromise,
|
|||
{
|
||||
EME_LOG("MediaKeySystemAccessManager::Request %s", NS_ConvertUTF16toUTF8(aKeySystem).get());
|
||||
|
||||
if (aKeySystem.IsEmpty()) {
|
||||
aPromise->MaybeReject(NS_ERROR_DOM_TYPE_ERR,
|
||||
NS_LITERAL_CSTRING("Key system string is empty"));
|
||||
// Don't notify DecoderDoctor, as there's nothing we or the user can
|
||||
// do to fix this situation; the site is using the API wrong.
|
||||
return;
|
||||
}
|
||||
if (aConfigs.IsEmpty()) {
|
||||
aPromise->MaybeReject(NS_ERROR_DOM_TYPE_ERR,
|
||||
NS_LITERAL_CSTRING("Candidate MediaKeySystemConfigs is empty"));
|
||||
// Don't notify DecoderDoctor, as there's nothing we or the user can
|
||||
// do to fix this situation; the site is using the API wrong.
|
||||
return;
|
||||
}
|
||||
|
||||
DecoderDoctorDiagnostics diagnostics;
|
||||
|
||||
// Parse keysystem, split it out into keySystem prefix, and version suffix.
|
||||
|
|
|
@ -81,8 +81,11 @@ IsWebMForced(DecoderDoctorDiagnostics* aDiagnostics)
|
|||
return !mp4supported || !hwsupported || VP9Benchmark::IsVP9DecodeFast();
|
||||
}
|
||||
|
||||
static nsresult
|
||||
IsTypeSupported(const nsAString& aType, DecoderDoctorDiagnostics* aDiagnostics)
|
||||
namespace dom {
|
||||
|
||||
/* static */
|
||||
nsresult
|
||||
MediaSource::IsTypeSupported(const nsAString& aType, DecoderDoctorDiagnostics* aDiagnostics)
|
||||
{
|
||||
if (aType.IsEmpty()) {
|
||||
return NS_ERROR_DOM_TYPE_ERR;
|
||||
|
@ -132,8 +135,6 @@ IsTypeSupported(const nsAString& aType, DecoderDoctorDiagnostics* aDiagnostics)
|
|||
return NS_ERROR_DOM_NOT_SUPPORTED_ERR;
|
||||
}
|
||||
|
||||
namespace dom {
|
||||
|
||||
/* static */ already_AddRefed<MediaSource>
|
||||
MediaSource::Constructor(const GlobalObject& aGlobal,
|
||||
ErrorResult& aRv)
|
||||
|
@ -221,7 +222,7 @@ MediaSource::AddSourceBuffer(const nsAString& aType, ErrorResult& aRv)
|
|||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
DecoderDoctorDiagnostics diagnostics;
|
||||
nsresult rv = mozilla::IsTypeSupported(aType, &diagnostics);
|
||||
nsresult rv = IsTypeSupported(aType, &diagnostics);
|
||||
diagnostics.StoreFormatDiagnostics(GetOwner()
|
||||
? GetOwner()->GetExtantDoc()
|
||||
: nullptr,
|
||||
|
@ -341,7 +342,7 @@ MediaSource::IsTypeSupported(const GlobalObject& aOwner, const nsAString& aType)
|
|||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
DecoderDoctorDiagnostics diagnostics;
|
||||
nsresult rv = mozilla::IsTypeSupported(aType, &diagnostics);
|
||||
nsresult rv = IsTypeSupported(aType, &diagnostics);
|
||||
nsCOMPtr<nsPIDOMWindowInner> window = do_QueryInterface(aOwner.GetAsSupports());
|
||||
diagnostics.StoreFormatDiagnostics(window ? window->GetExtantDoc() : nullptr,
|
||||
aType, NS_SUCCEEDED(rv), __func__);
|
||||
|
|
|
@ -65,6 +65,7 @@ public:
|
|||
void ClearLiveSeekableRange(ErrorResult& aRv);
|
||||
|
||||
static bool IsTypeSupported(const GlobalObject&, const nsAString& aType);
|
||||
static nsresult IsTypeSupported(const nsAString& aType, DecoderDoctorDiagnostics* aDiagnostics);
|
||||
|
||||
static bool Enabled(JSContext* cx, JSObject* aGlobal);
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче