FreeRDP
client/rdpsnd_main.c File Reference
#include <freerdp/config.h>
#include <sys/time.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <winpr/crt.h>
#include <winpr/assert.h>
#include <winpr/wlog.h>
#include <winpr/stream.h>
#include <winpr/cmdline.h>
#include <winpr/sysinfo.h>
#include <winpr/collections.h>
#include <freerdp/types.h>
#include <freerdp/addin.h>
#include <freerdp/freerdp.h>
#include <freerdp/codec/dsp.h>
#include <freerdp/client/channels.h>
#include "rdpsnd_common.h"
#include "rdpsnd_main.h"

Functions

static const char * rdpsnd_is_dyn_str (BOOL dynamic)
 
static void rdpsnd_virtual_channel_event_terminated (rdpsndPlugin *rdpsnd)
 
static UINT rdpsnd_virtual_channel_write (rdpsndPlugin *rdpsnd, wStream *s)
 
static UINT rdpsnd_send_quality_mode_pdu (rdpsndPlugin *rdpsnd)
 
static void rdpsnd_select_supported_audio_formats (rdpsndPlugin *rdpsnd)
 
static UINT rdpsnd_send_client_audio_formats (rdpsndPlugin *rdpsnd)
 
static UINT rdpsnd_recv_server_audio_formats_pdu (rdpsndPlugin *rdpsnd, wStream *s)
 
static UINT rdpsnd_send_training_confirm_pdu (rdpsndPlugin *rdpsnd, UINT16 wTimeStamp, UINT16 wPackSize)
 
static UINT rdpsnd_recv_training_pdu (rdpsndPlugin *rdpsnd, wStream *s)
 
static BOOL rdpsnd_apply_volume (rdpsndPlugin *rdpsnd)
 
static BOOL rdpsnd_ensure_device_is_open (rdpsndPlugin *rdpsnd, UINT32 wFormatNo, const AUDIO_FORMAT *format)
 
static UINT rdpsnd_recv_wave_info_pdu (rdpsndPlugin *rdpsnd, wStream *s, UINT16 BodySize)
 
static UINT rdpsnd_send_wave_confirm_pdu (rdpsndPlugin *rdpsnd, UINT16 wTimeStamp, BYTE cConfirmedBlockNo)
 
static BOOL rdpsnd_detect_overrun (rdpsndPlugin *rdpsnd, const AUDIO_FORMAT *format, size_t size)
 
static UINT rdpsnd_treat_wave (rdpsndPlugin *rdpsnd, wStream *s, size_t size)
 
static UINT rdpsnd_recv_wave_pdu (rdpsndPlugin *rdpsnd, wStream *s)
 
static UINT rdpsnd_recv_wave2_pdu (rdpsndPlugin *rdpsnd, wStream *s, UINT16 BodySize)
 
static void rdpsnd_recv_close_pdu (rdpsndPlugin *rdpsnd)
 
static UINT rdpsnd_recv_volume_pdu (rdpsndPlugin *rdpsnd, wStream *s)
 
static UINT rdpsnd_recv_pdu (rdpsndPlugin *rdpsnd, wStream *s)
 
static void rdpsnd_register_device_plugin (rdpsndPlugin *rdpsnd, rdpsndDevicePlugin *device)
 
static UINT rdpsnd_load_device_plugin (rdpsndPlugin *rdpsnd, const char *name, const ADDIN_ARGV *args)
 
static BOOL rdpsnd_set_subsystem (rdpsndPlugin *rdpsnd, const char *subsystem)
 
static BOOL rdpsnd_set_device_name (rdpsndPlugin *rdpsnd, const char *device_name)
 
static UINT rdpsnd_process_addin_args (rdpsndPlugin *rdpsnd, const ADDIN_ARGV *args)
 
static UINT rdpsnd_process_connect (rdpsndPlugin *rdpsnd)
 
static UINT rdpsnd_virtual_channel_event_data_received (rdpsndPlugin *plugin, void *pData, UINT32 dataLength, UINT32 totalLength, UINT32 dataFlags)
 
static VOID VCAPITYPE rdpsnd_virtual_channel_open_event_ex (LPVOID lpUserParam, DWORD openHandle, UINT event, LPVOID pData, UINT32 dataLength, UINT32 totalLength, UINT32 dataFlags)
 
