mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-29 05:40:27 -04:00
spa: libcamera: use references when getting camera properties
The argument is not nullable, so use a const lvalue reference to express that clearly.
This commit is contained in:
parent
80c548edb2
commit
fbc1589ffe
1 changed files with 14 additions and 22 deletions
|
|
@ -53,32 +53,25 @@ struct impl {
|
|||
|
||||
}
|
||||
|
||||
static const libcamera::Span<const int64_t> cameraDevice(
|
||||
const Camera *camera)
|
||||
static const libcamera::Span<const int64_t> cameraDevice(const Camera& camera)
|
||||
{
|
||||
const ControlList &props = camera->properties();
|
||||
|
||||
if (auto devices = props.get(properties::SystemDevices))
|
||||
if (auto devices = camera.properties().get(properties::SystemDevices))
|
||||
return devices.value();
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
static std::string cameraModel(const Camera *camera)
|
||||
static std::string cameraModel(const Camera& camera)
|
||||
{
|
||||
const ControlList &props = camera->properties();
|
||||
|
||||
if (auto model = props.get(properties::Model))
|
||||
if (auto model = camera.properties().get(properties::Model))
|
||||
return std::move(model.value());
|
||||
|
||||
return camera->id();
|
||||
return camera.id();
|
||||
}
|
||||
|
||||
static const char *cameraLoc(const Camera *camera)
|
||||
static const char *cameraLoc(const Camera& camera)
|
||||
{
|
||||
const ControlList &props = camera->properties();
|
||||
|
||||
if (auto location = props.get(properties::Location)) {
|
||||
if (auto location = camera.properties().get(properties::Location)) {
|
||||
switch (location.value()) {
|
||||
case properties::CameraLocationFront:
|
||||
return "front";
|
||||
|
|
@ -92,11 +85,9 @@ static const char *cameraLoc(const Camera *camera)
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
static const char *cameraRot(const Camera *camera)
|
||||
static const char *cameraRot(const Camera& camera)
|
||||
{
|
||||
const ControlList &props = camera->properties();
|
||||
|
||||
if (auto rotation = props.get(properties::Rotation)) {
|
||||
if (auto rotation = camera.properties().get(properties::Rotation)) {
|
||||
switch (rotation.value()) {
|
||||
case 90:
|
||||
return "90";
|
||||
|
|
@ -121,6 +112,7 @@ static int emit_info(struct impl *impl, bool full)
|
|||
struct spa_param_info params[2];
|
||||
char path[256], name[256], devices_str[256];
|
||||
struct spa_strbuf buf;
|
||||
Camera& camera = *impl->camera;
|
||||
|
||||
info = SPA_DEVICE_INFO_INIT();
|
||||
|
||||
|
|
@ -133,19 +125,19 @@ static int emit_info(struct impl *impl, bool full)
|
|||
ADD_ITEM(SPA_KEY_MEDIA_CLASS, "Video/Device");
|
||||
ADD_ITEM(SPA_KEY_API_LIBCAMERA_PATH, impl->device_id.c_str());
|
||||
|
||||
if (auto location = cameraLoc(impl->camera.get()))
|
||||
if (auto location = cameraLoc(camera))
|
||||
ADD_ITEM(SPA_KEY_API_LIBCAMERA_LOCATION, location);
|
||||
if (auto rotation = cameraRot(impl->camera.get()))
|
||||
if (auto rotation = cameraRot(camera))
|
||||
ADD_ITEM(SPA_KEY_API_LIBCAMERA_ROTATION, rotation);
|
||||
|
||||
const auto model = cameraModel(impl->camera.get());
|
||||
const auto model = cameraModel(camera);
|
||||
ADD_ITEM(SPA_KEY_DEVICE_PRODUCT_NAME, model.c_str());
|
||||
ADD_ITEM(SPA_KEY_DEVICE_DESCRIPTION, model.c_str());
|
||||
|
||||
snprintf(name, sizeof(name), "libcamera_device.%s", impl->device_id.c_str());
|
||||
ADD_ITEM(SPA_KEY_DEVICE_NAME, name);
|
||||
|
||||
auto device_numbers = cameraDevice(impl->camera.get());
|
||||
auto device_numbers = cameraDevice(camera);
|
||||
|
||||
if (!device_numbers.empty()) {
|
||||
spa_strbuf_init(&buf, devices_str, sizeof(devices_str));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue