GUAC-1196: Load RDPSND if RDPDR is loaded, but do not actually handle audio unless enabled.
This commit is contained in:
parent
0dddf47af0
commit
c3e2754ec4
@ -291,17 +291,8 @@ BOOL rdp_freerdp_pre_connect(freerdp* instance) {
|
|||||||
GUAC_RDP_AUDIO_CHANNELS,
|
GUAC_RDP_AUDIO_CHANNELS,
|
||||||
GUAC_RDP_AUDIO_BPS);
|
GUAC_RDP_AUDIO_BPS);
|
||||||
|
|
||||||
/* If an encoding is available, load the sound plugin */
|
/* Warn if no audio encoding is available */
|
||||||
if (guac_client_data->audio != NULL) {
|
if (guac_client_data->audio == NULL)
|
||||||
|
|
||||||
/* Load sound plugin */
|
|
||||||
if (freerdp_channels_load_plugin(channels, instance->settings,
|
|
||||||
"guacsnd", client))
|
|
||||||
guac_client_log(client, GUAC_LOG_WARNING,
|
|
||||||
"Failed to load guacsnd plugin. Audio will not work.");
|
|
||||||
|
|
||||||
}
|
|
||||||
else
|
|
||||||
guac_client_log(client, GUAC_LOG_INFO,
|
guac_client_log(client, GUAC_LOG_INFO,
|
||||||
"No available audio encoding. Sound disabled.");
|
"No available audio encoding. Sound disabled.");
|
||||||
|
|
||||||
@ -321,7 +312,7 @@ BOOL rdp_freerdp_pre_connect(freerdp* instance) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If RDPDR required, load it */
|
/* If RDPSND/RDPDR required, load them */
|
||||||
if (guac_client_data->settings.printing_enabled
|
if (guac_client_data->settings.printing_enabled
|
||||||
|| guac_client_data->settings.drive_enabled
|
|| guac_client_data->settings.drive_enabled
|
||||||
|| guac_client_data->settings.audio_enabled) {
|
|| guac_client_data->settings.audio_enabled) {
|
||||||
@ -330,7 +321,16 @@ BOOL rdp_freerdp_pre_connect(freerdp* instance) {
|
|||||||
if (freerdp_channels_load_plugin(channels, instance->settings,
|
if (freerdp_channels_load_plugin(channels, instance->settings,
|
||||||
"guacdr", client))
|
"guacdr", client))
|
||||||
guac_client_log(client, GUAC_LOG_WARNING,
|
guac_client_log(client, GUAC_LOG_WARNING,
|
||||||
"Failed to load guacdr plugin. Drive redirection and printing will not work.");
|
"Failed to load guacdr plugin. Drive redirection and "
|
||||||
|
"printing will not work. Sound MAY not work.");
|
||||||
|
|
||||||
|
/* Load RDPSND plugin */
|
||||||
|
if (freerdp_channels_load_plugin(channels, instance->settings,
|
||||||
|
"guacsnd", client))
|
||||||
|
guac_client_log(client, GUAC_LOG_WARNING,
|
||||||
|
"Failed to load guacsnd alongside guacdr plugin. Sound "
|
||||||
|
"will not work. Drive redirection and printing MAY not "
|
||||||
|
"work.");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,75 +92,86 @@ void guac_rdpsnd_formats_handler(guac_rdpsndPlugin* rdpsnd,
|
|||||||
Stream_Write_UINT16(output_stream, 6);
|
Stream_Write_UINT16(output_stream, 6);
|
||||||
Stream_Write_UINT8(output_stream, 0);
|
Stream_Write_UINT8(output_stream, 0);
|
||||||
|
|
||||||
/* Check each server format, respond if supported */
|
/* Check each server format, respond if supported and audio is enabled */
|
||||||
for (i=0; i < server_format_count; i++) {
|
if (audio != NULL) {
|
||||||
|
for (i=0; i < server_format_count; i++) {
|
||||||
|
|
||||||
unsigned char* format_start;
|
unsigned char* format_start;
|
||||||
|
|
||||||
int format_tag;
|
int format_tag;
|
||||||
int channels;
|
int channels;
|
||||||
int rate;
|
int rate;
|
||||||
int bps;
|
int bps;
|
||||||
int body_size;
|
int body_size;
|
||||||
|
|
||||||
/* Remember position in stream */
|
/* Remember position in stream */
|
||||||
Stream_GetPointer(input_stream, format_start);
|
Stream_GetPointer(input_stream, format_start);
|
||||||
|
|
||||||
/* Read format */
|
/* Read format */
|
||||||
Stream_Read_UINT16(input_stream, format_tag);
|
Stream_Read_UINT16(input_stream, format_tag);
|
||||||
Stream_Read_UINT16(input_stream, channels);
|
Stream_Read_UINT16(input_stream, channels);
|
||||||
Stream_Read_UINT32(input_stream, rate);
|
Stream_Read_UINT32(input_stream, rate);
|
||||||
Stream_Seek_UINT32(input_stream);
|
Stream_Seek_UINT32(input_stream);
|
||||||
Stream_Seek_UINT16(input_stream);
|
Stream_Seek_UINT16(input_stream);
|
||||||
Stream_Read_UINT16(input_stream, bps);
|
Stream_Read_UINT16(input_stream, bps);
|
||||||
|
|
||||||
/* Skip past extra data */
|
/* Skip past extra data */
|
||||||
Stream_Read_UINT16(input_stream, body_size);
|
Stream_Read_UINT16(input_stream, body_size);
|
||||||
Stream_Seek(input_stream, body_size);
|
Stream_Seek(input_stream, body_size);
|
||||||
|
|
||||||
/* If PCM, accept */
|
/* If PCM, accept */
|
||||||
if (format_tag == WAVE_FORMAT_PCM) {
|
if (format_tag == WAVE_FORMAT_PCM) {
|
||||||
|
|
||||||
/* If can fit another format, accept it */
|
/* If can fit another format, accept it */
|
||||||
if (rdpsnd->format_count < GUAC_RDP_MAX_FORMATS) {
|
if (rdpsnd->format_count < GUAC_RDP_MAX_FORMATS) {
|
||||||
|
|
||||||
/* Add channel */
|
/* Add channel */
|
||||||
int current = rdpsnd->format_count++;
|
int current = rdpsnd->format_count++;
|
||||||
rdpsnd->formats[current].rate = rate;
|
rdpsnd->formats[current].rate = rate;
|
||||||
rdpsnd->formats[current].channels = channels;
|
rdpsnd->formats[current].channels = channels;
|
||||||
rdpsnd->formats[current].bps = bps;
|
rdpsnd->formats[current].bps = bps;
|
||||||
|
|
||||||
/* Log format */
|
/* Log format */
|
||||||
guac_client_log(client, GUAC_LOG_INFO,
|
guac_client_log(client, GUAC_LOG_INFO,
|
||||||
"Accepted format: %i-bit PCM with %i channels at "
|
"Accepted format: %i-bit PCM with %i channels at "
|
||||||
"%i Hz",
|
"%i Hz",
|
||||||
bps, channels, rate);
|
bps, channels, rate);
|
||||||
|
|
||||||
/* Ensure audio stream is configured to use accepted format */
|
/* Ensure audio stream is configured to use accepted
|
||||||
guac_audio_stream_reset(audio, NULL, rate, channels, bps);
|
* format */
|
||||||
|
guac_audio_stream_reset(audio, NULL, rate, channels, bps);
|
||||||
|
|
||||||
/* Queue format for sending as accepted */
|
/* Queue format for sending as accepted */
|
||||||
Stream_EnsureRemainingCapacity(output_stream, 18 + body_size);
|
Stream_EnsureRemainingCapacity(output_stream,
|
||||||
Stream_Write(output_stream, format_start, 18 + body_size);
|
18 + body_size);
|
||||||
|
Stream_Write(output_stream, format_start, 18 + body_size);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* BEWARE that using Stream_EnsureRemainingCapacity means that any
|
* BEWARE that using Stream_EnsureRemainingCapacity means
|
||||||
* pointers returned via Stream_GetPointer on output_stream are invalid.
|
* that any pointers returned via Stream_GetPointer on
|
||||||
*/
|
* output_stream are invalid.
|
||||||
|
*/
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Otherwise, log that we dropped one */
|
||||||
|
else
|
||||||
|
guac_client_log(client, GUAC_LOG_INFO,
|
||||||
|
"Dropped valid format: %i-bit PCM with %i "
|
||||||
|
"channels at %i Hz",
|
||||||
|
bps, channels, rate);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Otherwise, log that we dropped one */
|
|
||||||
else
|
|
||||||
guac_client_log(client, GUAC_LOG_INFO,
|
|
||||||
"Dropped valid format: %i-bit PCM with %i channels at "
|
|
||||||
"%i Hz",
|
|
||||||
bps, channels, rate);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Otherwise, ignore all supported formats as we do not intend to actually
|
||||||
|
* receive audio */
|
||||||
|
else
|
||||||
|
guac_client_log(client, GUAC_LOG_DEBUG,
|
||||||
|
"Audio explicitly disabled. Ignoring supported formats.");
|
||||||
|
|
||||||
/* Calculate size of PDU */
|
/* Calculate size of PDU */
|
||||||
output_body_size = Stream_GetPosition(output_stream) - 4;
|
output_body_size = Stream_GetPosition(output_stream) - 4;
|
||||||
Stream_GetPointer(output_stream, output_stream_end);
|
Stream_GetPointer(output_stream, output_stream_end);
|
||||||
@ -257,10 +268,11 @@ void guac_rdpsnd_wave_info_handler(guac_rdpsndPlugin* rdpsnd,
|
|||||||
rdpsnd->next_pdu_is_wave = TRUE;
|
rdpsnd->next_pdu_is_wave = TRUE;
|
||||||
|
|
||||||
/* Reset audio stream if format has changed */
|
/* Reset audio stream if format has changed */
|
||||||
guac_audio_stream_reset(audio, NULL,
|
if (audio != NULL)
|
||||||
rdpsnd->formats[format].rate,
|
guac_audio_stream_reset(audio, NULL,
|
||||||
rdpsnd->formats[format].channels,
|
rdpsnd->formats[format].rate,
|
||||||
rdpsnd->formats[format].bps);
|
rdpsnd->formats[format].channels,
|
||||||
|
rdpsnd->formats[format].bps);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -286,8 +298,11 @@ void guac_rdpsnd_wave_handler(guac_rdpsndPlugin* rdpsnd,
|
|||||||
memcpy(buffer, rdpsnd->initial_wave_data, 4);
|
memcpy(buffer, rdpsnd->initial_wave_data, 4);
|
||||||
|
|
||||||
/* Write rest of audio packet */
|
/* Write rest of audio packet */
|
||||||
guac_audio_stream_write_pcm(audio, buffer, rdpsnd->incoming_wave_size + 4);
|
if (audio != NULL) {
|
||||||
guac_audio_stream_flush(audio);
|
guac_audio_stream_write_pcm(audio, buffer,
|
||||||
|
rdpsnd->incoming_wave_size + 4);
|
||||||
|
guac_audio_stream_flush(audio);
|
||||||
|
}
|
||||||
|
|
||||||
/* Write Wave Confirmation PDU */
|
/* Write Wave Confirmation PDU */
|
||||||
Stream_Write_UINT8(output_stream, SNDC_WAVECONFIRM);
|
Stream_Write_UINT8(output_stream, SNDC_WAVECONFIRM);
|
||||||
|
Loading…
Reference in New Issue
Block a user