FreeRDP
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Modules Pages
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
34static UINT AudinServerData(audin_server_context* audin, const SNDIN_DATA* data)
35{
36 rdpShadowClient* client = NULL;
37 rdpShadowSubsystem* subsystem = NULL;
38
39 WINPR_ASSERT(audin);
40 WINPR_ASSERT(data);
41
42 client = audin->userdata;
43 WINPR_ASSERT(client);
44 WINPR_ASSERT(client->server);
45 subsystem = client->server->subsystem;
46 WINPR_ASSERT(subsystem);
47
48 if (!client->mayInteract)
49 return CHANNEL_RC_OK;
50
51 if (!IFCALLRESULT(TRUE, subsystem->AudinServerReceiveSamples, subsystem, client,
52 audin_server_get_negotiated_format(client->audin), data->Data))
53 return ERROR_INTERNAL_ERROR;
54
55 return CHANNEL_RC_OK;
56}
57
58#endif
59
60BOOL shadow_client_audin_init(rdpShadowClient* client)
61{
62 WINPR_ASSERT(client);
63
64#if defined(CHANNEL_AUDIN_SERVER)
65 audin_server_context* audin = client->audin = audin_server_context_new(client->vcm);
66
67 if (!audin)
68 return FALSE;
69
70 audin->userdata = client;
71
72 audin->Data = AudinServerData;
73
74 if (client->subsystem->audinFormats)
75 {
76 if (client->subsystem->nAudinFormats > SSIZE_MAX)
77 goto fail;
78
79 if (!audin_server_set_formats(client->audin, (SSIZE_T)client->subsystem->nAudinFormats,
80 client->subsystem->audinFormats))
81 goto fail;
82 }
83 else
84 {
85 if (!audin_server_set_formats(client->audin, -1, NULL))
86 goto fail;
87 }
88
89 return TRUE;
90fail:
91 audin_server_context_free(audin);
92 client->audin = NULL;
93#endif
94 return FALSE;
95}
96
97void shadow_client_audin_uninit(rdpShadowClient* client)
98{
99 WINPR_ASSERT(client);
100
101#if defined(CHANNEL_AUDIN_SERVER)
102 audin_server_context_free(client->audin);
103 client->audin = NULL;
104#endif
105}