From de1c812fc978916def888b4d61678f5aee748471 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Wed, 10 Oct 2012 20:44:27 -0400 Subject: [PATCH] channels/rdpsnd: fix build on Windows --- channels/rdpsnd/ChannelOptions.cmake | 6 +-- channels/rdpsnd/client/rdpsnd_main.c | 17 ++++++- channels/rdpsnd/server/CMakeLists.txt | 2 +- channels/rdpsnd/server/rdpsnd.c | 7 ++- server/Windows/CMakeLists.txt | 4 ++ server/Windows/wf_interface.h | 4 ++ server/Windows/wf_rdpsnd.c | 69 +++++++++++++++++++++++++++ server/Windows/wf_rdpsnd.h | 32 +++++++++++++ 8 files changed, 132 insertions(+), 9 deletions(-) create mode 100644 server/Windows/wf_rdpsnd.c create mode 100644 server/Windows/wf_rdpsnd.h diff --git a/channels/rdpsnd/ChannelOptions.cmake b/channels/rdpsnd/ChannelOptions.cmake index 1b307d2ee..e22fe2f44 100644 --- a/channels/rdpsnd/ChannelOptions.cmake +++ b/channels/rdpsnd/ChannelOptions.cmake @@ -6,9 +6,5 @@ set(CHANNEL_SPECIFICATIONS "[MS-RDPEA]") string(TOUPPER "WITH_${CHANNEL_SHORT_NAME}" CHANNEL_OPTION) -if(WIN32) - option(${CHANNEL_OPTION} "Build ${CHANNEL_SHORT_NAME}" OFF) -else() - option(${CHANNEL_OPTION} "Build ${CHANNEL_SHORT_NAME}" ON) -endif() +option(${CHANNEL_OPTION} "Build ${CHANNEL_SHORT_NAME}" ON) diff --git a/channels/rdpsnd/client/rdpsnd_main.c b/channels/rdpsnd/client/rdpsnd_main.c index 182457311..fd359c4e2 100644 --- a/channels/rdpsnd/client/rdpsnd_main.c +++ b/channels/rdpsnd/client/rdpsnd_main.c @@ -80,10 +80,25 @@ struct data_out_item /* get time in milliseconds */ static UINT32 get_mstime(void) { +#ifndef _WIN32 struct timeval tp; - gettimeofday(&tp, 0); return (tp.tv_sec * 1000) + (tp.tv_usec / 1000); +#else + FILETIME ft; + UINT64 time64 = 0; + + GetSystemTimeAsFileTime(&ft); + + time64 |= ft.dwHighDateTime; + time64 <<= 32; + time64 |= ft.dwLowDateTime; + time64 /= 10000; + + /* fix epoch? */ + + return (UINT32) time64; +#endif } /* process the linked list of data that has queued to be sent */ diff --git a/channels/rdpsnd/server/CMakeLists.txt b/channels/rdpsnd/server/CMakeLists.txt index c10a5b9dc..49907f756 100644 --- a/channels/rdpsnd/server/CMakeLists.txt +++ b/channels/rdpsnd/server/CMakeLists.txt @@ -28,5 +28,5 @@ else() set(${MODULE_PREFIX}_LIBS freerdp-utils PARENT_SCOPE) endif() -set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "Channels/${MODULE_NAME}/Server") +#set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "Channels/${MODULE_NAME}/Server") diff --git a/channels/rdpsnd/server/rdpsnd.c b/channels/rdpsnd/server/rdpsnd.c index c4f261751..b56753e0e 100644 --- a/channels/rdpsnd/server/rdpsnd.c +++ b/channels/rdpsnd/server/rdpsnd.c @@ -25,6 +25,8 @@ #include #include +#include + #include #include #include @@ -127,7 +129,8 @@ static BOOL rdpsnd_server_recv_formats(rdpsnd_server* rdpsnd, STREAM* s) if (rdpsnd->context.num_client_formats > 0) { - rdpsnd->context.client_formats = xzalloc(rdpsnd->context.num_client_formats * sizeof(rdpsndFormat)); + rdpsnd->context.client_formats = (rdpsndFormat*) malloc(rdpsnd->context.num_client_formats * sizeof(rdpsndFormat)); + ZeroMemory(rdpsnd->context.client_formats, sizeof(rdpsndFormat)); for (i = 0; i < rdpsnd->context.num_client_formats; i++) { @@ -290,7 +293,7 @@ static void rdpsnd_server_select_format(rdpsnd_server_context* context, int clie if (rdpsnd->out_buffer_size < out_buffer_size) { - rdpsnd->out_buffer = realloc(rdpsnd->out_buffer, out_buffer_size); + rdpsnd->out_buffer = (BYTE*) realloc(rdpsnd->out_buffer, out_buffer_size); rdpsnd->out_buffer_size = out_buffer_size; } diff --git a/server/Windows/CMakeLists.txt b/server/Windows/CMakeLists.txt index 6c08ac469..dfe2f9743 100644 --- a/server/Windows/CMakeLists.txt +++ b/server/Windows/CMakeLists.txt @@ -33,6 +33,8 @@ set(${MODULE_PREFIX}_SRCS wf_mirage.h wf_peer.c wf_peer.h + wf_rdpsnd.c + wf_rdpsnd.h wf_settings.c wf_settings.h wf_info.c @@ -51,6 +53,8 @@ if(WITH_WIN8) set(${MODULE_PREFIX}_LIBS d3d11 dxgi dxguid) endif() +set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} freerdp-channels-server) + if(MONOLITHIC_BUILD) set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} freerdp) else() diff --git a/server/Windows/wf_interface.h b/server/Windows/wf_interface.h index 827501593..16d4be6fb 100644 --- a/server/Windows/wf_interface.h +++ b/server/Windows/wf_interface.h @@ -28,6 +28,7 @@ #include #include +#include typedef struct wf_info wfInfo; typedef struct wf_peer_context wfPeerContext; @@ -73,6 +74,9 @@ struct wf_peer_context HANDLE socketEvent; HANDLE socketThread; HANDLE socketSemaphore; + + WTSVirtualChannelManager* vcm; + rdpsnd_server_context* rdpsnd; }; struct wf_server diff --git a/server/Windows/wf_rdpsnd.c b/server/Windows/wf_rdpsnd.c new file mode 100644 index 000000000..54ea83c64 --- /dev/null +++ b/server/Windows/wf_rdpsnd.c @@ -0,0 +1,69 @@ +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * FreeRDP Windows Server (Audio Output) + * + * Copyright 2012 Marc-Andre Moreau + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include + +#include + +#include "wf_rdpsnd.h" + +static const rdpsndFormat test_audio_formats[] = +{ + { 0x11, 2, 22050, 1024, 4, 0, NULL }, /* IMA ADPCM, 22050 Hz, 2 channels */ + { 0x11, 1, 22050, 512, 4, 0, NULL }, /* IMA ADPCM, 22050 Hz, 1 channels */ + { 0x01, 2, 22050, 4, 16, 0, NULL }, /* PCM, 22050 Hz, 2 channels, 16 bits */ + { 0x01, 1, 22050, 2, 16, 0, NULL }, /* PCM, 22050 Hz, 1 channels, 16 bits */ + { 0x01, 2, 44100, 4, 16, 0, NULL }, /* PCM, 44100 Hz, 2 channels, 16 bits */ + { 0x01, 1, 44100, 2, 16, 0, NULL }, /* PCM, 44100 Hz, 1 channels, 16 bits */ + { 0x01, 2, 11025, 4, 16, 0, NULL }, /* PCM, 11025 Hz, 2 channels, 16 bits */ + { 0x01, 1, 11025, 2, 16, 0, NULL }, /* PCM, 11025 Hz, 1 channels, 16 bits */ + { 0x01, 2, 8000, 4, 16, 0, NULL }, /* PCM, 8000 Hz, 2 channels, 16 bits */ + { 0x01, 1, 8000, 2, 16, 0, NULL } /* PCM, 8000 Hz, 1 channels, 16 bits */ +}; + +static void wf_peer_rdpsnd_activated(rdpsnd_server_context* context) +{ + printf("RDPSND Activated\n"); +} + +BOOL wf_peer_rdpsnd_init(wfPeerContext* context) +{ + context->rdpsnd = rdpsnd_server_context_new(context->vcm); + context->rdpsnd->data = context; + + context->rdpsnd->server_formats = test_audio_formats; + context->rdpsnd->num_server_formats = + sizeof(test_audio_formats) / sizeof(test_audio_formats[0]); + + context->rdpsnd->src_format.wFormatTag = 1; + context->rdpsnd->src_format.nChannels = 2; + context->rdpsnd->src_format.nSamplesPerSec = 44100; + context->rdpsnd->src_format.wBitsPerSample = 16; + + context->rdpsnd->Activated = wf_peer_rdpsnd_activated; + + context->rdpsnd->Initialize(context->rdpsnd); + + return TRUE; +} diff --git a/server/Windows/wf_rdpsnd.h b/server/Windows/wf_rdpsnd.h new file mode 100644 index 000000000..0289cd245 --- /dev/null +++ b/server/Windows/wf_rdpsnd.h @@ -0,0 +1,32 @@ +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * FreeRDP Windows Server (Audio Output) + * + * Copyright 2012 Marc-Andre Moreau + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef WF_RDPSND_H +#define WF_RDPSND_H + +#include +#include +#include + +#include "wf_interface.h" + +BOOL wf_peer_rdpsnd_init(wfPeerContext* context); + +#endif /* WF_RDPSND_H */ +