CreateCaptureSession
该类代表了一个具体的相机会话,创建了与 Camera 设备的通道,而之后对于 Camera 设备的控制都是通过该通道来完成的。当需要进行预览或拍照时,首先通过该类创建一个 Session ,并且调用 startRepeatingRequest 方法开启预览流程,或者使用 capture 方法开始一次拍照动作
在CameraManager.openCamera() 成功后我们会在 CameraDevice.StateCallback 的 onOpened() 方法中获得到一个 CameraDevice 对象.
mCameraDevice.createCaptureSession(SessionConfiguretion config)
CameraDevice.java
//这个方法会在 CameraDeviceImpl里面实现
public void createCaptureSession(SessionConfiguration config) throws CameraAccessException{
throw new UnsupportedOperationException("No default implementation")
}
CameraDeviceImpl.java
public void createCaptureSession(SessionConfiguration config) throws CameraAccessException{
...
Lis<OutputConfiguration> outputConfigs = config.getOutputConfigurations();
createCaptureSessionInternal(config.getInputConfiguration(), outputConfigs, config.getStateCallback(), config.getExecutor(), config.getSessionType(), config.getSessionParameters());
}
private void createCaptureSessionInternal(InputConfigureation inputConfig, List<OutputConfiguration> outputConfigurations, CameraCaptureSession.StateCallback callback, Executor executor, int operatingMode, CaptureRequest sessoionParams) throws CameraAccessException{
...
if(mCurrentSession != null){
mCurrentSession.replaceSessionClose();
}
...
try{
//configure streams and then block until IDLE
configureSucces