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