libcamera: media_object: Add MediaPad string representations

Facilitate easy representations of a MediaPad object by preparing
it as a string and supporting output streams.

A MediaPad will be report in the following style:

  'imx283 1-001a'[0]

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Stefan Klug <stefan.klug@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
This commit is contained in:
Kieran Bingham
2024-09-11 23:18:13 +02:00
parent d900ec990d
commit 6837607ca3
2 changed files with 29 additions and 0 deletions
+25
View File
@@ -235,6 +235,31 @@ void MediaPad::addLink(MediaLink *link)
links_.push_back(link);
}
/**
* \brief Generate a string representation of the MediaPad
* \return A string representing the MediaPad
*/
std::string MediaPad::toString() const
{
std::stringstream ss;
ss << *this;
return ss.str();
}
/**
* \brief Insert a text representation of a MediaPad into an output stream
* \param[in] out The output stream
* \param[in] pad The MediaPad
* \return The output stream \a out
*/
std::ostream &operator<<(std::ostream &out, const MediaPad &pad)
{
out << "'" << pad.entity()->name() << "'[" << pad.index() << "]";
return out;
}
/**
* \class MediaEntity
* \brief The MediaEntity represents an entity in the media graph