2026-06-13 12:02:04 -04:00
|
|
|
#include <cameraIdentity.h>
|
|
|
|
|
#include <libcamera/property_ids.h>
|
|
|
|
|
#include <algorithm>
|
|
|
|
|
#include <cctype>
|
|
|
|
|
#include <optional>
|
2026-06-14 16:01:38 -04:00
|
|
|
#include <string_view>
|
2026-06-13 12:02:04 -04:00
|
|
|
|
|
|
|
|
namespace lcamera_dev {
|
|
|
|
|
|
|
|
|
|
std::string locationPropertyToLabel(int32_t locationValue)
|
|
|
|
|
{
|
|
|
|
|
using namespace libcamera::properties;
|
|
|
|
|
|
|
|
|
|
if (locationValue == CameraLocationFront) {
|
|
|
|
|
return "front";
|
|
|
|
|
}
|
|
|
|
|
if (locationValue == CameraLocationBack) {
|
|
|
|
|
return "back";
|
|
|
|
|
}
|
|
|
|
|
if (locationValue == CameraLocationExternal) {
|
|
|
|
|
return "external";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CameraIdentityRecord buildIdentityRecord(
|
|
|
|
|
const std::shared_ptr<libcamera::Camera>& camera)
|
|
|
|
|
{
|
|
|
|
|
CameraIdentityRecord record;
|
|
|
|
|
record.id = camera->id();
|
|
|
|
|
|
|
|
|
|
const libcamera::ControlList& props = camera->properties();
|
|
|
|
|
|
2026-06-14 16:01:38 -04:00
|
|
|
const std::optional<std::string_view> model =
|
2026-06-13 12:02:04 -04:00
|
|
|
props.get(libcamera::properties::Model);
|
|
|
|
|
if (model) {
|
2026-06-14 16:01:38 -04:00
|
|
|
record.model.assign(model->begin(), model->end());
|
2026-06-13 12:02:04 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const std::optional<int> location =
|
|
|
|
|
props.get(libcamera::properties::Location);
|
|
|
|
|
if (location)
|
|
|
|
|
{
|
|
|
|
|
record.locationLabel = locationPropertyToLabel(*location);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return record;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::vector<CameraIdentityRecord> buildIdentityRecords(
|
|
|
|
|
const std::vector<std::shared_ptr<libcamera::Camera>>& cameras)
|
|
|
|
|
{
|
|
|
|
|
std::vector<CameraIdentityRecord> records;
|
|
|
|
|
records.reserve(cameras.size());
|
|
|
|
|
|
|
|
|
|
for (const auto& camera : cameras)
|
|
|
|
|
{
|
|
|
|
|
if (!camera) { continue; }
|
|
|
|
|
|
|
|
|
|
records.push_back(buildIdentityRecord(camera));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return records;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace lcamera_dev
|