FreeRDP
Loading...
Searching...
No Matches
mutter_shadow.h
1
19#ifndef FREERDP_SERVER_SHADOW_MUTTER_SHADOW_H
20#define FREERDP_SERVER_SHADOW_MUTTER_SHADOW_H
21
22#include <freerdp/server/shadow.h>
23#include <freerdp/codec/audio.h>
24
25#include <winpr/crt.h>
26#include <winpr/synch.h>
27#include <winpr/thread.h>
28#include <winpr/stream.h>
29
30#include <systemd/sd-bus.h>
31#include <pipewire/pipewire.h>
32#include <libei.h>
33
34#define MUTTER_SHADOW_MAX_MONITORS 16
35#define MUTTER_SHADOW_CONNECTOR_SIZE 64
36
37typedef struct mutter_shadow_subsystem mutterShadowSubsystem;
38
40{
41 rdpShadowSubsystem common;
42
43 /* the session bus, and the remote desktop and screen cast sessions on it;
44 * used by the init and then only by the subsystem thread */
45 sd_bus* bus;
46 sd_bus_slot* streamAddedSlot;
47 sd_bus_slot* closedSlot;
48 sd_bus_slot* ownerSlot; /* GNOME Shell leaving the bus */
49 char* rdSessionPath;
50 char* scSessionPath;
51 char* streamPath;
52 char* mappingId; /* ties the stream to its libei region */
53 UINT32 nodeId;
54 BOOL haveNode;
55 BOOL closed;
56 BOOL shellGone;
57 BOOL monitorGone; /* the shared monitor left the layout */
58 BOOL closedLogged;
59 BOOL streamGone; /* Mutter ended the stream (the monitor's layout changed) */
60 UINT64 streamGoneAt;
61 BOOL awaitNode; /* a stream recorded again waits for its PipeWire node */
62 BOOL reconnect; /* that node is there: connect the PipeWire stream to it */
63
64 /* FREERDP_SHADOW_MUTTER_VIRTUAL=<w>x<h>: a monitor of its own for this server
65 * (RecordVirtual), for a session started without one (a headless GNOME),
66 * instead of a mirror of an existing monitor */
67 BOOL virtualMonitor;
68 UINT32 virtualWidth;
69 UINT32 virtualHeight;
70
71 /* the monitors as Mutter lays them out, and their connectors */
72 char connectors[MUTTER_SHADOW_MAX_MONITORS][MUTTER_SHADOW_CONNECTOR_SIZE];
73
74 /* PipeWire: the stream of the shared monitor, only in the subsystem thread
75 * once started. width and height are the stream's, which the surface follows */
76 struct pw_loop* loop;
77 struct pw_context* context;
78 struct pw_core* core;
79 struct spa_hook coreListener;
80 struct pw_registry* registry; /* tells when Mutter's node goes away */
81 struct spa_hook registryListener;
82 struct pw_stream* stream;
83 struct spa_hook streamListener;
84 UINT32 width;
85 UINT32 height;
86 UINT32 format; /* FreeRDP pixel format of the stream */
87 BOOL haveFormat;
88 BOOL started;
89 BOOL fullPaint;
90
91 /* the check for changes Mutter left out of its damage (mutter_repair_missed_damage) */
92 BOOL damageCheck;
93 BOOL damageMissSeen;
94 UINT64 damageFrames;
95 UINT64 damageTiles;
96 UINT64 damageLogged;
97
98 /* libei, under eiLock: the client threads post input, the subsystem
99 * thread reads its events */
100 CRITICAL_SECTION eiLock;
101 struct ei* ei;
102 struct ei_device* keyboard;
103 struct ei_device* pointer;
104 BOOL keyboardReady;
105 BOOL pointerReady;
106 uint32_t sequence;
107 uint32_t lockedMods;
108 BOOL lockedModsKnown;
109 UINT64 pointerInput; /* when a client last moved the pointer */
110
111 /* the cursor the clients draw: its last shape and position */
112 UINT32 cursorHash;
113 BOOL cursorKnown;
114 BOOL cursorResend;
115 BYTE* cursorPixels; /* the last shape, RGBA: Mutter only sends a shape when it changes */
116 UINT32 cursorWidth;
117 UINT32 cursorHeight;
118 UINT32 cursorXHot;
119 UINT32 cursorYHot;
120 INT32 cursorX;
121 INT32 cursorY;
122
123 /* sound: a capture of the default sink's monitor, running only while
124 * clients are connected; samples go out in messages of 20 ms */
125 struct pw_stream* audio;
126 struct spa_hook audioListener;
127 wStream* audioStream;
128 /* the format of the samples in each message: it outlives every client, since
129 * rdpsnd keeps the pointer as its source format */
130 AUDIO_FORMAT audioSourceFormat;
131 BOOL audioActive;
132 UINT64 audioFrames;
133 UINT64 audioMessages;
134 float audioPeak;
135 UINT64 audioLogged;
136
137 /* clipboard: D-Bus on the subsystem thread; an application may stall the pipes
138 * of a transfer, so the data moves on a thread of its own */
139 BOOL clipboardEnabled;
140 sd_bus_slot* selectionOwnerSlot;
141 sd_bus_slot* selectionTransferSlot;
142 wMessageQueue* clipboardJobs;
143 HANDLE clipboardThread;
144
145 /* the clients connected; the event tells the thread the count changed */
146 volatile LONG clients;
147 HANDLE clientsEvent;
148
149 HANDLE thread;
150 HANDLE stopEvent;
151};
152
153#endif /* FREERDP_SERVER_SHADOW_MUTTER_SHADOW_H */