2015-04-08 21:13:52 +03:00
|
|
|
/**
|
|
|
|
* FreeRDP: A Remote Desktop Protocol Implementation
|
|
|
|
*
|
|
|
|
* Copyright 2015 Jiang Zihao <zihao.jiang@yahoo.com>
|
2022-07-20 14:40:40 +03:00
|
|
|
* Copyright 2023 Pascal Nowack <Pascal.Nowack@gmx.de>
|
2015-04-08 21:13:52 +03:00
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2022-02-16 13:20:38 +03:00
|
|
|
#include <freerdp/config.h>
|
2015-04-08 21:13:52 +03:00
|
|
|
|
|
|
|
#include <freerdp/log.h>
|
|
|
|
#include "shadow.h"
|
|
|
|
|
|
|
|
#include "shadow_audin.h"
|
2018-09-25 17:45:08 +03:00
|
|
|
#include <freerdp/server/server-common.h>
|
2015-04-08 21:13:52 +03:00
|
|
|
|
2023-03-06 14:42:04 +03:00
|
|
|
#if defined(CHANNEL_AUDIN_SERVER)
|
|
|
|
#include <freerdp/server/audin.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(CHANNEL_AUDIN_SERVER)
|
2022-07-20 14:40:40 +03:00
|
|
|
|
|
|
|
static UINT AudinServerData(audin_server_context* audin, const SNDIN_DATA* data)
|
2015-04-08 21:13:52 +03:00
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
rdpShadowClient* client = NULL;
|
|
|
|
rdpShadowSubsystem* subsystem = NULL;
|
2022-07-20 14:40:40 +03:00
|
|
|
|
|
|
|
WINPR_ASSERT(audin);
|
|
|
|
WINPR_ASSERT(data);
|
|
|
|
|
|
|
|
client = audin->userdata;
|
|
|
|
WINPR_ASSERT(client);
|
|
|
|
WINPR_ASSERT(client->server);
|
|
|
|
subsystem = client->server->subsystem;
|
|
|
|
WINPR_ASSERT(subsystem);
|
2015-04-08 21:13:52 +03:00
|
|
|
|
|
|
|
if (!client->mayInteract)
|
2015-07-15 11:57:07 +03:00
|
|
|
return CHANNEL_RC_OK;
|
2015-04-08 21:13:52 +03:00
|
|
|
|
2022-07-20 14:40:40 +03:00
|
|
|
if (!IFCALLRESULT(TRUE, subsystem->AudinServerReceiveSamples, subsystem, client,
|
2023-05-16 14:47:36 +03:00
|
|
|
audin_server_get_negotiated_format(client->audin), data->Data))
|
2018-09-25 17:25:35 +03:00
|
|
|
return ERROR_INTERNAL_ERROR;
|
2018-02-20 14:15:30 +03:00
|
|
|
|
2015-07-15 11:57:07 +03:00
|
|
|
return CHANNEL_RC_OK;
|
2015-04-08 21:13:52 +03:00
|
|
|
}
|
2022-07-20 14:40:40 +03:00
|
|
|
|
2023-03-06 14:42:04 +03:00
|
|
|
#endif
|
2015-04-08 21:13:52 +03:00
|
|
|
|
2018-09-25 15:34:14 +03:00
|
|
|
BOOL shadow_client_audin_init(rdpShadowClient* client)
|
2015-04-08 21:13:52 +03:00
|
|
|
{
|
2022-07-20 14:40:40 +03:00
|
|
|
WINPR_ASSERT(client);
|
|
|
|
|
2023-03-06 14:42:04 +03:00
|
|
|
#if defined(CHANNEL_AUDIN_SERVER)
|
2023-05-16 14:47:36 +03:00
|
|
|
audin_server_context* audin = client->audin = audin_server_context_new(client->vcm);
|
2018-02-20 14:15:30 +03:00
|
|
|
|
2015-04-08 21:13:52 +03:00
|
|
|
if (!audin)
|
2018-09-25 15:34:14 +03:00
|
|
|
return FALSE;
|
2015-04-08 21:13:52 +03:00
|
|
|
|
2022-07-20 14:40:40 +03:00
|
|
|
audin->userdata = client;
|
|
|
|
|
|
|
|
audin->Data = AudinServerData;
|
2015-04-08 21:13:52 +03:00
|
|
|
|
|
|
|
if (client->subsystem->audinFormats)
|
|
|
|
{
|
2024-09-25 04:26:48 +03:00
|
|
|
if (client->subsystem->nAudinFormats > SSIZE_MAX)
|
|
|
|
goto fail;
|
|
|
|
|
|
|
|
if (!audin_server_set_formats(client->audin, (SSIZE_T)client->subsystem->nAudinFormats,
|
2023-05-16 14:47:36 +03:00
|
|
|
client->subsystem->audinFormats))
|
2018-09-25 15:34:14 +03:00
|
|
|
goto fail;
|
2015-04-08 21:13:52 +03:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2023-05-16 14:47:36 +03:00
|
|
|
if (!audin_server_set_formats(client->audin, -1, NULL))
|
|
|
|
goto fail;
|
2015-04-08 21:13:52 +03:00
|
|
|
}
|
|
|
|
|
2018-09-25 15:34:14 +03:00
|
|
|
return TRUE;
|
|
|
|
fail:
|
|
|
|
audin_server_context_free(audin);
|
|
|
|
client->audin = NULL;
|
2023-03-06 14:42:04 +03:00
|
|
|
#endif
|
2018-09-25 15:34:14 +03:00
|
|
|
return FALSE;
|
2015-04-08 21:13:52 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void shadow_client_audin_uninit(rdpShadowClient* client)
|
|
|
|
{
|
2022-07-20 14:40:40 +03:00
|
|
|
WINPR_ASSERT(client);
|
|
|
|
|
2023-03-06 14:42:04 +03:00
|
|
|
#if defined(CHANNEL_AUDIN_SERVER)
|
2023-05-16 14:47:36 +03:00
|
|
|
audin_server_context_free(client->audin);
|
|
|
|
client->audin = NULL;
|
2023-03-06 14:42:04 +03:00
|
|
|
#endif
|
2015-04-08 21:13:52 +03:00
|
|
|
}
|