From c721e71f4d7e3cd4fc9332fd55fb6942f54cec39 Mon Sep 17 00:00:00 2001 From: Ronghua Wu Date: Fri, 24 Apr 2015 15:29:49 -0700 Subject: DO NOT MERGE libmedia: add sub resource type audio-codec and video-codec. Bug: 20559813 Change-Id: If231cb44337ca7dc74c39fc3cd73e2b6f3cb85b8 (cherry picked from commit d4c1f6b4ecfef7323422359fc38bd1edb1abf205) --- media/libstagefright/MediaCodec.cpp | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) (limited to 'media/libstagefright/MediaCodec.cpp') diff --git a/media/libstagefright/MediaCodec.cpp b/media/libstagefright/MediaCodec.cpp index 7065a6e..aa0d2e6 100644 --- a/media/libstagefright/MediaCodec.cpp +++ b/media/libstagefright/MediaCodec.cpp @@ -434,7 +434,8 @@ status_t MediaCodec::init(const AString &name, bool nameIsType, bool encoder) { status_t err; Vector resources; const char *type = secureCodec ? kResourceSecureCodec : kResourceNonSecureCodec; - resources.push_back(MediaResource(String8(type), 1)); + const char *subtype = mIsVideo ? kResourceVideoCodec : kResourceAudioCodec; + resources.push_back(MediaResource(String8(type), String8(subtype), 1)); for (int i = 0; i <= kMaxRetry; ++i) { if (i > 0) { // Don't try to reclaim resource for the first time. @@ -492,7 +493,8 @@ status_t MediaCodec::configure( Vector resources; const char *type = (mFlags & kFlagIsSecure) ? kResourceSecureCodec : kResourceNonSecureCodec; - resources.push_back(MediaResource(String8(type), 1)); + const char *subtype = mIsVideo ? kResourceVideoCodec : kResourceAudioCodec; + resources.push_back(MediaResource(String8(type), String8(subtype), 1)); // Don't know the buffer size at this point, but it's fine to use 1 because // the reclaimResource call doesn't consider the requester's buffer size for now. resources.push_back(MediaResource(String8(kResourceGraphicMemory), 1)); @@ -557,9 +559,9 @@ uint64_t MediaCodec::getGraphicBufferSize() { return size; } -void MediaCodec::addResource(const char *type, uint64_t value) { +void MediaCodec::addResource(const String8 &type, const String8 &subtype, uint64_t value) { Vector resources; - resources.push_back(MediaResource(String8(type), value)); + resources.push_back(MediaResource(type, subtype, value)); mResourceManagerService->addResource( getCallingPid(), getId(mResourceManagerClient), mResourceManagerClient, resources); } @@ -571,7 +573,8 @@ status_t MediaCodec::start() { Vector resources; const char *type = (mFlags & kFlagIsSecure) ? kResourceSecureCodec : kResourceNonSecureCodec; - resources.push_back(MediaResource(String8(type), 1)); + const char *subtype = mIsVideo ? kResourceVideoCodec : kResourceAudioCodec; + resources.push_back(MediaResource(String8(type), String8(subtype), 1)); // Don't know the buffer size at this point, but it's fine to use 1 because // the reclaimResource call doesn't consider the requester's buffer size for now. resources.push_back(MediaResource(String8(kResourceGraphicMemory), 1)); @@ -1183,7 +1186,9 @@ void MediaCodec::onMessageReceived(const sp &msg) { mFlags &= ~kFlagIsSecure; resourceType = String8(kResourceNonSecureCodec); } - addResource(resourceType, 1); + + const char *subtype = mIsVideo ? kResourceVideoCodec : kResourceAudioCodec; + addResource(resourceType, String8(subtype), 1); (new AMessage)->postReply(mReplyID); break; @@ -1297,7 +1302,11 @@ void MediaCodec::onMessageReceived(const sp &msg) { // allocating input buffers, so this is a good // indication that now all buffers are allocated. if (mIsVideo) { - addResource(kResourceGraphicMemory, getGraphicBufferSize()); + String8 subtype; + addResource( + String8(kResourceGraphicMemory), + subtype, + getGraphicBufferSize()); } setState(STARTED); (new AMessage)->postReply(mReplyID); -- cgit v1.1