/src/FreeRDP/channels/rdpsnd/client/fake/rdpsnd_fake.c
Line | Count | Source (jump to first uncovered line) |
1 | | /** |
2 | | * FreeRDP: A Remote Desktop Protocol Implementation |
3 | | * Audio Output Virtual Channel |
4 | | * |
5 | | * Copyright 2019 Armin Novak <armin.novak@thincast.com> |
6 | | * Copyright 2019 Thincast Technologies GmbH |
7 | | * |
8 | | * Licensed under the Apache License, Version 2.0 (the "License"); |
9 | | * you may not use this file except in compliance with the License. |
10 | | * You may obtain a copy of the License at |
11 | | * |
12 | | * http://www.apache.org/licenses/LICENSE-2.0 |
13 | | * |
14 | | * Unless required by applicable law or agreed to in writing, software |
15 | | * distributed under the License is distributed on an "AS IS" BASIS, |
16 | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
17 | | * See the License for the specific language governing permissions and |
18 | | * limitations under the License. |
19 | | */ |
20 | | |
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(WINPR_ATTR_UNUSED rdpsndDevicePlugin* device, |
42 | | WINPR_ATTR_UNUSED const AUDIO_FORMAT* format, |
43 | | WINPR_ATTR_UNUSED UINT32 latency) |
44 | 0 | { |
45 | 0 | return TRUE; |
46 | 0 | } |
47 | | |
48 | | static void rdpsnd_fake_close(WINPR_ATTR_UNUSED rdpsndDevicePlugin* device) |
49 | 0 | { |
50 | 0 | } |
51 | | |
52 | | static BOOL rdpsnd_fake_set_volume(WINPR_ATTR_UNUSED rdpsndDevicePlugin* device, |
53 | | WINPR_ATTR_UNUSED UINT32 value) |
54 | 0 | { |
55 | 0 | return TRUE; |
56 | 0 | } |
57 | | |
58 | | static void rdpsnd_fake_free(rdpsndDevicePlugin* device) |
59 | 0 | { |
60 | 0 | rdpsndFakePlugin* fake = (rdpsndFakePlugin*)device; |
61 | |
|
62 | 0 | if (!fake) |
63 | 0 | return; |
64 | | |
65 | 0 | free(fake); |
66 | 0 | } |
67 | | |
68 | | static BOOL rdpsnd_fake_format_supported(WINPR_ATTR_UNUSED rdpsndDevicePlugin* device, |
69 | | WINPR_ATTR_UNUSED const AUDIO_FORMAT* format) |
70 | 0 | { |
71 | 0 | return TRUE; |
72 | 0 | } |
73 | | |
74 | | static UINT rdpsnd_fake_play(WINPR_ATTR_UNUSED rdpsndDevicePlugin* device, |
75 | | WINPR_ATTR_UNUSED const BYTE* data, WINPR_ATTR_UNUSED size_t size) |
76 | 0 | { |
77 | 0 | return CHANNEL_RC_OK; |
78 | 0 | } |
79 | | |
80 | | /** |
81 | | * Function description |
82 | | * |
83 | | * @return 0 on success, otherwise a Win32 error code |
84 | | */ |
85 | | static UINT rdpsnd_fake_parse_addin_args(rdpsndFakePlugin* fake, const ADDIN_ARGV* args) |
86 | 0 | { |
87 | 0 | int status = 0; |
88 | 0 | DWORD flags = 0; |
89 | 0 | const COMMAND_LINE_ARGUMENT_A* arg = NULL; |
90 | 0 | COMMAND_LINE_ARGUMENT_A rdpsnd_fake_args[] = { { NULL, 0, NULL, NULL, NULL, -1, NULL, NULL } }; |
91 | 0 | flags = |
92 | 0 | COMMAND_LINE_SIGIL_NONE | COMMAND_LINE_SEPARATOR_COLON | COMMAND_LINE_IGN_UNKNOWN_KEYWORD; |
93 | 0 | status = CommandLineParseArgumentsA(args->argc, args->argv, rdpsnd_fake_args, flags, fake, NULL, |
94 | 0 | NULL); |
95 | |
|
96 | 0 | if (status < 0) |
97 | 0 | return ERROR_INVALID_DATA; |
98 | | |
99 | 0 | arg = rdpsnd_fake_args; |
100 | |
|
101 | 0 | do |
102 | 0 | { |
103 | 0 | if (!(arg->Flags & COMMAND_LINE_VALUE_PRESENT)) |
104 | 0 | continue; |
105 | | |
106 | 0 | CommandLineSwitchStart(arg) CommandLineSwitchEnd(arg) |
107 | 0 | } while ((arg = CommandLineFindNextArgumentA(arg)) != NULL); |
108 | | |
109 | 0 | return CHANNEL_RC_OK; |
110 | 0 | } |
111 | | |
112 | | /** |
113 | | * Function description |
114 | | * |
115 | | * @return 0 on success, otherwise a Win32 error code |
116 | | */ |
117 | | FREERDP_ENTRY_POINT(UINT VCAPITYPE fake_freerdp_rdpsnd_client_subsystem_entry( |
118 | | PFREERDP_RDPSND_DEVICE_ENTRY_POINTS pEntryPoints)) |
119 | 0 | { |
120 | 0 | const ADDIN_ARGV* args = NULL; |
121 | 0 | rdpsndFakePlugin* fake = NULL; |
122 | 0 | UINT ret = CHANNEL_RC_OK; |
123 | 0 | fake = (rdpsndFakePlugin*)calloc(1, sizeof(rdpsndFakePlugin)); |
124 | |
|
125 | 0 | if (!fake) |
126 | 0 | return CHANNEL_RC_NO_MEMORY; |
127 | | |
128 | 0 | fake->device.Open = rdpsnd_fake_open; |
129 | 0 | fake->device.FormatSupported = rdpsnd_fake_format_supported; |
130 | 0 | fake->device.SetVolume = rdpsnd_fake_set_volume; |
131 | 0 | fake->device.Play = rdpsnd_fake_play; |
132 | 0 | fake->device.Close = rdpsnd_fake_close; |
133 | 0 | fake->device.Free = rdpsnd_fake_free; |
134 | 0 | args = pEntryPoints->args; |
135 | |
|
136 | 0 | if (args->argc > 1) |
137 | 0 | { |
138 | 0 | ret = rdpsnd_fake_parse_addin_args(fake, args); |
139 | |
|
140 | 0 | if (ret != CHANNEL_RC_OK) |
141 | 0 | { |
142 | 0 | WLog_ERR(TAG, "error parsing arguments"); |
143 | 0 | goto error; |
144 | 0 | } |
145 | 0 | } |
146 | | |
147 | 0 | pEntryPoints->pRegisterRdpsndDevice(pEntryPoints->rdpsnd, &fake->device); |
148 | 0 | return ret; |
149 | 0 | error: |
150 | 0 | rdpsnd_fake_free(&fake->device); |
151 | 0 | return ret; |
152 | 0 | } |