Bug 1041882 - Remove Froyo-specific OMX plugin support. r=snorp
authorMike Taylor <miket@mozilla.com>
Sat, 26 Sep 2015 09:06:00 +0200
changeset 265526 0b4987e8fe7d
parent 265525 f8d280b9d4fe
child 265527 6720d34c74b4
push id29464
push usercbook@mozilla.com
push dateFri, 02 Oct 2015 09:50:37 +0000
treeherdermozilla-central@af01a617cb76 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssnorp
bugs1041882
milestone44.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 1041882 - Remove Froyo-specific OMX plugin support. r=snorp
media/omx-plugin/OmxPlugin.cpp
media/omx-plugin/lib/gb/libstagefright/libstagefright.cpp
--- a/media/omx-plugin/OmxPlugin.cpp
+++ b/media/omx-plugin/OmxPlugin.cpp
@@ -21,31 +21,22 @@
 #include "mozilla/Types.h"
 #include "MPAPI.h"
 
 #include "android/log.h"
 
 #define MAX_DECODER_NAME_LEN 256
 #define AVC_MIME_TYPE "video/avc"
 
-#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
-
-#if !defined(MOZ_ANDROID_V2_X_X) && !defined(MOZ_ANDROID_HC)
+#if !defined(MOZ_ANDROID_GB) && !defined(MOZ_ANDROID_HC)
 #define MOZ_ANDROID_V4_OR_ABOVE
 #endif
 
 #if defined(MOZ_ANDROID_V4_OR_ABOVE)
 #include <I420ColorConverter.h>
 #endif
 
 using namespace MPAPI;
@@ -237,36 +228,32 @@ static sp<IOMX> GetOMX() {
 }
 #endif
 
 static uint32_t
 GetDefaultStagefrightFlags(PluginHost *aPluginHost)
 {
   uint32_t flags = DEFAULT_STAGEFRIGHT_FLAGS;
 
-#if !defined(MOZ_ANDROID_FROYO)
-
   char hardware[256] = "";
   aPluginHost->GetSystemInfoString("hardware", hardware, sizeof(hardware));
 
   if (!strcmp("qcom", hardware) ||
       !strncmp("mt", hardware, 2)) {
     // Qualcomm's OMXCodec implementation interprets this flag to mean that we
     // only want a thumbnail and therefore only need one frame. After the first
     // frame it returns EOS.
     // Some MediaTek chipsets have also been found to do the same.
     // All other OMXCodec implementations seen so far interpret this flag
     // sanely; some do not return full framebuffers unless this flag is passed.
     flags &= ~OMXCodec::kClientNeedsFramebuffer;
   }
 
   LOG("Hardware %s; using default flags %#x\n", hardware, flags);
 
-#endif
-
   return flags;
 }
 
 static uint32_t GetVideoCreationFlags(PluginHost* aPluginHost)
 {
 #ifdef MOZ_WIDGET_GONK
   // Flag value of zero means return a hardware or software decoder
   // depending on what the device supports.
@@ -276,17 +263,17 @@ static uint32_t GetVideoCreationFlags(Pl
   // CreationFlags flags. This is useful for A/B testing hardware and software
   // decoders for performance and bugs. The interesting flag values are:
   //  0 = Let Stagefright choose hardware or software decoding (default)
   //  8 = Force software decoding
   // 16 = Force hardware decoding
   int32_t flags = 0;
   aPluginHost->GetIntPref("media.stagefright.omxcodec.flags", &flags);
   if (flags != 0) {
-#if !defined(MOZ_ANDROID_V2_X_X)
+#if !defined(MOZ_ANDROID_GB)
     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
   }
@@ -441,17 +428,17 @@ static sp<MediaSource> CreateVideoSource
       LOG("Unknown video color format: %#x", videoColorFormat);
     } 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)
