Bug 1176218 - p12. Use new PDM's Supports(Trackinfo) in MP4Decoder - r=jya
authorGerald Squelart <gsquelart@mozilla.com>
Fri, 07 Oct 2016 15:51:22 +1100
changeset 317121 82be75a8428869b9c80db58a8789cab7bc1c01cf
parent 317120 2dd8be39ec85d4df43c26aa22b438b799b974731
child 317122 4429c8701a840b4b08c28507e909a429d37916d5
push id30792
push userphilringnalda@gmail.com
push dateSat, 08 Oct 2016 23:47:45 +0000
treeherdermozilla-central@313a2d049350 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjya
bugs1176218
milestone52.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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 */