Bug 1176218 - p12. Use new PDM's Supports(Trackinfo) in MP4Decoder - r=jya draft
authorGerald Squelart <gsquelart@mozilla.com>
Fri, 07 Oct 2016 15:51:22 +1100
changeset 422004 e809824285a85035b81ad7f91406bce6393384f6
parent 422003 6f43bf61dc6e51de3714c9a556428c7ba4fd484d
child 422005 40e5987deeffff652a88264f157391c0dbc0a2da
push id31653
push usergsquelart@mozilla.com
push dateFri, 07 Oct 2016 06:47:50 +0000
reviewersjya
bugs1176218
milestone52.0a1
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
dom/media/fmp4/MP4Decoder.cpp
--- 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 */