From 1c4d4801850559d6f919eef5c2ffbaf7675dbc46 Mon Sep 17 00:00:00 2001 From: Christian Rauch Date: Tue, 5 Jul 2022 10:55:48 +0100 Subject: libcamera: controls: Use std::optional to handle invalid control values Previously, ControlList::get() would use default constructed objects to indicate that a ControlList does not have the requested Control. This has several disadvantages: 1) It requires types to be default constructible, 2) it does not differentiate between a default constructed object and an object that happens to have the same state as a default constructed object. std::optional additionally stores the information if the object is valid or not, and therefore is more expressive than a default constructed object. Signed-off-by: Christian Rauch Reviewed-by: Jacopo Mondi Reviewed-by: Laurent Pinchart Signed-off-by: Laurent Pinchart --- src/gstreamer/gstlibcamerasrc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/gstreamer/gstlibcamerasrc.cpp') diff --git a/src/gstreamer/gstlibcamerasrc.cpp b/src/gstreamer/gstlibcamerasrc.cpp index a7a0c440..3d3efc0c 100644 --- a/src/gstreamer/gstlibcamerasrc.cpp +++ b/src/gstreamer/gstlibcamerasrc.cpp @@ -234,7 +234,7 @@ GstLibcameraSrcState::requestCompleted(Request *request) } if (GST_ELEMENT_CLOCK(src_)) { - int64_t timestamp = request->metadata().get(controls::SensorTimestamp); + int64_t timestamp = request->metadata().get(controls::SensorTimestamp).value_or(0); GstClockTime gst_base_time = GST_ELEMENT(src_)->base_time; GstClockTime gst_now = gst_clock_get_time(GST_ELEMENT_CLOCK(src_)); -- cgit v1.2.1