第14讲 从CameraServer角度详解Camera启动性能 - Android Camera性能分析

本讲是Android Camera性能分析专题的第14讲,我们介绍从CameraServer角度详解Camera启动性能,包括如下内容:

  1. 从CameraServer角度详解Camera启动性能
  2. CameraServer核心函数流程拆解
资源 描述
在线课程 极客笔记在线课程
知识星球 星球名称:深入浅出Android Camera
星球ID: 17296815
Wechat 极客笔记圈

从CameraServer角度详解Camera启动性能

模块 开始点 结束点
App 点击Camera App Icon 开始调用connectDevice
HAL 开始调用connectDevice 调用connectDevice结束
App 调用connectDevice结束 开始调用endConfigure
HAL 开始调用endConfigure 调用endConfigure结束
App 调用endConfigure结束 调用submitRequestList
HAL 调用submitRequestList CameraServer收到第一帧

CameraServer核心函数流程拆解

getCameraCharacteristics

1.shouldRejectSystemCameraConnection
2.getCameraCharacteristicsLocked // 从CameraProviderManager中获取CameraCharacteristics
3.getCameraCharacteristics::checkPermission

getCameraCharacteristics

connectDevice

会调用到HAL的CameraHal::openSession

1.validateConnectLocked
2.CameraDeviceClient::initializeImpl
      Camera2ClientBase::initializeImpl
            Camera3Device::initialize
                CameraHal::openSession
3.finishConnectLocked

connectDevice

createDefaultRequest

会调用到HAL的CameraHal::constructDefaultRequestSettings

1.CameraDeviceClient::createDefaultRequest
    Camera3Device::createDefaultRequest
        CameraHal::constructDefaultRequestSettings

createDefaultRequest

beginConfigure

CameraDeviceClient::beginConfigure //Not implemented yet

createStream

核心在创建 Camera3OutputStream

CameraDeviceClient::createStream
    SessionConfigurationUtils::createSurfaceFromGbp
        query(width,height,format,dataspace)
    Camera3Device::createStream
        new Camera3OutputStream
    setStreamTransformLocked

createStream

endConfigure

会调用到HAL的CameraHal::configureStreams

CameraDeviceClient::endConfigure
    Camera3Device::configureStreams
        Camera3Stream::startConfiguration
        CameraHal::configureStreams
        Camera3Stream::finishConfiguration
        Boost priority of request thread to SCHED_FIFO

endConfigure

submitRequestList

CaptureRequest送下来后会等待Active

CameraDeviceClient::submitRequestList
    Camera3Device::setStreamingRequestList
        Camera3Device::RequestThread::setRepeatingRequests
        Camera3Device::waitUntilStateThenRelock

submitRequestList

Request thread线程开始给HAL送Request,调用 CameraHal::processBatchCaptureRequests

Camera3Device::RequestThread::threadLoop
    Camera3Device::RequestThread::waitForNextRequestBatch
    Camera3Device::RequestThread::prepareHalRequests
    Camera3Device::RequestThread::sendRequestsBatch
        CameraHal::processBatchCaptureRequests

sendRequestsBatch

StatusTracker通知status变化:

Camera3Device::notifyStatus
    Camera3Device::internalUpdateStatusLocked
        mStatusChanged.broadcast
        Camera2ClientBase::notifyActive
            CameraService::BasicClient::startCameraStreamingOps

startCameraStreamingOps

Stream 0: first full buffer

HAL回调processCaptureResult后,如果有Buffer,则取出来 queueBuffer给 Consumer

Camera3Device::processCaptureResult
  Camera3OutputUtils::returnAndRemovePendingOutputBuffers
    Camera3OutputUtils::returnOutputBuffers
      Camera3Stream::returnBuffer
        Camera3OutputStream::returnBufferLocked
          Camera3IOStreamBase::returnAnyBufferLocked
            Camera3OutputStream::returnBufferCheckedLocked
              Camera3OutputStream::queueBufferToConsumer

Stream 0: first full buffer

Camera课程

Python教程

Java教程

Web教程

数据库教程

图形图像教程

办公软件教程

Linux教程

计算机教程

大数据教程

开发工具教程

Android Camera性能分析