FreeRDP
Loading...
Searching...
No Matches
shadow_audin.c
1
20#include <freerdp/config.h>
21
22#include <freerdp/log.h>
23#include "shadow.h"
24
25#include "shadow_audin.h"
26#include <freerdp/server/server-common.h>
27
28#if defined(CHANNEL_AUDIN_SERVER)
29#include <freerdp/server/audin.h>
30#endif
31
32#if defined(CHANNEL_AUDIN_SERVER)
33
34WINPR_ATTR_NODISCARD
35static UINT AudinServerData(audin_server_context* audin, const SNDIN_DATA* data)
36{
37 rdpShadowClient* client = nullptr;
38 rdpShadowSubsystem* subsystem = nullptr;
39
40 WINPR_ASSERT(audin);
41 WINPR_ASSERT(data);
42
43 client = audin->userdata;
44 WINPR_ASSERT(client);
45 WINPR_ASSERT(client->server);
46 subsystem = client->server->subsystem;
47 WINPR_ASSERT(subsystem);
48
49 if (!client->mayInteract)
50 return CHANNEL_RC_OK;
51
52 if (!IFCALLRESULT(TRUE, subsystem->AudinServerReceiveSamples, subsystem, client,
53 audin_server_get_negotiated_format(client->audin), data->Data))
54 return ERROR_INTERNAL_ERROR;
55
56 return CHANNEL_RC_OK;
57}
58
59#endif
60
61BOOL shadow_client_audin_init(rdpShadowClient* client)
62{
63 WINPR_ASSERT(client);
64
65#if defined(CHANNEL_AUDIN_SERVER)
66 audin_server_context* audin = client->audin = audin_server_context_new(client->vcm);
67
68 if (!audin)
69 return FALSE;
70
71 audin->userdata = client;
72
73 audin->Data = AudinServerData;
74
75 if (client->subsystem->audinFormats)
76 {
77 if (client->subsystem->nAudinFormats > SSIZE_MAX)
78 goto fail;
79
80 if (!audin_server_set_formats(client->audin, (SSIZE_T)client->subsystem->nAudinFormats,
81 client->subsystem->audinFormats))
82 goto fail;
83 }
84 else
85 {
86 if (!audin_server_set_formats(client->audin, -1, nullptr))
87 goto fail;
88 }
89
90 return TRUE;
91fail:
92 audin_server_context_free(audin);
93 client->audin = nullptr;
94#endif
95 return FALSE;
96}
97
98void shadow_client_audin_uninit(rdpShadowClient* client)
99{
100 WINPR_ASSERT(client);
101
102#if defined(CHANNEL_AUDIN_SERVER)
103 audin_server_context_free(client->audin);
104 client->audin = nullptr;
105#endif
106}