From d36c2d590c36794f7549fc14f2177b2d8c58d04f Mon Sep 17 00:00:00 2001 From: noahwilliamsson Date: Mon, 5 Sep 2022 10:28:35 +0200 Subject: [PATCH] device/libcamera: fix libcamera::Span API breakage (#11) After upgrading from the July, 2022 releases of Raspberry Pi's libcamera packages to the Aug, 2022 releases, compilation fails with: ``` g++ -std=c++17 -MMD -Werror -Wall -g -I/tmp/camera-streamer -D_GNU_SOURCE -DUSE_FFMPEG -DUSE_LIBCAMERA -I/usr/include/libcamera -DUSE_RTSP -I/usr/include/liveMedia -I/usr/include/groupsock -I/usr/include/BasicUsageEnvironment -I/usr/include/UsageEnvironment -DUSE_LIBDATACHANNEL -Ithird_party/libdatachannel/include -Ithird_party/libdatachannel/deps/json/include -c -o device/libcamera/device.o device/libcamera/device.cc In file included from device/libcamera/libcamera.hh:22, from device/libcamera/device.cc:2: /usr/include/libcamera/libcamera/controls.h: In instantiation of 'void libcamera::ControlList::set(const libcamera::Control&, const std::initializer_list<_Up>&) [with T = libcamera::Span; V = long int]': device/libcamera/device.cc:126:100: required from here /usr/include/libcamera/libcamera/controls.h:403:14: error: no matching function for call to 'libcamera::ControlValue::set >(libcamera::Span)' 403 | val->set(Span>{ value.begin(), value.size() }); | ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/libcamera/libcamera/controls.h:178:7: note: candidate: 'template::value) && (! std::is_same, typename std::remove_cv< >::type>::value)), std::nullptr_t>::type > void libcamera::ControlValue::set(const T&)' 178 | void set(const T &value) | ^~~ /usr/include/libcamera/libcamera/controls.h:178:7: note: template argument deduction/substitution failed: /usr/include/libcamera/libcamera/controls.h:177:30: error: no type named 'type' in 'struct std::enable_if' 177 | std::nullptr_t> = nullptr> | ^~~~~~~ /usr/include/libcamera/libcamera/controls.h:190:7: note: candidate: 'template::value || std::is_same, typename std::remove_cv< >::type>::value), std::nullptr_t>::type > void libcamera::ControlValue::set(const T&)' 190 | void set(const T &value) | ^~~ /usr/include/libcamera/libcamera/controls.h:190:7: note: template argument deduction/substitution failed: /usr/include/libcamera/libcamera/controls.h:403:14: note: cannot convert 'libcamera::Span((& value)->std::initializer_list::begin(), (& value)->std::initializer_list::size())' (type 'libcamera::Span') to type 'const libcamera::Span&' 403 | val->set(Span>{ value.begin(), value.size() }); | ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ``` After introducing this change (see raspberrypi/libcamera-apps PR 342), it works with both versions mentioned below: ``` $ apt list --installed libcamera-apps/now 0~git20220707+35266e8-1 arm64 [installed,upgradable to: 0~git20220830+1bf0cca-1] libcamera-dev/now 0~git20220705+f30ad033-1 arm64 [installed,upgradable to: 0~git20220826+3fad116f-1] libcamera-tools/now 0~git20220705+f30ad033-1 arm64 [installed,upgradable to: 0~git20220826+3fad116f-1] libcamera0/now 0~git20220705+f30ad033-1 arm64 [installed,upgradable to: 0~git20220826+3fad116f-1] ``` --- device/libcamera/device.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/device/libcamera/device.cc b/device/libcamera/device.cc index da0ed5d..5ebe76e 100644 --- a/device/libcamera/device.cc +++ b/device/libcamera/device.cc @@ -123,7 +123,7 @@ void libcamera_device_close(device_t *dev) int libcamera_device_set_fps(device_t *dev, int desired_fps) { int64_t frame_time = 1000000 / desired_fps; - dev->libcamera->controls.set(libcamera::controls::FrameDurationLimits, { frame_time, frame_time }); + dev->libcamera->controls.set(libcamera::controls::FrameDurationLimits, libcamera::Span({ frame_time, frame_time })); return 0; }