From 73b8963d143aca5548f8d89289dcba2a5234cbf5 Mon Sep 17 00:00:00 2001 From: Armin Novak Date: Mon, 2 Jul 2018 16:33:50 +0200 Subject: [PATCH] Added automatic format support filter. --- server/shadow/shadow_rdpsnd.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/server/shadow/shadow_rdpsnd.c b/server/shadow/shadow_rdpsnd.c index 5e47524..2b16eda 100644 --- a/server/shadow/shadow_rdpsnd.c +++ b/server/shadow/shadow_rdpsnd.c @@ -21,6 +21,8 @@ #endif #include +#include + #include "shadow.h" #include "shadow_rdpsnd.h" @@ -30,9 +32,13 @@ /* Default supported audio formats */ static const AUDIO_FORMAT default_supported_audio_formats[] = { + { WAVE_FORMAT_AAC_MS, 2, 44100, 176400, 4, 16, 0, NULL }, + { WAVE_FORMAT_MPEGLAYER3, 2, 44100, 176400, 4, 16, 0, NULL }, + { WAVE_FORMAT_GSM610, 2, 44100, 176400, 4, 16, 0, NULL }, { WAVE_FORMAT_PCM, 2, 44100, 176400, 4, 16, 0, NULL }, - { WAVE_FORMAT_ALAW, 2, 22050, 44100, 2, 8, 0, NULL } + { WAVE_FORMAT_ALAW, 2, 22050, 44100, 2, 8, 0, NULL }, }; +static AUDIO_FORMAT supported_audio_formats[ARRAYSIZE(default_supported_audio_formats)] = { 0 }; static void rdpsnd_activated(RdpsndServerContext* context) { @@ -84,10 +90,19 @@ int shadow_client_rdpsnd_init(rdpShadowClient* client) } else { + size_t x, y = 0; + + for (x = 0; x < ARRAYSIZE(default_supported_audio_formats); x++) + { + const AUDIO_FORMAT* format = &default_supported_audio_formats[x]; + + if (freerdp_dsp_supports_format(format, TRUE)) + supported_audio_formats[y++] = *format; + } + /* Set default audio formats. */ - rdpsnd->server_formats = default_supported_audio_formats; - rdpsnd->num_server_formats = - sizeof(default_supported_audio_formats) / sizeof(default_supported_audio_formats[0]); + rdpsnd->server_formats = supported_audio_formats; + rdpsnd->num_server_formats = y; } rdpsnd->src_format = rdpsnd->server_formats[0]; -- 2.7.4