[v3,1/2] libamera: media_pipeline: Add accessor for MediaPipeline list of entities
diff mbox series

Message ID 20251127154519.2038844-2-antoine.bouyer@nxp.com
State New
Headers show
Series
  • imx8-isi: Use MediaPipeline
Related show

Commit Message

Antoine Bouyer Nov. 27, 2025, 3:45 p.m. UTC
From: Andrei Gansari <andrei.gansari@nxp.com>

Exposes internal MediaEntity::Entity list to help extracting more
information regarding linked entities.

For example, when the pad index of the last device in the list need to be
retrieved from the media pipeline user.

Exposes as const to with a dedicated access to prevent any corruption from
user. Then it is still protected so as when the list was private.

Since MediaPipeline::Entity needs also to be moved to public, then need to
add some documentation in cpp source. Existing documentation from header
file is applied when available.

Signed-off-by: Andrei Gansari <andrei.gansari@nxp.com>
Signed-off-by: Antoine Bouyer <antoine.bouyer@nxp.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
---
 include/libcamera/internal/media_pipeline.h | 29 ++++---------
 src/libcamera/media_pipeline.cpp            | 46 +++++++++++++++++++++
 2 files changed, 53 insertions(+), 22 deletions(-)

Comments

Kieran Bingham Nov. 27, 2025, 4:28 p.m. UTC | #1
Quoting Antoine Bouyer (2025-11-27 15:45:17)
> From: Andrei Gansari <andrei.gansari@nxp.com>
> 
> Exposes internal MediaEntity::Entity list to help extracting more
> information regarding linked entities.
> 
> For example, when the pad index of the last device in the list need to be
> retrieved from the media pipeline user.
> 
> Exposes as const to with a dedicated access to prevent any corruption from
> user. Then it is still protected so as when the list was private.
> 
> Since MediaPipeline::Entity needs also to be moved to public, then need to
> add some documentation in cpp source. Existing documentation from header
> file is applied when available.
> 
> Signed-off-by: Andrei Gansari <andrei.gansari@nxp.com>
> Signed-off-by: Antoine Bouyer <antoine.bouyer@nxp.com>
> Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>

Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>

> ---
>  include/libcamera/internal/media_pipeline.h | 29 ++++---------
>  src/libcamera/media_pipeline.cpp            | 46 +++++++++++++++++++++
>  2 files changed, 53 insertions(+), 22 deletions(-)
> 
> diff --git a/include/libcamera/internal/media_pipeline.h b/include/libcamera/internal/media_pipeline.h
> index a7a4b8c559cd..f62e3e8c58b0 100644
> --- a/include/libcamera/internal/media_pipeline.h
> +++ b/include/libcamera/internal/media_pipeline.h
> @@ -23,36 +23,21 @@ struct V4L2SubdeviceFormat;
>  class MediaPipeline
>  {
>  public:
> -       int init(MediaEntity *source, std::string_view sink);
> -       int initLinks();
> -       int configure(CameraSensor *sensor, V4L2SubdeviceFormat *);
> -
> -private:
>         struct Entity {
> -               /* The media entity, always valid. */
>                 MediaEntity *entity;
> -               /*
> -                * Whether or not the entity is a subdev that supports the
> -                * routing API.
> -                */
>                 bool supportsRouting;
> -               /*
> -                * The local sink pad connected to the upstream entity, null for
> -                * the camera sensor at the beginning of the pipeline.
> -                */
>                 const MediaPad *sink;
> -               /*
> -                * The local source pad connected to the downstream entity, null
> -                * for the video node at the end of the pipeline.
> -                */
>                 const MediaPad *source;
> -               /*
> -                * The link on the source pad, to the downstream entity, null
> -                * for the video node at the end of the pipeline.
> -                */
>                 MediaLink *sourceLink;
>         };
>  
> +       int init(MediaEntity *source, std::string_view sink);
> +       int initLinks();
> +       int configure(CameraSensor *sensor, V4L2SubdeviceFormat *);
> +
> +       const std::list<Entity> &entities() const { return entities_; }
> +
> +private:
>         std::list<Entity> entities_;
>  };
>  
> diff --git a/src/libcamera/media_pipeline.cpp b/src/libcamera/media_pipeline.cpp
> index c4e9f69b8f6a..3c5517314a4a 100644
> --- a/src/libcamera/media_pipeline.cpp
> +++ b/src/libcamera/media_pipeline.cpp
> @@ -43,6 +43,52 @@ LOG_DEFINE_CATEGORY(MediaPipeline)
>   * two entities in a media graph.
>   */
>  
> +/**
> + * \struct MediaPipeline::Entity
> + * \brief A node composing the media pipeline
> + *
> + * The MediaPipeline::Entity structure stores how a MediaEntity composing a
> + * media pipeline is connected to other media entities. It stores pointers
> + * to the source pad, the sink pad and the media link traversed by the media
> + * pipeline, as well as a flag that reports if the entity supports internal
> + * routing.
> + */
> +
> +/**
> + * \var MediaPipeline::Entity::entity
> + * \brief Pointer to the libcamera::MediaEntity, always valid
> + */
> +
> +/**
> + * \var MediaPipeline::Entity::supportsRouting
> + * \brief Whether or not the entity is a subdev that supports the routing API
> + */
> +
> +/**
> + * \var MediaPipeline::Entity::sink
> + * \brief The local libcamera::MediaPad sink pad connected to the upstream entity,
> + * null for the camera sensor at the beginning of the pipeline
> + */
> +
> +/**
> + * \var MediaPipeline::Entity::source
> + * \brief The local libcamera::MediaPad source pad connected to the upstream entity,
> + * null for the last node at the end of the pipeline
> + */
> +
> +/**
> + * \var MediaPipeline::Entity::sourceLink
> + * \brief The link on the libcamera::MediaLink source pad, to the downstream entity,
> + * null for the last node at the end of the pipeline
> + */
> +
> +/**
> + * \fn MediaPipeline::entities()
> + * \brief Retrieve list of entities composing the media pipeline
> + * \return The list of MediaPipeline::Entity entities composing the media
> + * pipeline
> + */
> +
>  /**
>   * \brief Retrieve all source pads connected to a sink pad through active routes
>   *
> -- 
> 2.51.2
>

Patch
diff mbox series

diff --git a/include/libcamera/internal/media_pipeline.h b/include/libcamera/internal/media_pipeline.h
index a7a4b8c559cd..f62e3e8c58b0 100644
--- a/include/libcamera/internal/media_pipeline.h
+++ b/include/libcamera/internal/media_pipeline.h
@@ -23,36 +23,21 @@  struct V4L2SubdeviceFormat;
 class MediaPipeline
 {
 public:
-	int init(MediaEntity *source, std::string_view sink);
-	int initLinks();
-	int configure(CameraSensor *sensor, V4L2SubdeviceFormat *);
-
-private:
 	struct Entity {
-		/* The media entity, always valid. */
 		MediaEntity *entity;
