Bug 1176218 - p12. Use new PDM's Supports(Trackinfo) in MP4Decoder - r=jya
MP4Decoder can translate the new MediaContentType into the relevant TrackInfo
to interrogate PDMs about codec support, with extra information if present.
MozReview-Commit-ID: K0jcYm8pJrp
--- a/dom/media/fmp4/MP4Decoder.cpp
+++ b/dom/media/fmp4/MP4Decoder.cpp
@@ -99,56 +99,66 @@ MP4Decoder::CanHandleMediaType(const Med
#endif
aType.GetMIMEType().EqualsASCII("video/mp4") ||
aType.GetMIMEType().EqualsASCII("video/quicktime") ||
aType.GetMIMEType().EqualsASCII("video/x-m4v");
if (!isMP4Audio && !isMP4Video) {
return false;
}
- nsTArray<nsCString> codecMimes;
+ nsTArray<UniquePtr<TrackInfo>> trackInfos;
if (aType.GetCodecs().IsEmpty()) {
// No codecs specified. Assume AAC/H.264
if (isMP4Audio) {
- codecMimes.AppendElement(NS_LITERAL_CSTRING("audio/mp4a-latm"));
+ trackInfos.AppendElement(
+ CreateTrackInfoWithMIMETypeAndContentTypeExtraParameters(
+ NS_LITERAL_CSTRING("audio/mp4a-latm"), aType));
} else {
MOZ_ASSERT(isMP4Video);
- codecMimes.AppendElement(NS_LITERAL_CSTRING("video/avc"));
+ trackInfos.AppendElement(
+ CreateTrackInfoWithMIMETypeAndContentTypeExtraParameters(
+ NS_LITERAL_CSTRING("video/avc"), aType));
}
} else {
// Verify that all the codecs specified are ones that we expect that
// we can play.
nsTArray<nsString> codecs;
if (!ParseCodecsString(aType.GetCodecs(), codecs)) {
return false;
}
for (const nsString& codec : codecs) {
if (IsAACCodecString(codec)) {
- codecMimes.AppendElement(NS_LITERAL_CSTRING("audio/mp4a-latm"));
+ trackInfos.AppendElement(
+ CreateTrackInfoWithMIMETypeAndContentTypeExtraParameters(
+ NS_LITERAL_CSTRING("audio/mp4a-latm"), aType));
continue;
}
if (codec.EqualsLiteral("mp3")) {
- codecMimes.AppendElement(NS_LITERAL_CSTRING("audio/mpeg"));
+ trackInfos.AppendElement(
+ CreateTrackInfoWithMIMETypeAndContentTypeExtraParameters(
+ NS_LITERAL_CSTRING("audio/mpeg"), aType));
continue;
}
// Note: Only accept H.264 in a video content type, not in an audio
// content type.
if (IsWhitelistedH264Codec(codec) && isMP4Video) {
- codecMimes.AppendElement(NS_LITERAL_CSTRING("video/avc"));
+ trackInfos.AppendElement(
+ CreateTrackInfoWithMIMETypeAndContentTypeExtraParameters(
+ NS_LITERAL_CSTRING("video/avc"), aType));
continue;
}
// Some unsupported codec.
return false;
}
}
// Verify that we have a PDM that supports the whitelisted types.
RefPtr<PDMFactory> platform = new PDMFactory();
- for (const nsCString& codecMime : codecMimes) {
- if (!platform->SupportsMimeType(codecMime, aDiagnostics)) {
+ for (const auto& trackInfo : trackInfos) {
+ if (!trackInfo || !platform->Supports(*trackInfo, aDiagnostics)) {
return false;
}
}
return true;
}
/* static */