Android Camera API2——processCaptureResult

一、return buffer

1.Camera3Device

        #frameworks/av/services/camera/libcameraservice/device3/Camera3Device.cpp

        ProcessCaptureResult_3_4

2.Camera3OutputUtils

        #frameworks/av/services/camera/libcameraservice/device3/Camera3OutputUtils.cpp

         ProcessOneCaptureResultLocked 

                  processcaptureresult

                            returnAndRemovePendingOutputBuffers

                                     returnOutputBuffers

3.Camera3Stream

        #frameworks/av/services/camera/libcameraservice/device3/Camera3Stream.cpp

         stream->returnBuffer

                  camera3stream::returnBuffer

                                Camera3Stream::removeOutstandingBuffer(清空outputbuffer

                                returnBufferLocked

4.Camera3OutputStream

        camera3outputstream::returnBufferLocked

                          camera3Iostreambase::returnAnyBufferLocked

                                camera3outputstream::returnbuffercheckedlocked

                                            queueBufferToConsumer

                                                     consumer->queuebuffer(消费buffer

                          mHandoutOutputTotalBufferCount-- buffer减一

二、Camera metadata参数回调

1.Camera3OutputUtils

        #frameworks/av/services/camera/libcameraservice/device3/Camera3OutputUtils.cpp

        sendCaptureResult

             insertResultLocked(states, &captureResult, frameNumber)

                    states.resultQueue.insert

                    states.resultSignal.notify_one

2.FrameProcessorBase

        FrameProcessorBase的threadLoop也是在起预览的initializeImpl函数中触发,initializeImpl函数在openCamera时调用。

#/frameworks/av/services/camera/libcameraservice/api2/CameraDeviceClient.cpp
status_t CameraDeviceClient::initializeImpl(TProviderPtr providerPtr) {
    ATRACE_CALL();
    status_t res;

    res = Camera2ClientBase::initialize(providerPtr);
    if (res != OK) {
        return res;
    }

    String8 threadName;
    mFrameProcessor = new FrameProcessorBase(mDevice);
    threadName = String8::format("CDU-%s-FrameProc", mCameraIdStr.string());

        #frameworks/av/services/camera/libcameraservice/common/FrameProcessorBase.cpp 

        threadLoop       

                 device->waitForNextFrame(Camera3Device.cpp)

                 processNewFrames(device)

                          device->getNextResult (Camera3Device.cpp)

                                    processSingleFrame

                                            processListeners(result, device)

                                                 (*item)->onResultAvailable 

3.CameraDeviceClient

        #frameworks/av/services/camera/libcameraservice/api2/CameraDeviceClient.cpp

        CameraDeviceClient::onResultAvailable

              remoteCb->onResultReceived

4.CameraDeviceImpl

        #frameworks/base/core/java/android/hardware/camera2/impl/CameraDeviceImpl.java

        onResultReceived

               holder.getCallback().onCaptureProgressed 

               holder.getCallback().onCaptureCompleted //app侧获取的每一帧处理数据的回调,从回调参数CaptureResult中读取

你可能感兴趣的:(android)