gst: add rate control to the sink

Track the elapsed time between buffers and try to keep the buffer fill
level constant by changing the rate of the stream.

See #4374
This commit is contained in:
Wim Taymans 2024-11-26 17:45:41 +01:00
parent 22f0b858b1
commit 9419a12e74
5 changed files with 66 additions and 7 deletions

View file

@ -11,6 +11,7 @@
#include "gstpipewirecore.h"
#include <gst/gst.h>
#include <spa/utils/dll.h>
#include <pipewire/pipewire.h>
G_BEGIN_DECLS
@ -29,6 +30,13 @@ struct _GstPipeWireStream {
GstPipeWirePool *pool;
GstClock *clock;
guint64 position;
struct spa_dll dll;
double err_avg, err_var, err_wdw;
guint64 last_ts;
guint64 base_buffer_ts;
guint64 base_ts;
/* the actual pw stream */
struct pw_stream *pwstream;
struct spa_hook pwstream_listener;