codec编码传输流程是怎么样的,很多新手对此不是很清楚,为了帮助大家解决这个难题,下面小编将为大家详细讲解,有这方面需求的人可以来学习下,希望你能有所收获。
SurfaceMediaSource::read()锁控制从IGraphicBufferConsumer处读取buffer,当graphic产生数据
Overrun时等待
while (mStarted && mNumPendingBuffers == mMaxAcquiredBufferCount) {
mMediaBuffersAvailableCondition.wait(mMutex);
}
MediaPuller拿到该buffer后
status_t err = mSource->read(&mbuf);
notify->setInt32("what", kWhatAccessUnit);
notify->setBuffer("accessUnit", accessUnit);
notify->post();
Converter 接收CHECK_EQ(what, MediaPuller::kWhatAccessUnit);
后
mInputBufferQueue.push_back(accessUnit);
feedEncoderInputBuffers();
Converter::feedEncoderInputBuffers() 中拷贝buffer数据到codec的mEncoderInputBuffers
通过这个while循环来等待拷贝
while (!mInputBufferQueue.empty()&& !mAvailEncoderInputIndices.empty()){
memcpy(mEncoderInputBuffers.itemAt(bufferIndex)->data(),
buffer->data(),
buffer->size());
status_t err = mEncoder->queueInputBuffer(
bufferIndex, 0, (buffer == NULL) ? 0 : buffer->size(),
timeUs, flags);
5. 上面流程传递的是主要是共享内存buffer_handle_t,当codec 完成ACodec::BaseState::onOMXEmptyBufferDone后
// We're in "store-metadata-in-buffers" mode, the underlying
// OMX component had access to data that's implicitly refcounted
// by this "MediaBuffer" object. Now that the OMX component has
// told us that it's done with the input buffer, we can decrement
// the mediaBuffer's reference count.
info->mData->setMediaBufferBase(NULL);
才通知SurfaceMediaSource::signalBufferReturned()让graphic consumer来真正释放
mConsumer->releaseBuffer();
Stack 信息
#06 pc 000f4583 /system/lib/libstagefright.so (android::SurfaceMediaSource::signalBufferReturned(android::MediaBuffer*)+38)
#07 pc 000f45a5 /system/lib/libstagefright.so (non-virtual thunk to android::SurfaceMediaSource::signalBufferReturned(android::MediaBuffer*)+4)
#08 pc 0000b011 /system/lib/libstagefright_foundation.so (android::ABuffer::setMediaBufferBase(android::MediaBufferBase*)+16)
#09 pc 0008adeb /system/lib/libstagefright.so (android::ACodec::BaseState::onOMXEmptyBufferDone(unsigned int, int)+78)
#10 pc 0008aab5 /system/lib/libstagefright.so (android::ACodec::BaseState::onOMXMessage(android::sp<android::AMessage> const&)+228)
#11 pc 0008a731 /system/lib/libstagefright.so (android::ACodec::BaseState::onMessageReceived(android::sp<android::AMessage> const&)+744)
#12 pc 0008e779 /system/lib/libstagefright.so (android::ACodec::ExecutingState::onMessageReceived(android::sp<android::AMessage> const&)+508)
#13 pc 0000b5a1 /system/lib/libstagefright_foundation.so (android::AHierarchicalStateMachine::handleMessage(android::sp<android::AMessage> const&)+64)
#14 pc 0008a917 /system/lib/libstagefright.so (android::ACodec::BaseState::onOMXMessageList(android::sp<android::AMessage> const&)+106)
#15 pc 0008a5e7 /system/lib/libstagefright.so (android::ACodec::BaseState::onMessageReceived(android::sp<android::AMessage> const&)+414)
#16 pc 0008e779 /system/lib/libstagefright.so (android::ACodec::ExecutingState::onMessageReceived(android::sp<android::AMessage> const&)+508)
看完上述内容是否对您有帮助呢?如果还想对相关知识有进一步的了解或阅读更多相关文章,请关注亿速云行业资讯频道,感谢您对亿速云的支持。
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。