From 5f8336a5b319061f2715cdbcb995057a8fefb371 Mon Sep 17 00:00:00 2001 From: Chris Double Date: Fri, 30 Nov 2012 15:37:34 +1300 Subject: [PATCH] Bug 787228 - Part2: Add libomxplugin support for Gingerbread - r=cpeterson --HG-- extra : rebase_source : 74ae723b5d5b64d913119ea1285da1fc175f9455 --- media/omx-plugin/Makefile.in | 4 -- media/omx-plugin/OmxPlugin.cpp | 34 +++++++------ media/omx-plugin/gb/Makefile.in | 67 +++++++++++++++++++++++++ media/omx-plugin/gb/OmxPlugin236.cpp | 8 +++ media/omx-plugin/gb235/Makefile.in | 67 +++++++++++++++++++++++++ media/omx-plugin/gb235/OmxPlugin235.cpp | 8 +++ 6 files changed, 170 insertions(+), 18 deletions(-) create mode 100644 media/omx-plugin/gb/Makefile.in create mode 100644 media/omx-plugin/gb/OmxPlugin236.cpp create mode 100644 media/omx-plugin/gb235/Makefile.in create mode 100644 media/omx-plugin/gb235/OmxPlugin235.cpp diff --git a/media/omx-plugin/Makefile.in b/media/omx-plugin/Makefile.in index d498d3540878..540679744db1 100644 --- a/media/omx-plugin/Makefile.in +++ b/media/omx-plugin/Makefile.in @@ -34,10 +34,6 @@ USE_STATIC_LIBS = 1 NO_DIST_INSTALL = 1 NO_INSTALL = 1 -ifneq ($(MOZ_WIDGET_TOOLKIT),gonk) -DIRS += lib/ics/libutils lib/ics/libstagefright -endif - CPPSRCS = \ OmxPlugin.cpp \ $(NULL) diff --git a/media/omx-plugin/OmxPlugin.cpp b/media/omx-plugin/OmxPlugin.cpp index d90e08934994..13ced4fa4202 100644 --- a/media/omx-plugin/OmxPlugin.cpp +++ b/media/omx-plugin/OmxPlugin.cpp @@ -27,25 +27,19 @@ using namespace MPAPI; namespace android { -// MediaStreamSource is a DataSource that reads from a MPAPI media stream. +#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(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; } @@ -74,7 +68,7 @@ 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(data); size_t todo = size; @@ -90,7 +84,7 @@ ssize_t MediaStreamSource::readAt(off64_t offset, void *data, size_t size) 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(-1)) @@ -109,6 +103,7 @@ 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; @@ -259,12 +254,14 @@ static uint32_t GetVideoCreationFlags(PluginHost* aPluginHost) 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(flags); #endif @@ -311,7 +308,11 @@ static sp CreateVideoSource(PluginHost* aPluginHost, // 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); @@ -507,14 +508,19 @@ bool OmxDecoder::SetVideoFormat() { } 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) { diff --git a/media/omx-plugin/gb/Makefile.in b/media/omx-plugin/gb/Makefile.in new file mode 100644 index 000000000000..1de1f249b0cb --- /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) diff --git a/media/omx-plugin/gb/OmxPlugin236.cpp b/media/omx-plugin/gb/OmxPlugin236.cpp new file mode 100644 index 000000000000..eafb8202246e --- /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" diff --git a/media/omx-plugin/gb235/Makefile.in b/media/omx-plugin/gb235/Makefile.in new file mode 100644 index 000000000000..dddb4350fa40 --- /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) diff --git a/media/omx-plugin/gb235/OmxPlugin235.cpp b/media/omx-plugin/gb235/OmxPlugin235.cpp new file mode 100644 index 000000000000..dbf4e886040b --- /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"