[v3] gstreamer: Reconfigure when peer caps gain extra fields
diff mbox series

Message ID 20260818094507.4082940-1-elliot.chen@oss.nxp.com
State New
Headers show
Series
  • [v3] gstreamer: Reconfigure when peer caps gain extra fields
Related show

Commit Message

Elliot Chen (OSS) Aug. 18, 2026, 9:45 a.m. UTC
From: Elliot Chen <elliot.chen@nxp.com>

After initial negotiation, a downstream element may append extra
fields to the caps (e.g. colorimetry). The existing check only
handles empty peer caps. Add a structure comparison to detect such
changes and trigger reconfiguration with caps renegotiation.

Signed-off-by: Elliot Chen <elliot.chen@nxp.com>

---
Changes in v3:
- rename caps structure

Changes in v2:
- remove redundant checks both for caps and peercaps

Changes in v1:
- Initial submission
---
 src/gstreamer/gstlibcamerasrc.cpp | 12 ++++++++++++
 1 file changed, 12 insertions(+)

Comments

Jacopo Mondi Aug. 18, 2026, 9:52 a.m. UTC | #1
Hi Elliot,

On Tue, Aug 18, 2026 at 06:45:07PM +0900, elliot.chen@oss.nxp.com wrote:
> From: Elliot Chen <elliot.chen@nxp.com>
>
> After initial negotiation, a downstream element may append extra
> fields to the caps (e.g. colorimetry). The existing check only
> handles empty peer caps. Add a structure comparison to detect such
> changes and trigger reconfiguration with caps renegotiation.
>

Don't worry, I'll add
Closes: https://gitlab.freedesktop.org/camera/libcamera/-/work_items/344

When applying

> Signed-off-by: Elliot Chen <elliot.chen@nxp.com>

Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>

Nicolas: your tag was dropped, should I add it back when applying ?

Thanks
  j

>
> ---
> Changes in v3:
> - rename caps structure
>
> Changes in v2:
> - remove redundant checks both for caps and peercaps
>
> Changes in v1:
> - Initial submission
> ---
>  src/gstreamer/gstlibcamerasrc.cpp | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
>
> diff --git a/src/gstreamer/gstlibcamerasrc.cpp b/src/gstreamer/gstlibcamerasrc.cpp
> index 9061f9163..9541aa3f6 100644
> --- a/src/gstreamer/gstlibcamerasrc.cpp
> +++ b/src/gstreamer/gstlibcamerasrc.cpp
> @@ -744,6 +744,18 @@ gst_libcamera_src_task_run(gpointer user_data)
>  				reconfigure = true;
>  				break;
>  			}
> +
> +			/*
> +			 * Caps may gain extra fields after the initial negotiation (e.g.
> +			 * colorimetry added by a downstream element). Detect such changes
> +			 * and trigger reconfiguration.
> +			 */
> +			const GstStructure *caps0 = gst_caps_get_structure(caps, 0);
> +			const GstStructure *peercaps0 = gst_caps_get_structure(peercaps, 0);
> +			if (!gst_structure_is_equal(caps0, peercaps0)) {
> +				reconfigure = true;
> +				break;
> +			}
>  		}
>  	}
>
> --
> 2.34.1
>
Elliot Chen (OSS) Aug. 18, 2026, 9:55 a.m. UTC | #2
Hi Jacopo,
Thank you very much.


NXP Confidential
-----Original Message-----
From: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Sent: Tuesday, August 18, 2026 5:52 PM
To: Elliot Chen (OSS) <elliot.chen@oss.nxp.com>; nicolas@ndufresne.ca
Cc: libcamera-devel@lists.libcamera.org; Elliot Chen <elliot.chen@nxp.com>
Subject: Re: [PATCH v3] gstreamer: Reconfigure when peer caps gain extra fields

[You don't often get email from jacopo.mondi@ideasonboard.com. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]

Hi Elliot,

On Tue, Aug 18, 2026 at 06:45:07PM +0900, elliot.chen@oss.nxp.com wrote:
> From: Elliot Chen <elliot.chen@nxp.com>
>
> After initial negotiation, a downstream element may append extra
> fields to the caps (e.g. colorimetry). The existing check only handles
> empty peer caps. Add a structure comparison to detect such changes and
> trigger reconfiguration with caps renegotiation.
>

Don't worry, I'll add
Closes: https://gitlab.freedesktop.org/camera/libcamera/-/work_items/344

When applying

> Signed-off-by: Elliot Chen <elliot.chen@nxp.com>

Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>

Nicolas: your tag was dropped, should I add it back when applying ?

Thanks
  j

>
> ---
> Changes in v3:
> - rename caps structure
>
> Changes in v2:
> - remove redundant checks both for caps and peercaps
>
> Changes in v1:
> - Initial submission
> ---
>  src/gstreamer/gstlibcamerasrc.cpp | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
>
> diff --git a/src/gstreamer/gstlibcamerasrc.cpp
> b/src/gstreamer/gstlibcamerasrc.cpp
> index 9061f9163..9541aa3f6 100644
> --- a/src/gstreamer/gstlibcamerasrc.cpp
> +++ b/src/gstreamer/gstlibcamerasrc.cpp
> @@ -744,6 +744,18 @@ gst_libcamera_src_task_run(gpointer user_data)
>                               reconfigure = true;
>                               break;
>                       }
> +
> +                     /*
> +                      * Caps may gain extra fields after the initial negotiation (e.g.
> +                      * colorimetry added by a downstream element). Detect such changes
> +                      * and trigger reconfiguration.
> +                      */
> +                     const GstStructure *caps0 = gst_caps_get_structure(caps, 0);
> +                     const GstStructure *peercaps0 = gst_caps_get_structure(peercaps, 0);
> +                     if (!gst_structure_is_equal(caps0, peercaps0)) {
> +                             reconfigure = true;
> +                             break;
> +                     }
>               }
>       }
>
> --
> 2.34.1
>

Patch
diff mbox series

diff --git a/src/gstreamer/gstlibcamerasrc.cpp b/src/gstreamer/gstlibcamerasrc.cpp
index 9061f9163..9541aa3f6 100644
--- a/src/gstreamer/gstlibcamerasrc.cpp
+++ b/src/gstreamer/gstlibcamerasrc.cpp
@@ -744,6 +744,18 @@  gst_libcamera_src_task_run(gpointer user_data)
 				reconfigure = true;
 				break;
 			}
+
+			/*
+			 * Caps may gain extra fields after the initial negotiation (e.g.
+			 * colorimetry added by a downstream element). Detect such changes
+			 * and trigger reconfiguration.
+			 */
+			const GstStructure *caps0 = gst_caps_get_structure(caps, 0);
+			const GstStructure *peercaps0 = gst_caps_get_structure(peercaps, 0);
+			if (!gst_structure_is_equal(caps0, peercaps0)) {
+				reconfigure = true;
+				break;
+			}
 		}
 	}