[gnome-remote-desktop] pipewire-utils: Add functions to check whether PipeWire buffer has data
- From: Jonas Ådahl <jadahl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-remote-desktop] pipewire-utils: Add functions to check whether PipeWire buffer has data
- Date: Thu, 3 Mar 2022 20:24:29 +0000 (UTC)
commit 7421a47e957b345851f87d7e29f5627d18e9d388
Author: Pascal Nowack <Pascal Nowack gmx de>
Date: Mon Jan 31 13:31:04 2022 +0100
pipewire-utils: Add functions to check whether PipeWire buffer has data
These two functions check whether a PipeWire buffer has frame data or
a mouse pointer bitmap.
In the next commits, they are used to determine the latest PipeWire
buffer with frame data and the latest PipeWire buffer with a mouse
pointer bitmap.
src/grd-pipewire-utils.c | 31 ++++++++++++++++++++++++++++++-
src/grd-pipewire-utils.h | 5 +++++
2 files changed, 35 insertions(+), 1 deletion(-)
---
diff --git a/src/grd-pipewire-utils.c b/src/grd-pipewire-utils.c
index 46634e62..84b36c19 100644
--- a/src/grd-pipewire-utils.c
+++ b/src/grd-pipewire-utils.c
@@ -23,7 +23,6 @@
#include "grd-pipewire-utils.h"
#include <drm_fourcc.h>
-#include <pipewire/pipewire.h>
#include <spa/param/video/raw.h>
static gboolean is_pipewire_initialized = FALSE;
@@ -38,6 +37,36 @@ grd_maybe_initialize_pipewire (void)
}
}
+gboolean
+grd_pipewire_buffer_has_pointer_bitmap (struct pw_buffer *buffer)
+{
+ struct spa_meta_cursor *spa_meta_cursor;
+
+ spa_meta_cursor = spa_buffer_find_meta_data (buffer->buffer, SPA_META_Cursor,
+ sizeof *spa_meta_cursor);
+ if (spa_meta_cursor && spa_meta_cursor_is_valid (spa_meta_cursor))
+ {
+ struct spa_meta_bitmap *spa_meta_bitmap = NULL;
+
+ if (spa_meta_cursor->bitmap_offset)
+ {
+ spa_meta_bitmap = SPA_MEMBER (spa_meta_cursor,
+ spa_meta_cursor->bitmap_offset,
+ struct spa_meta_bitmap);
+ }
+ if (spa_meta_bitmap)
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+gboolean
+grd_pipewire_buffer_has_frame_data (struct pw_buffer *buffer)
+{
+ return buffer->buffer->datas[0].chunk->size > 0;
+}
+
gboolean
grd_spa_pixel_format_to_grd_pixel_format (uint32_t spa_format,
GrdPixelFormat *out_format)
diff --git a/src/grd-pipewire-utils.h b/src/grd-pipewire-utils.h
index 830db6de..072f9949 100644
--- a/src/grd-pipewire-utils.h
+++ b/src/grd-pipewire-utils.h
@@ -21,6 +21,7 @@
#define GRD_PIPEWIRE_UTILS_H
#include <gio/gio.h>
+#include <pipewire/pipewire.h>
#include <stdint.h>
#include <spa/param/video/format-utils.h>
@@ -39,6 +40,10 @@ typedef struct _GrdPipeWireSource
void grd_maybe_initialize_pipewire (void);
+gboolean grd_pipewire_buffer_has_pointer_bitmap (struct pw_buffer *buffer);
+
+gboolean grd_pipewire_buffer_has_frame_data (struct pw_buffer *buffer);
+
gboolean grd_spa_pixel_format_to_grd_pixel_format (uint32_t spa_format,
GrdPixelFormat *out_format);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]