mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-03 20:49:27 +00:00
Bug 821160 - Part2: Add libomxplugin support for froyo - r=cpeterson
This commit is contained in:
parent
ed39464d89
commit
87da45ea9f
@ -8,6 +8,7 @@
|
||||
#include <stagefright/MediaExtractor.h>
|
||||
#include <stagefright/MetaData.h>
|
||||
#include <stagefright/OMXCodec.h>
|
||||
#include <media/stagefright/MediaErrors.h>
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
#include <OMX.h>
|
||||
#else
|
||||
@ -24,6 +25,11 @@
|
||||
#undef LOG
|
||||
#define LOG(args...) __android_log_print(ANDROID_LOG_INFO, "OmxPlugin" , ## args)
|
||||
|
||||
#if defined(MOZ_ANDROID_FROYO) || defined(MOZ_ANDROID_GB)
|
||||
// Android versions 2.x.x have common API differences
|
||||
#define MOZ_ANDROID_V2_X_X
|
||||
#endif
|
||||
|
||||
using namespace MPAPI;
|
||||
|
||||
namespace android {
|
||||
@ -265,7 +271,7 @@ 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)
|
||||
#if !defined(MOZ_ANDROID_V2_X_X)
|
||||
LOG("media.stagefright.omxcodec.flags=%d", flags);
|
||||
if ((flags & OMXCodec::kHardwareCodecsOnly) != 0) {
|
||||
LOG("FORCE HARDWARE DECODING");
|
||||
@ -325,7 +331,7 @@ 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)
|
||||
#if defined(MOZ_ANDROID_V2_X_X)
|
||||
flags = OMXCodec::kPreferSoftwareCodecs;
|
||||
#else
|
||||
flags = OMXCodec::kSoftwareCodecsOnly;
|
||||
@ -398,18 +404,21 @@ bool OmxDecoder::Init() {
|
||||
sp<MediaSource> videoTrack;
|
||||
sp<MediaSource> videoSource;
|
||||
if (videoTrackIndex != -1 && (videoTrack = extractor->getTrack(videoTrackIndex)) != NULL) {
|
||||
#if defined(MOZ_ANDROID_FROYO)
|
||||
// Allow up to 720P video.
|
||||
sp<MetaData> meta = extractor->getTrackMetaData(videoTrackIndex);
|
||||
meta->setInt32(kKeyMaxInputSize, (1280 * 720 * 3) / 2);
|
||||
#endif
|
||||
videoSource = CreateVideoSource(mPluginHost, omx, videoTrack);
|
||||
if (videoSource == NULL) {
|
||||
LOG("OMXCodec failed to initialize video decoder for \"%s\"", videoMime);
|
||||
return false;
|
||||
}
|
||||
|
||||
status_t status = videoSource->start();
|
||||
if (status != OK) {
|
||||
LOG("videoSource->start() failed with status %#x", status);
|
||||
return false;
|
||||
}
|
||||
|
||||
int64_t durationUs;
|
||||
if (videoTrack->getFormat()->findInt64(kKeyDuration, &durationUs)) {
|
||||
if (durationUs < 0)
|
||||
@ -526,7 +535,7 @@ bool OmxDecoder::SetVideoFormat() {
|
||||
|
||||
int32_t cropRight, cropBottom;
|
||||
// Gingerbread does not support the kKeyCropRect key
|
||||
#if !defined(MOZ_ANDROID_GB)
|
||||
#if !defined(MOZ_ANDROID_V2_X_X)
|
||||
if (!format->findRect(kKeyCropRect, &mVideoCropLeft, &mVideoCropTop,
|
||||
&cropRight, &cropBottom)) {
|
||||
#endif
|
||||
@ -535,7 +544,7 @@ bool OmxDecoder::SetVideoFormat() {
|
||||
cropRight = mVideoStride - 1;
|
||||
cropBottom = mVideoSliceHeight - 1;
|
||||
LOG("crop rect not available, assuming no cropping");
|
||||
#if !defined(MOZ_ANDROID_GB)
|
||||
#if !defined(MOZ_ANDROID_V2_X_X)
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -550,10 +559,14 @@ bool OmxDecoder::SetVideoFormat() {
|
||||
MOZ_ASSERT(mVideoWidth > 0 && mVideoWidth <= mVideoStride);
|
||||
MOZ_ASSERT(mVideoHeight > 0 && mVideoHeight <= mVideoSliceHeight);
|
||||
|
||||
#if !defined(MOZ_ANDROID_FROYO)
|
||||
if (!format->findInt32(kKeyRotation, &mVideoRotation)) {
|
||||
#endif
|
||||
mVideoRotation = 0;
|
||||
#if !defined(MOZ_ANDROID_FROYO)
|
||||
LOG("rotation not available, assuming 0");
|
||||
}
|
||||
#endif
|
||||
|
||||
if (mVideoRotation != 0 && mVideoRotation != 90 &&
|
||||
mVideoRotation != 180 && mVideoRotation != 270) {
|
||||
@ -713,7 +726,7 @@ bool OmxDecoder::ToVideoFrame_ColorConverter(VideoFrame *aFrame, int64_t aTimeUs
|
||||
|
||||
aFrame->mSize = mVideoWidth * mVideoHeight * 2;
|
||||
|
||||
#ifdef MOZ_ANDROID_GB
|
||||
#if defined(MOZ_ANDROID_V2_X_X)
|
||||
mColorConverter->convert(mVideoWidth, mVideoHeight,
|
||||
aData, 0 /* srcSkip */,
|
||||
buffer, mVideoWidth * 2);
|
||||
@ -732,6 +745,9 @@ bool OmxDecoder::ToVideoFrame_ColorConverter(VideoFrame *aFrame, int64_t aTimeUs
|
||||
|
||||
bool OmxDecoder::ToVideoFrame(VideoFrame *aFrame, int64_t aTimeUs, void *aData, size_t aSize, bool aKeyFrame, BufferCallback *aBufferCallback) {
|
||||
switch (mVideoColorFormat) {
|
||||
// Froyo support is best handled with the android color conversion code. I
|
||||
// get corrupted videos when using our own routines below.
|
||||
#if !defined(MOZ_ANDROID_FROYO)
|
||||
case OMX_COLOR_FormatYUV420Planar: // e.g. Asus Transformer, Stagefright's software decoder
|
||||
ToVideoFrame_YUV420Planar(aFrame, aTimeUs, aData, aSize, aKeyFrame);
|
||||
break;
|
||||
@ -753,6 +769,7 @@ bool OmxDecoder::ToVideoFrame(VideoFrame *aFrame, int64_t aTimeUs, void *aData,
|
||||
case OMX_COLOR_Format16bitRGB565:
|
||||
return ToVideoFrame_RGB565(aFrame, aTimeUs, aData, aSize, aKeyFrame, aBufferCallback);
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
if (!ToVideoFrame_ColorConverter(aFrame, aTimeUs, aData, aSize, aKeyFrame, aBufferCallback)) {
|
||||
LOG("Unknown video color format: %#x", mVideoColorFormat);
|
||||
|
69
media/omx-plugin/froyo/Makefile.in
Normal file
69
media/omx-plugin/froyo/Makefile.in
Normal file
@ -0,0 +1,69 @@
|
||||
# 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 = omxpluginfroyo
|
||||
MODULE_NAME = omxpluginfroyo
|
||||
LIBRARY_NAME = omxpluginfroyo
|
||||
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 = \
|
||||
OmxPluginFroyo.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/froyo/libstagefright \
|
||||
-lstagefright \
|
||||
-L$(DEPTH)/media/omx-plugin/lib/gb/libstagefright_color_conversion \
|
||||
-lstagefright_color_conversion \
|
||||
$(NULL)
|
||||
|
||||
INCLUDES += \
|
||||
-I$(srcdir)/../include/froyo \
|
||||
-I$(srcdir)/../include/froyo/media/stagefright/openmax \
|
||||
$(NULL)
|
||||
|
||||
libs:: $(DLL_PREFIX)$(LIBRARY_NAME)$(DLL_SUFFIX)
|
||||
$(INSTALL) $< $(DEPTH)/dist/bin
|
||||
|
||||
libs:: $(PROGRAMS)
|
8
media/omx-plugin/froyo/OmxPluginFroyo.cpp
Normal file
8
media/omx-plugin/froyo/OmxPluginFroyo.cpp
Normal 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_FROYO
|
||||
#include "../OmxPlugin.cpp"
|
Loading…
x
Reference in New Issue
Block a user