Get real timestamps, better frame durations.
Uses clock_gettime instead of using a spoofed "1" all the time.
Only offers approximate default FPS of 30 as the valid range,
instead of the true maximum reported by the device,
as actually changing it isn't hooked up yet.
Removes the sensor frame duration variable;
CTS at least will just default to reading from the timestamp.
BUG: b/29457051
TEST: unit tests pass. Some previously failing cts tests now pass.
Change-Id: I505d7dd51fe45de55214cb802184bea46245f316
diff --git a/modules/camera/3_4/Android.mk b/modules/camera/3_4/Android.mk
index 592aa2f..fbb9a4b 100644
--- a/modules/camera/3_4/Android.mk
+++ b/modules/camera/3_4/Android.mk
@@ -41,6 +41,7 @@
camera.cpp \
capture_request.cpp \
format_metadata_factory.cpp \
+ metadata/boottime_state_delegate.cpp \
metadata/enum_converter.cpp \
metadata/metadata.cpp \
metadata/metadata_reader.cpp \
diff --git a/modules/camera/3_4/format_metadata_factory.cpp b/modules/camera/3_4/format_metadata_factory.cpp
index 9ec15ed..a08f9a8 100644
--- a/modules/camera/3_4/format_metadata_factory.cpp
+++ b/modules/camera/3_4/format_metadata_factory.cpp
@@ -184,7 +184,6 @@
// YUV_420_888. Min should be at most 15.
std::vector<std::array<int32_t, 2>> fps_ranges;
fps_ranges.push_back({{min_fps, max_yuv_fps}});
- fps_ranges.push_back({{max_yuv_fps, max_yuv_fps}});
std::array<int32_t, 2> video_fps_range;
int32_t video_fps = 30;
@@ -192,8 +191,8 @@
video_fps_range = {{max_yuv_fps, max_yuv_fps}};
} else {
video_fps_range = {{video_fps, video_fps}};
- fps_ranges.push_back(video_fps_range);
}
+ fps_ranges.push_back(video_fps_range);
// Construct the metadata components.
insertion_point = std::make_unique<Property<ArrayVector<int32_t, 4>>>(
diff --git a/modules/camera/3_4/metadata/boottime_state_delegate.cpp b/modules/camera/3_4/metadata/boottime_state_delegate.cpp
new file mode 100644
index 0000000..5024cb2
--- /dev/null
+++ b/modules/camera/3_4/metadata/boottime_state_delegate.cpp
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <errno.h>
+#include <string.h>
+
+#include "boottime_state_delegate.h"
+
+namespace v4l2_camera_hal {
+
+int BoottimeStateDelegate::GetValue(int64_t* value) {
+ struct timespec ts;
+
+ int res = clock_gettime(CLOCK_BOOTTIME, &ts);
+ if (res) {
+ HAL_LOGE("Failed to get BOOTTIME for state delegate: %d (%s)",
+ errno,
+ strerror(errno));
+ return -errno;
+ }
+ *value = ts.tv_sec * 1000000000ULL + ts.tv_nsec;
+
+ return 0;
+}
+
+} // namespace v4l2_camera_hal
diff --git a/modules/camera/3_4/metadata/boottime_state_delegate.h b/modules/camera/3_4/metadata/boottime_state_delegate.h
new file mode 100644
index 0000000..0a5c4b9
--- /dev/null
+++ b/modules/camera/3_4/metadata/boottime_state_delegate.h
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef V4L2_CAMERA_HAL_METADATA_BOOTTIME_STATE_DELEGATE_H_
+#define V4L2_CAMERA_HAL_METADATA_BOOTTIME_STATE_DELEGATE_H_
+
+#include "../common.h"
+#include "state_delegate_interface.h"
+
+namespace v4l2_camera_hal {
+
+// A StateDelegate is simply a dynamic value that can be queried.
+// The value may change between queries.
+class BoottimeStateDelegate : public StateDelegateInterface<int64_t> {
+ public:
+ BoottimeStateDelegate(){};
+ ~BoottimeStateDelegate(){};
+
+ int GetValue(int64_t* value) override;
+};
+
+} // namespace v4l2_camera_hal
+
+#endif // V4L2_CAMERA_HAL_METADATA_BOOTTIME_STATE_DELEGATE_H_
diff --git a/modules/camera/3_4/v4l2_metadata_factory.cpp b/modules/camera/3_4/v4l2_metadata_factory.cpp
index e17c140..0216d7c 100644
--- a/modules/camera/3_4/v4l2_metadata_factory.cpp
+++ b/modules/camera/3_4/v4l2_metadata_factory.cpp
@@ -20,6 +20,7 @@
#include "common.h"
#include "format_metadata_factory.h"
+#include "metadata/boottime_state_delegate.h"
#include "metadata/control.h"
#include "metadata/enum_converter.h"
#include "metadata/metadata_common.h"
@@ -485,20 +486,18 @@
components.insert(std::unique_ptr<PartialMetadataInterface>(
new Property<uint8_t>(ANDROID_SENSOR_INFO_TIMESTAMP_SOURCE,
ANDROID_SENSOR_INFO_TIMESTAMP_SOURCE_UNKNOWN)));
- // TODO(b/29457051): Actually get a timestamp here. For now spoofing as non-0.
- components.insert(FixedState<int64_t>(ANDROID_SENSOR_TIMESTAMP, 1));
+ components.insert(std::make_unique<State<int64_t>>(
+ ANDROID_SENSOR_TIMESTAMP, std::make_unique<BoottimeStateDelegate>()));
// No way to actually get shutter skew from V4L2.
components.insert(
FixedState<int64_t>(ANDROID_SENSOR_ROLLING_SHUTTER_SKEW, 0));
// No way to actually get orientation from V4L2.
components.insert(std::unique_ptr<PartialMetadataInterface>(
new Property<int32_t>(ANDROID_SENSOR_ORIENTATION, 0)));
- // TODO(b/31023611): Should actually do something for this, and range should
+ // TODO(b/31023611): Sensor frame duration. Range should
// be dependent on the stream configuration being used.
- components.insert(NoEffectOptionlessControl<int64_t>(
- ANDROID_SENSOR_FRAME_DURATION, 33333333L)); // 1/30 s.
- // TODO(30510395): subcomponents of face detection.
+ // TODO(b/30510395): subcomponents of face detection.
// Face detection not supported.
components.insert(NoEffectMenuControl<uint8_t>(
ANDROID_STATISTICS_FACE_DETECT_MODE,