wfreerdp-server: update and fix core functionality
This commit is contained in:
parent
41236e87e3
commit
fd8bbfd3b9
@ -36,14 +36,9 @@ int IDcount = 0;
|
||||
|
||||
BOOL CALLBACK moncb(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData)
|
||||
{
|
||||
|
||||
printf("%d\t(%d, %d), (%d, %d)\n",
|
||||
IDcount,
|
||||
lprcMonitor->left,
|
||||
lprcMonitor->top,
|
||||
lprcMonitor->right,
|
||||
lprcMonitor->bottom);
|
||||
|
||||
IDcount, lprcMonitor->left, lprcMonitor->top,
|
||||
lprcMonitor->right, lprcMonitor->bottom);
|
||||
|
||||
IDcount++;
|
||||
|
||||
@ -121,7 +116,6 @@ int main(int argc, char* argv[])
|
||||
index++;
|
||||
}
|
||||
|
||||
|
||||
if (index == argc - 1)
|
||||
{
|
||||
server->port = (DWORD) atoi(argv[index]);
|
||||
@ -160,7 +154,6 @@ int main(int argc, char* argv[])
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
printf("Starting server\n");
|
||||
|
||||
wfreerdp_server_start(server);
|
||||
|
@ -88,7 +88,6 @@ int wf_info_try_lock(wfInfo* wfi, DWORD dwMilliseconds)
|
||||
|
||||
int wf_info_unlock(wfInfo* wfi)
|
||||
{
|
||||
|
||||
if (ReleaseMutex(wfi->mutex) == 0)
|
||||
{
|
||||
printf("wf_info_unlock failed with 0x%08X\n", GetLastError());
|
||||
@ -102,12 +101,6 @@ wfInfo* wf_info_init()
|
||||
{
|
||||
wfInfo* wfi;
|
||||
|
||||
/*
|
||||
OSVERSIONINFOEX osvi;
|
||||
SYSTEM_INFO si;
|
||||
BOOL bOsVersionInfoEx;
|
||||
*/
|
||||
|
||||
wfi = (wfInfo*) malloc(sizeof(wfInfo));
|
||||
ZeroMemory(wfi, sizeof(wfInfo));
|
||||
|
||||
@ -126,9 +119,6 @@ wfInfo* wf_info_init()
|
||||
_tprintf(_T("CreateMutex error: %d\n"), GetLastError());
|
||||
}
|
||||
|
||||
//wfi->updateEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
|
||||
//printf("updateEvent created\n");
|
||||
|
||||
wfi->updateSemaphore = CreateSemaphore(NULL, 0, 32, NULL);
|
||||
|
||||
wfi->updateThread = CreateThread(NULL, 0, wf_update_thread, wfi, CREATE_SUSPENDED, NULL);
|
||||
@ -165,29 +155,6 @@ wfInfo* wf_info_init()
|
||||
}
|
||||
}
|
||||
RegCloseKey(hKey);
|
||||
|
||||
//detect windows version
|
||||
/*
|
||||
ZeroMemory(&si, sizeof(SYSTEM_INFO));
|
||||
ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX));
|
||||
|
||||
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
|
||||
bOsVersionInfoEx = GetVersionEx((OSVERSIONINFO*) &osvi);
|
||||
|
||||
wfi->win8 = FALSE;
|
||||
if(bOsVersionInfoEx != 0 )
|
||||
{
|
||||
if ( VER_PLATFORM_WIN32_NT==osvi.dwPlatformId &&
|
||||
osvi.dwMajorVersion > 4 )
|
||||
{
|
||||
if ( osvi.dwMajorVersion == 6 &&
|
||||
osvi.dwMinorVersion == 2)
|
||||
{
|
||||
wfi->win8 = TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
return wfi;
|
||||
|
@ -22,11 +22,15 @@
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
|
||||
#include <winpr/tchar.h>
|
||||
#include <winpr/windows.h>
|
||||
|
||||
#include <freerdp/freerdp.h>
|
||||
#include <freerdp/listener.h>
|
||||
#include <freerdp/constants.h>
|
||||
#include <freerdp/utils/tcp.h>
|
||||
#include <freerdp\listener.h>
|
||||
#include <freerdp/channels/wtsvc.h>
|
||||
#include <freerdp/channels/channels.h>
|
||||
|
||||
#include "wf_peer.h"
|
||||
#include "wf_settings.h"
|
||||
@ -180,6 +184,8 @@ wfServer* wfreerdp_server_new()
|
||||
server->port = 3389;
|
||||
}
|
||||
|
||||
WTSRegisterWtsApiFunctionTable(FreeRDP_InitWtsApi());
|
||||
|
||||
cbEvent = NULL;
|
||||
|
||||
return server;
|
||||
@ -229,7 +235,6 @@ FREERDP_API UINT32 wfreerdp_server_get_peer_hostname(int pId, wchar_t * dstStr)
|
||||
wfi = wf_info_get_instance();
|
||||
peer = wfi->peers[pId];
|
||||
|
||||
|
||||
if (peer)
|
||||
{
|
||||
UINT32 sLen;
|
||||
@ -243,7 +248,6 @@ FREERDP_API UINT32 wfreerdp_server_get_peer_hostname(int pId, wchar_t * dstStr)
|
||||
printf("nonexistent peer id=%d\n", pId);
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
FREERDP_API BOOL wfreerdp_server_peer_is_local(int pId)
|
||||
@ -254,7 +258,6 @@ FREERDP_API BOOL wfreerdp_server_peer_is_local(int pId)
|
||||
wfi = wf_info_get_instance();
|
||||
peer = wfi->peers[pId];
|
||||
|
||||
|
||||
if (peer)
|
||||
{
|
||||
return peer->local;
|
||||
@ -264,6 +267,7 @@ FREERDP_API BOOL wfreerdp_server_peer_is_local(int pId)
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
FREERDP_API BOOL wfreerdp_server_peer_is_connected(int pId)
|
||||
{
|
||||
wfInfo* wfi;
|
||||
@ -291,7 +295,6 @@ FREERDP_API BOOL wfreerdp_server_peer_is_activated(int pId)
|
||||
wfi = wf_info_get_instance();
|
||||
peer = wfi->peers[pId];
|
||||
|
||||
|
||||
if (peer)
|
||||
{
|
||||
return peer->activated;
|
||||
@ -310,7 +313,6 @@ FREERDP_API BOOL wfreerdp_server_peer_is_authenticated(int pId)
|
||||
wfi = wf_info_get_instance();
|
||||
peer = wfi->peers[pId];
|
||||
|
||||
|
||||
if (peer)
|
||||
{
|
||||
return peer->authenticated;
|
||||
|
@ -23,11 +23,11 @@
|
||||
#endif
|
||||
|
||||
#include <winpr/tchar.h>
|
||||
#include <winpr/stream.h>
|
||||
#include <winpr/windows.h>
|
||||
|
||||
#include <freerdp/listener.h>
|
||||
#include <freerdp/codec/rfx.h>
|
||||
#include <winpr/stream.h>
|
||||
|
||||
#include "wf_info.h"
|
||||
#include "wf_input.h"
|
||||
@ -57,7 +57,7 @@ void wf_peer_context_free(freerdp_peer* client, wfPeerContext* context)
|
||||
wf_rdpsnd_unlock();
|
||||
}
|
||||
|
||||
WTSCloseServer((HANDLE) context->vcm);
|
||||
WTSCloseServer(context->vcm);
|
||||
}
|
||||
|
||||
void wf_peer_init(freerdp_peer* client)
|
||||
@ -79,7 +79,7 @@ BOOL wf_peer_post_connect(freerdp_peer* client)
|
||||
wfi = context->info;
|
||||
settings = client->settings;
|
||||
|
||||
if ( (get_screen_info(wfi->screenID, NULL, &wfi->servscreen_width, &wfi->servscreen_height, &wfi->bitsPerPixel) == 0) ||
|
||||
if ((get_screen_info(wfi->screenID, NULL, &wfi->servscreen_width, &wfi->servscreen_height, &wfi->bitsPerPixel) == 0) ||
|
||||
(wfi->servscreen_width == 0) ||
|
||||
(wfi->servscreen_height == 0) ||
|
||||
(wfi->bitsPerPixel == 0) )
|
||||
@ -254,7 +254,7 @@ DWORD WINAPI wf_peer_main_loop(LPVOID lpParam)
|
||||
|
||||
wfi = context->info;
|
||||
|
||||
if (wfi->input_disabled == TRUE)
|
||||
if (wfi->input_disabled)
|
||||
{
|
||||
printf("client input is disabled\n");
|
||||
client->input->KeyboardEvent = wf_peer_keyboard_event_dummy;
|
||||
@ -309,7 +309,7 @@ DWORD WINAPI wf_peer_main_loop(LPVOID lpParam)
|
||||
}
|
||||
|
||||
//force disconnect
|
||||
if(wfi->force_all_disconnect == TRUE)
|
||||
if (wfi->force_all_disconnect == TRUE)
|
||||
{
|
||||
printf("Forcing Disconnect -> ");
|
||||
break;
|
||||
|
@ -108,10 +108,8 @@ DWORD WINAPI wf_update_thread(LPVOID lpParam)
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void wf_update_encode(wfInfo* wfi)
|
||||
{
|
||||
|
||||
RFX_RECT rect;
|
||||
long height, width;
|
||||
BYTE* pDataBits = NULL;
|
||||
@ -135,6 +133,7 @@ void wf_update_encode(wfInfo* wfi)
|
||||
//printf("x:%d y:%d w:%d h:%d\n", wfi->invalid.left, wfi->invalid.top, width, height);
|
||||
|
||||
Stream_Clear(wfi->s);
|
||||
|
||||
rfx_compose_message(wfi->rfx_context, wfi->s, &rect, 1,
|
||||
pDataBits, width, height, stride);
|
||||
|
||||
|
@ -33,14 +33,13 @@ int wf_rdpsnd_set_latest_peer(wfPeerContext* peer)
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int wf_wasapi_activate(RdpsndServerContext* context)
|
||||
{
|
||||
wchar_t * pattern = L"Stereo Mix";
|
||||
|
||||
wf_wasapi_get_device_string(pattern, &devStr);
|
||||
|
||||
if(devStr == NULL)
|
||||
if (devStr == NULL)
|
||||
{
|
||||
_tprintf(_T("Failed to match for output device! Disabling rdpsnd.\n"));
|
||||
return 1;
|
||||
@ -99,7 +98,6 @@ int wf_wasapi_get_device_string(LPWSTR pattern, LPWSTR * deviceStr)
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
hr = pEndpoint->lpVtbl->GetId(pEndpoint, &pwszID);
|
||||
if ( FAILED(hr) )
|
||||
{
|
||||
@ -107,8 +105,6 @@ int wf_wasapi_get_device_string(LPWSTR pattern, LPWSTR * deviceStr)
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
hr = pEndpoint->lpVtbl->OpenPropertyStore(pEndpoint, STGM_READ, &pProps);
|
||||
if ( FAILED(hr) )
|
||||
{
|
||||
@ -116,7 +112,6 @@ int wf_wasapi_get_device_string(LPWSTR pattern, LPWSTR * deviceStr)
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
hr = pProps->lpVtbl->GetValue(pProps, &PKEY_Device_FriendlyName, &nameVar);
|
||||
if ( FAILED(hr) )
|
||||
{
|
||||
@ -158,7 +153,6 @@ int wf_wasapi_get_device_string(LPWSTR pattern, LPWSTR * deviceStr)
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
DWORD WINAPI wf_rdpsnd_wasapi_thread(LPVOID lpParam)
|
||||
{
|
||||
IMMDeviceEnumerator *pEnumerator = NULL;
|
||||
@ -210,7 +204,6 @@ DWORD WINAPI wf_rdpsnd_wasapi_thread(LPVOID lpParam)
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
pwfx->wFormatTag = wfi->agreed_format->wFormatTag;
|
||||
pwfx->nChannels = wfi->agreed_format->nChannels;
|
||||
pwfx->nSamplesPerSec = wfi->agreed_format->nSamplesPerSec;
|
||||
@ -220,13 +213,9 @@ DWORD WINAPI wf_rdpsnd_wasapi_thread(LPVOID lpParam)
|
||||
pwfx->cbSize = wfi->agreed_format->cbSize;
|
||||
|
||||
hr = pAudioClient->lpVtbl->Initialize(
|
||||
pAudioClient,
|
||||
AUDCLNT_SHAREMODE_SHARED,
|
||||
0,
|
||||
hnsRequestedDuration,
|
||||
0,
|
||||
pwfx,
|
||||
NULL);
|
||||
pAudioClient, AUDCLNT_SHAREMODE_SHARED, 0,
|
||||
hnsRequestedDuration, 0, pwfx, NULL);
|
||||
|
||||
if (FAILED(hr))
|
||||
{
|
||||
_tprintf(_T("Failed to initialize the audio client\n"));
|
||||
@ -247,7 +236,6 @@ DWORD WINAPI wf_rdpsnd_wasapi_thread(LPVOID lpParam)
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
hnsActualDuration = (UINT32)REFTIMES_PER_SEC * bufferFrameCount / pwfx->nSamplesPerSec;
|
||||
|
||||
hr = pAudioClient->lpVtbl->Start(pAudioClient);
|
||||
@ -262,7 +250,6 @@ DWORD WINAPI wf_rdpsnd_wasapi_thread(LPVOID lpParam)
|
||||
{
|
||||
DWORD flags;
|
||||
|
||||
|
||||
Sleep(hnsActualDuration/REFTIMES_PER_MILLISEC/2);
|
||||
|
||||
hr = pCaptureClient->lpVtbl->GetNextPacketSize(pCaptureClient, &packetLength);
|
||||
@ -272,7 +259,7 @@ DWORD WINAPI wf_rdpsnd_wasapi_thread(LPVOID lpParam)
|
||||
exit(1);
|
||||
}
|
||||
|
||||
while(packetLength != 0)
|
||||
while (packetLength != 0)
|
||||
{
|
||||
hr = pCaptureClient->lpVtbl->GetBuffer(pCaptureClient, &pData, &numFramesAvailable, &flags, NULL, NULL);
|
||||
if (FAILED(hr))
|
||||
|
Loading…
Reference in New Issue
Block a user