gldmabufbufferpool: allow the dmabuf_pool configuration to change

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6792>
This commit is contained in:
Nicolas Dufresne 2024-08-29 14:37:36 +02:00
parent 533d115659
commit 5b55930db8

View file

@ -57,6 +57,7 @@ gst_gl_dmabuf_buffer_pool_set_config (GstBufferPool * pool,
{ {
GstGLDMABufBufferPool *self = GST_GL_DMABUF_BUFFER_POOL (pool); GstGLDMABufBufferPool *self = GST_GL_DMABUF_BUFFER_POOL (pool);
GstStructure *dma_config;
GstAllocator *allocator = NULL; GstAllocator *allocator = NULL;
GstAllocationParams alloc_params; GstAllocationParams alloc_params;
GstGLAllocationParams *glparams; GstGLAllocationParams *glparams;
@ -123,6 +124,34 @@ gst_gl_dmabuf_buffer_pool_set_config (GstBufferPool * pool,
self->priv->add_glsyncmeta = gst_buffer_pool_config_has_option (config, self->priv->add_glsyncmeta = gst_buffer_pool_config_has_option (config,
GST_BUFFER_POOL_OPTION_GL_SYNC_META); GST_BUFFER_POOL_OPTION_GL_SYNC_META);
/* Now configure the dma-buf pool, and sync the config */
dma_config = gst_buffer_pool_get_config (self->priv->dmabuf_pool);
gst_buffer_pool_config_set_params (dma_config, caps, size, min, max);
gst_buffer_pool_config_add_option (dma_config,
GST_BUFFER_POOL_OPTION_VIDEO_ALIGNMENT);
gst_buffer_pool_config_set_video_alignment (dma_config, &video_align);
if (!gst_buffer_pool_set_config (self->priv->dmabuf_pool, dma_config)) {
dma_config = gst_buffer_pool_get_config (self->priv->dmabuf_pool);
if (!gst_buffer_pool_config_validate_params (dma_config, caps, size, min,
max)) {
gst_structure_free (config);
return FALSE;
}
if (!gst_buffer_pool_config_get_params (dma_config, &caps, &size, &min,
&max)) {
gst_structure_free (dma_config);
goto wrong_config;
}
if (!gst_buffer_pool_set_config (self->priv->dmabuf_pool, dma_config))
return FALSE;
gst_buffer_pool_config_set_params (config, caps, size, min, max);
}
if (!GST_BUFFER_POOL_CLASS (parent_class)->set_config (pool, config)) { if (!GST_BUFFER_POOL_CLASS (parent_class)->set_config (pool, config)) {
return FALSE; return FALSE;
} }
@ -135,15 +164,7 @@ gst_gl_dmabuf_buffer_pool_set_config (GstBufferPool * pool,
self->priv->glparams->parent.alloc_flags |= self->priv->glparams->parent.alloc_flags |=
GST_GL_ALLOCATION_PARAMS_ALLOC_FLAG_WRAP_GPU_HANDLE; GST_GL_ALLOCATION_PARAMS_ALLOC_FLAG_WRAP_GPU_HANDLE;
/* Now configure the dma-buf pool. */ return TRUE;
config = gst_buffer_pool_get_config (self->priv->dmabuf_pool);
gst_buffer_pool_config_set_params (config, caps, size, min, max);
gst_buffer_pool_config_add_option (config,
GST_BUFFER_POOL_OPTION_VIDEO_ALIGNMENT);
gst_buffer_pool_config_set_video_alignment (config, &video_align);
return gst_buffer_pool_set_config (self->priv->dmabuf_pool, config);
wrong_config: wrong_config:
{ {