和你一起终身学习,这里是程序员Android
经典好文推荐,通过阅读本文,您将收获以下知识点:
Camera 起预览时候回调用CameraCaptureSession类的setRepeatingRequest方法,该方法的实现是由CameraCaptureSessionImpl来完成的。
(frameworks\base\core\java\android\hardware\camera2)
-
// 主要功能实现是通过CameraCaptureSessionImpl 实现
-
public abstract int setRepeatingRequest();
(frameworks\base\core\java\android\hardware\camera2\impl)
-
public int setRepeatingRequest(CaptureRequest request,......){
-
... ...
-
// 调用 CameraDeviceImpl中的 setRepeatingRequest方法
-
return addPendingSequence(());
-
... ...
-
}
-
第一个参数CaptureRequest只有一个Request,而在后面会将它包装成List.
(frameworks\base\core\java\android\hardware\camera2\impl)
-
-
public int setRepeatingRequest(){
-
List<CaptureRequest> requestList = new ArrayList<CaptureRequest>();
-
(request)
-
-
return submitCaptureRequest(requestList, callback, handler, /*streaming*/true);
-
}
-
-
-
private int submitCaptureRequest() {
-
... ...
-
// 通过Binder 调用 CameraDeviceClient 方法
-
requestInfo = (requestArray, repeating);
-
... ...
-
}
-
mRemoteDevice 是CameraServer进程当中执行openCamera成功后返回给Client端Binder对象的代理,它和CameraServer进程当中的CameraDeviceClient对象是对应的,只不过这里的mRemoteDevice还经过了Framework一点包装处理而已。
(frameworks\av\services\camera\libcameraservice\api2)
-
binder::Status CameraDeviceClient::submitRequestList(){
-
if(streaming){
-
//预览
-
mDevice->setStreamingRequestList();
-
}else{
-
//拍照
-
mDevice->captureList();
-
}
-
}
(frameworks\av\services\camera\libcameraservice\device3)
-
//预览
-
status_t Camera3Device::setStreamingRequestList(){
-
//预览和拍照都会调用到 submitRequestsHelper 方法
-
submitRequestsHelper();
-
}
-
-
-
//拍照
-
status_t Camera3Device::captureList(){
-
//预览和拍照都会调用到 submitRequestsHelper 方法
-
submitRequestsHelper();
-
}
-
-
// submitRequestsHelper 方法实现
-
status_t Camera3Device::submitRequestsHelper(){
-
-
if (repeating) {
-
//预览流程 setRepeatingRequests处理
-
res = mRequestThread->setRepeatingRequests(requestList, lastFrameNumber);
-
} else {
-
// 拍照流程处理 queueRequestList
-
res = mRequestThread->queueRequestList(requestList, lastFrameNumber);
-
}
-
}
-
//预览
-
status_t Camera3Device::RequestThread::setRepeatingRequests(){
-
... ...
-
}
-
//拍照
-
status_t Camera3Device::RequestThread::queueRequestList(){
-
... ...
-
}
-
-
//mRequestThread 流程分析
-
status_t Camera3Device::initializeCommonLocked() {
-
-
mRequestThread = new RequestThread();
-
res=mRequestThread->run();
-
-
}
-
-
// (frameworks\av\services\camera\libcameraservice\device3)
-
class RequestThread : public Thread {
-
... ...
-
}
-
-
bool Camera3Device::RequestThread::threadLoop(){
-
-
// Handle paused state. 如果没有Request请求时,将会等待50ms,再进行下一次判断
-
if (waitIfPaused()) {
-
return true;
-
}
-
// 最重要的三个方法 for the next batch of requests.拍照请求的优先级肯定是高于预览请求
-
waitForNextRequestBatch();
-
-
... ...
-
// 最重要的三个方法 a batch of HAL requests and output buffers.
-
res = prepareHalRequests();
-
-
... ...
-
//最重要的三个方法 3.如果该值为true,那么继续循环
-
submitRequestSuccess = sendRequestsBatch();
-
}
-
-
bool Camera3Device::RequestThread::sendRequestsBatch() {
-
-
-
res = mInterface->processBatchCaptureRequests(requests, &numRequestProcessed);
-
-
}
-
status_t Camera3Device::HalInterface::processBatchCaptureRequests(){
-
-
-
if (hidlSession_3_4 != nullptr) {
-
// 调用 中的方法
-
err = hidlSession_3_4->proce*tureRequest_3_4( );
-
} else {
-
err = mHidlSession->proce*tureRequest( );
-
}
-
-
}
-
-
(hardware\interfaces\camera\device\3.4\default)
-
Return<void> CameraDeviceSession::proce*tureRequest_3_4(){
-
-
s = processOneCaptureRequest_3_4(requests[i])
-
}
-
-
Status CameraDeviceSession::processOneCaptureRequest_3_4(){
-
-
// 这个会跳转到 中的process_capture_request 方法, 需要继续厘清跳转地方
-
ATRACE_BEGIN("camera3->process_capture_request");
-
status_t ret = mDevice->ops->process_capture_request(mDevice, &halRequest);
-
ATRACE_END();
-
}
-
-
-
(vendor\qcom\proprietary\camx\src\core\hal)
-
int process_capture_request(){
-
// 会跳转到 process_capture_request 方法
-
pHAL3->process_capture_request(pCamera3DeviceAPI, pCaptureRequestAPI);
-
}
-
(vendor\qcom\proprietary\camx\src\core\hal)
-
static int process_capture_request(){
-
-
result = pHALDevice->Proce*tureRequest(pRequest);
-
}
-
(vendor\qcom\proprietary\camx\src\core\hal)
-
CamxResult HALDevice::Proce*tureRequest(){
-
//调用 chi_override_process_request 方法
-
result = GetCHIAppCallbacks()->chi_override_process_request()
-
}
-
(vendor\qcom\proprietary\chi-cdk\core\chiframework)
-
static CDKResult chi_override_process_request(){
-
// 调用 OverrideProcessRequest方法
-
return pExtensionModule->OverrideProcessRequest();
-
-
}
(vendor\qcom\proprietary\chi-cdk\core\chiframework)
-
CDKResult ExtensionModule::OverrideProcessRequest(){
-
-
//选取 Usecase 去做Proce*tureRequest操作
-
result = m_pSelectedUsecase[logicalCameraId]->Proce*tureRequest(pCaptureRequest);
-
}
(vendor\qcom\proprietary\chi-cdk\core\chiframework)
-
CDKResult Usecase::Proce*tureRequest(){
-
// 调用指定的UseCase
-
result = ExecuteCaptureRequest(pRequest);
-
-
}
(vendor\qcom\proprietary\chi-cdk\core\chiusecase)
-
CDKResult AdvancedCameraUsecase::ExecuteCaptureRequest(){
-
-
-
if(TRUE == AdvancedFeatureEnabled()){
-
// AdvancedFeatureEnabled HDR MFNR
-
result = pFeature->ExecuteProcessRequest(pRequest);
-
}else{
-
-
// 没有任何Feature 执行的流程,拍照
-
result = CameraUsecaseBase::ExecuteCaptureRequest(pRequest);
-
}
-
}
-
-
-
CDKResult CameraUsecaseBase::ExecuteCaptureRequest(){
-
// 没有任何Feature 执行的流程
-
CheckAndActivatePipeline(m_sessions[session].pSession);
-
... ...
-
result = SubmitRequest(&submitRequest);
-
}
-
(vendor\qcom\proprietary\chi-cdk\core\chiframework)
-
CHX_INLINE CDKResult CheckAndActivatePipeline(){
-
//ActivatePipeline一般一个Feature 一个Pipeline,MFNR 有多个Pipeline
-
result = ExtensionModule::GetInstance()->ActivatePipeline();
-
}
-
-
(vendor\qcom\proprietary\chi-cdk\core\chiframework)
-
CDKResult ExtensionModule::ActivatePipeline()
-
{
-
return g_chiContextOps.pActivatePipeline();
-
}
(vendor\qcom\proprietary\camx\src\core\chi)
-
static CDKResult ChiActivatePipeline(){
-
-
result = pChiContext->ActivatePipeline();
-
-
}
-
(vendor\qcom\proprietary\camx\src\core\chi)
-
CamxResult ChiContext::ActivatePipeline(){
-
-
result = pChiSession->StreamOn();
-
-
}
-
(vendor\qcom\proprietary\camx\src\core)
-
CamxResult Session::StreamOn(){
-
-
result = pPipeline->StreamOn();
-
-
}
(vendor\qcom\proprietary\camx\src\core)
-
CamxResult Pipeline::StreamOn(){
-
-
result = m_pChiContext->GetHwContext()->StreamOn();
-
-
-
}
-
(vendor\qcom\proprietary\camx\src\core)
-
CamxResult HwContext::StreamOn(){
-
result = CSLStreamOn();
-
-
}
-
(vendor\qcom\proprietary\camx\src\csl)
-
CamxResult CSLStreamOn(){
-
-
pJumpTable->CSLStreamOn();
-
-
}
-
(vendor\qcom\proprietary\camx\src\csl\hw)
-
-
CamxResult CSLStreamOnHW(){
-
-
result = CSLHwStreamOnKMDHardwares();
-
-
}
-
(vendor\qcom\proprietary\camx\src\csl\hw)
-
CamxResult CSLHwStreamOnKMDHardwares(){
-
-
result = pHWDevice->();
-
}
-
然后返回执行 的CameraUsecaseBase::ExecuteCaptureRequest方法
-
CDKResult AdvancedCameraUsecase::ExecuteCaptureRequest(){
-
-
-
if(TRUE == AdvancedFeatureEnabled()){
-
result = pFeature->ExecuteProcessRequest(pRequest);
-
}else{
-
-
// 没有任何Feature 执行的流程
-
result = CameraUsecaseBase::ExecuteCaptureRequest(pRequest);
-
}
-
}
-
-
-
CDKResult CameraUsecaseBase::ExecuteCaptureRequest(){
-
// 没有任何Feature 执行的流程
-
CheckAndActivatePipeline(m_sessions[session].pSession);
-
//Chxusecase .cpp
-
result = SubmitRequest(&submitRequest);
-
}
-
(vendor\qcom\proprietary\chi-cdk\core\chiframework)
-
CDKResult Usecase::SubmitRequest(){
-
//
-
result = ExtensionModule::GetInstance()->SubmitRequest
-
}
(vendor\qcom\proprietary\chi-cdk\core\chiframework)
-
CDKResult ExtensionModule::SubmitRequest(){
-
result = g_chiContextOps.pSubmitPipelineRequest();
-
}
-
(vendor\qcom\proprietary\camx\src\core\chi)
-
static CDKResult ChiSubmitPipelineRequest(){
-
-
-
result = pChiContext->SubmitRequest();
-
}
(vendor\qcom\proprietary\camx\src\core\chi)
-
CamxResult ChiContext::SubmitRequest(){
-
-
result = pSession->Proce*tureRequest();
-
}
(vendor\qcom\proprietary\camx\src\core)
-
CamxResult Session::Proce*tureRequest(){
-
-
// 暂未找到跳转到ProcessRequest 的地方
-
-
}
-
-
CamxResult Session::ProcessRequest(){
-
-
result = m_pipelineData[].pPipeline->OpenRequest();
-
//
-
result = m_pipelineData[].pPipeline->ProcessRequest();
-
}
-
-
(vendor\qcom\proprietary\camx\src\core)
-
CamxResult Pipeline::ProcessRequest(){
-
m_ppOrderedNodes[nodeIndex]->SetupRequest();
-
-
result = m_pDeferredRequestQueue->AddDeferredNode();
-
// Consider any nodes now ready
-
m_pDeferredRequestQueue->DispatchReadyNodes();
-
}
(vendor\qcom\proprietary\camx\src\core)
-
VOID DeferredRequestQueue::DispatchReadyNodes(){
-
... ...
-
}
CamxRequest流程
参考文章
:///sinat_22657459/article/details/92380466
:///TaylorPotter/article/details/105630341
至此,本篇已结束。转载网络的文章,小编觉得很优秀,欢迎点击阅读原文,支持原创作者,如有侵权,恳请联系小编删除。同时感谢您的阅读,期待您的关注。
点个在看,方便您使用时快速查找!