rdpsnd: using new VirtualChannelEx api
This commit is contained in:
parent
088a04fa44
commit
d29848f383
@ -1288,7 +1288,7 @@ BOOL VCAPITYPE VirtualChannelEntryEx(PCHANNEL_ENTRY_POINTS pEntryPoints, PVOID p
|
|||||||
|
|
||||||
cliprdr->InitHandle = pInitHandle;
|
cliprdr->InitHandle = pInitHandle;
|
||||||
|
|
||||||
rc = cliprdr->channelEntryPoints.pVirtualChannelInitEx((void*) cliprdr, &cliprdr->InitHandle,
|
rc = cliprdr->channelEntryPoints.pVirtualChannelInitEx((void*) cliprdr, pInitHandle,
|
||||||
&cliprdr->channelDef, 1, VIRTUAL_CHANNEL_VERSION_WIN2000,
|
&cliprdr->channelDef, 1, VIRTUAL_CHANNEL_VERSION_WIN2000,
|
||||||
cliprdr_virtual_channel_init_event_ex);
|
cliprdr_virtual_channel_init_event_ex);
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ set(${MODULE_PREFIX}_SRCS
|
|||||||
rdpsnd_main.c
|
rdpsnd_main.c
|
||||||
rdpsnd_main.h)
|
rdpsnd_main.h)
|
||||||
|
|
||||||
add_channel_client_library(${MODULE_PREFIX} ${MODULE_NAME} ${CHANNEL_NAME} FALSE "VirtualChannelEntry")
|
add_channel_client_library(${MODULE_PREFIX} ${MODULE_NAME} ${CHANNEL_NAME} FALSE "VirtualChannelEntryEx")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@
|
|||||||
struct rdpsnd_plugin
|
struct rdpsnd_plugin
|
||||||
{
|
{
|
||||||
CHANNEL_DEF channelDef;
|
CHANNEL_DEF channelDef;
|
||||||
CHANNEL_ENTRY_POINTS_FREERDP channelEntryPoints;
|
CHANNEL_ENTRY_POINTS_FREERDP_EX channelEntryPoints;
|
||||||
|
|
||||||
HANDLE thread;
|
HANDLE thread;
|
||||||
wStream* data_in;
|
wStream* data_in;
|
||||||
@ -93,8 +93,6 @@ struct rdpsnd_plugin
|
|||||||
rdpContext* rdpcontext;
|
rdpContext* rdpcontext;
|
||||||
};
|
};
|
||||||
|
|
||||||
static rdpChannelHandles g_ChannelHandles = { NULL, NULL };
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function description
|
* Function description
|
||||||
*
|
*
|
||||||
@ -1130,14 +1128,14 @@ UINT rdpsnd_virtual_channel_write(rdpsndPlugin* rdpsnd, wStream* s)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
status = rdpsnd->channelEntryPoints.pVirtualChannelWrite(rdpsnd->OpenHandle,
|
status = rdpsnd->channelEntryPoints.pVirtualChannelWriteEx(rdpsnd->InitHandle, rdpsnd->OpenHandle,
|
||||||
Stream_Buffer(s), (UINT32) Stream_GetPosition(s), s);
|
Stream_Buffer(s), (UINT32) Stream_GetPosition(s), s);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (status != CHANNEL_RC_OK)
|
if (status != CHANNEL_RC_OK)
|
||||||
{
|
{
|
||||||
Stream_Free(s, TRUE);
|
Stream_Free(s, TRUE);
|
||||||
WLog_ERR(TAG, "VirtualChannelWrite failed with %s [%08X]",
|
WLog_ERR(TAG, "pVirtualChannelWriteEx failed with %s [%08X]",
|
||||||
WTSErrorToString(status), status);
|
WTSErrorToString(status), status);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1205,16 +1203,15 @@ static UINT rdpsnd_virtual_channel_event_data_received(rdpsndPlugin* plugin,
|
|||||||
return CHANNEL_RC_OK;
|
return CHANNEL_RC_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static VOID VCAPITYPE rdpsnd_virtual_channel_open_event(DWORD openHandle,
|
static VOID VCAPITYPE rdpsnd_virtual_channel_open_event_ex(LPVOID lpUserParam, DWORD openHandle, UINT event,
|
||||||
UINT event,
|
|
||||||
LPVOID pData, UINT32 dataLength, UINT32 totalLength, UINT32 dataFlags)
|
LPVOID pData, UINT32 dataLength, UINT32 totalLength, UINT32 dataFlags)
|
||||||
{
|
{
|
||||||
UINT error = CHANNEL_RC_OK;
|
UINT error = CHANNEL_RC_OK;
|
||||||
rdpsndPlugin* rdpsnd = (rdpsndPlugin*) freerdp_channel_get_open_handle_data(&g_ChannelHandles, openHandle);
|
rdpsndPlugin* rdpsnd = (rdpsndPlugin*) lpUserParam;
|
||||||
|
|
||||||
if (!rdpsnd || (rdpsnd->OpenHandle != openHandle))
|
if (!rdpsnd || (rdpsnd->OpenHandle != openHandle))
|
||||||
{
|
{
|
||||||
WLog_ERR(TAG, "rdpsnd_virtual_channel_open_event: error no match");
|
WLog_ERR(TAG, "error no match");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1238,7 +1235,7 @@ static VOID VCAPITYPE rdpsnd_virtual_channel_open_event(DWORD openHandle,
|
|||||||
|
|
||||||
if (error && rdpsnd->rdpcontext)
|
if (error && rdpsnd->rdpcontext)
|
||||||
setChannelError(rdpsnd->rdpcontext, error,
|
setChannelError(rdpsnd->rdpcontext, error,
|
||||||
"rdpsnd_virtual_channel_open_event reported an error");
|
"rdpsnd_virtual_channel_open_event_ex reported an error");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void* rdpsnd_virtual_channel_client_thread(void* arg)
|
static void* rdpsnd_virtual_channel_client_thread(void* arg)
|
||||||
@ -1305,19 +1302,17 @@ static UINT rdpsnd_virtual_channel_event_connected(rdpsndPlugin* rdpsnd,
|
|||||||
LPVOID pData, UINT32 dataLength)
|
LPVOID pData, UINT32 dataLength)
|
||||||
{
|
{
|
||||||
UINT32 status;
|
UINT32 status;
|
||||||
status = rdpsnd->channelEntryPoints.pVirtualChannelOpen(rdpsnd->InitHandle,
|
status = rdpsnd->channelEntryPoints.pVirtualChannelOpenEx(rdpsnd->InitHandle,
|
||||||
&rdpsnd->OpenHandle, rdpsnd->channelDef.name,
|
&rdpsnd->OpenHandle, rdpsnd->channelDef.name,
|
||||||
rdpsnd_virtual_channel_open_event);
|
rdpsnd_virtual_channel_open_event_ex);
|
||||||
|
|
||||||
if (status != CHANNEL_RC_OK)
|
if (status != CHANNEL_RC_OK)
|
||||||
{
|
{
|
||||||
WLog_ERR(TAG, "pVirtualChannelOpen failed with %s [%08X]",
|
WLog_ERR(TAG, "pVirtualChannelOpenEx failed with %s [%08X]",
|
||||||
WTSErrorToString(status), status);
|
WTSErrorToString(status), status);
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
freerdp_channel_add_open_handle_data(&g_ChannelHandles, rdpsnd->OpenHandle, (void*) rdpsnd);
|
|
||||||
|
|
||||||
rdpsnd->MsgPipe = MessagePipe_New();
|
rdpsnd->MsgPipe = MessagePipe_New();
|
||||||
|
|
||||||
if (!rdpsnd->MsgPipe)
|
if (!rdpsnd->MsgPipe)
|
||||||
@ -1360,11 +1355,11 @@ static UINT rdpsnd_virtual_channel_event_disconnected(rdpsndPlugin* rdpsnd)
|
|||||||
|
|
||||||
CloseHandle(rdpsnd->thread);
|
CloseHandle(rdpsnd->thread);
|
||||||
rdpsnd->thread = NULL;
|
rdpsnd->thread = NULL;
|
||||||
error = rdpsnd->channelEntryPoints.pVirtualChannelClose(rdpsnd->OpenHandle);
|
error = rdpsnd->channelEntryPoints.pVirtualChannelCloseEx(rdpsnd->InitHandle, rdpsnd->OpenHandle);
|
||||||
|
|
||||||
if (CHANNEL_RC_OK != error)
|
if (CHANNEL_RC_OK != error)
|
||||||
{
|
{
|
||||||
WLog_ERR(TAG, "pVirtualChannelClose failed with %s [%08X]",
|
WLog_ERR(TAG, "pVirtualChannelCloseEx failed with %s [%08X]",
|
||||||
WTSErrorToString(error), error);
|
WTSErrorToString(error), error);
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
@ -1404,27 +1399,24 @@ static UINT rdpsnd_virtual_channel_event_disconnected(rdpsndPlugin* rdpsnd)
|
|||||||
rdpsnd->device_name = NULL;
|
rdpsnd->device_name = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
freerdp_channel_remove_open_handle_data(&g_ChannelHandles, rdpsnd->OpenHandle);
|
|
||||||
|
|
||||||
return CHANNEL_RC_OK;
|
return CHANNEL_RC_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void rdpsnd_virtual_channel_event_terminated(rdpsndPlugin* rdpsnd)
|
static void rdpsnd_virtual_channel_event_terminated(rdpsndPlugin* rdpsnd)
|
||||||
{
|
{
|
||||||
freerdp_channel_remove_init_handle_data(&g_ChannelHandles, (void*) rdpsnd);
|
|
||||||
rdpsnd->InitHandle = 0;
|
rdpsnd->InitHandle = 0;
|
||||||
free(rdpsnd);
|
free(rdpsnd);
|
||||||
}
|
}
|
||||||
|
|
||||||
static VOID VCAPITYPE rdpsnd_virtual_channel_init_event(LPVOID pInitHandle,
|
static VOID VCAPITYPE rdpsnd_virtual_channel_init_event_ex(LPVOID lpUserParam, LPVOID pInitHandle,
|
||||||
UINT event, LPVOID pData, UINT dataLength)
|
UINT event, LPVOID pData, UINT dataLength)
|
||||||
{
|
{
|
||||||
UINT error = CHANNEL_RC_OK;
|
UINT error = CHANNEL_RC_OK;
|
||||||
rdpsndPlugin* plugin = (rdpsndPlugin*) freerdp_channel_get_init_handle_data(&g_ChannelHandles, pInitHandle);
|
rdpsndPlugin* plugin = (rdpsndPlugin*) lpUserParam;
|
||||||
|
|
||||||
if (!plugin || (plugin->InitHandle != pInitHandle))
|
if (!plugin || (plugin->InitHandle != pInitHandle))
|
||||||
{
|
{
|
||||||
WLog_ERR(TAG, "rdpsnd_virtual_channel_init_event: error no match");
|
WLog_ERR(TAG, "error no match");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1461,13 +1453,13 @@ static VOID VCAPITYPE rdpsnd_virtual_channel_init_event(LPVOID pInitHandle,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* rdpsnd is always built-in */
|
/* rdpsnd is always built-in */
|
||||||
#define VirtualChannelEntry rdpsnd_VirtualChannelEntry
|
#define VirtualChannelEntryEx rdpsnd_VirtualChannelEntryEx
|
||||||
|
|
||||||
BOOL VCAPITYPE VirtualChannelEntry(PCHANNEL_ENTRY_POINTS pEntryPoints)
|
BOOL VCAPITYPE VirtualChannelEntryEx(PCHANNEL_ENTRY_POINTS pEntryPoints, PVOID pInitHandle)
|
||||||
{
|
{
|
||||||
UINT rc;
|
UINT rc;
|
||||||
rdpsndPlugin* rdpsnd;
|
rdpsndPlugin* rdpsnd;
|
||||||
CHANNEL_ENTRY_POINTS_FREERDP* pEntryPointsEx;
|
CHANNEL_ENTRY_POINTS_FREERDP_EX* pEntryPointsEx;
|
||||||
|
|
||||||
if (!pEntryPoints)
|
if (!pEntryPoints)
|
||||||
{
|
{
|
||||||
@ -1493,31 +1485,33 @@ BOOL VCAPITYPE VirtualChannelEntry(PCHANNEL_ENTRY_POINTS pEntryPoints)
|
|||||||
rdpsnd->channelDef.options =
|
rdpsnd->channelDef.options =
|
||||||
CHANNEL_OPTION_INITIALIZED |
|
CHANNEL_OPTION_INITIALIZED |
|
||||||
CHANNEL_OPTION_ENCRYPT_RDP;
|
CHANNEL_OPTION_ENCRYPT_RDP;
|
||||||
strcpy(rdpsnd->channelDef.name, "rdpsnd");
|
|
||||||
pEntryPointsEx = (CHANNEL_ENTRY_POINTS_FREERDP*) pEntryPoints;
|
|
||||||
|
|
||||||
if ((pEntryPointsEx->cbSize >= sizeof(CHANNEL_ENTRY_POINTS_FREERDP)) &&
|
strcpy(rdpsnd->channelDef.name, "rdpsnd");
|
||||||
|
pEntryPointsEx = (CHANNEL_ENTRY_POINTS_FREERDP_EX*) pEntryPoints;
|
||||||
|
|
||||||
|
if ((pEntryPointsEx->cbSize >= sizeof(CHANNEL_ENTRY_POINTS_FREERDP_EX)) &&
|
||||||
(pEntryPointsEx->MagicNumber == FREERDP_CHANNEL_MAGIC_NUMBER))
|
(pEntryPointsEx->MagicNumber == FREERDP_CHANNEL_MAGIC_NUMBER))
|
||||||
{
|
{
|
||||||
rdpsnd->rdpcontext = pEntryPointsEx->context;
|
rdpsnd->rdpcontext = pEntryPointsEx->context;
|
||||||
}
|
}
|
||||||
|
|
||||||
CopyMemory(&(rdpsnd->channelEntryPoints), pEntryPoints,
|
|
||||||
sizeof(CHANNEL_ENTRY_POINTS_FREERDP));
|
|
||||||
rdpsnd->log = WLog_Get("com.freerdp.channels.rdpsnd.client");
|
rdpsnd->log = WLog_Get("com.freerdp.channels.rdpsnd.client");
|
||||||
rc = rdpsnd->channelEntryPoints.pVirtualChannelInit(&rdpsnd->InitHandle,
|
CopyMemory(&(rdpsnd->channelEntryPoints), pEntryPoints,
|
||||||
|
sizeof(CHANNEL_ENTRY_POINTS_FREERDP_EX));
|
||||||
|
|
||||||
|
rdpsnd->InitHandle = pInitHandle;
|
||||||
|
|
||||||
|
rc = rdpsnd->channelEntryPoints.pVirtualChannelInitEx((void*)rdpsnd, pInitHandle,
|
||||||
&rdpsnd->channelDef, 1, VIRTUAL_CHANNEL_VERSION_WIN2000,
|
&rdpsnd->channelDef, 1, VIRTUAL_CHANNEL_VERSION_WIN2000,
|
||||||
rdpsnd_virtual_channel_init_event);
|
rdpsnd_virtual_channel_init_event_ex);
|
||||||
|
|
||||||
if (CHANNEL_RC_OK != rc)
|
if (CHANNEL_RC_OK != rc)
|
||||||
{
|
{
|
||||||
WLog_ERR(TAG, "pVirtualChannelInit failed with %s [%08X]",
|
WLog_ERR(TAG, "pVirtualChannelInitEx failed with %s [%08X]",
|
||||||
WTSErrorToString(rc), rc);
|
WTSErrorToString(rc), rc);
|
||||||
free(rdpsnd);
|
free(rdpsnd);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
freerdp_channel_add_init_handle_data(&g_ChannelHandles, rdpsnd->InitHandle, (void*) rdpsnd);
|
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user