FreeRDP
rdpsnd_fake.c
1 
21 #include <freerdp/config.h>
22 
23 #include <stdio.h>
24 #include <stdlib.h>
25 #include <string.h>
26 
27 #include <winpr/crt.h>
28 #include <winpr/stream.h>
29 #include <winpr/cmdline.h>
30 
31 #include <freerdp/types.h>
32 #include <freerdp/settings.h>
33 
34 #include "rdpsnd_main.h"
35 
36 typedef struct
37 {
38  rdpsndDevicePlugin device;
39 } rdpsndFakePlugin;
40 
41 static BOOL rdpsnd_fake_open(rdpsndDevicePlugin* device, const AUDIO_FORMAT* format, UINT32 latency)
42 {
43  return TRUE;
44 }
45 
46 static void rdpsnd_fake_close(rdpsndDevicePlugin* device)
47 {
48 }
49 
50 static BOOL rdpsnd_fake_set_volume(rdpsndDevicePlugin* device, UINT32 value)
51 {
52  return TRUE;
53 }
54 
55 static void rdpsnd_fake_free(rdpsndDevicePlugin* device)
56 {
57  rdpsndFakePlugin* fake = (rdpsndFakePlugin*)device;
58 
59  if (!fake)
60  return;
61 
62  free(fake);
63 }
64 
65 static BOOL rdpsnd_fake_format_supported(rdpsndDevicePlugin* device, const AUDIO_FORMAT* format)
66 {
67  return TRUE;
68 }
69 
70 static UINT rdpsnd_fake_play(rdpsndDevicePlugin* device, const BYTE* data, size_t size)
71 {
72  return CHANNEL_RC_OK;
73 }
74 
80 static UINT rdpsnd_fake_parse_addin_args(rdpsndFakePlugin* fake, const ADDIN_ARGV* args)
81 {
82  int status = 0;
83  DWORD flags = 0;
84  const COMMAND_LINE_ARGUMENT_A* arg = NULL;
85  COMMAND_LINE_ARGUMENT_A rdpsnd_fake_args[] = { { NULL, 0, NULL, NULL, NULL, -1, NULL, NULL } };
86  flags =
87  COMMAND_LINE_SIGIL_NONE | COMMAND_LINE_SEPARATOR_COLON | COMMAND_LINE_IGN_UNKNOWN_KEYWORD;
88  status = CommandLineParseArgumentsA(args->argc, args->argv, rdpsnd_fake_args, flags, fake, NULL,
89  NULL);
90 
91  if (status < 0)
92  return ERROR_INVALID_DATA;
93 
94  arg = rdpsnd_fake_args;
95 
96  do
97  {
98  if (!(arg->Flags & COMMAND_LINE_VALUE_PRESENT))
99  continue;
100 
101  CommandLineSwitchStart(arg) CommandLineSwitchEnd(arg)
102  } while ((arg = CommandLineFindNextArgumentA(arg)) != NULL);
103 
104  return CHANNEL_RC_OK;
105 }
106 
112 FREERDP_ENTRY_POINT(UINT VCAPITYPE fake_freerdp_rdpsnd_client_subsystem_entry(
114 {
115  const ADDIN_ARGV* args = NULL;
116  rdpsndFakePlugin* fake = NULL;
117  UINT ret = CHANNEL_RC_OK;
118  fake = (rdpsndFakePlugin*)calloc(1, sizeof(rdpsndFakePlugin));
119 
120  if (!fake)
121  return CHANNEL_RC_NO_MEMORY;
122 
123  fake->device.Open = rdpsnd_fake_open;
124  fake->device.FormatSupported = rdpsnd_fake_format_supported;
125  fake->device.SetVolume = rdpsnd_fake_set_volume;
126  fake->device.Play = rdpsnd_fake_play;
127  fake->device.Close = rdpsnd_fake_close;
128  fake->device.Free = rdpsnd_fake_free;
129  args = pEntryPoints->args;
130 
131  if (args->argc > 1)
132  {
133  ret = rdpsnd_fake_parse_addin_args(fake, args);
134 
135  if (ret != CHANNEL_RC_OK)
136  {
137  WLog_ERR(TAG, "error parsing arguments");
138  goto error;
139  }
140  }
141 
142  pEntryPoints->pRegisterRdpsndDevice(pEntryPoints->rdpsnd, &fake->device);
143  return ret;
144 error:
145  rdpsnd_fake_free(&fake->device);
146  return ret;
147 }
Definition: client/rdpsnd.h:76