[gnome-remote-desktop] vnc/pipewire-stream: Move format details helper to common area
- From: Jonas Ådahl <jadahl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-remote-desktop] vnc/pipewire-stream: Move format details helper to common area
- Date: Wed, 8 Dec 2021 09:09:50 +0000 (UTC)
commit f637b34983d2e1783d5506eb3e9f274ca19dafc0
Author: Jonas Ådahl <jadahl gmail com>
Date: Fri Nov 5 16:32:19 2021 +0100
vnc/pipewire-stream: Move format details helper to common area
It'll be used by the RDP backend too.
src/grd-pipewire-utils.c | 33 +++++++++++++++++++++++++++++++++
src/grd-pipewire-utils.h | 5 +++++
src/grd-vnc-pipewire-stream.c | 37 ++-----------------------------------
3 files changed, 40 insertions(+), 35 deletions(-)
---
diff --git a/src/grd-pipewire-utils.c b/src/grd-pipewire-utils.c
index 2d85f92..1eb0357 100644
--- a/src/grd-pipewire-utils.c
+++ b/src/grd-pipewire-utils.c
@@ -22,6 +22,7 @@
#include "grd-pipewire-utils.h"
+#include <drm_fourcc.h>
#include <linux/dma-buf.h>
#include <pipewire/pipewire.h>
#include <spa/param/video/raw.h>
@@ -81,3 +82,35 @@ grd_sync_dma_buf (int fd,
}
}
}
+
+static struct
+{
+ enum spa_video_format spa_format;
+ uint32_t drm_format;
+ int bpp;
+} format_table[] = {
+ { SPA_VIDEO_FORMAT_ARGB, DRM_FORMAT_BGRA8888, 4 },
+ { SPA_VIDEO_FORMAT_BGRA, DRM_FORMAT_ARGB8888, 4 },
+ { SPA_VIDEO_FORMAT_xRGB, DRM_FORMAT_BGRX8888, 4 },
+ { SPA_VIDEO_FORMAT_BGRx, DRM_FORMAT_XRGB8888, 4 },
+};
+
+void
+grd_get_spa_format_details (enum spa_video_format spa_format,
+ uint32_t *drm_format,
+ int *bpp)
+{
+ int i;
+
+ for (i = 0; i < G_N_ELEMENTS (format_table); i++)
+ {
+ if (format_table[i].spa_format == spa_format)
+ {
+ *drm_format = format_table[i].drm_format;
+ *bpp = format_table[i].bpp;
+ return;
+ }
+ }
+
+ g_assert_not_reached ();
+}
diff --git a/src/grd-pipewire-utils.h b/src/grd-pipewire-utils.h
index fd40651..8be6f17 100644
--- a/src/grd-pipewire-utils.h
+++ b/src/grd-pipewire-utils.h
@@ -22,6 +22,7 @@
#include <gio/gio.h>
#include <stdint.h>
+#include <spa/param/video/format-utils.h>
#include "grd-types.h"
@@ -44,4 +45,8 @@ gboolean grd_spa_pixel_format_to_grd_pixel_format (uint32_t spa_format,
void grd_sync_dma_buf (int fd,
uint64_t start_or_end);
+void grd_get_spa_format_details (enum spa_video_format spa_format,
+ uint32_t *drm_format,
+ int *bpp);
+
#endif /* GRD_PIPEWIRE_UTILS_H */
diff --git a/src/grd-vnc-pipewire-stream.c b/src/grd-vnc-pipewire-stream.c
index 98d5d0b..b79158d 100644
--- a/src/grd-vnc-pipewire-stream.c
+++ b/src/grd-vnc-pipewire-stream.c
@@ -26,7 +26,6 @@
#include <pipewire/pipewire.h>
#include <spa/param/props.h>
#include <spa/param/format-utils.h>
-#include <spa/param/video/format-utils.h>
#include <spa/utils/result.h>
#include <sys/mman.h>
@@ -347,38 +346,6 @@ copy_frame_data (GrdVncFrame *frame,
}
}
-static struct
-{
- enum spa_video_format spa_format;
- uint32_t drm_format;
- int bpp;
-} format_table[] = {
- { SPA_VIDEO_FORMAT_ARGB, DRM_FORMAT_BGRA8888, 4 },
- { SPA_VIDEO_FORMAT_BGRA, DRM_FORMAT_ARGB8888, 4 },
- { SPA_VIDEO_FORMAT_xRGB, DRM_FORMAT_BGRX8888, 4 },
- { SPA_VIDEO_FORMAT_BGRx, DRM_FORMAT_XRGB8888, 4 },
-};
-
-static void
-get_spa_format_details (enum spa_video_format spa_format,
- uint32_t *drm_format,
- int *bpp)
-{
- int i;
-
- for (i = 0; i < G_N_ELEMENTS (format_table); i++)
- {
- if (format_table[i].spa_format == spa_format)
- {
- *drm_format = format_table[i].drm_format;
- *bpp = format_table[i].bpp;
- return;
- }
- }
-
- g_assert_not_reached ();
-}
-
static void
on_dma_buf_downloaded (gboolean success,
gpointer user_data)
@@ -409,8 +376,8 @@ process_buffer (GrdVncPipeWireStream *stream,
width = stream->spa_format.size.width;
dst_stride = grd_session_vnc_get_stride_for_width (stream->session,
width);
- get_spa_format_details (stream->spa_format.format,
- &drm_format, &bpp);
+ grd_get_spa_format_details (stream->spa_format.format,
+ &drm_format, &bpp);
frame = grd_vnc_frame_new (stream, callback, user_data);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]