Debug metadata often occurs in places where the metadata control list is not available e.g. in queueRequest() or processStatsBuffer() or even in a class far away from the metadata handling code. It is therefore difficult to add debug metadata without adding lots of boilerplate code. This can be mitigated by recording the metadata and forwarding it to the metadata control list when it becomes available. To solve the issue of code that is far away from the metadata context, add a chaining mechanism to allow loose coupling at runtime. Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
46 lines
805 B
C++
46 lines
805 B
C++
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
|
/*
|
|
* Copyright (C) 2024, Google Inc.
|
|
*
|
|
* Debug metadata helpers
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <libcamera/control_ids.h>
|
|
|
|
namespace libcamera {
|
|
|
|
class DebugMetadata
|
|
{
|
|
public:
|
|
DebugMetadata() = default;
|
|
|
|
void enableByControl(const ControlList &controls);
|
|
void enable(bool enable = true);
|
|
void setParent(DebugMetadata *parent);
|
|
void moveEntries(ControlList &list);
|
|
|
|
template<typename T, typename V>
|
|
void set(const Control<T> &ctrl, const V &value)
|
|
{
|
|
if (parent_) {
|
|
parent_->set(ctrl, value);
|
|
return;
|
|
}
|
|
|
|
if (!enabled_)
|
|
return;
|
|
|
|
cache_.set(ctrl, value);
|
|
}
|
|
|
|
void set(unsigned int id, const ControlValue &value);
|
|
|
|
private:
|
|
bool enabled_ = false;
|
|
DebugMetadata *parent_ = nullptr;
|
|
ControlList cache_;
|
|
};
|
|
|
|
} /* namespace libcamera */
|