FreeRDP
Loading...
Searching...
No Matches
shadow_rdpsnd.c
1
19#include <freerdp/config.h>
20
21#include <winpr/crt.h>
22#include <winpr/assert.h>
23#include <winpr/cast.h>
24
25#include <freerdp/log.h>
26#include <freerdp/codec/dsp.h>
27#include <freerdp/server/server-common.h>
28
29#include "shadow.h"
30
31#include "shadow_rdpsnd.h"
32
33#define TAG SERVER_TAG("shadow")
34
35static void rdpsnd_activated(RdpsndServerContext* context)
36{
37 for (size_t i = 0; i < context->num_client_formats; i++)
38 {
39 for (size_t j = 0; j < context->num_server_formats; j++)
40 {
41 if (audio_format_compatible(&context->server_formats[j], &context->client_formats[i]))
42 {
43 context->SelectFormat(context, WINPR_ASSERTING_INT_CAST(UINT16, i));
44 return;
45 }
46 }
47 }
48
49 WLog_ERR(TAG, "Could not agree on a audio format with the server\n");
50}
51
52int shadow_client_rdpsnd_init(rdpShadowClient* client)
53{
54 RdpsndServerContext* rdpsnd = NULL;
55 rdpsnd = client->rdpsnd = rdpsnd_server_context_new(client->vcm);
56
57 if (!rdpsnd)
58 {
59 return 0;
60 }
61
62 rdpsnd->data = client;
63
64 if (client->subsystem->rdpsndFormats)
65 {
66 rdpsnd->server_formats = client->subsystem->rdpsndFormats;
67 rdpsnd->num_server_formats = client->subsystem->nRdpsndFormats;
68 }
69 else
70 {
71 rdpsnd->num_server_formats = server_rdpsnd_get_formats(&rdpsnd->server_formats);
72 }
73
74 if (rdpsnd->num_server_formats > 0)
75 rdpsnd->src_format = &rdpsnd->server_formats[0];
76
77 rdpsnd->Activated = rdpsnd_activated;
78 rdpsnd->Initialize(rdpsnd, TRUE);
79 return 1;
80}
81
82void shadow_client_rdpsnd_uninit(rdpShadowClient* client)
83{
84 if (client->rdpsnd)
85 {
86 client->rdpsnd->Stop(client->rdpsnd);
87 rdpsnd_server_context_free(client->rdpsnd);
88 client->rdpsnd = NULL;
89 }
90}