FreeRDP
Loading...
Searching...
No Matches
shadow_encomsp.c
1
21#include <freerdp/config.h>
22
23#include <freerdp/log.h>
24#include "shadow.h"
25
26#include "shadow_encomsp.h"
27
28#define TAG SERVER_TAG("shadow")
29
35WINPR_ATTR_NODISCARD
36static UINT
37encomsp_change_participant_control_level(EncomspServerContext* context,
39{
40 BOOL inLobby = 0;
41 BOOL mayView = 0;
42 BOOL mayInteract = 0;
43 rdpShadowClient* client = (rdpShadowClient*)context->custom;
44
45 WLog_INFO(TAG,
46 "ChangeParticipantControlLevel: ParticipantId: %" PRIu32 " Flags: 0x%04" PRIX16 "",
47 pdu->ParticipantId, pdu->Flags);
48
49 mayView = (pdu->Flags & ENCOMSP_MAY_VIEW) != 0;
50 mayInteract = (pdu->Flags & ENCOMSP_MAY_INTERACT) != 0;
51
52 if (mayInteract && !mayView)
53 mayView = TRUE; /* may interact implies may view */
54
55 if (mayInteract)
56 {
57 if (!client->mayInteract)
58 {
59 /* request interact + view */
60 client->mayInteract = TRUE;
61 client->mayView = TRUE;
62 }
63 }
64 else if (mayView)
65 {
66 if (client->mayInteract)
67 {
68 /* release interact */
69 client->mayInteract = FALSE;
70 }
71 else if (!client->mayView)
72 {
73 /* request view */
74 client->mayView = TRUE;
75 }
76 }
77 else
78 {
79 if (client->mayInteract)
80 {
81 /* release interact + view */
82 client->mayView = FALSE;
83 client->mayInteract = FALSE;
84 }
85 else if (client->mayView)
86 {
87 /* release view */
88 client->mayView = FALSE;
89 client->mayInteract = FALSE;
90 }
91 }
92
93 inLobby = !(client->mayView);
94
95 if (inLobby != client->inLobby)
96 {
97 if (shadow_encoder_reset(client->encoder) < 0)
98 return ERROR_NOT_READY;
99 client->inLobby = inLobby;
100 }
101
102 return CHANNEL_RC_OK;
103}
104
105int shadow_client_encomsp_init(rdpShadowClient* client)
106{
107 WINPR_ASSERT(client);
108
109 EncomspServerContext* encomsp = client->encomsp = encomsp_server_context_new(client->vcm);
110 if (!encomsp)
111 return -1;
112
113 encomsp->rdpcontext = &client->context;
114
115 encomsp->custom = (void*)client;
116
117 encomsp->ChangeParticipantControlLevel = encomsp_change_participant_control_level;
118
119 if (client->encomsp)
120 {
121 const UINT rc = client->encomsp->Start(client->encomsp);
122 if (rc != CHANNEL_RC_OK)
123 return -1;
124 }
125
126 return 1;
127}
128
129void shadow_client_encomsp_uninit(rdpShadowClient* client)
130{
131 WINPR_ASSERT(client);
132 if (client->encomsp)
133 {
134 client->encomsp->Stop(client->encomsp);
135 encomsp_server_context_free(client->encomsp);
136 client->encomsp = nullptr;
137 }
138}