gst: skip invalid crop metadata in pipewiresrc

META_VideoCrop is present on every buffer negotiated through the
adapter, even when the producer never sets a meaningful crop
region. Before commit c634ef961, gst_buffer_get_video_crop_meta
returned NULL on new GstBuffers so the zero values were never
applied. After that commit, gst_buffer_add_video_crop_meta always
succeeds, and an invalid crop produces black frames.

Without this, the following produces black frames,

Producer:

gst-launch-1.0 videotestsrc is-live=true ! \
  video/x-raw,format=I420,width=1280,height=720,framerate=24/1 ! \
  pipewiresink mode=provide \
  stream-properties="properties,media.class=Video/Source,media.role=Camera" \
  client-name=VirtualCam

Consumer:

gst-launch-1.0 pipewiresrc path=<id> ! videoconvert ! autovideosink
This commit is contained in:
Charles 2026-04-21 20:16:19 +01:00
parent 2953f48d9b
commit 17e61256c5

View file

@ -781,7 +781,7 @@ static GstBuffer *dequeue_buffer(GstPipeWireSrc *pwsrc)
}
crop = data->crop;
if (crop) {
if (crop && spa_meta_region_is_valid(crop)) {
GstVideoCropMeta *meta = gst_buffer_add_video_crop_meta(buf);
if (meta) {
meta->x = crop->region.position.x;