Bug 805700 - Part1: omx plugin changes for Honeycomb support - r=cpeterson
authorChris Double <chris.double@double.co.nz>
Fri, 30 Nov 2012 16:05:37 +1300
changeset 114635 1ec8feec4ae175ef5602e8dbdcf0ea7654e8cc9b
parent 114634 72272b5881d73b158534fc5b190137d2061dc4a2
child 114636 d2dd27b5985c5456228cd29b4fdcac07f4267174
push id18885
push usercdouble@mozilla.com
push dateFri, 30 Nov 2012 19:19:05 +0000
treeherdermozilla-inbound@06dfb6d9f0c0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerscpeterson
bugs805700
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 805700 - Part1: omx plugin changes for Honeycomb support - r=cpeterson
content/media/plugins/MediaPluginHost.cpp
media/omx-plugin/hc/Makefile.in
media/omx-plugin/hc/OmxPluginHoneycomb.cpp
media/omx-plugin/include/gb/stagefright/DataSource.h
media/omx-plugin/include/gb/stagefright/OMXCodec.h
media/omx-plugin/lib/gb/libstagefright/libstagefright.cpp
media/omx-plugin/lib/hc/libstagefright/Makefile.in
media/omx-plugin/lib/hc/libstagefright/libstagefright.cpp
toolkit/components/downloads/test/unit/test_private_resume.js
--- a/content/media/plugins/MediaPluginHost.cpp
+++ b/content/media/plugins/MediaPluginHost.cpp
@@ -147,17 +147,20 @@ static const char* GetOmxLibraryName()
   }
 
   nsAutoString release_version;
   rv = infoService->GetPropertyAsAString(NS_LITERAL_STRING("release_version"), release_version);
   if (NS_SUCCEEDED(rv)) {
     ALOG("Android Release Version is: %s", NS_LossyConvertUTF16toASCII(release_version).get());
   }
 
