[libcamera-devel,v1,12/23] gst: libcamerasrc: Store the srcpad in a vector

Message ID 20200129033210.278800-13-nicolas@ndufresne.ca
State Superseded
Headers show
Series
  • GStreamer Element for libcamera
Related show

Commit Message

Nicolas Dufresne Jan. 29, 2020, 3:31 a.m. UTC
From: Nicolas Dufresne <nicolas.dufresne@collabora.com>

This will allow implementing generic algorithm even if we cannot
request pads yet.

Signed-off-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
---
 src/gstreamer/gstlibcamerasrc.cpp | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Laurent Pinchart Feb. 11, 2020, 11:15 p.m. UTC | #1
Hi Nicolas,

Thank you for the patch.

On Tue, Jan 28, 2020 at 10:31:59PM -0500, Nicolas Dufresne wrote:
> From: Nicolas Dufresne <nicolas.dufresne@collabora.com>
> 
> This will allow implementing generic algorithm even if we cannot
> request pads yet.
> 
> Signed-off-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
> ---
>  src/gstreamer/gstlibcamerasrc.cpp | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/src/gstreamer/gstlibcamerasrc.cpp b/src/gstreamer/gstlibcamerasrc.cpp
> index 4d0c7d0..be32a11 100644
> --- a/src/gstreamer/gstlibcamerasrc.cpp
> +++ b/src/gstreamer/gstlibcamerasrc.cpp
> @@ -22,6 +22,7 @@ GST_DEBUG_CATEGORY_STATIC(source_debug);
>  struct GstLibcameraSrcState {
>  	std::shared_ptr<CameraManager> cm;
>  	std::shared_ptr<Camera> cam;
> +	std::vector<GstPad *> srcpads;

Could you include <vector>, and generally, any C++ headers that is
required by std:: symbols that you use ? They're currently included
indirectly, but to avoid future compilation issues if headers get
refactored, including the dependencies explicitly is best.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

>  };
>  
>  struct _GstLibcameraSrc {
> @@ -29,7 +30,6 @@ struct _GstLibcameraSrc {
>  
>  	GRecMutex stream_lock;
>  	GstTask *task;
> -	GstPad *srcpad;
>  
>  	gchar *camera_name;
>  
> @@ -258,8 +258,8 @@ gst_libcamera_src_init(GstLibcameraSrc *self)
>  	gst_task_set_leave_callback(self->task, gst_libcamera_src_task_leave, self, nullptr);
>  	gst_task_set_lock(self->task, &self->stream_lock);
>  
> -	self->srcpad = gst_pad_new_from_template(templ, "src");
> -	gst_element_add_pad(GST_ELEMENT(self), self->srcpad);
> +	state->srcpads.push_back(gst_pad_new_from_template(templ, "src"));
> +	gst_element_add_pad(GST_ELEMENT(self), state->srcpads[0]);
>  	self->state = state;
>  }
>

Patch

diff --git a/src/gstreamer/gstlibcamerasrc.cpp b/src/gstreamer/gstlibcamerasrc.cpp
index 4d0c7d0..be32a11 100644
--- a/src/gstreamer/gstlibcamerasrc.cpp
+++ b/src/gstreamer/gstlibcamerasrc.cpp
@@ -22,6 +22,7 @@  GST_DEBUG_CATEGORY_STATIC(source_debug);
 struct GstLibcameraSrcState {
 	std::shared_ptr<CameraManager> cm;
 	std::shared_ptr<Camera> cam;
+	std::vector<GstPad *> srcpads;
 };
 
 struct _GstLibcameraSrc {
@@ -29,7 +30,6 @@  struct _GstLibcameraSrc {
 
 	GRecMutex stream_lock;
 	GstTask *task;
-	GstPad *srcpad;
 
 	gchar *camera_name;
 
@@ -258,8 +258,8 @@  gst_libcamera_src_init(GstLibcameraSrc *self)
 	gst_task_set_leave_callback(self->task, gst_libcamera_src_task_leave, self, nullptr);
 	gst_task_set_lock(self->task, &self->stream_lock);
 
-	self->srcpad = gst_pad_new_from_template(templ, "src");
-	gst_element_add_pad(GST_ELEMENT(self), self->srcpad);
+	state->srcpads.push_back(gst_pad_new_from_template(templ, "src"));
+	gst_element_add_pad(GST_ELEMENT(self), state->srcpads[0]);
 	self->state = state;
 }