本讲是Android Camera性能分析专题的第14讲,我们介绍从CameraServer角度详解Camera启动性能,包括如下内容:
- 从CameraServer角度详解Camera启动性能
- CameraServer核心函数流程拆解
资源 | 描述 |
---|---|
在线课程 | 极客笔记在线课程 |
知识星球 | 星球名称:深入浅出Android Camera 星球ID: 17296815 |
极客笔记圈 |
从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
connectDevice
会调用到HAL的CameraHal::openSession
1.validateConnectLocked
2.CameraDeviceClient::initializeImpl
Camera2ClientBase::initializeImpl
Camera3Device::initialize
CameraHal::openSession
3.finishConnectLocked
createDefaultRequest
会调用到HAL的CameraHal::constructDefaultRequestSettings
1.CameraDeviceClient::createDefaultRequest
Camera3Device::createDefaultRequest
CameraHal::constructDefaultRequestSettings
beginConfigure
CameraDeviceClient::beginConfigure //Not implemented yet
createStream
核心在创建 Camera3OutputStream
CameraDeviceClient::createStream
SessionConfigurationUtils::createSurfaceFromGbp
query(width,height,format,dataspace)
Camera3Device::createStream
new Camera3OutputStream
setStreamTransformLocked
endConfigure
会调用到HAL的CameraHal::configureStreams
CameraDeviceClient::endConfigure
Camera3Device::configureStreams
Camera3Stream::startConfiguration
CameraHal::configureStreams
Camera3Stream::finishConfiguration
Boost priority of request thread to SCHED_FIFO
submitRequestList
CaptureRequest送下来后会等待Active
CameraDeviceClient::submitRequestList
Camera3Device::setStreamingRequestList
Camera3Device::RequestThread::setRepeatingRequests
Camera3Device::waitUntilStateThenRelock
Request thread线程开始给HAL送Request,调用 CameraHal::processBatchCaptureRequests
Camera3Device::RequestThread::threadLoop
Camera3Device::RequestThread::waitForNextRequestBatch
Camera3Device::RequestThread::prepareHalRequests
Camera3Device::RequestThread::sendRequestsBatch
CameraHal::processBatchCaptureRequests
StatusTracker通知status变化:
Camera3Device::notifyStatus
Camera3Device::internalUpdateStatusLocked
mStatusChanged.broadcast
Camera2ClientBase::notifyActive
CameraService::BasicClient::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