static UINT rdpsnd_virtual_channel_event_connected (rdpsndPlugin *rdpsnd, LPVOID pData, UINT32 dataLength)
 
static void cleanup_internals (rdpsndPlugin *rdpsnd)
 
static UINT rdpsnd_virtual_channel_event_disconnected (rdpsndPlugin *rdpsnd)
 
static void queue_free (void *obj)
 
static void free_internals (rdpsndPlugin *rdpsnd)
 
static BOOL allocate_internals (rdpsndPlugin *rdpsnd)
 
static DWORD WINAPI play_thread (LPVOID arg)
 
static UINT rdpsnd_virtual_channel_event_initialized (rdpsndPlugin *rdpsnd)
 
static VOID VCAPITYPE rdpsnd_virtual_channel_init_event_ex (LPVOID lpUserParam, LPVOID pInitHandle, UINT event, LPVOID pData, UINT dataLength)
 
rdpContext * freerdp_rdpsnd_get_context (rdpsndPlugin *plugin)
 
static rdpsndPlugin * allocatePlugin (void)
 
 FREERDP_ENTRY_POINT (BOOL VCAPITYPE rdpsnd_VirtualChannelEntryEx(PCHANNEL_ENTRY_POINTS pEntryPoints, PVOID pInitHandle))
 
static UINT rdpsnd_on_open (IWTSVirtualChannelCallback *pChannelCallback)
 
static UINT rdpsnd_on_data_received (IWTSVirtualChannelCallback *pChannelCallback, wStream *data)
 
static UINT rdpsnd_on_close (IWTSVirtualChannelCallback *pChannelCallback)
 
static UINT rdpsnd_on_new_channel_connection (IWTSListenerCallback *pListenerCallback, IWTSVirtualChannel *pChannel, BYTE *Data, BOOL *pbAccept, IWTSVirtualChannelCallback **ppCallback)
 
static UINT rdpsnd_plugin_initialize (IWTSPlugin *pPlugin, IWTSVirtualChannelManager *pChannelMgr)
 
static UINT rdpsnd_plugin_terminated (IWTSPlugin *pPlugin)
 
 WINPR_ASSERT (pEntryPoints)
 
 WINPR_ASSERT (pEntryPoints->GetPlugin)
 
 if (!rdpsnd)
 

Variables

rdpsndPlugin * rdpsnd = NULL
 
 else
 
return CHANNEL_RC_BAD_CHANNEL
 
return error
 

Function Documentation

◆ allocate_internals()

static BOOL allocate_internals ( rdpsndPlugin *  rdpsnd)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ allocatePlugin()

static rdpsndPlugin* allocatePlugin ( void  )
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cleanup_internals()

static void cleanup_internals ( rdpsndPlugin *  rdpsnd)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ free_internals()

static void free_internals ( rdpsndPlugin *  rdpsnd)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ FREERDP_ENTRY_POINT()

FREERDP_ENTRY_POINT ( BOOL VCAPITYPE   rdpsnd_VirtualChannelEntryExPCHANNEL_ENTRY_POINTS pEntryPoints, PVOID pInitHandle)
Here is the call graph for this function:

◆ freerdp_rdpsnd_get_context()

rdpContext* freerdp_rdpsnd_get_context ( rdpsndPlugin *  plugin)

◆ if()

if ( rdpsnd)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ play_thread()

static DWORD WINAPI play_thread ( LPVOID  arg)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ queue_free()

static void queue_free ( void *  obj)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rdpsnd_apply_volume()

static BOOL rdpsnd_apply_volume ( rdpsndPlugin *  rdpsnd)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rdpsnd_detect_overrun()

