GUAC-1196: Use guac_client to access guac_audio_stream rather than storing the audio stream directly.
This commit is contained in:
parent
f9cc90307b
commit
0dddf47af0
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2013 Glyptodon LLC
|
||||
* Copyright (C) 2015 Glyptodon LLC
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@ -296,7 +296,7 @@ BOOL rdp_freerdp_pre_connect(freerdp* instance) {
|
||||
|
||||
/* Load sound plugin */
|
||||
if (freerdp_channels_load_plugin(channels, instance->settings,
|
||||
"guacsnd", guac_client_data->audio))
|
||||
"guacsnd", client))
|
||||
guac_client_log(client, GUAC_LOG_WARNING,
|
||||
"Failed to load guacsnd plugin. Audio will not work.");
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2013 Glyptodon LLC
|
||||
* Copyright (C) 2015 Glyptodon LLC
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@ -44,8 +44,7 @@
|
||||
/* MESSAGE HANDLERS */
|
||||
|
||||
void guac_rdpsnd_formats_handler(guac_rdpsndPlugin* rdpsnd,
|
||||
guac_audio_stream* audio, wStream* input_stream,
|
||||
guac_rdpsnd_pdu_header* header) {
|
||||
wStream* input_stream, guac_rdpsnd_pdu_header* header) {
|
||||
|
||||
int server_format_count;
|
||||
int server_version;
|
||||
@ -55,8 +54,12 @@ void guac_rdpsnd_formats_handler(guac_rdpsndPlugin* rdpsnd,
|
||||
int output_body_size;
|
||||
unsigned char* output_stream_end;
|
||||
|
||||
rdp_guac_client_data* guac_client_data =
|
||||
(rdp_guac_client_data*) audio->client->data;
|
||||
/* Get associated client data */
|
||||
guac_client* client = rdpsnd->client;
|
||||
rdp_guac_client_data* client_data = (rdp_guac_client_data*) client->data;
|
||||
|
||||
/* Get audio stream from client data */
|
||||
guac_audio_stream* audio = client_data->audio;
|
||||
|
||||
/* Format header */
|
||||
Stream_Seek(input_stream, 14);
|
||||
@ -128,7 +131,7 @@ void guac_rdpsnd_formats_handler(guac_rdpsndPlugin* rdpsnd,
|
||||
rdpsnd->formats[current].bps = bps;
|
||||
|
||||
/* Log format */
|
||||
guac_client_log(audio->client, GUAC_LOG_INFO,
|
||||
guac_client_log(client, GUAC_LOG_INFO,
|
||||
"Accepted format: %i-bit PCM with %i channels at "
|
||||
"%i Hz",
|
||||
bps, channels, rate);
|
||||
@ -149,7 +152,7 @@ void guac_rdpsnd_formats_handler(guac_rdpsndPlugin* rdpsnd,
|
||||
|
||||
/* Otherwise, log that we dropped one */
|
||||
else
|
||||
guac_client_log(audio->client, GUAC_LOG_INFO,
|
||||
guac_client_log(client, GUAC_LOG_INFO,
|
||||
"Dropped valid format: %i-bit PCM with %i channels at "
|
||||
"%i Hz",
|
||||
bps, channels, rate);
|
||||
@ -174,7 +177,7 @@ void guac_rdpsnd_formats_handler(guac_rdpsndPlugin* rdpsnd,
|
||||
Stream_SetPointer(output_stream, output_stream_end);
|
||||
|
||||
/* Send accepted formats */
|
||||
pthread_mutex_lock(&(guac_client_data->rdp_lock));
|
||||
pthread_mutex_lock(&(client_data->rdp_lock));
|
||||
svc_plugin_send((rdpSvcPlugin*)rdpsnd, output_stream);
|
||||
|
||||
/* If version greater than 6, must send Quality Mode PDU */
|
||||
@ -191,20 +194,20 @@ void guac_rdpsnd_formats_handler(guac_rdpsndPlugin* rdpsnd,
|
||||
svc_plugin_send((rdpSvcPlugin*)rdpsnd, output_stream);
|
||||
}
|
||||
|
||||
pthread_mutex_unlock(&(guac_client_data->rdp_lock));
|
||||
pthread_mutex_unlock(&(client_data->rdp_lock));
|
||||
|
||||
}
|
||||
|
||||
/* server is getting a feel of the round trip time */
|
||||
void guac_rdpsnd_training_handler(guac_rdpsndPlugin* rdpsnd,
|
||||
guac_audio_stream* audio, wStream* input_stream,
|
||||
guac_rdpsnd_pdu_header* header) {
|
||||
wStream* input_stream, guac_rdpsnd_pdu_header* header) {
|
||||
|
||||
int data_size;
|
||||
wStream* output_stream;
|
||||
|
||||
rdp_guac_client_data* guac_client_data =
|
||||
(rdp_guac_client_data*) audio->client->data;
|
||||
/* Get associated client data */
|
||||
guac_client* client = rdpsnd->client;
|
||||
rdp_guac_client_data* client_data = (rdp_guac_client_data*) client->data;
|
||||
|
||||
/* Read timestamp and data size */
|
||||
Stream_Read_UINT16(input_stream, rdpsnd->server_timestamp);
|
||||
@ -218,18 +221,24 @@ void guac_rdpsnd_training_handler(guac_rdpsndPlugin* rdpsnd,
|
||||
Stream_Write_UINT16(output_stream, rdpsnd->server_timestamp);
|
||||
Stream_Write_UINT16(output_stream, data_size);
|
||||
|
||||
pthread_mutex_lock(&(guac_client_data->rdp_lock));
|
||||
pthread_mutex_lock(&(client_data->rdp_lock));
|
||||
svc_plugin_send((rdpSvcPlugin*) rdpsnd, output_stream);
|
||||
pthread_mutex_unlock(&(guac_client_data->rdp_lock));
|
||||
pthread_mutex_unlock(&(client_data->rdp_lock));
|
||||
|
||||
}
|
||||
|
||||
void guac_rdpsnd_wave_info_handler(guac_rdpsndPlugin* rdpsnd,
|
||||
guac_audio_stream* audio, wStream* input_stream,
|
||||
guac_rdpsnd_pdu_header* header) {
|
||||
wStream* input_stream, guac_rdpsnd_pdu_header* header) {
|
||||
|
||||
int format;
|
||||
|
||||
/* Get associated client data */
|
||||
guac_client* client = rdpsnd->client;
|
||||
rdp_guac_client_data* client_data = (rdp_guac_client_data*) client->data;
|
||||
|
||||
/* Get audio stream from client data */
|
||||
guac_audio_stream* audio = client_data->audio;
|
||||
|
||||
/* Read wave information */
|
||||
Stream_Read_UINT16(input_stream, rdpsnd->server_timestamp);
|
||||
Stream_Read_UINT16(input_stream, format);
|
||||
@ -256,13 +265,16 @@ void guac_rdpsnd_wave_info_handler(guac_rdpsndPlugin* rdpsnd,
|
||||
}
|
||||
|
||||
void guac_rdpsnd_wave_handler(guac_rdpsndPlugin* rdpsnd,
|
||||
guac_audio_stream* audio, wStream* input_stream,
|
||||
guac_rdpsnd_pdu_header* header) {
|
||||
wStream* input_stream, guac_rdpsnd_pdu_header* header) {
|
||||
|
||||
rdpSvcPlugin* plugin = (rdpSvcPlugin*)rdpsnd;
|
||||
|
||||
rdp_guac_client_data* guac_client_data =
|
||||
(rdp_guac_client_data*) audio->client->data;
|
||||
/* Get associated client data */
|
||||
guac_client* client = rdpsnd->client;
|
||||
rdp_guac_client_data* client_data = (rdp_guac_client_data*) client->data;
|
||||
|
||||
/* Get audio stream from client data */
|
||||
guac_audio_stream* audio = client_data->audio;
|
||||
|
||||
/* Wave Confirmation PDU */
|
||||
wStream* output_stream = Stream_New(NULL, 8);
|
||||
@ -286,9 +298,9 @@ void guac_rdpsnd_wave_handler(guac_rdpsndPlugin* rdpsnd,
|
||||
Stream_Write_UINT8(output_stream, 0);
|
||||
|
||||
/* Send Wave Confirmation PDU */
|
||||
pthread_mutex_lock(&(guac_client_data->rdp_lock));
|
||||
pthread_mutex_lock(&(client_data->rdp_lock));
|
||||
svc_plugin_send(plugin, output_stream);
|
||||
pthread_mutex_unlock(&(guac_client_data->rdp_lock));
|
||||
pthread_mutex_unlock(&(client_data->rdp_lock));
|
||||
|
||||
/* We no longer expect to receive wave data */
|
||||
rdpsnd->next_pdu_is_wave = FALSE;
|
||||
@ -296,8 +308,7 @@ void guac_rdpsnd_wave_handler(guac_rdpsndPlugin* rdpsnd,
|
||||
}
|
||||
|
||||
void guac_rdpsnd_close_handler(guac_rdpsndPlugin* rdpsnd,
|
||||
guac_audio_stream* audio, wStream* input_stream,
|
||||
guac_rdpsnd_pdu_header* header) {
|
||||
wStream* input_stream, guac_rdpsnd_pdu_header* header) {
|
||||
|
||||
/* STUB: Do nothing for now */
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2013 Glyptodon LLC
|
||||
* Copyright (C) 2015 Glyptodon LLC
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@ -28,8 +28,6 @@
|
||||
|
||||
#include "rdpsnd_service.h"
|
||||
|
||||
#include <guacamole/audio.h>
|
||||
|
||||
#ifdef ENABLE_WINPR
|
||||
#include <winpr/stream.h>
|
||||
#else
|
||||
@ -125,36 +123,31 @@ typedef struct guac_rdpsnd_pdu_header {
|
||||
* Handler for the SNDC_FORMATS (Server Audio Formats and Version) PDU.
|
||||
*/
|
||||
void guac_rdpsnd_formats_handler(guac_rdpsndPlugin* rdpsnd,
|
||||
guac_audio_stream* audio, wStream* input_stream,
|
||||
guac_rdpsnd_pdu_header* header);
|
||||
wStream* input_stream, guac_rdpsnd_pdu_header* header);
|
||||
|
||||
/**
|
||||
* Handler for the SNDC_TRAINING (Training) PDU.
|
||||
*/
|
||||
void guac_rdpsnd_training_handler(guac_rdpsndPlugin* rdpsnd,
|
||||
guac_audio_stream* audio, wStream* input_stream,
|
||||
guac_rdpsnd_pdu_header* header);
|
||||
wStream* input_stream, guac_rdpsnd_pdu_header* header);
|
||||
|
||||
/**
|
||||
* Handler for the SNDC_WAVE (WaveInfo) PDU.
|
||||
*/
|
||||
void guac_rdpsnd_wave_info_handler(guac_rdpsndPlugin* rdpsnd,
|
||||
guac_audio_stream* audio, wStream* input_stream,
|
||||
guac_rdpsnd_pdu_header* header);
|
||||
wStream* input_stream, guac_rdpsnd_pdu_header* header);
|
||||
|
||||
/**
|
||||
* Handler for the SNDWAV (Wave) PDU which follows any WaveInfo PDU.
|
||||
*/
|
||||
void guac_rdpsnd_wave_handler(guac_rdpsndPlugin* rdpsnd,
|
||||
guac_audio_stream* audio, wStream* input_stream,
|
||||
guac_rdpsnd_pdu_header* header);
|
||||
wStream* input_stream, guac_rdpsnd_pdu_header* header);
|
||||
|
||||
/**
|
||||
* Handler for the SNDC_CLOSE (Close) PDU.
|
||||
*/
|
||||
void guac_rdpsnd_close_handler(guac_rdpsndPlugin* rdpsnd,
|
||||
guac_audio_stream* audio, wStream* input_stream,
|
||||
guac_rdpsnd_pdu_header* header);
|
||||
wStream* input_stream, guac_rdpsnd_pdu_header* header);
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2013 Glyptodon LLC
|
||||
* Copyright (C) 2015 Glyptodon LLC
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@ -30,7 +30,6 @@
|
||||
|
||||
#include <freerdp/constants.h>
|
||||
#include <freerdp/utils/svc_plugin.h>
|
||||
#include <guacamole/audio.h>
|
||||
#include <guacamole/client.h>
|
||||
|
||||
#ifdef ENABLE_WINPR
|
||||
@ -73,11 +72,11 @@ void guac_rdpsnd_process_connect(rdpSvcPlugin* plugin) {
|
||||
|
||||
guac_rdpsndPlugin* rdpsnd = (guac_rdpsndPlugin*) plugin;
|
||||
|
||||
/* Get audio stream from plugin parameters */
|
||||
guac_audio_stream* audio = rdpsnd->audio =
|
||||
(guac_audio_stream*) plugin->channel_entry_points.pExtendedData;
|
||||
/* Get client from plugin parameters */
|
||||
guac_client* client = rdpsnd->client =
|
||||
(guac_client*) plugin->channel_entry_points.pExtendedData;
|
||||
|
||||
/* NULL out pExtendedData so we don't lose our guac_audio_stream due to an
|
||||
/* NULL out pExtendedData so we don't lose our guac_client due to an
|
||||
* automatic free() within libfreerdp */
|
||||
plugin->channel_entry_points.pExtendedData = NULL;
|
||||
|
||||
@ -87,7 +86,7 @@ void guac_rdpsnd_process_connect(rdpSvcPlugin* plugin) {
|
||||
#endif
|
||||
|
||||
/* Log that sound has been loaded */
|
||||
guac_client_log(audio->client, GUAC_LOG_INFO, "guacsnd connected.");
|
||||
guac_client_log(client, GUAC_LOG_INFO, "guacsnd connected.");
|
||||
|
||||
}
|
||||
|
||||
@ -105,9 +104,6 @@ void guac_rdpsnd_process_receive(rdpSvcPlugin* plugin,
|
||||
guac_rdpsndPlugin* rdpsnd = (guac_rdpsndPlugin*) plugin;
|
||||
guac_rdpsnd_pdu_header header;
|
||||
|
||||
/* Get audio stream from plugin */
|
||||
guac_audio_stream* audio = rdpsnd->audio;
|
||||
|
||||
/* Read RDPSND PDU header */
|
||||
Stream_Read_UINT8(input_stream, header.message_type);
|
||||
Stream_Seek_UINT8(input_stream);
|
||||
@ -118,7 +114,7 @@ void guac_rdpsnd_process_receive(rdpSvcPlugin* plugin,
|
||||
* ignore the header and parse as a Wave PDU.
|
||||
*/
|
||||
if (rdpsnd->next_pdu_is_wave) {
|
||||
guac_rdpsnd_wave_handler(rdpsnd, audio, input_stream, &header);
|
||||
guac_rdpsnd_wave_handler(rdpsnd, input_stream, &header);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -127,26 +123,22 @@ void guac_rdpsnd_process_receive(rdpSvcPlugin* plugin,
|
||||
|
||||
/* Server Audio Formats and Version PDU */
|
||||
case SNDC_FORMATS:
|
||||
guac_rdpsnd_formats_handler(rdpsnd, audio,
|
||||
input_stream, &header);
|
||||
guac_rdpsnd_formats_handler(rdpsnd, input_stream, &header);
|
||||
break;
|
||||
|
||||
/* Training PDU */
|
||||
case SNDC_TRAINING:
|
||||
guac_rdpsnd_training_handler(rdpsnd, audio,
|
||||
input_stream, &header);
|
||||
guac_rdpsnd_training_handler(rdpsnd, input_stream, &header);
|
||||
break;
|
||||
|
||||
/* WaveInfo PDU */
|
||||
case SNDC_WAVE:
|
||||
guac_rdpsnd_wave_info_handler(rdpsnd, audio,
|
||||
input_stream, &header);
|
||||
guac_rdpsnd_wave_info_handler(rdpsnd, input_stream, &header);
|
||||
break;
|
||||
|
||||
/* Close PDU */
|
||||
case SNDC_CLOSE:
|
||||
guac_rdpsnd_close_handler(rdpsnd, audio,
|
||||
input_stream, &header);
|
||||
guac_rdpsnd_close_handler(rdpsnd, input_stream, &header);
|
||||
break;
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2013 Glyptodon LLC
|
||||
* Copyright (C) 2015 Glyptodon LLC
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@ -27,7 +27,7 @@
|
||||
#include "config.h"
|
||||
|
||||
#include <freerdp/utils/svc_plugin.h>
|
||||
#include <guacamole/audio.h>
|
||||
#include <guacamole/client.h>
|
||||
|
||||
#ifdef ENABLE_WINPR
|
||||
#include <winpr/stream.h>
|
||||
@ -80,9 +80,10 @@ typedef struct guac_rdpsndPlugin {
|
||||
rdpSvcPlugin plugin;
|
||||
|
||||
/**
|
||||
* The current audio stream.
|
||||
* The Guacamole client associated with the guac_audio_stream that this
|
||||
* plugin should use to stream received audio packets.
|
||||
*/
|
||||
guac_audio_stream* audio;
|
||||
guac_client* client;
|
||||
|
||||
/**
|
||||
* The block number of the last SNDC_WAVE (WaveInfo) PDU received.
|
||||
|
Loading…
Reference in New Issue
Block a user