Bug 1330284 - Use MediaContentType in AndroidMediaPluginHost::FindDecoder - r=jya
authorGerald Squelart <gsquelart@mozilla.com>
Wed, 28 Dec 2016 09:51:48 +1100
changeset 374474 71dea91ccdda17c50a08e42ed31281f6a8a743af
parent 374473 540717f0dc54df66f71ecb40fe547a744d7bcb27
child 374475 3271745425d782a0f643410f3d14efa46586d10c
push id6996
push userjlorenzo@mozilla.com
push dateMon, 06 Mar 2017 20:48:21 +0000
treeherdermozilla-beta@d89512dab048 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjya
bugs1330284
milestone53.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 1330284 - Use MediaContentType in AndroidMediaPluginHost::FindDecoder - r=jya MozReview-Commit-ID: 8IwazcFA5Jr
dom/media/DecoderTraits.cpp
dom/media/android/AndroidMediaPluginHost.cpp
dom/media/android/AndroidMediaPluginHost.h
--- a/dom/media/DecoderTraits.cpp
+++ b/dom/media/DecoderTraits.cpp
@@ -166,18 +166,17 @@ CanHandleCodecsType(const MediaContentTy
   if (FlacDecoder::IsSupportedType(aType)) {
     return CANPLAY_YES;
   }
 #ifdef MOZ_DIRECTSHOW
   DirectShowDecoder::GetSupportedCodecs(aType, &codecList);
 #endif
 #ifdef MOZ_ANDROID_OMX
   if (MediaDecoder::IsAndroidMediaPluginEnabled()) {
-    EnsureAndroidMediaPluginHost()->FindDecoder(aType.Type().AsString(),
-                                                &codecList);
+    EnsureAndroidMediaPluginHost()->FindDecoder(aType, &codecList);
   }
 #endif
   if (!codecList) {
     return CANPLAY_MAYBE;
   }
 
   // See http://www.rfc-editor.org/rfc/rfc4281.txt for the description
   // of the 'codecs' parameter
@@ -249,17 +248,17 @@ CanHandleMediaType(const MediaContentTyp
   }
 #ifdef MOZ_DIRECTSHOW
   if (DirectShowDecoder::GetSupportedCodecs(mimeType, nullptr)) {
     return CANPLAY_MAYBE;
   }
 #endif
 #ifdef MOZ_ANDROID_OMX
   if (MediaDecoder::IsAndroidMediaPluginEnabled() &&
-      EnsureAndroidMediaPluginHost()->FindDecoder(mimeType.Type().AsString(), nullptr)) {
+      EnsureAndroidMediaPluginHost()->FindDecoder(mimeType, nullptr)) {
     return CANPLAY_MAYBE;
   }
 #endif
   return CANPLAY_NO;
 }
 
 /* static */
 CanPlayStatus
@@ -334,18 +333,17 @@ InstantiateDecoder(const MediaContentTyp
     return decoder.forget();
   }
   if (FlacDecoder::IsSupportedType(aType)) {
     decoder = new FlacDecoder(aOwner);
     return decoder.forget();
   }
 #ifdef MOZ_ANDROID_OMX
   if (MediaDecoder::IsAndroidMediaPluginEnabled() &&
-      EnsureAndroidMediaPluginHost()->FindDecoder(aType.Type().AsString(),
-                                                  nullptr)) {
+      EnsureAndroidMediaPluginHost()->FindDecoder(aType, nullptr)) {
     decoder = new AndroidMediaDecoder(aOwner, aType.Type().AsString());
     return decoder.forget();
   }
 #endif
 
   if (WebMDecoder::IsSupportedType(aType)) {
     decoder = new WebMDecoder(aOwner);
     return decoder.forget();
--- a/dom/media/android/AndroidMediaPluginHost.cpp
+++ b/dom/media/android/AndroidMediaPluginHost.cpp
@@ -1,14 +1,15 @@
 /* -*- 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 "mozilla/Preferences.h"
+#include "MediaContentType.h"
 #include "MediaResource.h"
 #include "mozilla/dom/HTMLMediaElement.h"
 #include "mozilla/Services.h"
 #include "AndroidMediaPluginHost.h"
 #include "nsAutoPtr.h"
 #include "nsXPCOMStrings.h"
 #include "nsISeekableStream.h"
 #include "nsIGfxInfo.h"
@@ -221,20 +222,21 @@ AndroidMediaPluginHost::AndroidMediaPlug
   }
 }
 
 AndroidMediaPluginHost::~AndroidMediaPluginHost() {
   mResourceServer->Stop();
   MOZ_COUNT_DTOR(AndroidMediaPluginHost);
 }
 
-bool AndroidMediaPluginHost::FindDecoder(const nsACString& aMimeType, const char* const** aCodecs)
+bool AndroidMediaPluginHost::FindDecoder(const MediaContentType& aMimeType,
+                                         const char* const** aCodecs)
 {
   const char *chars;
-  size_t len = NS_CStringGetData(aMimeType, &chars, nullptr);
+  size_t len = NS_CStringGetData(aMimeType.Type().AsString(), &chars, nullptr);
   for (size_t n = 0; n < mPlugins.Length(); ++n) {
     Manifest *plugin = mPlugins[n];
     const char* const *codecs;
     if (plugin->CanDecode(chars, len, &codecs)) {
       if (aCodecs)
         *aCodecs = codecs;
       return true;
     }
--- a/dom/media/android/AndroidMediaPluginHost.h
+++ b/dom/media/android/AndroidMediaPluginHost.h
@@ -8,28 +8,30 @@
 
 #include "nsTArray.h"
 #include "MediaResource.h"
 #include "MPAPI.h"
 #include "AndroidMediaResourceServer.h"
 
 namespace mozilla {
 
+class MediaContentType;
+
 class AndroidMediaPluginHost {
   RefPtr<AndroidMediaResourceServer> mResourceServer;
   nsTArray<MPAPI::Manifest *> mPlugins;
 
   MPAPI::Manifest *FindPlugin(const nsACString& aMimeType);
 public:
   AndroidMediaPluginHost();
   ~AndroidMediaPluginHost();
 
   static void Shutdown();
 
-  bool FindDecoder(const nsACString& aMimeType, const char* const** aCodecs);
+  bool FindDecoder(const MediaContentType& aMimeType, const char* const** aCodecs);
   MPAPI::Decoder *CreateDecoder(mozilla::MediaResource *aResource, const nsACString& aMimeType);
   void DestroyDecoder(MPAPI::Decoder *aDecoder);
 };
 
 // Must be called on the main thread. Creates the plugin host if it doesn't
 // already exist.
 AndroidMediaPluginHost *EnsureAndroidMediaPluginHost();