summaryrefslogtreecommitdiff
path: root/src/gstreamer/gstlibcamerasrc.cpp
diff options
context:
space:
mode:
authorChristian Rauch <Rauch.Christian@gmx.de>2022-07-05 10:55:48 +0100
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2022-07-19 14:21:54 +0300
commit1c4d4801850559d6f919eef5c2ffbaf7675dbc46 (patch)
treed1686453c2d047565b9708bc9e03d375fcfa8578 /src/gstreamer/gstlibcamerasrc.cpp
parentef77e2637985b61dc99669b4396647ad13acb204 (diff)
libcamera: controls: Use std::optional to handle invalid control values
Previously, ControlList::get<T>() 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<T> 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 <Rauch.Christian@gmx.de> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Diffstat (limited to 'src/gstreamer/gstlibcamerasrc.cpp')
-rw-r--r--src/gstreamer/gstlibcamerasrc.cpp2
1 files changed, 1 insertions, 1 deletions
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_));