pipewire-[backend|plugin]: Add timestamps to buffers

In Pipewire and Gstreamer terminology Weston is a "live" source (as we
do not explicitly set PW_KEY_STREAM_IS_LIVE to false).
Such sources, be it compositors, cameras or microphones, usually set
the current system time as timestamps on buffers in order to make life
easier for consumers. Thus let's do so as well.

This notably helps when recording using `gstpipewiresrc` with the
`keepalive-time` property set.

Signed-off-by: Robert Mader <robert.mader@collabora.com>
This commit is contained in:
Robert Mader 2023-04-19 18:46:43 +02:00 committed by Robert Mader
parent 34400d7d16
commit 445ff6728b
2 changed files with 8 additions and 2 deletions

View file

@ -597,7 +597,10 @@ pipewire_submit_buffer(struct pipewire_output *output,
if ((h = spa_buffer_find_meta_data(spa_buffer, SPA_META_Header,
sizeof(struct spa_meta_header)))) {
h->pts = -1;
struct timespec ts;
clock_gettime(CLOCK_MONOTONIC, &ts);
h->pts = SPA_TIMESPEC_TO_NSEC(&ts);
h->flags = 0;
h->seq = output->seq;
h->dts_offset = 0;

View file

@ -192,7 +192,10 @@ pipewire_output_handle_frame(struct pipewire_output *output, int fd,
if ((h = spa_buffer_find_meta_data(spa_buffer, SPA_META_Header,
sizeof(struct spa_meta_header)))) {
h->pts = -1;
struct timespec ts;
clock_gettime(CLOCK_MONOTONIC, &ts);
h->pts = SPA_TIMESPEC_TO_NSEC(&ts);
h->flags = 0;
h->seq = output->seq++;
h->dts_offset = 0;