Loading include/media/stagefright/ACodec.h +3 −0 Original line number Diff line number Diff line Loading @@ -281,6 +281,9 @@ private: status_t requestIDRFrame(); status_t setParameters(const sp<AMessage> ¶ms); // Send EOS on input stream. void onSignalEndOfInputStream(); DISALLOW_EVIL_CONSTRUCTORS(ACodec); }; Loading include/media/stagefright/MediaCodec.h +2 −0 Original line number Diff line number Diff line Loading @@ -212,6 +212,8 @@ private: sp<AMessage> mActivityNotify; bool mHaveInputSurface; MediaCodec(const sp<ALooper> &looper); static status_t PostAndAwaitResponse( Loading media/libstagefright/ACodec.cpp +24 −15 Original line number Diff line number Diff line Loading @@ -241,9 +241,6 @@ struct ACodec::ExecutingState : public ACodec::BaseState { // to fill with data. void resume(); // Send EOS on input stream. void onSignalEndOfInputStream(); // Returns true iff input and output buffers are in play. bool active() const { return mActive; } Loading Loading @@ -3413,6 +3410,12 @@ bool ACodec::LoadedToIdleState::onMessageReceived(const sp<AMessage> &msg) { return true; } case kWhatSignalEndOfInputStream: { mCodec->onSignalEndOfInputStream(); return true; } default: return BaseState::onMessageReceived(msg); } Loading Loading @@ -3458,6 +3461,12 @@ bool ACodec::IdleToExecutingState::onMessageReceived(const sp<AMessage> &msg) { return true; } case kWhatSignalEndOfInputStream: { mCodec->onSignalEndOfInputStream(); return true; } default: return BaseState::onMessageReceived(msg); } Loading Loading @@ -3538,17 +3547,6 @@ void ACodec::ExecutingState::resume() { mActive = true; } void ACodec::ExecutingState::onSignalEndOfInputStream() { sp<AMessage> notify = mCodec->mNotify->dup(); notify->setInt32("what", ACodec::kWhatSignaledInputEOS); status_t err = mCodec->mOMX->signalEndOfInputStream(mCodec->mNode); if (err != OK) { notify->setInt32("err", err); } notify->post(); } void ACodec::ExecutingState::stateEntered() { ALOGV("[%s] Now Executing", mCodec->mComponentName.c_str()); Loading Loading @@ -3640,7 +3638,7 @@ bool ACodec::ExecutingState::onMessageReceived(const sp<AMessage> &msg) { case ACodec::kWhatSignalEndOfInputStream: { onSignalEndOfInputStream(); mCodec->onSignalEndOfInputStream(); handled = true; break; } Loading Loading @@ -3678,6 +3676,17 @@ status_t ACodec::setParameters(const sp<AMessage> ¶ms) { return OK; } void ACodec::onSignalEndOfInputStream() { sp<AMessage> notify = mNotify->dup(); notify->setInt32("what", ACodec::kWhatSignaledInputEOS); status_t err = mOMX->signalEndOfInputStream(mNode); if (err != OK) { notify->setInt32("err", err); } notify->post(); } bool ACodec::ExecutingState::onOMXEvent( OMX_EVENTTYPE event, OMX_U32 data1, OMX_U32 data2) { switch (event) { Loading media/libstagefright/MediaCodec.cpp +14 −6 Original line number Diff line number Diff line Loading @@ -69,7 +69,8 @@ MediaCodec::MediaCodec(const sp<ALooper> &looper) mDequeueInputTimeoutGeneration(0), mDequeueInputReplyID(0), mDequeueOutputTimeoutGeneration(0), mDequeueOutputReplyID(0) { mDequeueOutputReplyID(0), mHaveInputSurface(false) { } MediaCodec::~MediaCodec() { Loading Loading @@ -160,8 +161,6 @@ status_t MediaCodec::createInputSurface( sp<IGraphicBufferProducer>* bufferProducer) { sp<AMessage> msg = new AMessage(kWhatCreateInputSurface, id()); // TODO(fadden): require MediaFormat colorFormat == AndroidOpaque sp<AMessage> response; status_t err = PostAndAwaitResponse(msg, &response); if (err == NO_ERROR) { Loading Loading @@ -256,8 +255,6 @@ status_t MediaCodec::queueSecureInputBuffer( } status_t MediaCodec::dequeueInputBuffer(size_t *index, int64_t timeoutUs) { // TODO(fadden): fail if an input Surface has been configured sp<AMessage> msg = new AMessage(kWhatDequeueInputBuffer, id()); msg->setInt64("timeoutUs", timeoutUs); Loading Loading @@ -604,6 +601,9 @@ void MediaCodec::onMessageReceived(const sp<AMessage> &msg) { CHECK_EQ(mState, CONFIGURING); setState(CONFIGURED); // reset input surface flag mHaveInputSurface = false; (new AMessage)->postReply(mReplyID); break; } Loading @@ -618,6 +618,7 @@ void MediaCodec::onMessageReceived(const sp<AMessage> &msg) { msg->findObject("input-surface", &obj); CHECK(obj != NULL); response->setObject("input-surface", obj); mHaveInputSurface = true; } else { response->setInt32("err", err); } Loading Loading @@ -1029,10 +1030,17 @@ void MediaCodec::onMessageReceived(const sp<AMessage> &msg) { case kWhatDequeueInputBuffer: { // TODO(fadden): make this fail if we're using an input Surface uint32_t replyID; CHECK(msg->senderAwaitsResponse(&replyID)); if (mHaveInputSurface) { ALOGE("dequeueInputBuffer can't be used with input surface"); sp<AMessage> response = new AMessage; response->setInt32("err", INVALID_OPERATION); response->postReply(replyID); break; } if (handleDequeueInputBuffer(replyID, true /* new request */)) { break; } Loading media/libstagefright/omx/GraphicBufferSource.cpp +15 −10 Original line number Diff line number Diff line Loading @@ -15,6 +15,7 @@ */ #define LOG_TAG "GraphicBufferSource" //#define LOG_NDEBUG 0 #include <utils/Log.h> #include <GraphicBufferSource.h> Loading Loading @@ -110,15 +111,12 @@ void GraphicBufferSource::omxExecuting() { } } void GraphicBufferSource::omxIdling(){ void GraphicBufferSource::omxLoaded(){ Mutex::Autolock autoLock(mMutex); ALOGV("--> idling"); if (!mExecuting) { // Transition from "loading" to "idling". Nothing to do. return; } ALOGV("--> loaded"); CHECK(mExecuting); ALOGV("Dropped down to idle, avail=%d eos=%d eosSent=%d", ALOGV("Dropped down to loaded, avail=%d eos=%d eosSent=%d", mNumFramesAvailable, mEndOfStream, mEndOfStreamSent); // Codec is no longer executing. Discard all codec-related state. Loading Loading @@ -282,10 +280,15 @@ status_t GraphicBufferSource::fillCodecBuffer_l() { return OK; } void GraphicBufferSource::signalEndOfInputStream() { status_t GraphicBufferSource::signalEndOfInputStream() { Mutex::Autolock autoLock(mMutex); ALOGV("signalEndOfInputStream: exec=%d avail=%d", mExecuting, mNumFramesAvailable); ALOGV("signalEndOfInputStream: exec=%d avail=%d eos=%d", mExecuting, mNumFramesAvailable, mEndOfStream); if (mEndOfStream) { ALOGE("EOS was already signaled"); return INVALID_OPERATION; } // Set the end-of-stream flag. If no frames are pending from the // BufferQueue, and a codec buffer is available, and we're executing, Loading @@ -300,6 +303,8 @@ void GraphicBufferSource::signalEndOfInputStream() { if (mExecuting && mNumFramesAvailable == 0) { submitEndOfInputStream_l(); } return OK; } status_t GraphicBufferSource::submitBuffer_l(sp<GraphicBuffer>& graphicBuffer, Loading Loading
include/media/stagefright/ACodec.h +3 −0 Original line number Diff line number Diff line Loading @@ -281,6 +281,9 @@ private: status_t requestIDRFrame(); status_t setParameters(const sp<AMessage> ¶ms); // Send EOS on input stream. void onSignalEndOfInputStream(); DISALLOW_EVIL_CONSTRUCTORS(ACodec); }; Loading
include/media/stagefright/MediaCodec.h +2 −0 Original line number Diff line number Diff line Loading @@ -212,6 +212,8 @@ private: sp<AMessage> mActivityNotify; bool mHaveInputSurface; MediaCodec(const sp<ALooper> &looper); static status_t PostAndAwaitResponse( Loading
media/libstagefright/ACodec.cpp +24 −15 Original line number Diff line number Diff line Loading @@ -241,9 +241,6 @@ struct ACodec::ExecutingState : public ACodec::BaseState { // to fill with data. void resume(); // Send EOS on input stream. void onSignalEndOfInputStream(); // Returns true iff input and output buffers are in play. bool active() const { return mActive; } Loading Loading @@ -3413,6 +3410,12 @@ bool ACodec::LoadedToIdleState::onMessageReceived(const sp<AMessage> &msg) { return true; } case kWhatSignalEndOfInputStream: { mCodec->onSignalEndOfInputStream(); return true; } default: return BaseState::onMessageReceived(msg); } Loading Loading @@ -3458,6 +3461,12 @@ bool ACodec::IdleToExecutingState::onMessageReceived(const sp<AMessage> &msg) { return true; } case kWhatSignalEndOfInputStream: { mCodec->onSignalEndOfInputStream(); return true; } default: return BaseState::onMessageReceived(msg); } Loading Loading @@ -3538,17 +3547,6 @@ void ACodec::ExecutingState::resume() { mActive = true; } void ACodec::ExecutingState::onSignalEndOfInputStream() { sp<AMessage> notify = mCodec->mNotify->dup(); notify->setInt32("what", ACodec::kWhatSignaledInputEOS); status_t err = mCodec->mOMX->signalEndOfInputStream(mCodec->mNode); if (err != OK) { notify->setInt32("err", err); } notify->post(); } void ACodec::ExecutingState::stateEntered() { ALOGV("[%s] Now Executing", mCodec->mComponentName.c_str()); Loading Loading @@ -3640,7 +3638,7 @@ bool ACodec::ExecutingState::onMessageReceived(const sp<AMessage> &msg) { case ACodec::kWhatSignalEndOfInputStream: { onSignalEndOfInputStream(); mCodec->onSignalEndOfInputStream(); handled = true; break; } Loading Loading @@ -3678,6 +3676,17 @@ status_t ACodec::setParameters(const sp<AMessage> ¶ms) { return OK; } void ACodec::onSignalEndOfInputStream() { sp<AMessage> notify = mNotify->dup(); notify->setInt32("what", ACodec::kWhatSignaledInputEOS); status_t err = mOMX->signalEndOfInputStream(mNode); if (err != OK) { notify->setInt32("err", err); } notify->post(); } bool ACodec::ExecutingState::onOMXEvent( OMX_EVENTTYPE event, OMX_U32 data1, OMX_U32 data2) { switch (event) { Loading
media/libstagefright/MediaCodec.cpp +14 −6 Original line number Diff line number Diff line Loading @@ -69,7 +69,8 @@ MediaCodec::MediaCodec(const sp<ALooper> &looper) mDequeueInputTimeoutGeneration(0), mDequeueInputReplyID(0), mDequeueOutputTimeoutGeneration(0), mDequeueOutputReplyID(0) { mDequeueOutputReplyID(0), mHaveInputSurface(false) { } MediaCodec::~MediaCodec() { Loading Loading @@ -160,8 +161,6 @@ status_t MediaCodec::createInputSurface( sp<IGraphicBufferProducer>* bufferProducer) { sp<AMessage> msg = new AMessage(kWhatCreateInputSurface, id()); // TODO(fadden): require MediaFormat colorFormat == AndroidOpaque sp<AMessage> response; status_t err = PostAndAwaitResponse(msg, &response); if (err == NO_ERROR) { Loading Loading @@ -256,8 +255,6 @@ status_t MediaCodec::queueSecureInputBuffer( } status_t MediaCodec::dequeueInputBuffer(size_t *index, int64_t timeoutUs) { // TODO(fadden): fail if an input Surface has been configured sp<AMessage> msg = new AMessage(kWhatDequeueInputBuffer, id()); msg->setInt64("timeoutUs", timeoutUs); Loading Loading @@ -604,6 +601,9 @@ void MediaCodec::onMessageReceived(const sp<AMessage> &msg) { CHECK_EQ(mState, CONFIGURING); setState(CONFIGURED); // reset input surface flag mHaveInputSurface = false; (new AMessage)->postReply(mReplyID); break; } Loading @@ -618,6 +618,7 @@ void MediaCodec::onMessageReceived(const sp<AMessage> &msg) { msg->findObject("input-surface", &obj); CHECK(obj != NULL); response->setObject("input-surface", obj); mHaveInputSurface = true; } else { response->setInt32("err", err); } Loading Loading @@ -1029,10 +1030,17 @@ void MediaCodec::onMessageReceived(const sp<AMessage> &msg) { case kWhatDequeueInputBuffer: { // TODO(fadden): make this fail if we're using an input Surface uint32_t replyID; CHECK(msg->senderAwaitsResponse(&replyID)); if (mHaveInputSurface) { ALOGE("dequeueInputBuffer can't be used with input surface"); sp<AMessage> response = new AMessage; response->setInt32("err", INVALID_OPERATION); response->postReply(replyID); break; } if (handleDequeueInputBuffer(replyID, true /* new request */)) { break; } Loading
media/libstagefright/omx/GraphicBufferSource.cpp +15 −10 Original line number Diff line number Diff line Loading @@ -15,6 +15,7 @@ */ #define LOG_TAG "GraphicBufferSource" //#define LOG_NDEBUG 0 #include <utils/Log.h> #include <GraphicBufferSource.h> Loading Loading @@ -110,15 +111,12 @@ void GraphicBufferSource::omxExecuting() { } } void GraphicBufferSource::omxIdling(){ void GraphicBufferSource::omxLoaded(){ Mutex::Autolock autoLock(mMutex); ALOGV("--> idling"); if (!mExecuting) { // Transition from "loading" to "idling". Nothing to do. return; } ALOGV("--> loaded"); CHECK(mExecuting); ALOGV("Dropped down to idle, avail=%d eos=%d eosSent=%d", ALOGV("Dropped down to loaded, avail=%d eos=%d eosSent=%d", mNumFramesAvailable, mEndOfStream, mEndOfStreamSent); // Codec is no longer executing. Discard all codec-related state. Loading Loading @@ -282,10 +280,15 @@ status_t GraphicBufferSource::fillCodecBuffer_l() { return OK; } void GraphicBufferSource::signalEndOfInputStream() { status_t GraphicBufferSource::signalEndOfInputStream() { Mutex::Autolock autoLock(mMutex); ALOGV("signalEndOfInputStream: exec=%d avail=%d", mExecuting, mNumFramesAvailable); ALOGV("signalEndOfInputStream: exec=%d avail=%d eos=%d", mExecuting, mNumFramesAvailable, mEndOfStream); if (mEndOfStream) { ALOGE("EOS was already signaled"); return INVALID_OPERATION; } // Set the end-of-stream flag. If no frames are pending from the // BufferQueue, and a codec buffer is available, and we're executing, Loading @@ -300,6 +303,8 @@ void GraphicBufferSource::signalEndOfInputStream() { if (mExecuting && mNumFramesAvailable == 0) { submitEndOfInputStream_l(); } return OK; } status_t GraphicBufferSource::submitBuffer_l(sp<GraphicBuffer>& graphicBuffer, Loading