summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Huber <andih@google.com>2010-02-11 11:00:26 -0800
committerAndreas Huber <andih@google.com>2010-02-11 11:03:01 -0800
commit988e3f0b2c74095deae580157c57935a98573052 (patch)
treef50e2a5ae509d9f180cdba6e092055abf82d3f18
parent2f5b04733badcb8bd5131aef9d99c9a9e84a3a21 (diff)
downloadframeworks_av-988e3f0b2c74095deae580157c57935a98573052.zip
frameworks_av-988e3f0b2c74095deae580157c57935a98573052.tar.gz
frameworks_av-988e3f0b2c74095deae580157c57935a98573052.tar.bz2
Support for rendering through an overlay on the droid even if a software renderer is active.
-rw-r--r--media/libstagefright/Android.mk8
-rw-r--r--media/libstagefright/AwesomePlayer.cpp63
-rw-r--r--media/libstagefright/colorconversion/SoftwareRenderer.cpp1
3 files changed, 67 insertions, 5 deletions
diff --git a/media/libstagefright/Android.mk b/media/libstagefright/Android.mk
index 58eb12e..88d61a6 100644
--- a/media/libstagefright/Android.mk
+++ b/media/libstagefright/Android.mk
@@ -88,6 +88,14 @@ LOCAL_STATIC_LIBRARIES += \
LOCAL_SHARED_LIBRARIES += \
libstagefright_color_conversion
+ifeq ($(TARGET_OS)-$(TARGET_SIMULATOR),linux-true)
+ LOCAL_LDLIBS += -lpthread -ldl
+endif
+
+ifneq ($(TARGET_SIMULATOR),true)
+LOCAL_SHARED_LIBRARIES += libdl
+endif
+
endif
ifeq ($(TARGET_OS)-$(TARGET_SIMULATOR),linux-true)
diff --git a/media/libstagefright/AwesomePlayer.cpp b/media/libstagefright/AwesomePlayer.cpp
index a13b242..b6dcf46 100644
--- a/media/libstagefright/AwesomePlayer.cpp
+++ b/media/libstagefright/AwesomePlayer.cpp
@@ -18,6 +18,8 @@
#define LOG_TAG "AwesomePlayer"
#include <utils/Log.h>
+#include <dlfcn.h>
+
#include "include/AwesomePlayer.h"
#include "include/Prefetcher.h"
#include "include/SoftwareRenderer.h"
@@ -80,13 +82,16 @@ private:
struct AwesomeLocalRenderer : public AwesomeRenderer {
AwesomeLocalRenderer(
+ const char *componentName,
OMX_COLOR_FORMATTYPE colorFormat,
const sp<ISurface> &surface,
size_t displayWidth, size_t displayHeight,
size_t decodedWidth, size_t decodedHeight)
- : mTarget(new SoftwareRenderer(
- colorFormat, surface, displayWidth, displayHeight,
- decodedWidth, decodedHeight)) {
+ : mTarget(NULL),
+ mLibHandle(NULL) {
+ init(componentName,
+ colorFormat, surface, displayWidth,
+ displayHeight, decodedWidth, decodedHeight);
}
virtual void render(MediaBuffer *buffer) {
@@ -99,15 +104,64 @@ protected:
virtual ~AwesomeLocalRenderer() {
delete mTarget;
mTarget = NULL;
+
+ if (mLibHandle) {
+ dlclose(mLibHandle);
+ mLibHandle = NULL;
+ }
}
private:
- SoftwareRenderer *mTarget;
+ VideoRenderer *mTarget;
+ void *mLibHandle;
+
+ void init(
+ const char *componentName,
+ OMX_COLOR_FORMATTYPE colorFormat,
+ const sp<ISurface> &surface,
+ size_t displayWidth, size_t displayHeight,
+ size_t decodedWidth, size_t decodedHeight);
AwesomeLocalRenderer(const AwesomeLocalRenderer &);
AwesomeLocalRenderer &operator=(const AwesomeLocalRenderer &);;
};
+void AwesomeLocalRenderer::init(
+ const char *componentName,
+ OMX_COLOR_FORMATTYPE colorFormat,
+ const sp<ISurface> &surface,
+ size_t displayWidth, size_t displayHeight,
+ size_t decodedWidth, size_t decodedHeight) {
+ mLibHandle = dlopen("libstagefrighthw.so", RTLD_NOW);
+
+ if (mLibHandle) {
+ typedef VideoRenderer *(*CreateRendererFunc)(
+ const sp<ISurface> &surface,
+ const char *componentName,
+ OMX_COLOR_FORMATTYPE colorFormat,
+ size_t displayWidth, size_t displayHeight,
+ size_t decodedWidth, size_t decodedHeight);
+
+ CreateRendererFunc func =
+ (CreateRendererFunc)dlsym(
+ mLibHandle,
+ "_Z14createRendererRKN7android2spINS_8ISurfaceEEEPKc20"
+ "OMX_COLOR_FORMATTYPEjjjj");
+
+ if (func) {
+ mTarget =
+ (*func)(surface, componentName, colorFormat,
+ displayWidth, displayHeight, decodedWidth, decodedHeight);
+ }
+ }
+
+ if (mTarget == NULL) {
+ mTarget = new SoftwareRenderer(
+ colorFormat, surface, displayWidth, displayHeight,
+ decodedWidth, decodedHeight);
+ }
+}
+
AwesomePlayer::AwesomePlayer()
: mTimeSource(NULL),
mAudioPlayer(NULL),
@@ -448,6 +502,7 @@ void AwesomePlayer::initRenderer_l() {
// Other decoders are instantiated locally and as a consequence
// allocate their buffers in local address space.
mVideoRenderer = new AwesomeLocalRenderer(
+ component,
(OMX_COLOR_FORMATTYPE)format,
mISurface,
mVideoWidth, mVideoHeight,
diff --git a/media/libstagefright/colorconversion/SoftwareRenderer.cpp b/media/libstagefright/colorconversion/SoftwareRenderer.cpp
index ed91eea..56c5102 100644
--- a/media/libstagefright/colorconversion/SoftwareRenderer.cpp
+++ b/media/libstagefright/colorconversion/SoftwareRenderer.cpp
@@ -40,7 +40,6 @@ SoftwareRenderer::SoftwareRenderer(
mDecodedHeight(decodedHeight),
mFrameSize(mDecodedWidth * mDecodedHeight * 2), // RGB565
mIndex(0) {
- // TODO: How do I allocate physical memory on Droid?
mMemoryHeap = new MemoryHeapBase("/dev/pmem_adsp", 2 * mFrameSize);
if (mMemoryHeap->heapID() < 0) {
LOGI("Creating physical memory heap failed, reverting to regular heap.");