Bug 787228 - Part2: Add libomxplugin support for Gingerbread - r=cpeterson
authorChris Double <chris.double@double.co.nz>
Fri, 30 Nov 2012 15:37:34 +1300
changeset 114631 ee61282f73b5718f2d0f355fa51d679f6561a8c7
parent 114630 a0e2b7b7f5c4993f1238b53e18cb7bcac8657a57
child 114632 117f7cf6369fdca0773e924a48315309e2a4d8b4
push id23926
push userryanvm@gmail.com
push dateSat, 01 Dec 2012 15:27:30 +0000
treeherdermozilla-central@ecdf0e332f17 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerscpeterson
bugs787228
milestone20.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 787228 - Part2: Add libomxplugin support for Gingerbread - r=cpeterson
media/omx-plugin/Makefile.in
media/omx-plugin/OmxPlugin.cpp
media/omx-plugin/gb/Makefile.in
media/omx-plugin/gb/OmxPlugin236.cpp
media/omx-plugin/gb235/Makefile.in
media/omx-plugin/gb235/OmxPlugin235.cpp
toolkit/components/downloads/test/unit/test_private_resume.js
--- a/media/omx-plugin/Makefile.in
+++ b/media/omx-plugin/Makefile.in
@@ -29,20 +29,16 @@ STL_FLAGS =
 
 # must link statically with the CRT; this isn't Gecko code
 USE_STATIC_LIBS = 1
 
 # Need to custom install OMX media plugin
 NO_DIST_INSTALL = 1
 NO_INSTALL = 1
 
-ifneq ($(MOZ_WIDGET_TOOLKIT),gonk)
-DIRS += lib/ics/libutils lib/ics/libstagefright
-endif
-
 CPPSRCS = \
     OmxPlugin.cpp \
     $(NULL)
 
 include $(topsrcdir)/config/rules.mk
 
 ifdef GNU_CXX
 # Turn off C++ 11 features due to conflicts with Android OS headers and char16_t definition
