其他分享
首页 > 其他分享> > CameraAppFramework流程之setRepeatingRequest

CameraAppFramework流程之setRepeatingRequest

作者:互联网

CameraCaptureSession.SetRepeatingRequest

App 调用该方法开始预览流程,通过层层调用最终会调用到Framework中的submitCaptureRequest方法,该方法主要作了两件事:

/*CameraCaptureSession.java*/
public abstract int setRepeatingRequest(CaptureRequest request, CaptureCallback listener, Handler handler) throws CameraAccessException;

/*CameraCaptureSessionImpl.java*/
public synchronized int setRepeatingRequest(CaptureRequest request, CaptureCallback callback, Handler handler) throws CameraAccessException{
    ...
    handler = CameraDeviceImpl.checkHandler(handler, callback);//获取Looper并创建handler
    return this.addPendingSequence(this.mDeviceImpl.setRepeatingRequest(request, this.createCaptureCallbackProxy(handler, callback), this.mDeviceHandler));
}

/*CameraDeviceImpl.java*/
public int setRepeatingRequest(CaptureRequest request, CameraDeviceImpl.CaptureCallback callback, Executor executor) throws CameraAccessException{
    List<CaptureRequest> requestList = new ArrayList();
    requestList.add(request);
    return this.submitCaptureRequest(requestList, callback, executor, true);
}

private int submitCaptureRequest(List<CaptureRequest> requestList, CameraDeviceImpl.CaptureCallback callback, Executor executor, boolean repeating) throws CameraAccessException{
    ...
    synchronized(this.mInterfaceLock){
        ...
        SubmitInfo requestInfo = this.mRemoteDevice.submitRequestList(requestArray, repeating);
        ...
        if(this.mIdle){
            this.mDeviceExector.execute(this.mCallOnActive);
        }
        
        this.mIdle = false;
        return requestInfo.getRequestId();
    }
}

/*ICameraDeviceUserWrapper.java*/
public SubmitInfo submitRequestList(CaptureRequest[] requestList, boolean streaming) throws CameraAccessExceotion{
    try{
        return this.mRemoteDevice.submitRequestList(requestList, streaming);//ICameraDeviceUser mRemoteDevice
    } catch(Throwable var4){
        CameraManager.throwAsPublicException(var4);
        throw new UnsupportedOperationException("UnExpected exception", var4);
    }
}

/*ICameraDeviceUser.java*/
//ICameraDeviceUser是一个接口(interface),有三个类实现了这个接口,分别如下

/*ICameraDeviceUser.Stub.Proxy.submitRequestList 匿名内部类的匿名内部类的实现*/
public SubmitInfo submitRequestList(CaptureRequest[] requestList, boolean streaming) throws RemoteException{
    Parcel _data = Parcel.obtain()
    SubmitInfo _result;
    ...
    if(!_status && ICameraDeviceUser.Stub.getDefaultImpl() != null){
        SubmitInfo var6 = ICameraDeviceUser.Stub.getDefaultImpl().submitRequestList(requestList, streaming);
    }
    
    ...
    if(0 != _reply.readInt()){
        _result = (SubmitInfo)SubmitInfo.CREATOR.createFromParcel(_reply);
    }
}

/*ICameraDeviceUser.Default.submitRequestList 匿名内部类的实现*/
public SubmitInfo submitRequestList(CaptureRequest[] requestList, boolean streaming) throws RemoteException{
    return null;
}

/*CameraDeviceUserShim.java 具体类的实现*/
public SubmitInfo submitRequestList(CaptureRequest[] request, boolean streaming){
    ...
    return this.mLegacyDevice.submitRequestList(request, streaming);
}

/*LegacyCameraDevice.java*/
public SubmitInfo submitRequestList(CaptureRequest[] requestList, boolean repeating){
    ...
    return this.mRequestThreadManager.submitCaptureRequests(requestList, repeating);
}

/*RequestThreadManager.java*/
public SubmitInfo submitCaptureRequests(CaptureRequest[] requests, boolean repeating){
    Handler handler = this.mRequestThread.waitAndGetHandler();
    synchronized(this.mIdleLock){
        SubmitInfo info = this.mRequestQueue.submit(requests, repeating);
        handler.sendEmptyMessage(2);
        return info;
    }
}

标签:CameraAppFramework,return,submitRequestList,setRepeatingRequest,流程,requestList,S
来源: https://blog.csdn.net/qq_29639599/article/details/121084530