FreeRDP
Loading...
Searching...
No Matches
server/common/server.c
1
20#include <freerdp/config.h>
21
22#include <winpr/wtypes.h>
23#include <freerdp/codec/audio.h>
24#include <freerdp/codec/dsp.h>
25
26#include <freerdp/server/server-common.h>
27#include <freerdp/log.h>
28
29#define TAG FREERDP_TAG("server.common")
30
31size_t server_audin_get_formats(AUDIO_FORMAT** dst_formats)
32{
33 /* Default supported audio formats */
34 BYTE adpcm_data_7[] = { 0xf4, 0x07, 0x07, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00,
35 0xff, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x40, 0x00, 0xf0, 0x00,
36 0x00, 0x00, 0xcc, 0x01, 0x30, 0xff, 0x88, 0x01, 0x18, 0xff };
37 BYTE adpcm_data_3[] = { 0xf4, 0x03, 0x07, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00,
38 0xff, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x40, 0x00, 0xf0, 0x00,
39 0x00, 0x00, 0xcc, 0x01, 0x30, 0xff, 0x88, 0x01, 0x18, 0xff };
40 BYTE adpcm_data_1[] = { 0xf4, 0x01, 0x07, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00,
41 0xff, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x40, 0x00, 0xf0, 0x00,
42 0x00, 0x00, 0xcc, 0x01, 0x30, 0xff, 0x88, 0x01, 0x18, 0xff };
43 BYTE adpcm_dvi_data_7[] = { 0xf9, 0x07 };
44 BYTE adpcm_dvi_data_3[] = { 0xf9, 0x03 };
45 BYTE adpcm_dvi_data_1[] = { 0xf9, 0x01 };
46 BYTE gsm610_data[] = { 0x40, 0x01 };
47 const AUDIO_FORMAT default_supported_audio_formats[] = {
48 /* Formats sent by windows 10 server */
49 { WAVE_FORMAT_AAC_MS, 2, 44100, 24000, 4, 16, 0, nullptr },
50 { WAVE_FORMAT_AAC_MS, 2, 44100, 20000, 4, 16, 0, nullptr },
51 { WAVE_FORMAT_AAC_MS, 2, 44100, 16000, 4, 16, 0, nullptr },
52 { WAVE_FORMAT_AAC_MS, 2, 44100, 12000, 4, 16, 0, nullptr },
53 { WAVE_FORMAT_ADPCM, 2, 44100, 44359, 2048, 4, 32, adpcm_data_7 },
54 { WAVE_FORMAT_DVI_ADPCM, 2, 44100, 44251, 2048, 4, 2, adpcm_dvi_data_7 },
55 { WAVE_FORMAT_ALAW, 2, 22050, 44100, 2, 8, 0, nullptr },
56 { WAVE_FORMAT_ADPCM, 2, 22050, 22311, 1024, 4, 32, adpcm_data_3 },
57 { WAVE_FORMAT_DVI_ADPCM, 2, 22050, 22201, 1024, 4, 2, adpcm_dvi_data_3 },
58 { WAVE_FORMAT_ADPCM, 1, 44100, 22179, 1024, 4, 32, adpcm_data_7 },
59 { WAVE_FORMAT_DVI_ADPCM, 1, 44100, 22125, 1024, 4, 2, adpcm_dvi_data_7 },
60 { WAVE_FORMAT_ADPCM, 2, 11025, 11289, 512, 4, 32, adpcm_data_1 },
61 { WAVE_FORMAT_DVI_ADPCM, 2, 11025, 11177, 512, 4, 2, adpcm_dvi_data_1 },
62 { WAVE_FORMAT_ADPCM, 1, 22050, 11155, 512, 4, 32, adpcm_data_3 },
63 { WAVE_FORMAT_DVI_ADPCM, 1, 22050, 11100, 512, 4, 2, adpcm_dvi_data_3 },
64 { WAVE_FORMAT_GSM610, 1, 44100, 8957, 65, 0, 2, gsm610_data },
65 { WAVE_FORMAT_ADPCM, 2, 8000, 8192, 512, 4, 32, adpcm_data_1 },
66 { WAVE_FORMAT_DVI_ADPCM, 2, 8000, 8110, 512, 4, 2, adpcm_dvi_data_1 },
67 { WAVE_FORMAT_ADPCM, 1, 11025, 5644, 256, 4, 32, adpcm_data_1 },
68 { WAVE_FORMAT_DVI_ADPCM, 1, 11025, 5588, 256, 4, 2, adpcm_dvi_data_1 },
69 { WAVE_FORMAT_GSM610, 1, 22050, 4478, 65, 0, 2, gsm610_data },
70 { WAVE_FORMAT_ADPCM, 1, 8000, 4096, 256, 4, 32, adpcm_data_1 },
71 { WAVE_FORMAT_DVI_ADPCM, 1, 8000, 4055, 256, 4, 2, adpcm_dvi_data_1 },
72 { WAVE_FORMAT_GSM610, 1, 11025, 2239, 65, 0, 2, gsm610_data },
73 { WAVE_FORMAT_GSM610, 1, 8000, 1625, 65, 0, 2, gsm610_data },
74 /* Formats added for others */
75
76 { WAVE_FORMAT_MSG723, 2, 44100, 0, 4, 16, 0, nullptr },
77 { WAVE_FORMAT_MSG723, 2, 22050, 0, 4, 16, 0, nullptr },
78 { WAVE_FORMAT_MSG723, 1, 44100, 0, 4, 16, 0, nullptr },
79 { WAVE_FORMAT_MSG723, 1, 22050, 0, 4, 16, 0, nullptr },
80 { WAVE_FORMAT_PCM, 2, 44100, 176400, 4, 16, 0, nullptr },
81 { WAVE_FORMAT_PCM, 2, 22050, 88200, 4, 16, 0, nullptr },
82 { WAVE_FORMAT_PCM, 1, 44100, 88200, 4, 16, 0, nullptr },
83 { WAVE_FORMAT_PCM, 1, 22050, 44100, 4, 16, 0, nullptr },
84 { WAVE_FORMAT_MULAW, 2, 44100, 88200, 4, 16, 0, nullptr },
85 { WAVE_FORMAT_MULAW, 2, 22050, 44100, 4, 16, 0, nullptr },
86 { WAVE_FORMAT_MULAW, 1, 44100, 44100, 4, 16, 0, nullptr },
87 { WAVE_FORMAT_MULAW, 1, 22050, 22050, 4, 16, 0, nullptr },
88 { WAVE_FORMAT_ALAW, 2, 44100, 88200, 2, 8, 0, nullptr },
89 { WAVE_FORMAT_ALAW, 2, 22050, 44100, 2, 8, 0, nullptr },
90 { WAVE_FORMAT_ALAW, 1, 44100, 44100, 2, 8, 0, nullptr },
91 { WAVE_FORMAT_ALAW, 1, 22050, 22050, 2, 8, 0, nullptr }
92 };
93 const size_t nrDefaultFormatsMax = ARRAYSIZE(default_supported_audio_formats);
94 size_t nr_formats = 0;
95 AUDIO_FORMAT* formats = audio_formats_new(nrDefaultFormatsMax);
96
97 if (!dst_formats)
98 goto fail;
99
100 *dst_formats = nullptr;
101
102 if (!formats)
103 goto fail;
104
105 for (size_t x = 0; x < nrDefaultFormatsMax; x++)
106 {
107 const AUDIO_FORMAT* format = &default_supported_audio_formats[x];
108
109 if (freerdp_dsp_supports_format(format, FALSE))
110 {
111 AUDIO_FORMAT* dst = &formats[nr_formats++];
112
113 if (!audio_format_copy(format, dst))
114 goto fail;
115 }
116 }
117
118 *dst_formats = formats;
119 return nr_formats;
120fail:
121 audio_formats_free(formats, nrDefaultFormatsMax);
122 return 0;
123}
124
125size_t server_rdpsnd_get_formats(AUDIO_FORMAT** dst_formats)
126{
127 /* Default supported audio formats */
128 static const AUDIO_FORMAT default_supported_audio_formats[] = {
129 { WAVE_FORMAT_AAC_MS, 2, 44100, 176400, 4, 16, 0, nullptr },
130 { WAVE_FORMAT_MPEGLAYER3, 2, 44100, 176400, 4, 16, 0, nullptr },
131 { WAVE_FORMAT_MSG723, 2, 44100, 176400, 4, 16, 0, nullptr },
132 { WAVE_FORMAT_GSM610, 2, 44100, 176400, 4, 16, 0, nullptr },
133 { WAVE_FORMAT_ADPCM, 2, 44100, 176400, 4, 16, 0, nullptr },
134 { WAVE_FORMAT_PCM, 2, 44100, 176400, 4, 16, 0, nullptr },
135 { WAVE_FORMAT_ALAW, 2, 22050, 44100, 2, 8, 0, nullptr },
136 { WAVE_FORMAT_MULAW, 2, 22050, 44100, 2, 8, 0, nullptr },
137 };
138 AUDIO_FORMAT* supported_audio_formats =
139 audio_formats_new(ARRAYSIZE(default_supported_audio_formats));
140
141 if (!supported_audio_formats)
142 goto fail;
143
144 {
145 size_t y = 0;
146 for (size_t x = 0; x < ARRAYSIZE(default_supported_audio_formats); x++)
147 {
148 const AUDIO_FORMAT* format = &default_supported_audio_formats[x];
149
150 if (freerdp_dsp_supports_format(format, TRUE))
151 supported_audio_formats[y++] = *format;
152 }
153
154 /* Set default audio formats. */
155 *dst_formats = supported_audio_formats;
156 return y;
157 }
158fail:
159 audio_formats_free(supported_audio_formats, ARRAYSIZE(default_supported_audio_formats));
160
161 if (dst_formats)
162 *dst_formats = nullptr;
163
164 return 0;
165}
166
167void freerdp_server_warn_unmaintained(int argc, char* argv[])
168{
169 const char* app = (argc > 0) ? argv[0] : "INVALID_ARGV";
170 const DWORD log_level = WLOG_WARN;
171 wLog* log = WLog_Get(TAG);
172 WINPR_ASSERT(log);
173
174 if (!WLog_IsLevelActive(log, log_level))
175 return;
176
177 WLog_Print_unchecked(log, log_level, "[unmaintained] %s server is currently unmaintained!",
178 app);
179 WLog_Print_unchecked(
180 log, log_level,
181 " If problems occur please check https://github.com/FreeRDP/FreeRDP/issues for "
182 "known issues!");
183 WLog_Print_unchecked(
184 log, log_level,
185 "Be prepared to fix issues yourself though as nobody is actively working on this.");
186 WLog_Print_unchecked(
187 log, log_level,
188 " Developers hang out in https://matrix.to/#/#FreeRDP:matrix.org?via=matrix.org "
189 "- don't hesitate to ask some questions. (replies might take some time depending "
190 "on your timezone) - if you intend using this component write us a message");
191}
192
193void freerdp_server_warn_experimental(int argc, char* argv[])
194{
195 const char* app = (argc > 0) ? argv[0] : "INVALID_ARGV";
196 const DWORD log_level = WLOG_WARN;
197 wLog* log = WLog_Get(TAG);
198 WINPR_ASSERT(log);
199
200 if (!WLog_IsLevelActive(log, log_level))
201 return;
202
203 WLog_Print_unchecked(log, log_level, "[experimental] %s server is currently experimental!",
204 app);
205 WLog_Print_unchecked(
206 log, log_level,
207 " If problems occur please check https://github.com/FreeRDP/FreeRDP/issues for "
208 "known issues or create a new one!");
209 WLog_Print_unchecked(
210 log, log_level,
211 " Developers hang out in https://matrix.to/#/#FreeRDP:matrix.org?via=matrix.org "
212 "- don't hesitate to ask some questions. (replies might take some time depending "
213 "on your timezone)");
214}
215
216void freerdp_server_warn_deprecated(int argc, char* argv[])
217{
218 const char* app = (argc > 0) ? argv[0] : "INVALID_ARGV";
219 const DWORD log_level = WLOG_WARN;
220 wLog* log = WLog_Get(TAG);
221 WINPR_ASSERT(log);
222
223 if (!WLog_IsLevelActive(log, log_level))
224 return;
225
226 WLog_Print_unchecked(log, log_level, "[deprecated] %s server has been deprecated", app);
227 WLog_Print_unchecked(log, log_level, "As replacement there is a SDL based client available.");
228 WLog_Print_unchecked(
229 log, log_level,
230 "If you are interested in keeping %s alive get in touch with the developers", app);
231 WLog_Print_unchecked(
232 log, log_level,
233 "The project is hosted at https://github.com/freerdp/freerdp and "
234 " developers hang out in https://matrix.to/#/#FreeRDP:matrix.org?via=matrix.org "
235 "- don't hesitate to ask some questions. (replies might take some time depending "
236 "on your timezone)");
237}