--- a/media/omx-plugin/OmxPlugin.cpp
+++ b/media/omx-plugin/OmxPlugin.cpp
@@ -22,35 +22,29 @@
 
 #undef LOG
 #define LOG(args...)  __android_log_print(ANDROID_LOG_INFO, "OmxPlugin" , ## args)
 
 using namespace MPAPI;
 
 namespace android {
 
+#if !defined(MOZ_STAGEFRIGHT_OFF_T)
+#define MOZ_STAGEFRIGHT_OFF_T off64_t
+#endif
+
 // MediaStreamSource is a DataSource that reads from a MPAPI media stream.
-
 class MediaStreamSource : public DataSource {
   PluginHost *mPluginHost;
 public:
   MediaStreamSource(PluginHost *aPluginHost, Decoder *aDecoder);
 
   virtual status_t initCheck() const;
-  virtual ssize_t readAt(off64_t offset, void *data, size_t size);
-  virtual ssize_t readAt(off_t offset, void *data, size_t size) {
-    return readAt(static_cast<off64_t>(offset), data, size);
-  }
-  virtual status_t getSize(off_t *size) {
-    off64_t size64;
-    status_t status = getSize(&size64);
-    *size = size64;
-    return status;
-  }
-  virtual status_t getSize(off64_t *size);
+  virtual ssize_t readAt(MOZ_STAGEFRIGHT_OFF_T offset, void *data, size_t size);
+  virtual status_t getSize(MOZ_STAGEFRIGHT_OFF_T *size);
   virtual uint32_t flags() {
     return kWantsPrefetching;
   }
 
   virtual ~MediaStreamSource();
 
 private:
   Decoder *mDecoder;
@@ -69,33 +63,33 @@ MediaStreamSource::~MediaStreamSource()
 {
 }
 
 status_t MediaStreamSource::initCheck() const
 {
   return OK;
 }
 
-ssize_t MediaStreamSource::readAt(off64_t offset, void *data, size_t size)
+ssize_t MediaStreamSource::readAt(MOZ_STAGEFRIGHT_OFF_T offset, void *data, size_t size)
 {
   char *ptr = reinterpret_cast<char *>(data);
   size_t todo = size;
   while (todo > 0) {
     uint32_t bytesRead;
     if (!mPluginHost->Read(mDecoder, ptr, offset, todo, &bytesRead)) {
       return ERROR_IO;
     }
     offset += bytesRead;
     todo -= bytesRead;
     ptr += bytesRead;
   }
   return size;
 }
 
-status_t MediaStreamSource::getSize(off64_t *size)
+status_t MediaStreamSource::getSize(MOZ_STAGEFRIGHT_OFF_T *size)
 {
   uint64_t length = mPluginHost->GetLength(mDecoder);
   if (length == static_cast<uint64_t>(-1))
     return ERROR_UNSUPPORTED;
 
   *size = length;
 
   return OK;
@@ -104,16 +98,17 @@ status_t MediaStreamSource::getSize(off6
 }  // namespace android
 
 using namespace android;
 
 namespace OmxPlugin {
 
 const int OMX_QCOM_COLOR_FormatYVU420PackedSemiPlanar32m4ka = 0x7FA30C01;
 const int OMX_QCOM_COLOR_FormatYVU420SemiPlanar = 0x7FA30C00;
+const int OMX_TI_COLOR_FormatYUV420PackedSemiPlanar = 0x7F000100;
 
 class OmxDecoder {
   PluginHost *mPluginHost;
   Decoder *mDecoder;
 #ifndef MOZ_WIDGET_GONK
   OMXClient mClient;
 #endif
   sp<MediaSource> mVideoTrack;
@@ -254,22 +249,24 @@ 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_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
   }
   return static_cast<uint32_t>(flags);
 #endif
 }
 
 static sp<MediaSource> CreateVideoSource(PluginHost* aPluginHost,
                                          const sp<IOMX>& aOmx,
                                          const sp<MediaSource>& aVideoTrack)
@@ -306,17 +303,21 @@ 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_GB)
+    flags = OMXCodec::kPreferSoftwareCodecs;
+#else
     flags = OMXCodec::kSoftwareCodecsOnly;
+#endif
   }
 
   MOZ_ASSERT(flags != 0);
   return OMXCodec::Create(aOmx, aVideoTrack->getFormat(), false, aVideoTrack,
                           NULL, flags);
 }
 
 bool OmxDecoder::Init() {
@@ -502,24 +503,29 @@ bool OmxDecoder::SetVideoFormat() {
   }
 
   if (mVideoSliceHeight <= 0) {
     LOG("slice height %d must be positive", mVideoSliceHeight);
     return false;
   }
 
   int32_t cropRight, cropBottom;
+  // Gingerbread does not support the kKeyCropRect key
+#if !defined(MOZ_ANDROID_GB)
   if (!format->findRect(kKeyCropRect, &mVideoCropLeft, &mVideoCropTop,
                                       &cropRight, &cropBottom)) {
+#endif
     mVideoCropLeft = 0;
     mVideoCropTop = 0;
     cropRight = mVideoStride - 1;
     cropBottom = mVideoSliceHeight - 1;
     LOG("crop rect not available, assuming no cropping");
+#if !defined(MOZ_ANDROID_GB)
   }
+#endif
 
   if (mVideoCropLeft < 0 || mVideoCropLeft >= cropRight || cropRight >= mVideoStride ||
       mVideoCropTop < 0 || mVideoCropTop >= cropBottom || cropBottom >= mVideoSliceHeight) {
     LOG("invalid crop rect %d,%d-%d,%d", mVideoCropLeft, mVideoCropTop, cropRight, cropBottom);
     return false;
   }
 
   mVideoWidth = cropRight - mVideoCropLeft + 1;
new file mode 100644
--- /dev/null
+++ b/media/omx-plugin/gb/Makefile.in
@@ -0,0 +1,67 @@
+# Copyright 2012 Mozilla Foundation and Mozilla contributors
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+DEPTH   = @DEPTH@
+topsrcdir = @top_srcdir@
+srcdir    = @srcdir@
+VPATH   = @srcdir@
+
+include $(DEPTH)/config/autoconf.mk
+
+MODULE = omxplugingb
+MODULE_NAME = omxplugingb
+LIBRARY_NAME = omxplugingb
+FORCE_SHARED_LIB = 1
+
+# Don't use STL wrappers; this isn't Gecko code
+STL_FLAGS =
+
+# must link statically with the CRT; this isn't Gecko code
+USE_STATIC_LIBS = 1
+
+# Need to custom install OMX media plugin
+NO_DIST_INSTALL = 1
+NO_INSTALL = 1
+
+CPPSRCS = \
+    OmxPlugin236.cpp \
+    $(NULL)
+
+include $(topsrcdir)/config/rules.mk
+
+ifdef GNU_CXX
+# Turn off C++ 11 features due to conflicts with Android OS headers and char16_t definition
+CXXFLAGS += -std=gnu++98
+endif
+
+INCLUDES        += \
+                -I$(srcdir)/../../../content/media/plugins \
+                $(NULL)
+
+EXTRA_DSO_LDOPTS += \
+		-L$(DEPTH)/media/omx-plugin/lib/gb/libutils \
+		-lutils \
+		-L$(DEPTH)/media/omx-plugin/lib/gb/libstagefright \
+		-lstagefright \
+		$(NULL)
+
+INCLUDES        += \
+                -I$(srcdir)/../include/gb \
+                -I$(srcdir)/../include/gb/media/stagefright/openmax \
+                $(NULL)
+
+libs::	$(DLL_PREFIX)$(LIBRARY_NAME)$(DLL_SUFFIX)
+	$(INSTALL) $< $(DEPTH)/dist/bin
+
+libs:: $(PROGRAMS)
new file mode 100644
--- /dev/null
+++ b/media/omx-plugin/gb/OmxPlugin236.cpp
@@ -0,0 +1,8 @@
+/* -*- 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/. */
+#define MOZ_STAGEFRIGHT_OFF_T off64_t
+#define MOZ_ANDROID_GB
+#include "../OmxPlugin.cpp"
new file mode 100644
--- /dev/null
+++ b/media/omx-plugin/gb235/Makefile.in
@@ -0,0 +1,67 @@
+# Copyright 2012 Mozilla Foundation and Mozilla contributors
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+DEPTH   = @DEPTH@
+topsrcdir = @top_srcdir@
+srcdir    = @srcdir@
+VPATH   = @srcdir@
+
+include $(DEPTH)/config/autoconf.mk
+
+MODULE = omxplugingb235
+MODULE_NAME = omxplugingb235
+LIBRARY_NAME = omxplugingb235
+FORCE_SHARED_LIB = 1
+
+# Don't use STL wrappers; this isn't Gecko code
+STL_FLAGS =
+
+# must link statically with the CRT; this isn't Gecko code
+USE_STATIC_LIBS = 1
+
+# Need to custom install OMX media plugin
+NO_DIST_INSTALL = 1
+NO_INSTALL = 1
+
+CPPSRCS = \
+    OmxPlugin235.cpp \
+    $(NULL)
+
+include $(topsrcdir)/config/rules.mk
+
+ifdef GNU_CXX
+# Turn off C++ 11 features due to conflicts with Android OS headers and char16_t definition
+CXXFLAGS += -std=gnu++98
+endif
+
+INCLUDES        += \
+                -I$(srcdir)/../../../content/media/plugins \
+                $(NULL)
+
+EXTRA_DSO_LDOPTS += \
+		-L$(DEPTH)/media/omx-plugin/lib/gb/libutils \
+		-lutils \
+		-L$(DEPTH)/media/omx-plugin/lib/gb235/libstagefright \
+		-lstagefright \
+		$(NULL)
+
+INCLUDES        += \
+                -I$(srcdir)/../include/gb \
+                -I$(srcdir)/../include/gb/media/stagefright/openmax \
+                $(NULL)
+
+libs::	$(DLL_PREFIX)$(LIBRARY_NAME)$(DLL_SUFFIX)
+	$(INSTALL) $< $(DEPTH)/dist/bin
+
+libs:: $(PROGRAMS)
new file mode 100644
--- /dev/null
+++ b/media/omx-plugin/gb235/OmxPlugin235.cpp
@@ -0,0 +1,8 @@
+/* -*- 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/. */
+#define MOZ_STAGEFRIGHT_OFF_T off_t
+#define MOZ_ANDROID_GB
+#include "../OmxPlugin.cpp"