mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -05:00 
			
		
		
		
	libcamera: Implement proper dmabuf negotiation support
According to https://docs.pipewire.org/page_dma_buf.html, i.e. announce
each format once with, once without `SPA_FORMAT_VIDEO_modifier`
property.
Note: currently libcamera always uses `DRM_FORMAT_MOD_LINEAR` (`== 0`),
so `pix.modifier()` returning `0` does not mean that no modifier is
supported.
This is needed for clients using the new DMABuf negotiation pattern,
such as gstpipewiresrc after 602aa7d5.
			
			
This commit is contained in:
		
							parent
							
								
									1e6920c33b
								
							
						
					
					
						commit
						950b62a8d8
					
				
					 1 changed files with 52 additions and 42 deletions
				
			
		| 
						 | 
					@ -326,6 +326,10 @@ next_fmt:
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	port->size_index++;
 | 
						port->size_index++;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						for (i = 0; i < 2; i++) {
 | 
				
			||||||
 | 
							if (i > 0)
 | 
				
			||||||
 | 
								result.index = result.next++;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		spa_pod_builder_init(&b, buffer, sizeof(buffer));
 | 
							spa_pod_builder_init(&b, buffer, sizeof(buffer));
 | 
				
			||||||
		spa_pod_builder_push_object(&b, &f[0], SPA_TYPE_OBJECT_Format, SPA_PARAM_EnumFormat);
 | 
							spa_pod_builder_push_object(&b, &f[0], SPA_TYPE_OBJECT_Format, SPA_PARAM_EnumFormat);
 | 
				
			||||||
		spa_pod_builder_add(&b,
 | 
							spa_pod_builder_add(&b,
 | 
				
			||||||
| 
						 | 
					@ -337,12 +341,13 @@ next_fmt:
 | 
				
			||||||
			spa_pod_builder_prop(&b, SPA_FORMAT_VIDEO_format, 0);
 | 
								spa_pod_builder_prop(&b, SPA_FORMAT_VIDEO_format, 0);
 | 
				
			||||||
			spa_pod_builder_id(&b, info->format);
 | 
								spa_pod_builder_id(&b, info->format);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	if (info->pix.modifier()) {
 | 
					
 | 
				
			||||||
		spa_pod_builder_prop(&b, SPA_FORMAT_VIDEO_modifier, 0);
 | 
							if (i == 0) {
 | 
				
			||||||
 | 
								spa_pod_builder_prop(&b, SPA_FORMAT_VIDEO_modifier, SPA_POD_PROP_FLAG_MANDATORY);
 | 
				
			||||||
			spa_pod_builder_long(&b, info->pix.modifier());
 | 
								spa_pod_builder_long(&b, info->pix.modifier());
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	spa_pod_builder_prop(&b, SPA_FORMAT_VIDEO_size, 0);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							spa_pod_builder_prop(&b, SPA_FORMAT_VIDEO_size, 0);
 | 
				
			||||||
		if (sizeRange.hStep != 0 && sizeRange.vStep != 0) {
 | 
							if (sizeRange.hStep != 0 && sizeRange.vStep != 0) {
 | 
				
			||||||
			spa_pod_builder_push_choice(&b, &f[1], SPA_CHOICE_Step, 0);
 | 
								spa_pod_builder_push_choice(&b, &f[1], SPA_CHOICE_Step, 0);
 | 
				
			||||||
			spa_pod_builder_frame(&b, &f[1]);
 | 
								spa_pod_builder_frame(&b, &f[1]);
 | 
				
			||||||
| 
						 | 
					@ -366,10 +371,15 @@ next_fmt:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		fmt = (struct spa_pod*) spa_pod_builder_pop(&b, &f[0]);
 | 
							fmt = (struct spa_pod*) spa_pod_builder_pop(&b, &f[0]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (spa_pod_filter(&b, &result.param, fmt, filter) < 0)
 | 
							if (spa_pod_filter(&b, &result.param, fmt, filter) < 0) {
 | 
				
			||||||
 | 
								if (i == 0)
 | 
				
			||||||
 | 
									continue;
 | 
				
			||||||
 | 
								else
 | 
				
			||||||
				goto next;
 | 
									goto next;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		spa_node_emit_result(&impl->hooks, seq, 0, SPA_RESULT_TYPE_NODE_PARAMS, &result);
 | 
							spa_node_emit_result(&impl->hooks, seq, 0, SPA_RESULT_TYPE_NODE_PARAMS, &result);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (++count != num)
 | 
						if (++count != num)
 | 
				
			||||||
		goto next;
 | 
							goto next;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue