Bug 1206977: P14. Remove obsolete / redundant code. r=cpearce
☠☠ backed out by 005264192a61 ☠ ☠
authorJean-Yves Avenard <jyavenard@mozilla.com>
Wed, 07 Oct 2015 11:14:46 +1100
changeset 299894 51b1b076a3869983a5597240bceccfd46972f160
parent 299893 dec7c35469d1a64a3c7c24370a69782bdeea738d
child 299895 8752bb087900a6de7d51efc5dc781cc518643cea
push idunknown
push userunknown
push dateunknown
reviewerscpearce
bugs1206977
milestone44.0a1
Bug 1206977: P14. Remove obsolete / redundant code. r=cpearce
dom/media/MP3Decoder.cpp
dom/media/fmp4/MP4Decoder.cpp
dom/media/fmp4/MP4Decoder.h
--- a/dom/media/MP3Decoder.cpp
+++ b/dom/media/MP3Decoder.cpp
@@ -24,60 +24,28 @@ MP3Decoder::Clone() {
 
 MediaDecoderStateMachine*
 MP3Decoder::CreateStateMachine() {
   nsRefPtr<MediaDecoderReader> reader =
       new MediaFormatReader(this, new mp3::MP3Demuxer(GetResource()));
   return new MediaDecoderStateMachine(this, reader);
 }
 
-static already_AddRefed<MediaDataDecoder>
-CreateTestMP3Decoder(AudioInfo& aConfig)
-{
-  PDMFactory::Init();
-
-  nsRefPtr<PDMFactory> platform = new PDMFactory();
-  nsRefPtr<MediaDataDecoder> decoder(
-    platform->CreateDecoder(aConfig, nullptr, nullptr));
-
-  return decoder.forget();
-}
-
-static bool
-CanCreateMP3Decoder()
-{
-  static bool haveCachedResult = false;
-  static bool result = false;
-  if (haveCachedResult) {
-    return result;
-  }
-  AudioInfo config;
-  config.mMimeType = "audio/mpeg";
-  config.mRate = 48000;
-  config.mChannels = 2;
-  config.mBitDepth = 16;
-  nsRefPtr<MediaDataDecoder> decoder(CreateTestMP3Decoder(config));
-  if (decoder) {
-    decoder->Shutdown();
-    result = true;
-  }
-  haveCachedResult = true;
-  return result;
-}
-
 /* static */
 bool
 MP3Decoder::IsEnabled() {
-  return CanCreateMP3Decoder();
+  PDMFactory::Init();
+  nsRefPtr<PDMFactory> platform = new PDMFactory();
+  return platform->SupportsMimeType(NS_LITERAL_CSTRING("audio/mpeg"));
 }
 
 /* static */
 bool MP3Decoder::CanHandleMediaType(const nsACString& aType,
                                     const nsAString& aCodecs)
 {
   if (aType.EqualsASCII("audio/mp3") || aType.EqualsASCII("audio/mpeg")) {
-    return CanCreateMP3Decoder() &&
+    return IsEnabled() &&
       (aCodecs.IsEmpty() || aCodecs.EqualsASCII("mp3"));
   }
   return false;
 }
 
 } // namespace mozilla
--- a/dom/media/fmp4/MP4Decoder.cpp
+++ b/dom/media/fmp4/MP4Decoder.cpp
@@ -219,89 +219,9 @@ MP4Decoder::IsVideoAccelerated(layers::L
     aFailureReason.AssignLiteral("Failed to create H264 decoder");
     return false;
   }
   bool result = decoder->IsHardwareAccelerated(aFailureReason);
   decoder->Shutdown();
   return result;
 }
 
-/* static */ bool
-MP4Decoder::CanCreateH264Decoder()
-{
-#ifdef XP_WIN
-  static bool haveCachedResult = false;
-  static bool result = false;
-  if (haveCachedResult) {
-    return result;
-  }
-  VideoInfo config;
-  nsRefPtr<MediaDataDecoder> decoder(
-    CreateTestH264Decoder(layers::LayersBackend::LAYERS_BASIC, config));
-  if (decoder) {
-    decoder->Shutdown();
-    result = true;
-  }
-  haveCachedResult = true;
-  return result;
-#else
-  return IsEnabled();
-#endif
-}
-
-#ifdef XP_WIN
-static already_AddRefed<MediaDataDecoder>
-CreateTestAACDecoder(AudioInfo& aConfig)
-{
-  PDMFactory::Init();
-
-  nsRefPtr<PDMFactory> platform = new PDMFactory();
-  nsRefPtr<MediaDataDecoder> decoder(
-    platform->CreateDecoder(aConfig, nullptr, nullptr));
-
-  return decoder.forget();
-}
-
-// bipbop.mp4's extradata/config...
-static const uint8_t sTestAACExtraData[] = {
-  0x03, 0x80, 0x80, 0x80, 0x22, 0x00, 0x02, 0x00, 0x04, 0x80,
-  0x80, 0x80, 0x14, 0x40, 0x15, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x11, 0x51, 0x00, 0x00, 0x11, 0x51, 0x05, 0x80, 0x80, 0x80,
-  0x02, 0x13, 0x90, 0x06, 0x80, 0x80, 0x80, 0x01, 0x02
-};
-
-static const uint8_t sTestAACConfig[] = { 0x13, 0x90 };
-
-#endif // XP_WIN
-
-/* static */ bool
-MP4Decoder::CanCreateAACDecoder()
-{
-#ifdef XP_WIN
-  static bool haveCachedResult = false;
-  static bool result = false;
-  if (haveCachedResult) {
-    return result;
-  }
-  AudioInfo config;
-  config.mMimeType = "audio/mp4a-latm";
-  config.mRate = 22050;
-  config.mChannels = 2;
-  config.mBitDepth = 16;
-  config.mProfile = 2;
-  config.mExtendedProfile = 2;
-  config.mCodecSpecificConfig->AppendElements(sTestAACConfig,
-                                              MOZ_ARRAY_LENGTH(sTestAACConfig));
-  config.mExtraData->AppendElements(sTestAACExtraData,
-                                    MOZ_ARRAY_LENGTH(sTestAACExtraData));
-  nsRefPtr<MediaDataDecoder> decoder(CreateTestAACDecoder(config));
-  if (decoder) {
-    decoder->Shutdown();
-    result = true;
-  }
-  haveCachedResult = true;
-  return result;
-#else
-  return IsEnabled();
-#endif
-}
-
 } // namespace mozilla
--- a/dom/media/fmp4/MP4Decoder.h
+++ b/dom/media/fmp4/MP4Decoder.h
@@ -33,15 +33,13 @@ public:
                                  const nsAString& aCodecs);
 
   static bool CanHandleMediaType(const nsAString& aMIMEType);
 
   // Returns true if the MP4 backend is preffed on.
   static bool IsEnabled();
 
   static bool IsVideoAccelerated(layers::LayersBackend aBackend, nsACString& aReason);
-  static bool CanCreateAACDecoder();
-  static bool CanCreateH264Decoder();
 };
 
 } // namespace mozilla
 
 #endif