summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/libcamera/internal/media_object.h4
-rw-r--r--src/libcamera/media_object.cpp25
2 files changed, 29 insertions, 0 deletions
diff --git a/include/libcamera/internal/media_object.h b/include/libcamera/internal/media_object.h
index d80d5f45..9356d204 100644
--- a/include/libcamera/internal/media_object.h
+++ b/include/libcamera/internal/media_object.h
@@ -48,6 +48,8 @@ public:
unsigned int flags() const { return flags_; }
int setEnabled(bool enable);
+ std::string toString() const;
+
private:
LIBCAMERA_DISABLE_COPY_AND_MOVE(MediaLink)
@@ -61,6 +63,8 @@ private:
unsigned int flags_;
};
+std::ostream &operator<<(std::ostream &out, const MediaLink &link);
+
class MediaPad : public MediaObject
{
public:
diff --git a/src/libcamera/media_object.cpp b/src/libcamera/media_object.cpp
index 25f16707..3e3772a6 100644
--- a/src/libcamera/media_object.cpp
+++ b/src/libcamera/media_object.cpp
@@ -147,6 +147,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
* \return The source pad at the origin of the link