diff options
author | Robert Mader <robert.mader@collabora.com> | 2023-04-19 18:46:43 +0200 |
---|---|---|
committer | Robert Mader <robert.mader@posteo.de> | 2023-04-20 12:32:49 +0000 |
commit | 445ff6728b9d6e6007159b0baf9e24770f8c5a88 (patch) | |
tree | 28284f955084ab45c368c013ace2a978af218b83 | |
parent | 34400d7d1686d53ceaf79ff1142349a1a171db68 (diff) | |
download | weston-445ff6728b9d6e6007159b0baf9e24770f8c5a88.tar.gz |
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>
-rw-r--r-- | libweston/backend-pipewire/pipewire.c | 5 | ||||
-rw-r--r-- | pipewire/pipewire-plugin.c | 5 |
2 files changed, 8 insertions, 2 deletions
diff --git a/libweston/backend-pipewire/pipewire.c b/libweston/backend-pipewire/pipewire.c index 6586aec1..0329e914 100644 --- a/libweston/backend-pipewire/pipewire.c +++ b/libweston/backend-pipewire/pipewire.c @@ -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; diff --git a/pipewire/pipewire-plugin.c b/pipewire/pipewire-plugin.c index 748ba492..cb07521a 100644 --- a/pipewire/pipewire-plugin.c +++ b/pipewire/pipewire-plugin.c @@ -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; |