Camera API 2, Device 2/3: Implement idle and shutter callbacks
- Update callback Binder interface
- Rename frameId to be requestId to be consistent and disambiguate
from frameNumber.
- Implement shutter callback from HAL2/3 notify()
- Add in-flight tracking to HAL2
- Add requestId to in-flight tracking
- Report requestId from shutter callback
- Implement idle callback from HAL3 process_capture_result
- Add new idle tracker thread
- Update all idle waiting to use the tracker
- Add reporting from request thread, all streams to tracker
- Remove existing idle waiting infrastructure
Bug: 10549462
Change-Id: I867bfc248e3848c50e71527e3561fe92dc037958
diff --git a/services/camera/libcameraservice/api2/CameraDeviceClient.cpp b/services/camera/libcameraservice/api2/CameraDeviceClient.cpp
index 76d44bf..72126c1 100644
--- a/services/camera/libcameraservice/api2/CameraDeviceClient.cpp
+++ b/services/camera/libcameraservice/api2/CameraDeviceClient.cpp
@@ -45,14 +45,6 @@
cameraId, cameraFacing, clientPid, clientUid, servicePid),
mRemoteCallback(remoteCallback) {
}
-void CameraDeviceClientBase::notifyError() {
- // Thread safe. Don't bother locking.
- sp<ICameraDeviceCallbacks> remoteCb = mRemoteCallback;
-
- if (remoteCb != 0) {
- remoteCb->notifyCallback(CAMERA_MSG_ERROR, CAMERA_ERROR_RELEASED, 0);
- }
-}
// Interface used by CameraService
@@ -164,7 +156,6 @@
metadata.update(ANDROID_REQUEST_OUTPUT_STREAMS, &outputStreamIds[0],
outputStreamIds.size());
- // TODO: @hide ANDROID_REQUEST_ID, or use another request token
int32_t requestId = mRequestIdCounter++;
metadata.update(ANDROID_REQUEST_ID, &requestId, /*size*/1);
ALOGV("%s: Camera %d: Submitting request with ID %d",
@@ -501,6 +492,34 @@
return dumpDevice(fd, args);
}
+
+void CameraDeviceClient::notifyError() {
+ // Thread safe. Don't bother locking.
+ sp<ICameraDeviceCallbacks> remoteCb = getRemoteCallback();
+
+ if (remoteCb != 0) {
+ remoteCb->onDeviceError(ICameraDeviceCallbacks::ERROR_CAMERA_DEVICE);
+ }
+}
+
+void CameraDeviceClient::notifyIdle() {
+ // Thread safe. Don't bother locking.
+ sp<ICameraDeviceCallbacks> remoteCb = getRemoteCallback();
+
+ if (remoteCb != 0) {
+ remoteCb->onDeviceIdle();
+ }
+}
+
+void CameraDeviceClient::notifyShutter(int requestId,
+ nsecs_t timestamp) {
+ // Thread safe. Don't bother locking.
+ sp<ICameraDeviceCallbacks> remoteCb = getRemoteCallback();
+ if (remoteCb != 0) {
+ remoteCb->onCaptureStarted(requestId, timestamp);
+ }
+}
+
// TODO: refactor the code below this with IProCameraUser.
// it's 100% copy-pasted, so lets not change it right now to make it easier.
@@ -532,8 +551,8 @@
}
/** Device-related methods */
-void CameraDeviceClient::onFrameAvailable(int32_t frameId,
- const CameraMetadata& frame) {
+void CameraDeviceClient::onFrameAvailable(int32_t requestId,
+ const CameraMetadata& frame) {
ATRACE_CALL();
ALOGV("%s", __FUNCTION__);
@@ -541,7 +560,7 @@
sp<ICameraDeviceCallbacks> remoteCb = mRemoteCallback;
if (remoteCb != NULL) {
ALOGV("%s: frame = %p ", __FUNCTION__, &frame);
- remoteCb->onResultReceived(frameId, frame);
+ remoteCb->onResultReceived(requestId, frame);
}
}