From 0ccbd5da7fb9377659106e3629883236bd9f4059 Mon Sep 17 00:00:00 2001 From: Chris Double Date: Fri, 30 Nov 2012 16:05:37 +1300 Subject: [PATCH] Bug 805700 - Part1: omx plugin changes for Honeycomb support - r=cpeterson --HG-- extra : rebase_source : 3b36cfa2d5b25db4b1a66727f4349f71a6e2a7db --- content/media/plugins/MediaPluginHost.cpp | 5 +- media/omx-plugin/hc/Makefile.in | 67 +++++++++++++++++++ media/omx-plugin/hc/OmxPluginHoneycomb.cpp | 10 +++ .../include/gb/stagefright/DataSource.h | 16 ++++- .../include/gb/stagefright/OMXCodec.h | 10 ++- .../lib/gb/libstagefright/libstagefright.cpp | 13 +++- .../lib/hc/libstagefright/Makefile.in | 59 ++++++++++++++++ .../lib/hc/libstagefright/libstagefright.cpp | 9 +++ 8 files changed, 184 insertions(+), 5 deletions(-) create mode 100644 media/omx-plugin/hc/Makefile.in create mode 100644 media/omx-plugin/hc/OmxPluginHoneycomb.cpp create mode 100644 media/omx-plugin/lib/hc/libstagefright/Makefile.in create mode 100644 media/omx-plugin/lib/hc/libstagefright/libstagefright.cpp diff --git a/content/media/plugins/MediaPluginHost.cpp b/content/media/plugins/MediaPluginHost.cpp index 1c0b86df80b4..9e1b9d9485c4 100644 --- a/content/media/plugins/MediaPluginHost.cpp +++ b/content/media/plugins/MediaPluginHost.cpp @@ -152,7 +152,10 @@ static const char* GetOmxLibraryName() 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"; diff --git a/media/omx-plugin/hc/Makefile.in b/media/omx-plugin/hc/Makefile.in new file mode 100644 index 000000000000..1b31cd9bb526 --- /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) diff --git a/media/omx-plugin/hc/OmxPluginHoneycomb.cpp b/media/omx-plugin/hc/OmxPluginHoneycomb.cpp new file mode 100644 index 000000000000..36e8adefcdc9 --- /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 +#include "../OmxPlugin.cpp" diff --git a/media/omx-plugin/include/gb/stagefright/DataSource.h b/media/omx-plugin/include/gb/stagefright/DataSource.h index 752d1935f45e..30dab5e8fd7e 100644 --- a/media/omx-plugin/include/gb/stagefright/DataSource.h +++ b/media/omx-plugin/include/gb/stagefright/DataSource.h @@ -25,6 +25,9 @@ #include #include #include +#if defined(MOZ_ANDROID_HC) +#include +#endif #if !defined(STAGEFRIGHT_EXPORT) #define STAGEFRIGHT_EXPORT @@ -58,7 +61,7 @@ public: 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); @@ -81,6 +84,17 @@ public: 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() {} diff --git a/media/omx-plugin/include/gb/stagefright/OMXCodec.h b/media/omx-plugin/include/gb/stagefright/OMXCodec.h index 8274dfbf9577..cd0ea831f9cf 100644 --- a/media/omx-plugin/include/gb/stagefright/OMXCodec.h +++ b/media/omx-plugin/include/gb/stagefright/OMXCodec.h @@ -18,6 +18,9 @@ #define OMX_CODEC_H_ +#if defined(MOZ_ANDROID_HC) +#include +#endif #include #include #include @@ -44,7 +47,12 @@ struct OMXCodec : public MediaSource, const sp &meta, bool createEncoder, const sp &source, const char *matchComponentName = NULL, - uint32_t flags = 0); + uint32_t flags = 0 +#if defined(MOZ_ANDROID_HC) + ,const sp &nativeWindow = NULL +#endif + ); + static void setComponentRole( const sp &omx, IOMX::node_id node, bool isEncoder, diff --git a/media/omx-plugin/lib/gb/libstagefright/libstagefright.cpp b/media/omx-plugin/lib/gb/libstagefright/libstagefright.cpp index 60c11f90c020..8bda631036d3 100644 --- a/media/omx-plugin/lib/gb/libstagefright/libstagefright.cpp +++ b/media/omx-plugin/lib/gb/libstagefright/libstagefright.cpp @@ -18,6 +18,10 @@ #include "stagefright/OMXCodec.h" #include "stagefright/OMXClient.h" +#if defined(MOZ_ANDROID_HC) +#include +#endif + namespace android { MOZ_EXPORT void MediaBuffer::release() { @@ -83,7 +87,7 @@ MOZ_EXPORT sp DataSource::CreateFromURI( } -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; } @@ -107,7 +111,12 @@ MOZ_EXPORT sp OMXCodec::Create( const sp &meta, bool createEncoder, const sp &source, const char *matchComponentName, - uint32_t flags) + uint32_t flags +#if defined(MOZ_ANDROID_HC) + ,const sp &nativeWindow +#endif + ) + { return 0; } diff --git a/media/omx-plugin/lib/hc/libstagefright/Makefile.in b/media/omx-plugin/lib/hc/libstagefright/Makefile.in new file mode 100644 index 000000000000..ec39fd6b0f34 --- /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) + + diff --git a/media/omx-plugin/lib/hc/libstagefright/libstagefright.cpp b/media/omx-plugin/lib/hc/libstagefright/libstagefright.cpp new file mode 100644 index 000000000000..3945cedc1897 --- /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"