Loading include/media/stagefright/MediaCodec.h +4 −0 Original line number Diff line number Diff line Loading @@ -113,6 +113,8 @@ struct MediaCodec : public AHandler { // pending, an error is pending. void requestActivityNotification(const sp<AMessage> ¬ify); status_t getName(AString *componentName) const; protected: virtual ~MediaCodec(); virtual void onMessageReceived(const sp<AMessage> &msg); Loading Loading @@ -154,6 +156,7 @@ private: kWhatCodecNotify = 'codc', kWhatRequestIDRFrame = 'ridr', kWhatRequestActivityNotification = 'racN', kWhatGetName = 'getN', }; enum { Loading @@ -178,6 +181,7 @@ private: sp<ALooper> mLooper; sp<ALooper> mCodecLooper; sp<ACodec> mCodec; AString mComponentName; uint32_t mReplyID; uint32_t mFlags; sp<SurfaceTextureClient> mNativeWindow; Loading media/libstagefright/MediaCodec.cpp +40 −4 Original line number Diff line number Diff line Loading @@ -302,6 +302,20 @@ status_t MediaCodec::getOutputFormat(sp<AMessage> *format) const { return OK; } status_t MediaCodec::getName(AString *name) const { sp<AMessage> msg = new AMessage(kWhatGetName, id()); sp<AMessage> response; status_t err; if ((err = PostAndAwaitResponse(msg, &response)) != OK) { return err; } CHECK(response->findString("name", name)); return OK; } status_t MediaCodec::getInputBuffers(Vector<sp<ABuffer> > *buffers) const { sp<AMessage> msg = new AMessage(kWhatGetBuffers, id()); msg->setInt32("portIndex", kPortIndexInput); Loading Loading @@ -534,16 +548,15 @@ void MediaCodec::onMessageReceived(const sp<AMessage> &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; Loading Loading @@ -1171,6 +1184,25 @@ void MediaCodec::onMessageReceived(const sp<AMessage> &msg) { break; } case kWhatGetName: { uint32_t replyID; CHECK(msg->senderAwaitsResponse(&replyID)); if (mComponentName.empty()) { sp<AMessage> response = new AMessage; response->setInt32("err", INVALID_OPERATION); response->postReply(replyID); break; } sp<AMessage> response = new AMessage; response->setString("name", mComponentName.c_str()); response->postReply(replyID); break; } default: TRESPASS(); } Loading Loading @@ -1240,6 +1272,10 @@ void MediaCodec::setState(State newState) { mActivityNotify.clear(); } if (newState == UNINITIALIZED) { mComponentName.clear(); } mState = newState; cancelPendingDequeueOperations(); Loading Loading
include/media/stagefright/MediaCodec.h +4 −0 Original line number Diff line number Diff line Loading @@ -113,6 +113,8 @@ struct MediaCodec : public AHandler { // pending, an error is pending. void requestActivityNotification(const sp<AMessage> ¬ify); status_t getName(AString *componentName) const; protected: virtual ~MediaCodec(); virtual void onMessageReceived(const sp<AMessage> &msg); Loading Loading @@ -154,6 +156,7 @@ private: kWhatCodecNotify = 'codc', kWhatRequestIDRFrame = 'ridr', kWhatRequestActivityNotification = 'racN', kWhatGetName = 'getN', }; enum { Loading @@ -178,6 +181,7 @@ private: sp<ALooper> mLooper; sp<ALooper> mCodecLooper; sp<ACodec> mCodec; AString mComponentName; uint32_t mReplyID; uint32_t mFlags; sp<SurfaceTextureClient> mNativeWindow; Loading
media/libstagefright/MediaCodec.cpp +40 −4 Original line number Diff line number Diff line Loading @@ -302,6 +302,20 @@ status_t MediaCodec::getOutputFormat(sp<AMessage> *format) const { return OK; } status_t MediaCodec::getName(AString *name) const { sp<AMessage> msg = new AMessage(kWhatGetName, id()); sp<AMessage> response; status_t err; if ((err = PostAndAwaitResponse(msg, &response)) != OK) { return err; } CHECK(response->findString("name", name)); return OK; } status_t MediaCodec::getInputBuffers(Vector<sp<ABuffer> > *buffers) const { sp<AMessage> msg = new AMessage(kWhatGetBuffers, id()); msg->setInt32("portIndex", kPortIndexInput); Loading Loading @@ -534,16 +548,15 @@ void MediaCodec::onMessageReceived(const sp<AMessage> &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; Loading Loading @@ -1171,6 +1184,25 @@ void MediaCodec::onMessageReceived(const sp<AMessage> &msg) { break; } case kWhatGetName: { uint32_t replyID; CHECK(msg->senderAwaitsResponse(&replyID)); if (mComponentName.empty()) { sp<AMessage> response = new AMessage; response->setInt32("err", INVALID_OPERATION); response->postReply(replyID); break; } sp<AMessage> response = new AMessage; response->setString("name", mComponentName.c_str()); response->postReply(replyID); break; } default: TRESPASS(); } Loading Loading @@ -1240,6 +1272,10 @@ void MediaCodec::setState(State newState) { mActivityNotify.clear(); } if (newState == UNINITIALIZED) { mComponentName.clear(); } mState = newState; cancelPendingDequeueOperations(); Loading