Expose a variation of the createRenderer API that works on a plain Surface.
diff --git a/include/media/IOMX.h b/include/media/IOMX.h
index 857b2bd..7e5ff61 100644
--- a/include/media/IOMX.h
+++ b/include/media/IOMX.h
@@ -31,6 +31,7 @@
class IOMXObserver;
class IOMXRenderer;
class ISurface;
+class Surface;
class IOMX : public IInterface {
public:
@@ -87,6 +88,16 @@
OMX_COLOR_FORMATTYPE colorFormat,
size_t encodedWidth, size_t encodedHeight,
size_t displayWidth, size_t displayHeight) = 0;
+
+ // Note: This method is _not_ virtual, it exists as a wrapper around
+ // the virtual "createRenderer" method above facilitating extraction
+ // of the ISurface from a regular Surface.
+ sp<IOMXRenderer> createRenderer(
+ const sp<Surface> &surface,
+ const char *componentName,
+ OMX_COLOR_FORMATTYPE colorFormat,
+ size_t encodedWidth, size_t encodedHeight,
+ size_t displayWidth, size_t displayHeight);
};
struct omx_message {
diff --git a/include/ui/Surface.h b/include/ui/Surface.h
index 5665c1f..d5dad31 100644
--- a/include/ui/Surface.h
+++ b/include/ui/Surface.h
@@ -35,8 +35,8 @@
// ---------------------------------------------------------------------------
class BufferMapper;
+class IOMX;
class Rect;
-class MediaPlayerImpl;
class Surface;
class SurfaceComposerClient;
struct per_client_cblk_t;
@@ -181,7 +181,7 @@
// mediaplayer needs access to ISurface for display
friend class MediaPlayer;
friend class Test;
- friend class MediaPlayerImpl;
+ friend class IOMX;
const sp<ISurface>& getISurface() const { return mSurface; }
status_t getBufferLocked(int index);
diff --git a/media/libmedia/IOMX.cpp b/media/libmedia/IOMX.cpp
index b0f466b..d1dbc5c 100644
--- a/media/libmedia/IOMX.cpp
+++ b/media/libmedia/IOMX.cpp
@@ -6,6 +6,7 @@
#include <binder/Parcel.h>
#include <media/IOMX.h>
#include <ui/ISurface.h>
+#include <ui/Surface.h>
namespace android {
@@ -29,6 +30,18 @@
RENDERER_RENDER,
};
+sp<IOMXRenderer> IOMX::createRenderer(
+ const sp<Surface> &surface,
+ const char *componentName,
+ OMX_COLOR_FORMATTYPE colorFormat,
+ size_t encodedWidth, size_t encodedHeight,
+ size_t displayWidth, size_t displayHeight) {
+ return createRenderer(
+ surface->getISurface(),
+ componentName, colorFormat, encodedWidth, encodedHeight,
+ displayWidth, displayHeight);
+}
+
static void *readVoidStar(const Parcel *parcel) {
// FIX if sizeof(void *) != sizeof(int32)
return (void *)parcel->readInt32();
diff --git a/media/libstagefright/MediaPlayerImpl.cpp b/media/libstagefright/MediaPlayerImpl.cpp
index 341f002..f2e62f5 100644
--- a/media/libstagefright/MediaPlayerImpl.cpp
+++ b/media/libstagefright/MediaPlayerImpl.cpp
@@ -646,15 +646,21 @@
success = success && meta->findInt32(kKeyHeight, &decodedHeight);
assert(success);
- const sp<ISurface> &isurface =
- mSurface.get() != NULL ? mSurface->getISurface() : mISurface;
-
- mVideoRenderer =
- mClient.interface()->createRenderer(
- isurface, component,
- (OMX_COLOR_FORMATTYPE)format,
- decodedWidth, decodedHeight,
- mVideoWidth, mVideoHeight);
+ if (mSurface.get() != NULL) {
+ mVideoRenderer =
+ mClient.interface()->createRenderer(
+ mSurface, component,
+ (OMX_COLOR_FORMATTYPE)format,
+ decodedWidth, decodedHeight,
+ mVideoWidth, mVideoHeight);
+ } else {
+ mVideoRenderer =
+ mClient.interface()->createRenderer(
+ mISurface, component,
+ (OMX_COLOR_FORMATTYPE)format,
+ decodedWidth, decodedHeight,
+ mVideoWidth, mVideoHeight);
+ }
}
void MediaPlayerImpl::depopulateISurface() {