diff options
Diffstat (limited to 'media/libstagefright/MediaCodec.cpp')
-rw-r--r-- | media/libstagefright/MediaCodec.cpp | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/media/libstagefright/MediaCodec.cpp b/media/libstagefright/MediaCodec.cpp index c2ffdf2..5e0ee55 100644 --- a/media/libstagefright/MediaCodec.cpp +++ b/media/libstagefright/MediaCodec.cpp @@ -51,6 +51,7 @@ #include <private/android_filesystem_config.h> #include <utils/Log.h> #include <utils/Singleton.h> +#include <stagefright/AVExtensions.h> namespace android { @@ -313,7 +314,7 @@ status_t MediaCodec::init(const AString &name, bool nameIsType, bool encoder) { // queue. if (nameIsType || !strncasecmp(name.c_str(), "omx.", 4)) { - mCodec = new ACodec; + mCodec = AVFactory::get()->createACodec(); } else if (!nameIsType && !strncasecmp(name.c_str(), "android.filter.", 15)) { mCodec = new MediaFilter; @@ -899,6 +900,8 @@ status_t MediaCodec::getBufferAndFormat( } *format = info.mFormat; } + } else { + return BAD_INDEX; } return OK; } @@ -1012,6 +1015,12 @@ bool MediaCodec::handleDequeueOutputBuffer(const sp<AReplyToken> &replyID, bool if (omxFlags & OMX_BUFFERFLAG_EOS) { flags |= BUFFER_FLAG_EOS; } + if (omxFlags & OMX_BUFFERFLAG_EXTRADATA) { + flags |= BUFFER_FLAG_EXTRADATA; + } + if (omxFlags & OMX_BUFFERFLAG_DATACORRUPT) { + flags |= BUFFER_FLAG_DATACORRUPT; + } response->setInt32("flags", flags); response->postReply(replyID); @@ -1168,7 +1177,8 @@ void MediaCodec::onMessageReceived(const sp<AMessage> &msg) { CHECK(msg->findString("componentName", &mComponentName)); - if (mComponentName.startsWith("OMX.google.")) { + if (mComponentName.startsWith("OMX.google.") || + mComponentName.startsWith("OMX.ffmpeg.")) { mFlags |= kFlagUsesSoftwareRenderer; } else { mFlags &= ~kFlagUsesSoftwareRenderer; @@ -1205,6 +1215,7 @@ void MediaCodec::onMessageReceived(const sp<AMessage> &msg) { // reset input surface flag mHaveInputSurface = false; + CHECK(msg->findString("componentName", &mComponentName)); CHECK(msg->findMessage("input-format", &mInputFormat)); CHECK(msg->findMessage("output-format", &mOutputFormat)); @@ -2314,6 +2325,7 @@ size_t MediaCodec::updateBuffers( uint32_t bufferID; CHECK(msg->findInt32("buffer-id", (int32_t*)&bufferID)); + Mutex::Autolock al(mBufferLock); Vector<BufferInfo> *buffers = &mPortBuffers[portIndex]; @@ -2401,7 +2413,12 @@ status_t MediaCodec::onQueueInputBuffer(const sp<AMessage> &msg) { } if (offset + size > info->mData->capacity()) { - return -EINVAL; + if ( ((int)size == (int)-1) && !(flags & BUFFER_FLAG_EOS)) { + size = 0; + ALOGD("EOS, reset size to zero"); + } + else + return -EINVAL; } sp<AMessage> reply = info->mNotify; @@ -2558,7 +2575,7 @@ ssize_t MediaCodec::dequeuePortBuffer(int32_t portIndex) { info->mOwnedByClient = true; // set image-data - if (info->mFormat != NULL) { + if (info->mFormat != NULL && mIsVideo) { sp<ABuffer> imageData; if (info->mFormat->findBuffer("image-data", &imageData)) { info->mData->meta()->setBuffer("image-data", imageData); @@ -2673,6 +2690,9 @@ void MediaCodec::onOutputBufferAvailable() { if (omxFlags & OMX_BUFFERFLAG_EOS) { flags |= BUFFER_FLAG_EOS; } + if (omxFlags & OMX_BUFFERFLAG_DATACORRUPT) { + flags |= BUFFER_FLAG_DATACORRUPT; + } msg->setInt32("flags", flags); |