FreeRDP
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Modules Pages
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
35static UINT
36encomsp_change_participant_control_level(EncomspServerContext* context,
38{
39 BOOL inLobby = 0;
40 BOOL mayView = 0;
41 BOOL mayInteract = 0;
42 rdpShadowClient* client = (rdpShadowClient*)context->custom;
43
44 WLog_INFO(TAG,
45 "ChangeParticipantControlLevel: ParticipantId: %" PRIu32 " Flags: 0x%04" PRIX16 "",
46 pdu->ParticipantId, pdu->Flags);
47
48 mayView = (pdu->Flags & ENCOMSP_MAY_VIEW) ? TRUE : FALSE;
49 mayInteract = (pdu->Flags & ENCOMSP_MAY_INTERACT) ? TRUE : FALSE;
50
51 if (mayInteract && !mayView)
52 mayView = TRUE; /* may interact implies may view */
53
54 if (mayInteract)
55 {
56 if (!client->mayInteract)
57 {
58 /* request interact + view */
59 client->mayInteract = TRUE;
60 client->mayView = TRUE;
61 }
62 }
63 else if (mayView)
64 {
65 if (client->mayInteract)
66 {
67 /* release interact */
68 client->mayInteract = FALSE;
69 }
70 else if (!client->mayView)
71 {
72 /* request view */
73 client->mayView = TRUE;
74 }
75 }
76 else
77 {
78 if (client->mayInteract)
79 {
80 /* release interact + view */
81 client->mayView = FALSE;
82 client->mayInteract = FALSE;
83 }
84 else if (client->mayView)
85 {
86 /* release view */
87 client->mayView = FALSE;
88 client->mayInteract = FALSE;
89 }
90 }
91
92 inLobby = client->mayView ? FALSE : TRUE;
93
94 if (inLobby != client->inLobby)
95 {
96 shadow_encoder_reset(client->encoder);
97 client->inLobby = inLobby;
98 }
99
100 return CHANNEL_RC_OK;
101}
102
103int shadow_client_encomsp_init(rdpShadowClient* client)
104{
105 EncomspServerContext* encomsp = NULL;
106
107 encomsp = client->encomsp = encomsp_server_context_new(client->vcm);
108
109 encomsp->rdpcontext = &client->context;
110
111 encomsp->custom = (void*)client;
112
113 encomsp->ChangeParticipantControlLevel = encomsp_change_participant_control_level;
114
115 if (client->encomsp)
116 client->encomsp->Start(client->encomsp);
117
118 return 1;
119}
120
121void shadow_client_encomsp_uninit(rdpShadowClient* client)
122{
123 if (client->encomsp)
124 {
125 client->encomsp->Stop(client->encomsp);
126 encomsp_server_context_free(client->encomsp);
127 client->encomsp = NULL;
128 }
129}