static BOOL rdpsnd_detect_overrun ( rdpsndPlugin *  rdpsnd,
const AUDIO_FORMAT format,
size_t  size 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rdpsnd_ensure_device_is_open()

static BOOL rdpsnd_ensure_device_is_open ( rdpsndPlugin *  rdpsnd,
UINT32  wFormatNo,
const AUDIO_FORMAT format 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rdpsnd_is_dyn_str()

static const char* rdpsnd_is_dyn_str ( BOOL  dynamic)
static
Here is the caller graph for this function:

◆ rdpsnd_load_device_plugin()

static UINT rdpsnd_load_device_plugin ( rdpsndPlugin *  rdpsnd,
const char *  name,
const ADDIN_ARGV args 
)
static

Function description

Returns
0 on success, otherwise a Win32 error code
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rdpsnd_on_close()

static UINT rdpsnd_on_close ( IWTSVirtualChannelCallback *  pChannelCallback)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rdpsnd_on_data_received()

static UINT rdpsnd_on_data_received ( IWTSVirtualChannelCallback *  pChannelCallback,
wStream data 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rdpsnd_on_new_channel_connection()

static UINT rdpsnd_on_new_channel_connection ( IWTSListenerCallback *  pListenerCallback,
IWTSVirtualChannel *  pChannel,
BYTE Data,
BOOL *  pbAccept,
IWTSVirtualChannelCallback **  ppCallback 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rdpsnd_on_open()

static UINT rdpsnd_on_open ( IWTSVirtualChannelCallback *  pChannelCallback)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rdpsnd_plugin_initialize()

static UINT rdpsnd_plugin_initialize ( IWTSPlugin *  pPlugin,
IWTSVirtualChannelManager *  pChannelMgr 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rdpsnd_plugin_terminated()

static UINT rdpsnd_plugin_terminated ( IWTSPlugin *  pPlugin)
static

Function description

Returns
0 on success, otherwise a Win32 error code
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rdpsnd_process_addin_args()

static UINT rdpsnd_process_addin_args ( rdpsndPlugin *  rdpsnd,
const ADDIN_ARGV args 
)
static

Function description

Returns
0 on success, otherwise a Win32 error code
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rdpsnd_process_connect()

static UINT rdpsnd_process_connect ( rdpsndPlugin *  rdpsnd)
static

Function description

Returns
0 on success, otherwise a Win32 error code
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rdpsnd_recv_close_pdu()

static void rdpsnd_recv_close_pdu ( rdpsndPlugin *  rdpsnd)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rdpsnd_recv_pdu()

static UINT rdpsnd_recv_pdu ( rdpsndPlugin *  rdpsnd,
wStream s 
)
static

Function description

Returns
0 on success, otherwise a Win32 error code
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rdpsnd_recv_server_audio_formats_pdu()

static UINT rdpsnd_recv_server_audio_formats_pdu ( rdpsndPlugin *  rdpsnd,
wStream s 
)
static

Function description

Returns
0 on success, otherwise a Win32 error code
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rdpsnd_recv_training_pdu()

static UINT rdpsnd_recv_training_pdu ( rdpsndPlugin *  rdpsnd,
wStream s 
)
static

Function description

Returns
0 on success, otherwise a Win32 error code
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rdpsnd_recv_volume_pdu()

static UINT rdpsnd_recv_volume_pdu ( rdpsndPlugin *  rdpsnd,
wStream s 
)
static

Function description

Returns
0 on success, otherwise a Win32 error code
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rdpsnd_recv_wave2_pdu()

static UINT rdpsnd_recv_wave2_pdu ( rdpsndPlugin *  rdpsnd,
wStream s,
UINT16  BodySize 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rdpsnd_recv_wave_info_pdu()

static UINT rdpsnd_recv_wave_info_pdu ( rdpsndPlugin *  rdpsnd,
wStream s,
UINT16  BodySize 
)
static

Function description

Returns
0 on success, otherwise a Win32 error code
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rdpsnd_recv_wave_pdu()

static UINT rdpsnd_recv_wave_pdu ( rdpsndPlugin *  rdpsnd,
wStream s 
)
static

Function description

Returns
0 on success, otherwise a Win32 error code

The Wave PDU is a special case: it is always sent after a Wave Info PDU, and we do not process its header. Instead, the header is pad that needs to be filled with the first four bytes of the audio sample data sent as part of the preceding Wave Info PDU.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ rdpsnd_register_device_plugin()

static void rdpsnd_register_device_plugin ( rdpsndPlugin *  rdpsnd,
rdpsndDevicePlugin *  device 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rdpsnd_select_supported_audio_formats()

static void rdpsnd_select_supported_audio_formats ( rdpsndPlugin *  rdpsnd)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rdpsnd_send_client_audio_formats()

static UINT rdpsnd_send_client_audio_formats ( rdpsndPlugin *  rdpsnd)
static

Function description

Returns
0 on success, otherwise a Win32 error code
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rdpsnd_send_quality_mode_pdu()

static UINT rdpsnd_send_quality_mode_pdu ( rdpsndPlugin *  rdpsnd)
static

Function description

Returns
0 on success, otherwise a Win32 error code
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rdpsnd_send_training_confirm_pdu()

static UINT rdpsnd_send_training_confirm_pdu ( rdpsndPlugin *  rdpsnd,
UINT16  wTimeStamp,
UINT16  wPackSize 
)
static

Function description

Returns
0 on success, otherwise a Win32 error code
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rdpsnd_send_wave_confirm_pdu()

static UINT rdpsnd_send_wave_confirm_pdu ( rdpsndPlugin *  rdpsnd,
UINT16  wTimeStamp,
BYTE  cConfirmedBlockNo 
)
static

Function description

Returns
0 on success, otherwise a Win32 error code
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rdpsnd_set_device_name()

static BOOL rdpsnd_set_device_name ( rdpsndPlugin *  rdpsnd,
const char *  device_name 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rdpsnd_set_subsystem()

static BOOL rdpsnd_set_subsystem ( rdpsndPlugin *  rdpsnd,
const char *  subsystem 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rdpsnd_treat_wave()

static UINT rdpsnd_treat_wave ( rdpsndPlugin *  rdpsnd,
wStream s,
size_t  size 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rdpsnd_virtual_channel_event_connected()

static UINT rdpsnd_virtual_channel_event_connected ( rdpsndPlugin *  rdpsnd,
LPVOID  pData,
UINT32  dataLength 
)
static

Function description

Returns
0 on success, otherwise a Win32 error code
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rdpsnd_virtual_channel_event_data_received()

static UINT rdpsnd_virtual_channel_event_data_received ( rdpsndPlugin *  plugin,
void *  pData,
UINT32  dataLength,
UINT32  totalLength,
UINT32  dataFlags 
)
static

Function description

Returns
0 on success, otherwise a Win32 error code
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rdpsnd_virtual_channel_event_disconnected()

static UINT rdpsnd_virtual_channel_event_disconnected ( rdpsndPlugin *  rdpsnd)
static

Function description

Returns
0 on success, otherwise a Win32 error code
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rdpsnd_virtual_channel_event_initialized()

static UINT rdpsnd_virtual_channel_event_initialized ( rdpsndPlugin *  rdpsnd)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rdpsnd_virtual_channel_event_terminated()

void rdpsnd_virtual_channel_event_terminated ( rdpsndPlugin *  rdpsnd)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rdpsnd_virtual_channel_init_event_ex()

static VOID VCAPITYPE rdpsnd_virtual_channel_init_event_ex ( LPVOID  lpUserParam,
LPVOID  pInitHandle,
UINT  event,
LPVOID  pData,
UINT  dataLength 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rdpsnd_virtual_channel_open_event_ex()

static VOID VCAPITYPE rdpsnd_virtual_channel_open_event_ex ( LPVOID  lpUserParam,
DWORD  openHandle,
UINT  event,
LPVOID  pData,
UINT32  dataLength,
UINT32  totalLength,
UINT32  dataFlags 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rdpsnd_virtual_channel_write()

UINT rdpsnd_virtual_channel_write ( rdpsndPlugin *  rdpsnd,
wStream s 
)
static

Function description

Returns
0 on success, otherwise a Win32 error code
Here is the call graph for this function:
Here is the caller graph for this function:

◆ WINPR_ASSERT() [1/2]

WINPR_ASSERT ( pEntryPoints  )
Here is the caller graph for this function:

◆ WINPR_ASSERT() [2/2]

WINPR_ASSERT ( pEntryPoints->  GetPlugin)

Variable Documentation

◆ CHANNEL_RC_BAD_CHANNEL

return CHANNEL_RC_BAD_CHANNEL

◆ else

else
Initial value:
{
WLog_ERR(TAG, "%s could not get rdpsnd Plugin.", rdpsnd_is_dyn_str(TRUE))
#define TAG
Definition: client/ainput_main.c:39
static const char * rdpsnd_is_dyn_str(BOOL dynamic)
Definition: client/rdpsnd_main.c:120
#define WLog_ERR(tag,...)
Definition: include/winpr/wlog.h:206

◆ error

return error

◆ rdpsnd

rdpsnd = NULL

Function description

Returns
0 on success, otherwise a Win32 error code