gst: sink: Manage buffer pool memory manually

Let's make sure we own the memory in buffers, so that we can be
resilient to the PW link going away. This currently maintains the status
quo of copying data into the pipewirepool for sending to the remote end,
but moves the allocation of buffers so that ownership is maintained by
the sink in all cases.

There are some tricky corners, especially with bufferpool vs. buffers
param negotiation -- bufferpool parameters can be negotiated in
GStreamer before the link even comes up, so we try to adapt the buffers
param to use the negotiated value. For now, that is more brittle than
tying those two aspects together. We can revisit this if we can find a
way to tie pipeline state and link state more closely.

Co-authored-by: Arun Raghavan <arun@asymptotic.io>
This commit is contained in:
Taruntej Kanakamalla 2025-03-20 21:13:03 -04:00 committed by Wim Taymans
parent 1b258f4ecc
commit ee2c6eb41e
4 changed files with 151 additions and 37 deletions

View file

@ -9,6 +9,7 @@
#include <gst/gst.h>
#include <gst/audio/audio.h>
#include <gst/video/video.h>
#include <pipewire/pipewire.h>
@ -40,14 +41,19 @@ struct _GstPipeWirePool {
GWeakRef stream;
guint n_buffers;
gboolean has_video;
gboolean add_metavideo;
GstAudioInfo audio_info;
GstVideoInfo video_info;
GstVideoAlignment video_align;
GstAllocator *fd_allocator;
GstAllocator *dmabuf_allocator;
GstAllocator *shm_allocator;
GCond cond;
gboolean paused;
gboolean allocate_memory;
};
enum GstPipeWirePoolMode {