Blame server/shadow/shadow_encomsp.c

Packit Service fa4841
/**
Packit Service fa4841
 * FreeRDP: A Remote Desktop Protocol Implementation
Packit Service fa4841
 *
Packit Service fa4841
 * Copyright 2014 Marc-Andre Moreau <marcandre.moreau@gmail.com>
Packit Service fa4841
 * Copyright 2015 Thincast Technologies GmbH
Packit Service fa4841
 * Copyright 2015 DI (FH) Martin Haimberger <martin.haimberger@thincast.com>
Packit Service fa4841
 *
Packit Service fa4841
 * Licensed under the Apache License, Version 2.0 (the "License");
Packit Service fa4841
 * you may not use this file except in compliance with the License.
Packit Service fa4841
 * You may obtain a copy of the License at
Packit Service fa4841
 *
Packit Service fa4841
 *     http://www.apache.org/licenses/LICENSE-2.0
Packit Service fa4841
 *
Packit Service fa4841
 * Unless required by applicable law or agreed to in writing, software
Packit Service fa4841
 * distributed under the License is distributed on an "AS IS" BASIS,
Packit Service fa4841
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Packit Service fa4841
 * See the License for the specific language governing permissions and
Packit Service fa4841
 * limitations under the License.
Packit Service fa4841
 */
Packit Service fa4841
Packit Service fa4841
#ifdef HAVE_CONFIG_H
Packit Service fa4841
#include "config.h"
Packit Service fa4841
#endif
Packit Service fa4841
Packit Service fa4841
#include <freerdp/log.h>
Packit Service fa4841
#include "shadow.h"
Packit Service fa4841
Packit Service fa4841
#include "shadow_encomsp.h"
Packit Service fa4841
Packit Service fa4841
#define TAG SERVER_TAG("shadow")
Packit Service fa4841
Packit Service fa4841
/**
Packit Service fa4841
 * Function description
Packit Service fa4841
 *
Packit Service fa4841
 * @return 0 on success, otherwise a Win32 error code
Packit Service fa4841
 */
Packit Service b1ea74
static UINT
Packit Service b1ea74
encomsp_change_participant_control_level(EncomspServerContext* context,
Packit Service b1ea74
                                         ENCOMSP_CHANGE_PARTICIPANT_CONTROL_LEVEL_PDU* pdu)
Packit Service fa4841
{
Packit Service fa4841
	BOOL inLobby;
Packit Service fa4841
	BOOL mayView;
Packit Service fa4841
	BOOL mayInteract;
Packit Service b1ea74
	rdpShadowClient* client = (rdpShadowClient*)context->custom;
Packit Service fa4841
Packit Service b1ea74
	WLog_INFO(TAG,
Packit Service b1ea74
	          "ChangeParticipantControlLevel: ParticipantId: %" PRIu32 " Flags: 0x%04" PRIX16 "",
Packit Service b1ea74
	          pdu->ParticipantId, pdu->Flags);
Packit Service fa4841
Packit Service fa4841
	mayView = (pdu->Flags & ENCOMSP_MAY_VIEW) ? TRUE : FALSE;
Packit Service fa4841
	mayInteract = (pdu->Flags & ENCOMSP_MAY_INTERACT) ? TRUE : FALSE;
Packit Service fa4841
Packit Service fa4841
	if (mayInteract && !mayView)
Packit Service fa4841
		mayView = TRUE; /* may interact implies may view */
Packit Service fa4841
Packit Service fa4841
	if (mayInteract)
Packit Service fa4841
	{
Packit Service fa4841
		if (!client->mayInteract)
Packit Service fa4841
		{
Packit Service fa4841
			/* request interact + view */
Packit Service fa4841
			client->mayInteract = TRUE;
Packit Service fa4841
			client->mayView = TRUE;
Packit Service fa4841
		}
Packit Service fa4841
	}
Packit Service fa4841
	else if (mayView)
Packit Service fa4841
	{
Packit Service fa4841
		if (client->mayInteract)
Packit Service fa4841
		{
Packit Service fa4841
			/* release interact */
Packit Service fa4841
			client->mayInteract = FALSE;
Packit Service fa4841
		}
Packit Service fa4841
		else if (!client->mayView)
Packit Service fa4841
		{
Packit Service fa4841
			/* request view */
Packit Service fa4841
			client->mayView = TRUE;
Packit Service fa4841
		}
Packit Service fa4841
	}
Packit Service fa4841
	else
Packit Service fa4841
	{
Packit Service fa4841
		if (client->mayInteract)
Packit Service fa4841
		{
Packit Service fa4841
			/* release interact + view */
Packit Service fa4841
			client->mayView = FALSE;
Packit Service fa4841
			client->mayInteract = FALSE;
Packit Service fa4841
		}
Packit Service fa4841
		else if (client->mayView)
Packit Service fa4841
		{
Packit Service fa4841
			/* release view */
Packit Service fa4841
			client->mayView = FALSE;
Packit Service fa4841
			client->mayInteract = FALSE;
Packit Service fa4841
		}
Packit Service fa4841
	}
Packit Service fa4841
Packit Service fa4841
	inLobby = client->mayView ? FALSE : TRUE;
Packit Service fa4841
Packit Service fa4841
	if (inLobby != client->inLobby)
Packit Service fa4841
	{
Packit Service fa4841
		shadow_encoder_reset(client->encoder);
Packit Service fa4841
		client->inLobby = inLobby;
Packit Service fa4841
	}
Packit Service fa4841
Packit Service fa4841
	return CHANNEL_RC_OK;
Packit Service fa4841
}
Packit Service fa4841
Packit Service fa4841
int shadow_client_encomsp_init(rdpShadowClient* client)
Packit Service fa4841
{
Packit Service fa4841
	EncomspServerContext* encomsp;
Packit Service fa4841
Packit Service fa4841
	encomsp = client->encomsp = encomsp_server_context_new(client->vcm);
Packit Service fa4841
Packit Service fa4841
	encomsp->rdpcontext = &client->context;
Packit Service fa4841
Packit Service b1ea74
	encomsp->custom = (void*)client;
Packit Service fa4841
Packit Service fa4841
	encomsp->ChangeParticipantControlLevel = encomsp_change_participant_control_level;
Packit Service fa4841
Packit Service fa4841
	if (client->encomsp)
Packit Service fa4841
		client->encomsp->Start(client->encomsp);
Packit Service fa4841
Packit Service fa4841
	return 1;
Packit Service fa4841
}
Packit Service fa4841
Packit Service fa4841
void shadow_client_encomsp_uninit(rdpShadowClient* client)
Packit Service fa4841
{
Packit Service b1ea74
	if (client->encomsp)
Packit Service b1ea74
	{
Packit Service fa4841
		client->encomsp->Stop(client->encomsp);
Packit Service fa4841
		encomsp_server_context_free(client->encomsp);
Packit Service fa4841
		client->encomsp = NULL;
Packit Service fa4841
	}
Packit Service fa4841
}