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