Bug 829408 - Force stagefright to return readable video frames on Gingerbread on the Galaxy SII r=doublec
authorEdwin Flores <eflores@mozilla.com>
Mon, 25 Feb 2013 12:03:55 +1300
changeset 122838 e9c76968a95ebfd91c872c37c8e4c01874babd7e
parent 122819 e48e1afb1899fc41cdad2c7bf0632d240018047f
child 122839 86c4d6a9775a59a48a99c7b702fa02a859c32218
push id1387
push userphilringnalda@gmail.com
push dateTue, 26 Feb 2013 22:32:56 +0000
treeherderfx-team@ad4cc4e97774 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdoublec
bugs829408
milestone22.0a1
Bug 829408 - Force stagefright to return readable video frames on Gingerbread on the Galaxy SII r=doublec
media/omx-plugin/OmxPlugin.cpp
--- a/media/omx-plugin/OmxPlugin.cpp
+++ b/media/omx-plugin/OmxPlugin.cpp
@@ -17,16 +17,22 @@
 #include <algorithm>
 
 #include "mozilla/Assertions.h"
 #include "mozilla/Types.h"
 #include "MPAPI.h"
 
 #include "android/log.h"
 
+#if !defined(MOZ_ANDROID_FROYO)
+#define DEFAULT_STAGEFRIGHT_FLAGS OMXCodec::kClientNeedsFramebuffer
+#else
+#define DEFAULT_STAGEFRIGHT_FLAGS 0
+#endif
+
 #undef LOG
 #define LOG(args...)  __android_log_print(ANDROID_LOG_INFO, "OmxPlugin" , ## args)
 
 #if defined(MOZ_ANDROID_FROYO) || defined(MOZ_ANDROID_GB)
 // Android versions 2.x.x have common API differences
 #define MOZ_ANDROID_V2_X_X
 #endif
 
@@ -280,29 +286,32 @@ static uint32_t GetVideoCreationFlags(Pl
     LOG("media.stagefright.omxcodec.flags=%d", flags);
     if ((flags & OMXCodec::kHardwareCodecsOnly) != 0) {
       LOG("FORCE HARDWARE DECODING");
     } else if ((flags & OMXCodec::kSoftwareCodecsOnly) != 0) {
       LOG("FORCE SOFTWARE DECODING");
     }
 #endif
   }
+
+  flags |= DEFAULT_STAGEFRIGHT_FLAGS;
+
   return static_cast<uint32_t>(flags);
 #endif
 }
 
 static sp<MediaSource> CreateVideoSource(PluginHost* aPluginHost,
                                          const sp<IOMX>& aOmx,
                                          const sp<MediaSource>& aVideoTrack)
 {
   uint32_t flags = GetVideoCreationFlags(aPluginHost);
-  if (flags == 0) {
+  if (flags == DEFAULT_STAGEFRIGHT_FLAGS) {
     // Let Stagefright choose hardware or software decoder.
     sp<MediaSource> videoSource = OMXCodec::Create(aOmx, aVideoTrack->getFormat(),
-                                                   false, aVideoTrack, NULL, 0);
+                                                   false, aVideoTrack, NULL, flags);
     if (videoSource == NULL)
       return NULL;
 
     // Now that OMXCodec has parsed the video's AVCDecoderConfigurationRecord,
     // check whether we know how to decode this video.
     int32_t videoColorFormat;
     if (videoSource->getFormat()->findInt32(kKeyColorFormat, &videoColorFormat)) {
       switch (videoColorFormat) {
@@ -332,23 +341,23 @@ static sp<MediaSource> CreateVideoSource
     } else {
       LOG("Video color format not found");
     }
 
     // Throw away the videoSource and try again with new flags.
     LOG("Falling back to software decoder");
     videoSource.clear();
 #if defined(MOZ_ANDROID_V2_X_X)
-    flags = OMXCodec::kPreferSoftwareCodecs;
+    flags = DEFAULT_STAGEFRIGHT_FLAGS | OMXCodec::kPreferSoftwareCodecs;
 #else
-    flags = OMXCodec::kSoftwareCodecsOnly;
+    flags = DEFAULT_STAGEFRIGHT_FLAGS | OMXCodec::kSoftwareCodecsOnly;
 #endif
   }
 
-  MOZ_ASSERT(flags != 0);
+  MOZ_ASSERT(flags != DEFAULT_STAGEFRIGHT_FLAGS);
   return OMXCodec::Create(aOmx, aVideoTrack->getFormat(), false, aVideoTrack,
                           NULL, flags);
 }
 
 bool OmxDecoder::Init() {
   //register sniffers, if they are not registered in this process.
   DataSource::RegisterDefaultSniffers();