我们看到ICameraDeviceCallbacks 所处位置是CameraDeviceClient向CameraDevice返回位置。
谷歌原文解释:
ICameraDeviceCallbacks is the CameraDevice callbacks to the application framework.
这个回调是在CameraDevice的继承类CameraDeviceImpl定义,从打开相机经过ICameraService中MakeClient传给CameraDeviceClient中。
参考open流程:
Android Camera2架构-OpenCamera2流程Frameworks层到HAL层(1)
也就是说在CameraDeviceClient中会通过这些回调函数通知CameraDevice一些消息。
具体看ICameraDeviceCallbacks.aidl里面定义的消息方法。
interface ICameraDeviceCallbacks
{
// Error codes for onDeviceError
const int ERROR_CAMERA_INVALID_ERROR = -1; // To indicate all invalid error codes
const int ERROR_CAMERA_DISCONNECTED = 0;
const int ERROR_CAMERA_DEVICE = 1;
const int ERROR_CAMERA_SERVICE = 2;
const int ERROR_CAMERA_REQUEST = 3;
const int ERROR_CAMERA_RESULT = 4;
const int ERROR_CAMERA_BUFFER = 5;
const int ERROR_CAMERA_DISABLED = 6;
oneway void onDeviceError(int errorCode, in CaptureResultExtras resultExtras);
oneway void onDeviceIdle();
oneway void onCaptureStarted(in CaptureResultExtras resultExtras, long timestamp);
oneway void onResultReceived(in CameraMetadataNative result,
in CaptureResultExtras resultExtras,
in PhysicalCaptureResultInfo[] physicalCaptureResultInfos);
oneway void onPrepared(int streamId);
/**
* Repeating request encountered an error and was stopped.
*
* @param lastFrameNumber Frame number of the last frame of the streaming request.
* @param repeatingRequestId the ID of the repeating request being stopped
*/
oneway void onRepeatingRequestError(in long lastFrameNumber,
in int repeatingRequestId);
oneway void onRequestQueueEmpty();
}
比如:
说当CameraDeviceCilent收到onResultReceived消息时候就会触发ICameraDeviceCallbacks.onResultReceived()方法通知到CameraDevice。
返回Result参考
Android Camera2架构-ResultThread处理队列中的预览和拍照请求流程Frameworks层到HAL层(1)