libcamera: media_object: Add MediaLink string representations
Various parts of libcamera print the representation of a MediaLink by inline joining the parts to make a string representation. This repeated use case can be supported with a common helper to print the MediaLink in a common manner using the existing toString() and operator<< overload style to make it easier to report on MediaLink types. This implementation will report in the following style: 'imx283 1-001a'[0] -> 'video-mux'[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:
@@ -146,6 +146,31 @@ MediaLink::MediaLink(const struct media_v2_link *link, MediaPad *source,
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Generate a string representation of the MediaLink
|
||||
* \return A string representing the MediaLink
|
||||
*/
|
||||
std::string MediaLink::toString() const
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << *this;
|
||||
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Insert a text representation of a Link into an output stream
|
||||
* \param[in] out The output stream
|
||||
* \param[in] link The MediaLink
|
||||
* \return The output stream \a out
|
||||
*/
|
||||
std::ostream &operator<<(std::ostream &out, const MediaLink &link)
|
||||
{
|
||||
out << *link.source() << " -> " << *link.sink();
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
/**
|
||||
* \fn MediaLink::source()
|
||||
* \brief Retrieve the link's source pad
|
||||
|
||||
Reference in New Issue
Block a user