summaryrefslogtreecommitdiffstats
path: root/include/media
diff options
context:
space:
mode:
authorJamie Gennis <jgennis@google.com>2010-10-07 14:08:38 -0700
committerJamie Gennis <jgennis@google.com>2010-10-20 11:03:30 -0700
commit6a9da9fc558263548ebfbae2cbf177eb7454a41b (patch)
tree267bd7076e4e9a6b6db1235d73e6a306a30b9496 /include/media
parent4d63523ece864ea783cf9ceeb036400af5804397 (diff)
downloadframeworks_av-6a9da9fc558263548ebfbae2cbf177eb7454a41b.zip
frameworks_av-6a9da9fc558263548ebfbae2cbf177eb7454a41b.tar.gz
frameworks_av-6a9da9fc558263548ebfbae2cbf177eb7454a41b.tar.bz2
Add decode-to-ANativeWindow support to Stagefright.
This change adds support to Stagefright for doing OMX video decoding directly into buffers dequeued from an ANativeWindow. It does this by registering the dequeued buffers with the OMX component using an Android-specific OMX extension, and then exchanging buffers between the OMX component and the ANativeWindow. Change-Id: Ida66f836503255a68d378c6903d96dfe9747ce87
Diffstat (limited to 'include/media')
-rw-r--r--include/media/stagefright/MediaBuffer.h6
-rw-r--r--include/media/stagefright/MetaData.h3
-rw-r--r--include/media/stagefright/OMXCodec.h21
3 files changed, 28 insertions, 2 deletions
diff --git a/include/media/stagefright/MediaBuffer.h b/include/media/stagefright/MediaBuffer.h
index 339e6fb..c1c4f94 100644
--- a/include/media/stagefright/MediaBuffer.h
+++ b/include/media/stagefright/MediaBuffer.h
@@ -25,6 +25,7 @@
namespace android {
+class GraphicBuffer;
class MediaBuffer;
class MediaBufferObserver;
class MetaData;
@@ -48,6 +49,8 @@ public:
MediaBuffer(size_t size);
+ MediaBuffer(const sp<GraphicBuffer>& graphicBuffer);
+
// Decrements the reference count and returns the buffer to its
// associated MediaBufferGroup if the reference count drops to 0.
void release();
@@ -63,6 +66,8 @@ public:
void set_range(size_t offset, size_t length);
+ sp<GraphicBuffer> graphicBuffer() const;
+
sp<MetaData> meta_data();
// Clears meta data and resets the range to the full extent.
@@ -94,6 +99,7 @@ private:
void *mData;
size_t mSize, mRangeOffset, mRangeLength;
+ sp<GraphicBuffer> mGraphicBuffer;
bool mOwnsData;
diff --git a/include/media/stagefright/MetaData.h b/include/media/stagefright/MetaData.h
index d2bd9f2..423f385 100644
--- a/include/media/stagefright/MetaData.h
+++ b/include/media/stagefright/MetaData.h
@@ -99,6 +99,9 @@ enum {
kKeyValidSamples = 'valD', // int32_t
kKeyIsUnreadable = 'unre', // bool (int32_t)
+
+ // An indication that a video buffer has been rendered.
+ kKeyRendered = 'rend', // bool (int32_t)
};
enum {
diff --git a/include/media/stagefright/OMXCodec.h b/include/media/stagefright/OMXCodec.h
index 1d94160..6fef2e7 100644
--- a/include/media/stagefright/OMXCodec.h
+++ b/include/media/stagefright/OMXCodec.h
@@ -18,6 +18,7 @@
#define OMX_CODEC_H_
+#include <android/native_window.h>
#include <media/IOMX.h>
#include <media/stagefright/MediaBuffer.h>
#include <media/stagefright/MediaSource.h>
@@ -44,7 +45,8 @@ struct OMXCodec : public MediaSource,
const sp<MetaData> &meta, bool createEncoder,
const sp<MediaSource> &source,
const char *matchComponentName = NULL,
- uint32_t flags = 0);
+ uint32_t flags = 0,
+ const sp<ANativeWindow> &nativeWindow = NULL);
static void setComponentRole(
const sp<IOMX> &omx, IOMX::node_id node, bool isEncoder,
@@ -114,6 +116,7 @@ private:
struct BufferInfo {
IOMX::buffer_id mBuffer;
bool mOwnedByComponent;
+ bool mOwnedByNativeWindow;
sp<IMemory> mMem;
size_t mSize;
void *mData;
@@ -159,13 +162,21 @@ private:
bool mPaused;
+ sp<ANativeWindow> mNativeWindow;
+
+ // The index in each of the mPortBuffers arrays of the buffer that will be
+ // submitted to OMX next. This only applies when using buffers from a
+ // native window.
+ size_t mNextNativeBufferIndex[2];
+
// A list of indices into mPortStatus[kPortIndexOutput] filled with data.
List<size_t> mFilledBuffers;
Condition mBufferFilled;
OMXCodec(const sp<IOMX> &omx, IOMX::node_id node, uint32_t quirks,
bool isEncoder, const char *mime, const char *componentName,
- const sp<MediaSource> &source);
+ const sp<MediaSource> &source,
+ const sp<ANativeWindow> &nativeWindow);
void addCodecSpecificData(const void *data, size_t size);
void clearCodecSpecificData();
@@ -216,6 +227,11 @@ private:
status_t allocateBuffers();
status_t allocateBuffersOnPort(OMX_U32 portIndex);
+ status_t allocateOutputBuffersFromNativeWindow();
+
+ status_t queueBufferToNativeWindow(BufferInfo *info);
+ status_t cancelBufferToNativeWindow(BufferInfo *info);
+ BufferInfo* dequeueBufferFromNativeWindow();
status_t freeBuffersOnPort(
OMX_U32 portIndex, bool onlyThoseWeOwn = false);
@@ -250,6 +266,7 @@ private:
status_t init();
void initOutputFormat(const sp<MetaData> &inputFormat);
+ status_t initNativeWindow();
void dumpPortStatus(OMX_U32 portIndex);