-  if (version == 10 && release_version >= NS_LITERAL_STRING("2.3.6")) {
+  if (version == 13 || version == 12 || version == 11) {
+    return "lib/libomxpluginhc.so";
+  }
+  else if (version == 10 && release_version >= NS_LITERAL_STRING("2.3.6")) {
     // Gingerbread versions from 2.3.6 and above have a different DataSource
     // layout to those on 2.3.5 and below.
     return "lib/libomxplugingb.so";
   }
   else if (version == 9 || (version == 10 && release_version <= NS_LITERAL_STRING("2.3.5"))) {
     // Gingerbread versions from 2.3.5 and below have a different DataSource
     // than 2.3.6 and above.
     return "lib/libomxplugingb235.so";
new file mode 100644
--- /dev/null
+++ b/media/omx-plugin/hc/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 = omxpluginhc
+MODULE_NAME = omxpluginhc
+LIBRARY_NAME = omxpluginhc
+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 = \
+    OmxPluginHoneycomb.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/hc/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/hc/OmxPluginHoneycomb.cpp
@@ -0,0 +1,10 @@
+/* -*- 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
+#define MOZ_ANDROID_HC
+#include <ui/egl/android_natives.h>
+#include "../OmxPlugin.cpp"
--- a/media/omx-plugin/include/gb/stagefright/DataSource.h
+++ b/media/omx-plugin/include/gb/stagefright/DataSource.h
@@ -20,16 +20,19 @@
 
 #include <sys/types.h>
 
 #include <utils/Errors.h>
 #include <utils/KeyedVector.h>
 #include <utils/List.h>
 #include <utils/RefBase.h>
 #include <utils/threads.h>
+#if defined(MOZ_ANDROID_HC)
+#include <utils/String8.h>
+#endif
 
 #if !defined(STAGEFRIGHT_EXPORT)
 #define STAGEFRIGHT_EXPORT
 #endif
 
 #if !defined(MOZ_STAGEFRIGHT_OFF_T)
 #define MOZ_STAGEFRIGHT_OFF_T off64_t
 #endif
@@ -53,17 +56,17 @@ public:
 
     DataSource() {}
 
     virtual status_t initCheck() const = 0;
 
     virtual ssize_t readAt(MOZ_STAGEFRIGHT_OFF_T offset, void *data, size_t size) = 0;
 
     // Convenience methods:
-    bool getUInt16(off_t offset, uint16_t *x);
+    bool getUInt16(MOZ_STAGEFRIGHT_OFF_T offset, uint16_t *x);
 
     // May return ERROR_UNSUPPORTED.
     virtual status_t getSize(MOZ_STAGEFRIGHT_OFF_T *size);
 
     virtual uint32_t flags() {
         return 0;
     }
 
@@ -76,16 +79,27 @@ public:
     // its state without duplicating effort already exerted by the sniffer.
     typedef bool (*SnifferFunc)(
             const sp<DataSource> &source, String8 *mimeType,
             float *confidence, sp<AMessage> *meta);
 
     static void RegisterSniffer(SnifferFunc func);
     static void RegisterDefaultSniffers();
 
+#if defined(MOZ_ANDROID_HC)
+    virtual void* DrmInitialization() {
+        return NULL;
+    }
+    virtual void getDrmInfo(void **handle, void **client) {};
+
+    virtual String8 getUri() {
+        return String8();
+    }
+#endif
+
 protected:
     virtual ~DataSource() {}
 
 private:
     static Mutex gSnifferMutex;
     static List<SnifferFunc> gSniffers;
 
     DataSource(const DataSource &);
--- a/media/omx-plugin/include/gb/stagefright/OMXCodec.h
+++ b/media/omx-plugin/include/gb/stagefright/OMXCodec.h
@@ -13,16 +13,19 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
 
 #ifndef OMX_CODEC_H_
 
 #define OMX_CODEC_H_
 
+#if defined(MOZ_ANDROID_HC)
+#include <android/native_window.h>
+#endif
 #include <media/IOMX.h>
 #include <media/stagefright/MediaBuffer.h>
 #include <media/stagefright/MediaSource.h>
 #include <utils/threads.h>
 
 namespace android {
 
 class MemoryDealer;
@@ -39,17 +42,22 @@ struct OMXCodec : public MediaSource,
         // data for example for thumbnail extraction.
         kClientNeedsFramebuffer  = 4,
     };
     static sp<MediaSource> Create(
             const sp<IOMX> &omx,
             const sp<MetaData> &meta, bool createEncoder,
             const sp<MediaSource> &source,
             const char *matchComponentName = NULL,
-            uint32_t flags = 0);
+            uint32_t flags = 0
+#if defined(MOZ_ANDROID_HC)
+            ,const sp<ANativeWindow> &nativeWindow = NULL
+#endif
+	    );
+
 
     static void setComponentRole(
             const sp<IOMX> &omx, IOMX::node_id node, bool isEncoder,
             const char *mime);
 
     virtual status_t start(MetaData *params = NULL);
     virtual status_t stop();
 
--- a/media/omx-plugin/lib/gb/libstagefright/libstagefright.cpp
+++ b/media/omx-plugin/lib/gb/libstagefright/libstagefright.cpp
@@ -13,16 +13,20 @@
 #include "media/stagefright/openmax/OMX_Types.h"
 #include "media/stagefright/openmax/OMX_Index.h"
 #include "media/stagefright/openmax/OMX_IVCommon.h"
 #include "media/stagefright/openmax/OMX_Video.h"
 #include "media/stagefright/openmax/OMX_Core.h"
 #include "stagefright/OMXCodec.h"
 #include "stagefright/OMXClient.h"
 
+#if defined(MOZ_ANDROID_HC)
+#include <android/native_window.h>
+#endif
+
 namespace android {
 MOZ_EXPORT void MediaBuffer::release()
 {
 }
 
 MOZ_EXPORT size_t MediaBuffer::range_offset() const
 {
   return 0;
@@ -78,17 +82,17 @@ MOZ_EXPORT void MediaSource::ReadOptions
 
 MOZ_EXPORT sp<DataSource> DataSource::CreateFromURI(
           const char *uri,
           const KeyedVector<String8, String8> *headers) {
   return 0;
 }
 
 
-MOZ_EXPORT bool DataSource::getUInt16(off_t offset, uint16_t *x)
+MOZ_EXPORT bool DataSource::getUInt16(MOZ_STAGEFRIGHT_OFF_T offset, uint16_t *x)
 {
   return false;
 }
 
 MOZ_EXPORT status_t DataSource::getSize(MOZ_STAGEFRIGHT_OFF_T *size)
 {
   return 0;
 }
@@ -102,17 +106,22 @@ MOZ_EXPORT sp<MediaExtractor> MediaExtra
   return 0;
 }
 
 MOZ_EXPORT sp<MediaSource> OMXCodec::Create(
             const sp<IOMX> &omx,
             const sp<MetaData> &meta, bool createEncoder,
             const sp<MediaSource> &source,
             const char *matchComponentName,
-            uint32_t flags)
+            uint32_t flags
+#if defined(MOZ_ANDROID_HC)
+	    ,const sp<ANativeWindow> &nativeWindow
+#endif
+	    )
+
 {
   return 0;
 }
 
 MOZ_EXPORT OMXClient::OMXClient()
 {
 }
 
new file mode 100644
--- /dev/null
+++ b/media/omx-plugin/lib/hc/libstagefright/Makefile.in
@@ -0,0 +1,59 @@
+# 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 = libandroidstagefrighthc
+MODULE_NAME = libandroidstagefrighthc
+LIBRARY_NAME = stagefright
+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
+
+ifneq ($(MOZ_WIDGET_TOOLKIT),gonk)
+CPPSRCS = \
+	libstagefright.cpp \
+	$(NULL)
+endif
+
+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$(topsrcdir)/media/omx-plugin/include/gb \
+                -I$(topsrcdir)/media/omx-plugin/include/gb/media/stagefright/openmax \
+                $(NULL)
+
+EXTRA_DSO_LDOPTS += \
+		-L$(DEPTH)/media/omx-plugin/lib/gb/libutils \
+		-lutils \
+		$(NULL)
+
+
new file mode 100644
--- /dev/null
+++ b/media/omx-plugin/lib/hc/libstagefright/libstagefright.cpp
@@ -0,0 +1,9 @@
+/* -*- 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_HC
+#define MOZ_ANDROID_GB
+#include "../../gb/libstagefright/libstagefright.cpp"