19#include <freerdp/config.h>
22#include <winpr/assert.h>
23#include <winpr/cast.h>
25#include <freerdp/log.h>
26#include <freerdp/codec/dsp.h>
27#include <freerdp/server/server-common.h>
31#include "shadow_rdpsnd.h"
33#define TAG SERVER_TAG("shadow")
35static void rdpsnd_activated(RdpsndServerContext* context)
37 WINPR_ASSERT(context);
38 for (
size_t i = 0; i < context->num_client_formats; i++)
40 for (
size_t j = 0; j < context->num_server_formats; j++)
42 if (audio_format_compatible(&context->server_formats[j], &context->client_formats[i]))
44 const UINT rc = context->SelectFormat(context, WINPR_ASSERTING_INT_CAST(UINT16, i));
45 if (rc != CHANNEL_RC_OK)
46 WLog_WARN(TAG,
"SelectFormat failed with %" PRIu32, rc);
52 WLog_ERR(TAG,
"Could not agree on a audio format with the server\n");
55int shadow_client_rdpsnd_init(rdpShadowClient* client)
58 RdpsndServerContext* rdpsnd = client->rdpsnd = rdpsnd_server_context_new(client->vcm);
65 rdpsnd->data = client;
67 if (client->subsystem->rdpsndFormats)
69 rdpsnd->server_formats = client->subsystem->rdpsndFormats;
70 rdpsnd->num_server_formats = client->subsystem->nRdpsndFormats;
74 rdpsnd->num_server_formats = server_rdpsnd_get_formats(&rdpsnd->server_formats);
77 if (rdpsnd->num_server_formats > 0)
78 rdpsnd->src_format = &rdpsnd->server_formats[0];
80 rdpsnd->Activated = rdpsnd_activated;
82 const UINT error = rdpsnd->Initialize(rdpsnd, TRUE);
83 if (error != CHANNEL_RC_OK)
88void shadow_client_rdpsnd_uninit(rdpShadowClient* client)
93 client->rdpsnd->Stop(client->rdpsnd);
94 rdpsnd_server_context_free(client->rdpsnd);
95 client->rdpsnd =
nullptr;