libcamera: stream: Add operator<<() to print StreamRole as a string
libcamera prints stream role values in log messages. To be more user-friendly, add a specialization of operator<<() to print the role name as a string instead of a numerical value. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
This commit is contained in:
parent
c7bbe0ca3a
commit
baf3be12ef
2 changed files with 22 additions and 0 deletions
|
@ -9,6 +9,7 @@
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <ostream>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
@ -70,6 +71,8 @@ enum StreamRole {
|
||||||
|
|
||||||
using StreamRoles = std::vector<StreamRole>;
|
using StreamRoles = std::vector<StreamRole>;
|
||||||
|
|
||||||
|
std::ostream &operator<<(std::ostream &out, StreamRole role);
|
||||||
|
|
||||||
class Stream
|
class Stream
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -417,6 +417,25 @@ std::string StreamConfiguration::toString() const
|
||||||
* acceptable.
|
* acceptable.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Insert a text representation of a StreamRole into an output stream
|
||||||
|
* \param[in] out The output stream
|
||||||
|
* \param[in] role The StreamRole
|
||||||
|
* \return The output stream \a out
|
||||||
|
*/
|
||||||
|
std::ostream &operator<<(std::ostream &out, StreamRole role)
|
||||||
|
{
|
||||||
|
static constexpr std::array<const char *, 4> names{
|
||||||
|
"Raw",
|
||||||
|
"StillCapture",
|
||||||
|
"VideoRecording",
|
||||||
|
"Viewfinder",
|
||||||
|
};
|
||||||
|
|
||||||
|
out << names[static_cast<std::underlying_type_t<StreamRole>>(role)];
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \typedef StreamRoles
|
* \typedef StreamRoles
|
||||||
* \brief A vector of StreamRole
|
* \brief A vector of StreamRole
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue