diff options
author | Lajos Molnar <lajos@google.com> | 2013-07-22 12:57:43 -0700 |
---|---|---|
committer | Lajos Molnar <lajos@google.com> | 2013-08-06 13:19:26 -0700 |
commit | d0715867861c216e88a4a7523b6da8a3cb128724 (patch) | |
tree | 9b474094654a2dccb440fd9ca4a87f8afbdb9278 | |
parent | b08ab81bab9e8cd2e3a7fff02725a387070fd078 (diff) | |
download | frameworks_av-d0715867861c216e88a4a7523b6da8a3cb128724.zip frameworks_av-d0715867861c216e88a4a7523b6da8a3cb128724.tar.gz frameworks_av-d0715867861c216e88a4a7523b6da8a3cb128724.tar.bz2 |
IOMX: add updateGraphicBufferInMeta method for metadata mode
This is used to set the handle in the metadata buffer that is
valid in the mediaserver process, as well as to keep a reference
for the graphic buffers in BufferMeta.
Change-Id: I46bb68d8bed894f357eeeb25368360d11b276634
Signed-off-by: Lajos Molnar <lajos@google.com>
-rw-r--r-- | include/media/IOMX.h | 4 | ||||
-rw-r--r-- | media/libmedia/IOMX.cpp | 33 | ||||
-rw-r--r-- | media/libstagefright/ACodec.cpp | 17 | ||||
-rw-r--r-- | media/libstagefright/OMXClient.cpp | 11 | ||||
-rw-r--r-- | media/libstagefright/include/OMX.h | 4 | ||||
-rw-r--r-- | media/libstagefright/include/OMXNodeInstance.h | 4 | ||||
-rw-r--r-- | media/libstagefright/omx/OMX.cpp | 7 | ||||
-rw-r--r-- | media/libstagefright/omx/OMXNodeInstance.cpp | 20 |
8 files changed, 94 insertions, 6 deletions
diff --git a/include/media/IOMX.h b/include/media/IOMX.h index 38f9d11..6d116f0 100644 --- a/include/media/IOMX.h +++ b/include/media/IOMX.h @@ -97,6 +97,10 @@ public: node_id node, OMX_U32 port_index, const sp<GraphicBuffer> &graphicBuffer, buffer_id *buffer) = 0; + virtual status_t updateGraphicBufferInMeta( + node_id node, OMX_U32 port_index, + const sp<GraphicBuffer> &graphicBuffer, buffer_id buffer) = 0; + virtual status_t createInputSurface( node_id node, OMX_U32 port_index, sp<IGraphicBufferProducer> *bufferProducer) = 0; diff --git a/media/libmedia/IOMX.cpp b/media/libmedia/IOMX.cpp index 5bbb2f0..ef99f4f 100644 --- a/media/libmedia/IOMX.cpp +++ b/media/libmedia/IOMX.cpp @@ -52,6 +52,7 @@ enum { OBSERVER_ON_MSG, GET_GRAPHIC_BUFFER_USAGE, SET_INTERNAL_OPTION, + UPDATE_GRAPHIC_BUFFER_IN_META, }; class BpOMX : public BpInterface<IOMX> { @@ -283,6 +284,21 @@ public: return err; } + virtual status_t updateGraphicBufferInMeta( + node_id node, OMX_U32 port_index, + const sp<GraphicBuffer> &graphicBuffer, buffer_id buffer) { + Parcel data, reply; + data.writeInterfaceToken(IOMX::getInterfaceDescriptor()); + data.writeIntPtr((intptr_t)node); + data.writeInt32(port_index); + data.write(*graphicBuffer); + data.writeIntPtr((intptr_t)buffer); + remote()->transact(UPDATE_GRAPHIC_BUFFER_IN_META, data, &reply); + + status_t err = reply.readInt32(); + return err; + } + virtual status_t createInputSurface( node_id node, OMX_U32 port_index, sp<IGraphicBufferProducer> *bufferProducer) { @@ -691,6 +707,23 @@ status_t BnOMX::onTransact( return NO_ERROR; } + case UPDATE_GRAPHIC_BUFFER_IN_META: + { + CHECK_OMX_INTERFACE(IOMX, data, reply); + + node_id node = (void*)data.readIntPtr(); + OMX_U32 port_index = data.readInt32(); + sp<GraphicBuffer> graphicBuffer = new GraphicBuffer(); + data.read(*graphicBuffer); + buffer_id buffer = (void*)data.readIntPtr(); + + status_t err = updateGraphicBufferInMeta( + node, port_index, graphicBuffer, buffer); + reply->writeInt32(err); + + return NO_ERROR; + } + case CREATE_INPUT_SURFACE: { CHECK_OMX_INTERFACE(IOMX, data, reply); diff --git a/media/libstagefright/ACodec.cpp b/media/libstagefright/ACodec.cpp index 00804c5..5aefa58 100644 --- a/media/libstagefright/ACodec.cpp +++ b/media/libstagefright/ACodec.cpp @@ -833,15 +833,20 @@ ACodec::BufferInfo *ACodec::dequeueBufferFromNativeWindow() { oldest->mGraphicBuffer = new GraphicBuffer(buf, false); oldest->mStatus = BufferInfo::OWNED_BY_US; - struct VideoDecoderOutputMetaData metaData; - metaData.eType = kMetadataBufferTypeGrallocSource; - metaData.pHandle = oldest->mGraphicBuffer->handle; - memcpy(oldest->mData->base(), &metaData, sizeof(metaData)); + mOMX->updateGraphicBufferInMeta( + mNode, kPortIndexOutput, oldest->mGraphicBuffer, + oldest->mBufferID); - ALOGV("replaced oldest buffer #%u with age %u (%p stored in %p)", + VideoDecoderOutputMetaData *metaData = + reinterpret_cast<VideoDecoderOutputMetaData *>( + oldest->mData->base()); + CHECK_EQ(metaData->eType, kMetadataBufferTypeGrallocSource); + + ALOGV("replaced oldest buffer #%u with age %u (%p/%p stored in %p)", oldest - &mBuffers[kPortIndexOutput][0], mDequeueCounter - oldest->mDequeuedAt, - metaData.pHandle, oldest->mData->base()); + metaData->pHandle, + oldest->mGraphicBuffer->handle, oldest->mData->base()); return oldest; } diff --git a/media/libstagefright/OMXClient.cpp b/media/libstagefright/OMXClient.cpp index 810d88f..9820ef5 100644 --- a/media/libstagefright/OMXClient.cpp +++ b/media/libstagefright/OMXClient.cpp @@ -83,6 +83,10 @@ struct MuxOMX : public IOMX { node_id node, OMX_U32 port_index, const sp<GraphicBuffer> &graphicBuffer, buffer_id *buffer); + virtual status_t updateGraphicBufferInMeta( + node_id node, OMX_U32 port_index, + const sp<GraphicBuffer> &graphicBuffer, buffer_id buffer); + virtual status_t createInputSurface( node_id node, OMX_U32 port_index, sp<IGraphicBufferProducer> *bufferProducer); @@ -287,6 +291,13 @@ status_t MuxOMX::useGraphicBuffer( node, port_index, graphicBuffer, buffer); } +status_t MuxOMX::updateGraphicBufferInMeta( + node_id node, OMX_U32 port_index, + const sp<GraphicBuffer> &graphicBuffer, buffer_id buffer) { + return getOMX(node)->updateGraphicBufferInMeta( + node, port_index, graphicBuffer, buffer); +} + status_t MuxOMX::createInputSurface( node_id node, OMX_U32 port_index, sp<IGraphicBufferProducer> *bufferProducer) { diff --git a/media/libstagefright/include/OMX.h b/media/libstagefright/include/OMX.h index 7fed7d4..7e53af3 100644 --- a/media/libstagefright/include/OMX.h +++ b/media/libstagefright/include/OMX.h @@ -79,6 +79,10 @@ public: node_id node, OMX_U32 port_index, const sp<GraphicBuffer> &graphicBuffer, buffer_id *buffer); + virtual status_t updateGraphicBufferInMeta( + node_id node, OMX_U32 port_index, + const sp<GraphicBuffer> &graphicBuffer, buffer_id buffer); + virtual status_t createInputSurface( node_id node, OMX_U32 port_index, sp<IGraphicBufferProducer> *bufferProducer); diff --git a/media/libstagefright/include/OMXNodeInstance.h b/media/libstagefright/include/OMXNodeInstance.h index f6ae376..ae498b4 100644 --- a/media/libstagefright/include/OMXNodeInstance.h +++ b/media/libstagefright/include/OMXNodeInstance.h @@ -66,6 +66,10 @@ struct OMXNodeInstance { OMX_U32 portIndex, const sp<GraphicBuffer> &graphicBuffer, OMX::buffer_id *buffer); + status_t updateGraphicBufferInMeta( + OMX_U32 portIndex, const sp<GraphicBuffer> &graphicBuffer, + OMX::buffer_id buffer); + status_t createInputSurface( OMX_U32 portIndex, sp<IGraphicBufferProducer> *bufferProducer); diff --git a/media/libstagefright/omx/OMX.cpp b/media/libstagefright/omx/OMX.cpp index 4b1dbe6..aaa9f89 100644 --- a/media/libstagefright/omx/OMX.cpp +++ b/media/libstagefright/omx/OMX.cpp @@ -345,6 +345,13 @@ status_t OMX::useGraphicBuffer( port_index, graphicBuffer, buffer); } +status_t OMX::updateGraphicBufferInMeta( + node_id node, OMX_U32 port_index, + const sp<GraphicBuffer> &graphicBuffer, buffer_id buffer) { + return findInstance(node)->updateGraphicBufferInMeta( + port_index, graphicBuffer, buffer); +} + status_t OMX::createInputSurface( node_id node, OMX_U32 port_index, sp<IGraphicBufferProducer> *bufferProducer) { diff --git a/media/libstagefright/omx/OMXNodeInstance.cpp b/media/libstagefright/omx/OMXNodeInstance.cpp index 525e18d..8d100f1 100644 --- a/media/libstagefright/omx/OMXNodeInstance.cpp +++ b/media/libstagefright/omx/OMXNodeInstance.cpp @@ -70,6 +70,10 @@ struct BufferMeta { header->nFilledLen); } + void setGraphicBuffer(const sp<GraphicBuffer> &graphicBuffer) { + mGraphicBuffer = graphicBuffer; + } + private: sp<GraphicBuffer> mGraphicBuffer; sp<IMemory> mMem; @@ -566,6 +570,22 @@ status_t OMXNodeInstance::useGraphicBuffer( return OK; } +status_t OMXNodeInstance::updateGraphicBufferInMeta( + OMX_U32 portIndex, const sp<GraphicBuffer>& graphicBuffer, + OMX::buffer_id buffer) { + Mutex::Autolock autoLock(mLock); + + OMX_BUFFERHEADERTYPE *header = (OMX_BUFFERHEADERTYPE *)(buffer); + VideoDecoderOutputMetaData *metadata = + (VideoDecoderOutputMetaData *)(header->pBuffer); + BufferMeta *bufferMeta = (BufferMeta *)(header->pAppPrivate); + bufferMeta->setGraphicBuffer(graphicBuffer); + metadata->eType = kMetadataBufferTypeGrallocSource; + metadata->pHandle = graphicBuffer->handle; + + return OK; +} + status_t OMXNodeInstance::createInputSurface( OMX_U32 portIndex, sp<IGraphicBufferProducer> *bufferProducer) { Mutex::Autolock autolock(mLock); |