@@ -7,6 +7,9 @@
#include "camera_device.h"
+#include <libcamera/controls.h>
+#include <libcamera/property_ids.h>
+
#include "log.h"
#include "utils.h"
@@ -97,6 +100,8 @@ camera_metadata_t *CameraDevice::getStaticMetadata()
if (staticMetadata_)
return staticMetadata_->get();
+ const ControlList &properties = camera_->properties();
+
/*
* The here reported metadata are enough to implement a basic capture
* example application, but a real camera implementation will require
@@ -261,9 +266,15 @@ camera_metadata_t *CameraDevice::getStaticMetadata()
staticMetadata_->addEntry(ANDROID_SENSOR_INFO_EXPOSURE_TIME_RANGE,
&exposureTimeRange, 2);
+ /*
+ * Android reports orientation as clockwise correction, while libcamera
+ * uses counter-clockwise.
+ */
int32_t orientation = 0;
- staticMetadata_->addEntry(ANDROID_SENSOR_ORIENTATION,
- &orientation, 1);
+ if (properties.contains(properties::Rotation))
+ orientation = (360 - properties.get(properties::Rotation))
+ % 360;
+ staticMetadata_->addEntry(ANDROID_SENSOR_ORIENTATION, &orientation, 1);
std::vector<int32_t> testPatterModes = {
ANDROID_SENSOR_TEST_PATTERN_MODE_OFF,
@@ -310,6 +321,20 @@ camera_metadata_t *CameraDevice::getStaticMetadata()
lensApertures.size());
uint8_t lensFacing = ANDROID_LENS_FACING_FRONT;
+ if (properties.contains(properties::Location)) {
+ int32_t location = properties.get(properties::Location);
+ switch (location) {
+ case properties::CameraLocationFront:
+ lensFacing = ANDROID_LENS_FACING_FRONT;
+ break;
+ case properties::CameraLocationBack:
+ lensFacing = ANDROID_LENS_FACING_BACK;
+ break;
+ case properties::CameraLocationExternal:
+ lensFacing = ANDROID_LENS_FACING_EXTERNAL;
+ break;
+ }
+ }
staticMetadata_->addEntry(ANDROID_LENS_FACING, &lensFacing, 1);
std::vector<float> lensFocalLenghts = {