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

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

Commit Message

Elliot Chen (OSS) Aug. 18, 2026, 3:10 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 v2:
- remove redundant checks both for caps and peercaps

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

Patch
diff mbox series

diff --git a/src/gstreamer/gstlibcamerasrc.cpp b/src/gstreamer/gstlibcamerasrc.cpp
index 9061f9163..24a4293a5 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 *CapsStruct = gst_caps_get_structure(caps, 0);
+			const GstStructure *peerCapsStruct = gst_caps_get_structure(peercaps, 0);
+			if (!gst_structure_is_equal(CapsStruct, peerCapsStruct)) {
+				reconfigure = true;
+				break;
+			}
 		}
 	}