+#if defined(MOZ_ANDROID_GB)
     flags = DEFAULT_STAGEFRIGHT_FLAGS | OMXCodec::kPreferSoftwareCodecs;
 #else
     flags = DEFAULT_STAGEFRIGHT_FLAGS | OMXCodec::kSoftwareCodecsOnly;
 #endif
   }
 
   MOZ_ASSERT(flags != DEFAULT_STAGEFRIGHT_FLAGS);
   return OMXCodec::Create(aOmx, aVideoTrack->getFormat(), false, aVideoTrack,
@@ -516,21 +503,16 @@ bool OmxDecoder::Init()
   sp<IOMX> omx = GetOMX();
 #else
   sp<IOMX> omx = sClientInstance.get()->interface();
 #endif
 
   sp<MediaSource> videoTrack;
   sp<MediaSource> videoSource;
   if (videoTrackIndex != -1 && (videoTrack = extractor->getTrack(videoTrackIndex)) != nullptr) {
-#if defined(MOZ_ANDROID_FROYO)
-    // Allow up to 720P video.
-    sp<MetaData> meta = extractor->getTrackMetaData(videoTrackIndex);
-    meta->setInt32(kKeyMaxInputSize, (1280 * 720 * 3) / 2);
-#endif
     videoSource = CreateVideoSource(mPluginHost, omx, videoTrack);
     if (videoSource == nullptr) {
       LOG("OMXCodec failed to initialize video decoder for \"%s\"", videoMime);
       return false;
     }
     status_t status = videoSource->start();
     if (status != OK) {
       LOG("videoSource->start() failed with status %#x", status);
@@ -618,17 +600,17 @@ bool OmxDecoder::Init()
 
 bool OmxDecoder::SetVideoFormat() {
   sp<MetaData> format = mVideoSource->getFormat();
 
   // Stagefright's kKeyWidth and kKeyHeight are what MPAPI calls stride and
   // slice height. Stagefright only seems to use its kKeyStride and
   // kKeySliceHeight to initialize camera video formats.
 
-#if defined(DEBUG) && !defined(MOZ_ANDROID_FROYO)
+#if defined(DEBUG)
   int32_t unexpected;
   if (format->findInt32(kKeyStride, &unexpected))
     LOG("Expected kKeyWidth, but found kKeyStride %d", unexpected);
   if (format->findInt32(kKeySliceHeight, &unexpected))
     LOG("Expected kKeyHeight, but found kKeySliceHeight %d", unexpected);
 #endif // DEBUG
 
   const char *componentName;
@@ -646,48 +628,44 @@ bool OmxDecoder::SetVideoFormat() {
   }
 
   if (mVideoSliceHeight <= 0) {
     LOG("slice height %d must be positive", mVideoSliceHeight);
     return false;
   }
 
   // Gingerbread does not support the kKeyCropRect key
-#if !defined(MOZ_ANDROID_V2_X_X)
+#if !defined(MOZ_ANDROID_GB)
   if (!format->findRect(kKeyCropRect, &mVideoCropLeft, &mVideoCropTop,
                                       &mVideoCropRight, &mVideoCropBottom)) {
 #endif
     mVideoCropLeft = 0;
     mVideoCropTop = 0;
     mVideoCropRight = mVideoStride - 1;
     mVideoCropBottom = mVideoSliceHeight - 1;
     LOG("crop rect not available, assuming no cropping");
-#if !defined(MOZ_ANDROID_V2_X_X)
+#if !defined(MOZ_ANDROID_GB)
   }
 #endif
 
   if (mVideoCropLeft < 0 || mVideoCropLeft >= mVideoCropRight || mVideoCropRight >= mVideoStride ||
       mVideoCropTop < 0 || mVideoCropTop >= mVideoCropBottom || mVideoCropBottom >= mVideoSliceHeight) {
     LOG("invalid crop rect %d,%d-%d,%d", mVideoCropLeft, mVideoCropTop, mVideoCropRight, mVideoCropBottom);
     return false;
   }
 
   mVideoWidth = mVideoCropRight - mVideoCropLeft + 1;
   mVideoHeight = mVideoCropBottom - mVideoCropTop + 1;
   MOZ_ASSERT(mVideoWidth > 0 && mVideoWidth <= mVideoStride);
   MOZ_ASSERT(mVideoHeight > 0 && mVideoHeight <= mVideoSliceHeight);
 
-#if !defined(MOZ_ANDROID_FROYO)
   if (!format->findInt32(kKeyRotation, &mVideoRotation)) {
-#endif
     mVideoRotation = 0;
-#if !defined(MOZ_ANDROID_FROYO)
     LOG("rotation not available, assuming 0");
   }
-#endif
 
   if (mVideoRotation != 0 && mVideoRotation != 90 &&
       mVideoRotation != 180 && mVideoRotation != 270) {
     LOG("invalid rotation %d, assuming 0", mVideoRotation);
   }
 
   LOG("width: %d height: %d component: %s format: %#x stride: %d sliceHeight: %d rotation: %d crop: %d,%d-%d,%d",
       mVideoWidth, mVideoHeight, componentName, mVideoColorFormat,
@@ -837,17 +815,17 @@ bool OmxDecoder::ToVideoFrame_ColorConve
   void *buffer = (*aBufferCallback)(mVideoWidth, mVideoHeight, MPAPI::RGB565);
 
   if (!buffer) {
     return false;
   }
 
   aFrame->mSize = mVideoWidth * mVideoHeight * 2;
 
-#if defined(MOZ_ANDROID_V2_X_X)
+#if defined(MOZ_ANDROID_GB)
   mColorConverter->convert(mVideoWidth, mVideoHeight,
                            aData, 0 /* srcSkip */,
                            buffer, mVideoWidth * 2);
 #else
   mColorConverter->convert(aData, mVideoStride, mVideoSliceHeight,
                            mVideoCropLeft, mVideoCropTop,
                            mVideoCropLeft + mVideoWidth - 1,
                            mVideoCropTop + mVideoHeight - 1,
@@ -890,19 +868,16 @@ bool OmxDecoder::ToVideoFrame_I420ColorC
   return result == OK;
 #else
   return false;
 #endif
 }
 
 bool OmxDecoder::ToVideoFrame(VideoFrame *aFrame, int64_t aTimeUs, void *aData, size_t aSize, bool aKeyFrame, BufferCallback *aBufferCallback) {
   switch (mVideoColorFormat) {
-// Froyo support is best handled with the android color conversion code. I
-// get corrupted videos when using our own routines below.
-#if !defined(MOZ_ANDROID_FROYO)
   case OMX_COLOR_FormatYUV420Planar: // e.g. Asus Transformer, Stagefright's software decoder
     ToVideoFrame_YUV420Planar(aFrame, aTimeUs, aData, aSize, aKeyFrame);
     break;
   case OMX_COLOR_FormatCbYCrY: // e.g. Droid 1
     ToVideoFrame_CbYCrY(aFrame, aTimeUs, aData, aSize, aKeyFrame);
     break;
   case OMX_COLOR_FormatYUV420SemiPlanar: // e.g. Galaxy S III
     ToVideoFrame_YUV420SemiPlanar(aFrame, aTimeUs, aData, aSize, aKeyFrame);
@@ -914,17 +889,16 @@ bool OmxDecoder::ToVideoFrame(VideoFrame
     ToVideoFrame_YVU420PackedSemiPlanar32m4ka(aFrame, aTimeUs, aData, aSize, aKeyFrame);
     break;
   case OMX_TI_COLOR_FormatYUV420PackedSemiPlanar: // e.g. Galaxy Nexus
     ToVideoFrame_YUV420PackedSemiPlanar(aFrame, aTimeUs, aData, aSize, aKeyFrame);
     break;
   case OMX_COLOR_Format16bitRGB565:
     return ToVideoFrame_RGB565(aFrame, aTimeUs, aData, aSize, aKeyFrame, aBufferCallback);
     break;
-#endif
   default:
     if (!ToVideoFrame_ColorConverter(aFrame, aTimeUs, aData, aSize, aKeyFrame, aBufferCallback) &&
         !ToVideoFrame_I420ColorConverter(aFrame, aTimeUs, aData, aSize, aKeyFrame, aBufferCallback)) {
       LOG("Unknown video color format: %#x", mVideoColorFormat);
       return false;
     }
   }
   return true;
--- a/media/omx-plugin/lib/gb/libstagefright/libstagefright.cpp
+++ b/media/omx-plugin/lib/gb/libstagefright/libstagefright.cpp
@@ -76,21 +76,17 @@ MOZ_EXPORT bool MetaData::findCString(ui
 {
   return false;
 }
  
 MOZ_EXPORT MediaSource::ReadOptions::ReadOptions()
 {
 }
 
-MOZ_EXPORT void MediaSource::ReadOptions::setSeekTo(int64_t time_us
-#if !defined(MOZ_ANDROID_FROYO)
-, SeekMode mode
-#endif
-)
+MOZ_EXPORT void MediaSource::ReadOptions::setSeekTo(int64_t time_us, SeekMode mode)
 {
 }
 
 MOZ_EXPORT sp<DataSource> DataSource::CreateFromURI(
           const char *uri,
           const KeyedVector<String8, String8> *headers) {
   return 0;
 }