Added support for AUDIO_PLAYBACK_DVC

Support audio on dynamic channel. Please refer to MS-RDPEA.
This commit is contained in:
Steve Pronovost 2021-10-16 11:55:46 -07:00 committed by akallabeth
parent c5e4fc71bc
commit f6f4acc921
3 changed files with 36 additions and 5 deletions

View File

@ -673,13 +673,40 @@ static UINT rdpsnd_server_start(RdpsndServerContext* context)
DWORD bytesReturned;
RdpsndServerPrivate* priv = context->priv;
UINT error = ERROR_INTERNAL_ERROR;
priv->ChannelHandle =
WTSVirtualChannelOpen(context->vcm, WTS_CURRENT_SESSION, RDPSND_CHANNEL_NAME);
PULONG pSessionId = NULL;
if (!priv->ChannelHandle)
priv->SessionId = WTS_CURRENT_SESSION;
if (context->use_dynamic_virtual_channel)
{
WLog_ERR(TAG, "WTSVirtualChannelOpen failed!");
return ERROR_INTERNAL_ERROR;
if (WTSQuerySessionInformationA(context->vcm, WTS_CURRENT_SESSION, WTSSessionId,
(LPSTR*)&pSessionId, &bytesReturned))
{
priv->SessionId = (DWORD)*pSessionId;
WTSFreeMemory(pSessionId);
priv->ChannelHandle = (HANDLE)WTSVirtualChannelOpenEx(
priv->SessionId, "AUDIO_PLAYBACK_DVC", WTS_CHANNEL_OPTION_DYNAMIC);
if (!priv->ChannelHandle)
{
WLog_ERR(TAG, "Open audio dynamic virtual channel (AUDIO_PLAYBACK_DVC) failed!");
return ERROR_INTERNAL_ERROR;
}
}
else
{
WLog_ERR(TAG, "WTSQuerySessionInformationA failed!");
return ERROR_INTERNAL_ERROR;
}
}
else
{
priv->ChannelHandle =
WTSVirtualChannelOpen(context->vcm, WTS_CURRENT_SESSION, RDPSND_CHANNEL_NAME);
if (!priv->ChannelHandle)
{
WLog_ERR(TAG, "Open audio static virtual channel (rdpsnd) failed!");
return ERROR_INTERNAL_ERROR;
}
}
if (!WTSVirtualChannelQuery(priv->ChannelHandle, WTSVirtualEventHandle, &buffer,

View File

@ -39,6 +39,7 @@ struct _rdpsnd_server_private
HANDLE StopEvent;
HANDLE channelEvent;
void* ChannelHandle;
DWORD SessionId;
BOOL waitingHeader;
DWORD expectedBytes;

View File

@ -56,6 +56,9 @@ struct _rdpsnd_server_context
/* Server self-defined pointer. */
void* data;
/* Server to request to use dynamic virtual channel. */
BOOL use_dynamic_virtual_channel;
/* Server supported formats. Set by server. */
AUDIO_FORMAT* server_formats;
size_t num_server_formats;