From 8601efe463bf3331fa2a389ee13db25f21d28eb9 Mon Sep 17 00:00:00 2001 From: Martin Storsjo Date: Tue, 25 Sep 2012 11:43:02 +0300 Subject: MediaCodec: Add a method for getting the component name If the codec was chosen based on mime type, the caller does not know what component actually was chosen. This allows getting essential information (such as supported color formats, for a video encoder) for this component. Change-Id: Ie471f40f8104b37d27ced3dba5a54facc6504b1b --- media/libstagefright/MediaCodec.cpp | 44 +++++++++++++++++++++++++++++++++---- 1 file changed, 40 insertions(+), 4 deletions(-) (limited to 'media/libstagefright/MediaCodec.cpp') diff --git a/media/libstagefright/MediaCodec.cpp b/media/libstagefright/MediaCodec.cpp index 56e6df0..cb8a651 100644 --- a/media/libstagefright/MediaCodec.cpp +++ b/media/libstagefright/MediaCodec.cpp @@ -302,6 +302,20 @@ status_t MediaCodec::getOutputFormat(sp *format) const { return OK; } +status_t MediaCodec::getName(AString *name) const { + sp msg = new AMessage(kWhatGetName, id()); + + sp response; + status_t err; + if ((err = PostAndAwaitResponse(msg, &response)) != OK) { + return err; + } + + CHECK(response->findString("name", name)); + + return OK; +} + status_t MediaCodec::getInputBuffers(Vector > *buffers) const { sp msg = new AMessage(kWhatGetBuffers, id()); msg->setInt32("portIndex", kPortIndexInput); @@ -534,16 +548,15 @@ void MediaCodec::onMessageReceived(const sp &msg) { CHECK_EQ(mState, INITIALIZING); setState(INITIALIZED); - AString componentName; - CHECK(msg->findString("componentName", &componentName)); + CHECK(msg->findString("componentName", &mComponentName)); - if (componentName.startsWith("OMX.google.")) { + if (mComponentName.startsWith("OMX.google.")) { mFlags |= kFlagIsSoftwareCodec; } else { mFlags &= ~kFlagIsSoftwareCodec; } - if (componentName.endsWith(".secure")) { + if (mComponentName.endsWith(".secure")) { mFlags |= kFlagIsSecure; } else { mFlags &= ~kFlagIsSecure; @@ -1171,6 +1184,25 @@ void MediaCodec::onMessageReceived(const sp &msg) { break; } + case kWhatGetName: + { + uint32_t replyID; + CHECK(msg->senderAwaitsResponse(&replyID)); + + if (mComponentName.empty()) { + sp response = new AMessage; + response->setInt32("err", INVALID_OPERATION); + + response->postReply(replyID); + break; + } + + sp response = new AMessage; + response->setString("name", mComponentName.c_str()); + response->postReply(replyID); + break; + } + default: TRESPASS(); } @@ -1240,6 +1272,10 @@ void MediaCodec::setState(State newState) { mActivityNotify.clear(); } + if (newState == UNINITIALIZED) { + mComponentName.clear(); + } + mState = newState; cancelPendingDequeueOperations(); -- cgit v1.1