Bug 1176218 - p3. Add DecoderTraits::CanHandleContentType - r=jya
authorGerald Squelart <gsquelart@mozilla.com>
Mon, 26 Sep 2016 16:43:16 +1000
changeset 317110 989afc4cbc443fbbe175dbd4c808efa64f29ca61
parent 317109 0bed1d9a4bb27ea2fa4e1361c35226b3fa9c4347
child 317111 0578fd79f0f014c2bf05588d0f63372f322e1ac9
push id32985
push usergsquelart@mozilla.com
push dateSat, 08 Oct 2016 05:00:27 +0000
treeherderautoland@4429c8701a84 [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 - p3. Add DecoderTraits::CanHandleContentType - r=jya Instead of taking MIME&codecs strings, CanHandleContentType takes an MediaContentType, which can be used to access these and other parameters. MozReview-Commit-ID: 14Cg6JoQS0g
dom/media/DecoderTraits.cpp
dom/media/DecoderTraits.h
--- a/dom/media/DecoderTraits.cpp
+++ b/dom/media/DecoderTraits.cpp
@@ -1,15 +1,16 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim:set ts=2 sw=2 sts=2 et cindent: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "DecoderTraits.h"
+#include "MediaContentType.h"
 #include "MediaDecoder.h"
 #include "nsCharSeparatedTokenizer.h"
 #include "nsMimeTypes.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/Telemetry.h"
 
 #include "OggDecoder.h"
 #include "OggReader.h"
@@ -487,16 +488,31 @@ DecoderTraits::CanHandleMediaType(const 
   if (MediaDecoder::IsAndroidMediaPluginEnabled() &&
       EnsureAndroidMediaPluginHost()->FindDecoder(nsDependentCString(aMIMEType), nullptr)) {
     return CANPLAY_MAYBE;
   }
 #endif
   return CANPLAY_NO;
 }
 
+/* static */
+CanPlayStatus
+DecoderTraits::CanHandleContentType(const MediaContentType& aContentType,
+                                    DecoderDoctorDiagnostics* aDiagnostics)
+{
+  if (!aContentType.IsValid()) {
+    return CANPLAY_NO;
+  }
+
+  return CanHandleMediaType(aContentType.GetMIMEType().Data(),
+                            aContentType.HaveCodecs(),
+                            aContentType.GetCodecs(),
+                            aDiagnostics);
+}
+
 // Instantiates but does not initialize decoder.
 static
 already_AddRefed<MediaDecoder>
 InstantiateDecoder(const nsACString& aType,
                    MediaDecoderOwner* aOwner,
                    DecoderDoctorDiagnostics* aDiagnostics)
 {
   MOZ_ASSERT(NS_IsMainThread());
--- a/dom/media/DecoderTraits.h
+++ b/dom/media/DecoderTraits.h
@@ -11,28 +11,33 @@
 
 class nsAString;
 class nsACString;
 
 namespace mozilla {
 
 class AbstractMediaDecoder;
 class DecoderDoctorDiagnostics;
+class MediaContentType;
 class MediaDecoder;
 class MediaDecoderOwner;
 class MediaDecoderReader;
 
 enum CanPlayStatus {
   CANPLAY_NO,
   CANPLAY_MAYBE,
   CANPLAY_YES
 };
 
 class DecoderTraits {
 public:
+  // Returns the CanPlayStatus indicating if we can handle this content type.
+  static CanPlayStatus CanHandleContentType(const MediaContentType& aContentType,
+                                            DecoderDoctorDiagnostics* aDiagnostics);
+
   // Returns the CanPlayStatus indicating if we can handle this
   // MIME type. The MIME type should not include the codecs parameter.
   // That parameter should be passed in aRequestedCodecs, and will only be
   // used if whether a given MIME type being handled depends on the
   // codec that will be used.  If the codecs parameter has not been
   // specified, pass false in aHaveRequestedCodecs.
   static CanPlayStatus CanHandleMediaType(const char* aMIMEType,
                                           bool aHaveRequestedCodecs,