summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShivaprasad Hongal <shongal@codeaurora.org>2015-07-30 18:00:18 -0700
committerSatish Kamuju <skamuj@codeaurora.org>2015-10-06 17:37:32 +0530
commit1ee2a02ee471d8c5d7b3c3bd3ab720f3dcfea056 (patch)
tree9e6156dc3c8c52168fd56aa0f06b211c5fd36155
parentbc3028750d3438ebf108298e93f12de461f56430 (diff)
downloadframeworks_av-1ee2a02ee471d8c5d7b3c3bd3ab720f3dcfea056.zip
frameworks_av-1ee2a02ee471d8c5d7b3c3bd3ab720f3dcfea056.tar.gz
frameworks_av-1ee2a02ee471d8c5d7b3c3bd3ab720f3dcfea056.tar.bz2
Stagefright: Enable custom allocation mode.
Enable custom allocation mode Change-Id: Idf3f6c0eb9d17d361d2e5b6c36b1fe7586236565
-rw-r--r--include/media/stagefright/ACodec.h9
-rw-r--r--media/libavextensions/media/AVMediaExtensions.h6
-rw-r--r--media/libmedia/ICrypto.cpp5
-rw-r--r--media/libmedia/IOMX.cpp3
-rw-r--r--media/libstagefright/ACodec.cpp22
5 files changed, 37 insertions, 8 deletions
diff --git a/include/media/stagefright/ACodec.h b/include/media/stagefright/ACodec.h
index aaaf2d1..33fb963 100644
--- a/include/media/stagefright/ACodec.h
+++ b/include/media/stagefright/ACodec.h
@@ -177,6 +177,7 @@ protected:
sp<GraphicBuffer> mGraphicBuffer;
int mFenceFd;
FrameRenderTracker::Info *mRenderInfo;
+ int mCustomData;
// The following field and 4 methods are used for debugging only
bool mIsReadFence;
@@ -275,7 +276,7 @@ protected:
status_t setCyclicIntraMacroblockRefresh(const sp<AMessage> &msg, int32_t mode);
status_t allocateBuffersOnPort(OMX_U32 portIndex);
status_t freeBuffersOnPort(OMX_U32 portIndex);
- status_t freeBuffer(OMX_U32 portIndex, size_t i);
+ virtual status_t freeBuffer(OMX_U32 portIndex, size_t i);
status_t handleSetSurface(const sp<Surface> &surface);
status_t setupNativeWindowSizeFormatAndUsage(
@@ -436,6 +437,12 @@ protected:
virtual status_t getVQZIPInfo(const sp<AMessage> &msg) {
return OK;
}
+ virtual bool canAllocateBuffer(OMX_U32 /* portIndex */) {
+ return false;
+ }
+ virtual void enableCustomAllocationMode(const sp<AMessage> &/* msg */) {}
+ virtual status_t allocateBuffer(
+ OMX_U32 portIndex, size_t bufSize, BufferInfo &info);
sp<IOMXObserver> createObserver();
diff --git a/media/libavextensions/media/AVMediaExtensions.h b/media/libavextensions/media/AVMediaExtensions.h
index ea5245c..6cf39f2 100644
--- a/media/libavextensions/media/AVMediaExtensions.h
+++ b/media/libavextensions/media/AVMediaExtensions.h
@@ -37,6 +37,7 @@
namespace android {
class MediaRecorder;
+class Parcel;
/*
* Common delegate to the classes in libstagefright
*/
@@ -60,6 +61,11 @@ struct AVMediaUtils {
}
virtual sp<MediaRecorder> createMediaRecorder(const String16& opPackageName);
+ virtual void writeCustomData(
+ Parcel * /* reply */, void * /* buffer_data */) {}
+ virtual void readCustomData(
+ const Parcel * /* reply */, void ** /*buffer_data */ ) {}
+ virtual void closeFileDescriptor(void * /* buffer_ptr */) {}
// ----- NO TRESSPASSING BEYOND THIS LINE ------
DECLARE_LOADABLE_SINGLETON(AVMediaUtils);
};
diff --git a/media/libmedia/ICrypto.cpp b/media/libmedia/ICrypto.cpp
index 9f65bde..f80357f 100644
--- a/media/libmedia/ICrypto.cpp
+++ b/media/libmedia/ICrypto.cpp
@@ -24,6 +24,7 @@
#include <media/stagefright/MediaErrors.h>
#include <media/stagefright/foundation/ADebug.h>
#include <media/stagefright/foundation/AString.h>
+#include <media/AVMediaExtensions.h>
namespace android {
@@ -136,6 +137,7 @@ struct BpCrypto : public BpInterface<ICrypto> {
if (secure) {
data.writeInt64(static_cast<uint64_t>(reinterpret_cast<uintptr_t>(dstPtr)));
+ AVMediaUtils::get()->writeCustomData(&data, dstPtr);
}
remote()->transact(DECRYPT, data, &reply);
@@ -297,6 +299,7 @@ status_t BnCrypto::onTransact(
void *secureBufferId, *dstPtr;
if (secure) {
secureBufferId = reinterpret_cast<void *>(static_cast<uintptr_t>(data.readInt64()));
+ AVMediaUtils::get()->readCustomData(&data, &secureBufferId);
} else {
dstPtr = malloc(totalSize);
CHECK(dstPtr != NULL);
@@ -332,6 +335,8 @@ status_t BnCrypto::onTransact(
}
free(dstPtr);
dstPtr = NULL;
+ } else {
+ AVMediaUtils::get()->closeFileDescriptor(dstPtr);
}
delete[] subSamples;
diff --git a/media/libmedia/IOMX.cpp b/media/libmedia/IOMX.cpp
index 16da65e..ac2e872 100644
--- a/media/libmedia/IOMX.cpp
+++ b/media/libmedia/IOMX.cpp
@@ -22,6 +22,7 @@
#include <binder/Parcel.h>
#include <media/IOMX.h>
#include <media/stagefright/foundation/ADebug.h>
+#include <media/AVMediaExtensions.h>
namespace android {
@@ -472,6 +473,7 @@ public:
*buffer = (buffer_id)reply.readInt32();
*buffer_data = (void *)reply.readInt64();
+ AVMediaUtils::get()->readCustomData(&reply, buffer_data);
return err;
}
@@ -974,6 +976,7 @@ status_t BnOMX::onTransact(
if (err == OK) {
reply->writeInt32((int32_t)buffer);
reply->writeInt64((uintptr_t)buffer_data);
+ AVMediaUtils::get()->writeCustomData(reply, buffer_data);
}
return NO_ERROR;
diff --git a/media/libstagefright/ACodec.cpp b/media/libstagefright/ACodec.cpp
index 97a0be0..238cd47 100644
--- a/media/libstagefright/ACodec.cpp
+++ b/media/libstagefright/ACodec.cpp
@@ -832,15 +832,11 @@ status_t ACodec::allocateBuffersOnPort(OMX_U32 portIndex) {
: OMXCodec::kRequiresAllocateBufferOnOutputPorts;
if ((portIndex == kPortIndexInput && (mFlags & kFlagIsSecure))
- || (portIndex == kPortIndexOutput && usingMetadataOnEncoderOutput())) {
+ || (portIndex == kPortIndexOutput && usingMetadataOnEncoderOutput())
+ || canAllocateBuffer(portIndex)) {
mem.clear();
- void *ptr;
- err = mOMX->allocateBuffer(
- mNode, portIndex, bufSize, &info.mBufferID,
- &ptr);
-
- info.mData = new ABuffer(ptr, bufSize);
+ err = allocateBuffer(portIndex, bufSize, info);
} else if (mQuirks & requiresAllocateBufferBit) {
err = mOMX->allocateBufferWithBackup(
mNode, portIndex, mem, &info.mBufferID, allottedSize);
@@ -1643,6 +1639,8 @@ status_t ACodec::configureCodec(
return err;
}
+ enableCustomAllocationMode(msg);
+
int32_t bitRate = 0;
// FLAC encoder doesn't need a bitrate, other encoders do
if (encoder && strcasecmp(mime, MEDIA_MIMETYPE_AUDIO_FLAC)
@@ -6385,6 +6383,16 @@ sp<IOMXObserver> ACodec::createObserver() {
return observer;
}
+status_t ACodec::allocateBuffer(
+ OMX_U32 portIndex, size_t bufSize, BufferInfo &info) {
+ void *ptr;
+ status_t err = mOMX->allocateBuffer(
+ mNode, portIndex, bufSize, &info.mBufferID, &ptr);
+
+ info.mData = new ABuffer(ptr, bufSize);
+ return err;
+}
+
bool ACodec::ExecutingState::onOMXFrameRendered(int64_t mediaTimeUs, nsecs_t systemNano) {
mCodec->onFrameRendered(mediaTimeUs, systemNano);
return true;