-		/*
-		 * Whether or not the entity is a subdev that supports the
-		 * routing API.
-		 */
 		bool supportsRouting;
-		/*
-		 * The local sink pad connected to the upstream entity, null for
-		 * the camera sensor at the beginning of the pipeline.
-		 */
 		const MediaPad *sink;
-		/*
-		 * The local source pad connected to the downstream entity, null
-		 * for the video node at the end of the pipeline.
-		 */
 		const MediaPad *source;
-		/*
-		 * The link on the source pad, to the downstream entity, null
-		 * for the video node at the end of the pipeline.
-		 */
 		MediaLink *sourceLink;
 	};
 
+	int init(MediaEntity *source, std::string_view sink);
+	int initLinks();
+	int configure(CameraSensor *sensor, V4L2SubdeviceFormat *);
+
+	const std::list<Entity> &entities() const { return entities_; }
+
+private:
 	std::list<Entity> entities_;
 };
 
diff --git a/src/libcamera/media_pipeline.cpp b/src/libcamera/media_pipeline.cpp
index c4e9f69b8f6a..3c5517314a4a 100644
--- a/src/libcamera/media_pipeline.cpp
+++ b/src/libcamera/media_pipeline.cpp
@@ -43,6 +43,52 @@  LOG_DEFINE_CATEGORY(MediaPipeline)
  * two entities in a media graph.
  */
 
+/**
+ * \struct MediaPipeline::Entity
+ * \brief A node composing the media pipeline
+ *
+ * The MediaPipeline::Entity structure stores how a MediaEntity composing a
+ * media pipeline is connected to other media entities. It stores pointers
+ * to the source pad, the sink pad and the media link traversed by the media
+ * pipeline, as well as a flag that reports if the entity supports internal
+ * routing.
+ */
+
+/**
+ * \var MediaPipeline::Entity::entity
+ * \brief Pointer to the libcamera::MediaEntity, always valid
+ */
+
+/**
+ * \var MediaPipeline::Entity::supportsRouting
+ * \brief Whether or not the entity is a subdev that supports the routing API
+ */
+
+/**
+ * \var MediaPipeline::Entity::sink
+ * \brief The local libcamera::MediaPad sink pad connected to the upstream entity,
+ * null for the camera sensor at the beginning of the pipeline
+ */
+
+/**
+ * \var MediaPipeline::Entity::source
+ * \brief The local libcamera::MediaPad source pad connected to the upstream entity,
+ * null for the last node at the end of the pipeline
+ */
+
+/**
+ * \var MediaPipeline::Entity::sourceLink
+ * \brief The link on the libcamera::MediaLink source pad, to the downstream entity,
+ * null for the last node at the end of the pipeline
+ */
+
+/**
+ * \fn MediaPipeline::entities()
+ * \brief Retrieve list of entities composing the media pipeline
+ * \return The list of MediaPipeline::Entity entities composing the media
+ * pipeline
+ */
+
 /**
  * \brief Retrieve all source pads connected to a sink pad through active routes
  *