Bug 787228 - Part2: Add libomxplugin support for Gingerbread - r=cpeterson

--HG--
extra : rebase_source : 74ae723b5d5b64d913119ea1285da1fc175f9455
This commit is contained in:
Chris Double 2012-11-30 15:37:34 +13:00
parent ec57b1d1a1
commit 4c26180a04
6 changed files with 170 additions and 18 deletions

View File

@ -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)

View File

@ -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<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;
}
@ -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<char *>(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<uint64_t>(-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<uint32_t>(flags);
#endif
@ -311,7 +308,11 @@ static sp<MediaSource> 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) {

View File

@ -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)

View File

@ -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"

View File

@ -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)

View File

@ -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"