modules: camera: Shutter notify message support
The shutter callback timestamp should originate from the sensor itself,
since it knows exactly when the first line of the frame started
exposing. However, as a fallback (or in the CPU-painting case) query
CLOCK_BOOTTIME instead.
Change-Id: Id57c05525e9c575d009b9deb96a69557fccac16b
diff --git a/modules/camera/Camera.cpp b/modules/camera/Camera.cpp
index 10464cb..1c307de 100644
--- a/modules/camera/Camera.cpp
+++ b/modules/camera/Camera.cpp
@@ -544,6 +544,7 @@
// TODO: return actual captured/reprocessed settings
result.result = request->settings;
// TODO: asynchronously return results
+ notifyShutter(request->frame_number, 0);
mCallbackOps->process_capture_result(mCallbackOps, &result);
return 0;
@@ -606,6 +607,31 @@
return 0;
}
+void Camera::notifyShutter(uint32_t frame_number, uint64_t timestamp)
+{
+ int res;
+ struct timespec ts;
+
+ // If timestamp is 0, get timestamp from right now instead
+ if (timestamp == 0) {
+ ALOGW("%s:%d: No timestamp provided, using CLOCK_BOOTTIME",
+ __func__, mId);
+ res = clock_gettime(CLOCK_BOOTTIME, &ts);
+ if (res == 0) {
+ timestamp = ts.tv_sec * 1000000000ULL + ts.tv_nsec;
+ } else {
+ ALOGE("%s:%d: No timestamp and failed to get CLOCK_BOOTTIME %s(%d)",
+ __func__, mId, strerror(errno), errno);
+ }
+ }
+ camera3_notify_msg_t m;
+ memset(&m, 0, sizeof(m));
+ m.type = CAMERA3_MSG_SHUTTER;
+ m.message.shutter.frame_number = frame_number;
+ m.message.shutter.timestamp = timestamp;
+ mCallbackOps->notify(mCallbackOps, &m);
+}
+
void Camera::getMetadataVendorTagOps(vendor_tag_query_ops_t *ops)
{
ALOGV("%s:%d: ops=%p", __func__, mId, ops);