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