I want to capture image while recording video using camera2 API.

Two separate demos are available.
1. [To capture image](https://github.com/googlesamples/android-Camera2Basic) and 
2. [To record video](https://github.com/googlesamples/android-Camera2Video)

I tried to combine them into one app. But confused in many things. Like

* CameraDevice is single which representation of a single camera connected to an Android device.
* Different template needed in request. For image : `mCameraDevice.createCaptureRequest(CameraDevice.TEMPLATE_PREVIEW);` and for video `mCameraDevice.createCaptureRequest(CameraDevice.TEMPLATE_RECORD);`
* In createCaptureSession method surface of ImageReader is needed and for video MediaRecorder is needed.

CameraCaptureSession.StateCallback is needed in createCaptureSession method for both image and video.

And camera2 APIs are new. So no more examples available on Google.

Anyone has any idea about this? like how to capture photo while recording in android?