Pass stream to guac_rdpsnd.
This commit is contained in:
parent
f417f37f5f
commit
2960331884
@ -31,6 +31,7 @@
|
|||||||
|
|
||||||
#include <guacamole/client.h>
|
#include <guacamole/client.h>
|
||||||
|
|
||||||
|
#include "audio.h"
|
||||||
#include "service.h"
|
#include "service.h"
|
||||||
#include "messages.h"
|
#include "messages.h"
|
||||||
|
|
||||||
@ -39,7 +40,7 @@
|
|||||||
/* receives a list of server supported formats and returns a list
|
/* receives a list of server supported formats and returns a list
|
||||||
of client supported formats */
|
of client supported formats */
|
||||||
void guac_rdpsnd_process_message_formats(guac_rdpsndPlugin* rdpsnd,
|
void guac_rdpsnd_process_message_formats(guac_rdpsndPlugin* rdpsnd,
|
||||||
guac_client* client, STREAM* input_stream) {
|
audio_stream* audio, STREAM* input_stream) {
|
||||||
|
|
||||||
uint16 wNumberOfFormats;
|
uint16 wNumberOfFormats;
|
||||||
uint16 nFormat;
|
uint16 nFormat;
|
||||||
@ -96,7 +97,7 @@ void guac_rdpsnd_process_message_formats(guac_rdpsndPlugin* rdpsnd,
|
|||||||
|
|
||||||
if (format->wFormatTag == WAVE_FORMAT_PCM) {
|
if (format->wFormatTag == WAVE_FORMAT_PCM) {
|
||||||
|
|
||||||
guac_client_log_info(client,
|
guac_client_log_info(audio->client,
|
||||||
"Accepted format: %i-bit PCM with %i channels at "
|
"Accepted format: %i-bit PCM with %i channels at "
|
||||||
"%i Hz",
|
"%i Hz",
|
||||||
format->wBitsPerSample,
|
format->wBitsPerSample,
|
||||||
@ -143,7 +144,7 @@ void guac_rdpsnd_process_message_formats(guac_rdpsndPlugin* rdpsnd,
|
|||||||
|
|
||||||
/* server is getting a feel of the round trip time */
|
/* server is getting a feel of the round trip time */
|
||||||
void guac_rdpsnd_process_message_training(guac_rdpsndPlugin* rdpsnd,
|
void guac_rdpsnd_process_message_training(guac_rdpsndPlugin* rdpsnd,
|
||||||
guac_client* client, STREAM* input_stream) {
|
audio_stream* audio, STREAM* input_stream) {
|
||||||
|
|
||||||
uint16 wTimeStamp;
|
uint16 wTimeStamp;
|
||||||
uint16 wPackSize;
|
uint16 wPackSize;
|
||||||
@ -165,7 +166,7 @@ void guac_rdpsnd_process_message_training(guac_rdpsndPlugin* rdpsnd,
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void guac_rdpsnd_process_message_wave_info(guac_rdpsndPlugin* rdpsnd, guac_client* client, STREAM* input_stream, uint16 BodySize) {
|
void guac_rdpsnd_process_message_wave_info(guac_rdpsndPlugin* rdpsnd, audio_stream* audio, STREAM* input_stream, uint16 BodySize) {
|
||||||
|
|
||||||
uint16 wFormatNo;
|
uint16 wFormatNo;
|
||||||
|
|
||||||
@ -184,7 +185,7 @@ void guac_rdpsnd_process_message_wave_info(guac_rdpsndPlugin* rdpsnd, guac_clien
|
|||||||
|
|
||||||
/* header is not removed from data in this function */
|
/* header is not removed from data in this function */
|
||||||
void rdpsnd_process_message_wave(guac_rdpsndPlugin* rdpsnd,
|
void rdpsnd_process_message_wave(guac_rdpsndPlugin* rdpsnd,
|
||||||
guac_client* client, STREAM* input_stream) {
|
audio_stream* audio, STREAM* input_stream) {
|
||||||
|
|
||||||
rdpSvcPlugin* plugin = (rdpSvcPlugin*)rdpsnd;
|
rdpSvcPlugin* plugin = (rdpSvcPlugin*)rdpsnd;
|
||||||
|
|
||||||
@ -202,7 +203,7 @@ void rdpsnd_process_message_wave(guac_rdpsndPlugin* rdpsnd,
|
|||||||
buffer = stream_get_head(input_stream);
|
buffer = stream_get_head(input_stream);
|
||||||
size = stream_get_size(input_stream);
|
size = stream_get_size(input_stream);
|
||||||
|
|
||||||
guac_client_log_info(client, "Got sound: %i bytes.", size);
|
guac_client_log_info(audio->client, "Got sound: %i bytes.", size);
|
||||||
|
|
||||||
output_stream = stream_new(8);
|
output_stream = stream_new(8);
|
||||||
stream_write_uint8(output_stream, SNDC_WAVECONFIRM);
|
stream_write_uint8(output_stream, SNDC_WAVECONFIRM);
|
||||||
@ -217,7 +218,7 @@ void rdpsnd_process_message_wave(guac_rdpsndPlugin* rdpsnd,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void guac_rdpsnd_process_message_setvolume(guac_rdpsndPlugin* rdpsnd,
|
void guac_rdpsnd_process_message_setvolume(guac_rdpsndPlugin* rdpsnd,
|
||||||
guac_client* client, STREAM* input_stream) {
|
audio_stream* audio, STREAM* input_stream) {
|
||||||
|
|
||||||
/* Ignored for now */
|
/* Ignored for now */
|
||||||
uint32 dwVolume;
|
uint32 dwVolume;
|
||||||
@ -226,7 +227,7 @@ void guac_rdpsnd_process_message_setvolume(guac_rdpsndPlugin* rdpsnd,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void guac_rdpsnd_process_message_close(guac_rdpsndPlugin* rdpsnd,
|
void guac_rdpsnd_process_message_close(guac_rdpsndPlugin* rdpsnd,
|
||||||
guac_client* client) {
|
audio_stream* audio) {
|
||||||
rdpsnd->plugin.interval_ms = 10;
|
rdpsnd->plugin.interval_ms = 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,22 +54,22 @@ typedef struct rdpsndFormat {
|
|||||||
} rdpsndFormat;
|
} rdpsndFormat;
|
||||||
|
|
||||||
void guac_rdpsnd_process_message_formats(guac_rdpsndPlugin* rdpsnd,
|
void guac_rdpsnd_process_message_formats(guac_rdpsndPlugin* rdpsnd,
|
||||||
guac_client* client, STREAM* data_in);
|
audio_stream* audio, STREAM* data_in);
|
||||||
|
|
||||||
void guac_rdpsnd_process_message_training(guac_rdpsndPlugin* rdpsnd,
|
void guac_rdpsnd_process_message_training(guac_rdpsndPlugin* rdpsnd,
|
||||||
guac_client* client, STREAM* data_in);
|
audio_stream* audio, STREAM* data_in);
|
||||||
|
|
||||||
void guac_rdpsnd_process_message_wave_info(guac_rdpsndPlugin* rdpsnd,
|
void guac_rdpsnd_process_message_wave_info(guac_rdpsndPlugin* rdpsnd,
|
||||||
guac_client* client, STREAM* data_in, uint16 BodySize);
|
audio_stream* audio, STREAM* data_in, uint16 BodySize);
|
||||||
|
|
||||||
void rdpsnd_process_message_wave(guac_rdpsndPlugin* rdpsnd,
|
void rdpsnd_process_message_wave(guac_rdpsndPlugin* rdpsnd,
|
||||||
guac_client* client, STREAM* data_in);
|
audio_stream* audio, STREAM* data_in);
|
||||||
|
|
||||||
void guac_rdpsnd_process_message_setvolume(guac_rdpsndPlugin* rdpsnd,
|
void guac_rdpsnd_process_message_setvolume(guac_rdpsndPlugin* rdpsnd,
|
||||||
guac_client* client, STREAM* data_in);
|
audio_stream* audio, STREAM* data_in);
|
||||||
|
|
||||||
void guac_rdpsnd_process_message_close(guac_rdpsndPlugin* rdpsnd,
|
void guac_rdpsnd_process_message_close(guac_rdpsndPlugin* rdpsnd,
|
||||||
guac_client* client);
|
audio_stream* audio);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -31,6 +31,7 @@
|
|||||||
|
|
||||||
#include <guacamole/client.h>
|
#include <guacamole/client.h>
|
||||||
|
|
||||||
|
#include "audio.h"
|
||||||
#include "service.h"
|
#include "service.h"
|
||||||
#include "messages.h"
|
#include "messages.h"
|
||||||
|
|
||||||
@ -41,12 +42,12 @@ DEFINE_SVC_PLUGIN(guac_rdpsnd, "rdpsnd",
|
|||||||
|
|
||||||
void guac_rdpsnd_process_connect(rdpSvcPlugin* plugin) {
|
void guac_rdpsnd_process_connect(rdpSvcPlugin* plugin) {
|
||||||
|
|
||||||
/* Get client from plugin */
|
/* Get audio stream from plugin */
|
||||||
guac_client* client = (guac_client*)
|
audio_stream* audio = (audio_stream*)
|
||||||
plugin->channel_entry_points.pExtendedData;
|
plugin->channel_entry_points.pExtendedData;
|
||||||
|
|
||||||
/* Log that sound has been loaded */
|
/* Log that sound has been loaded */
|
||||||
guac_client_log_info(client, "guac_rdpsnd connected.");
|
guac_client_log_info(audio->client, "guac_rdpsnd connected.");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -63,15 +64,15 @@ void guac_rdpsnd_process_receive(rdpSvcPlugin* plugin,
|
|||||||
|
|
||||||
guac_rdpsndPlugin* rdpsnd = (guac_rdpsndPlugin*) plugin;
|
guac_rdpsndPlugin* rdpsnd = (guac_rdpsndPlugin*) plugin;
|
||||||
|
|
||||||
/* Get client from plugin */
|
/* Get audio stream from plugin */
|
||||||
guac_client* client = (guac_client*)
|
audio_stream* audio = (audio_stream*)
|
||||||
plugin->channel_entry_points.pExtendedData;
|
plugin->channel_entry_points.pExtendedData;
|
||||||
|
|
||||||
uint8 msgType;
|
uint8 msgType;
|
||||||
uint16 BodySize;
|
uint16 BodySize;
|
||||||
|
|
||||||
if (rdpsnd->expectingWave) {
|
if (rdpsnd->expectingWave) {
|
||||||
rdpsnd_process_message_wave(rdpsnd, client, input_stream);
|
rdpsnd_process_message_wave(rdpsnd, audio, input_stream);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -83,23 +84,23 @@ void guac_rdpsnd_process_receive(rdpSvcPlugin* plugin,
|
|||||||
switch (msgType) {
|
switch (msgType) {
|
||||||
|
|
||||||
case SNDC_FORMATS:
|
case SNDC_FORMATS:
|
||||||
guac_rdpsnd_process_message_formats(rdpsnd, client, input_stream);
|
guac_rdpsnd_process_message_formats(rdpsnd, audio, input_stream);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SNDC_TRAINING:
|
case SNDC_TRAINING:
|
||||||
guac_rdpsnd_process_message_training(rdpsnd, client, input_stream);
|
guac_rdpsnd_process_message_training(rdpsnd, audio, input_stream);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SNDC_WAVE:
|
case SNDC_WAVE:
|
||||||
guac_rdpsnd_process_message_wave_info(rdpsnd, client, input_stream, BodySize);
|
guac_rdpsnd_process_message_wave_info(rdpsnd, audio, input_stream, BodySize);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SNDC_CLOSE:
|
case SNDC_CLOSE:
|
||||||
guac_rdpsnd_process_message_close(rdpsnd, client);
|
guac_rdpsnd_process_message_close(rdpsnd, audio);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SNDC_SETVOLUME:
|
case SNDC_SETVOLUME:
|
||||||
guac_rdpsnd_process_message_setvolume(rdpsnd, client, input_stream);
|
guac_rdpsnd_process_message_setvolume(rdpsnd, audio, input_stream);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -45,6 +45,7 @@
|
|||||||
|
|
||||||
#include <guacamole/client.h>
|
#include <guacamole/client.h>
|
||||||
|
|
||||||
|
#include "audio.h"
|
||||||
#include "rdp_keymap.h"
|
#include "rdp_keymap.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -138,6 +139,11 @@ typedef struct rdp_guac_client_data {
|
|||||||
*/
|
*/
|
||||||
char* clipboard;
|
char* clipboard;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Audio output, if any.
|
||||||
|
*/
|
||||||
|
audio_stream* audio;
|
||||||
|
|
||||||
} rdp_guac_client_data;
|
} rdp_guac_client_data;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -61,6 +61,9 @@
|
|||||||
#include <guacamole/client.h>
|
#include <guacamole/client.h>
|
||||||
#include <guacamole/error.h>
|
#include <guacamole/error.h>
|
||||||
|
|
||||||
|
#include "audio.h"
|
||||||
|
#include "ogg_encoder.h"
|
||||||
|
|
||||||
#include "client.h"
|
#include "client.h"
|
||||||
#include "guac_handlers.h"
|
#include "guac_handlers.h"
|
||||||
#include "rdp_keymap.h"
|
#include "rdp_keymap.h"
|
||||||
@ -110,16 +113,43 @@ boolean rdp_freerdp_pre_connect(freerdp* instance) {
|
|||||||
rdpPointer* pointer;
|
rdpPointer* pointer;
|
||||||
rdpPrimaryUpdate* primary;
|
rdpPrimaryUpdate* primary;
|
||||||
CLRCONV* clrconv;
|
CLRCONV* clrconv;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
rdp_guac_client_data* guac_client_data =
|
||||||
|
(rdp_guac_client_data*) client->data;
|
||||||
|
|
||||||
/* Load clipboard plugin */
|
/* Load clipboard plugin */
|
||||||
if (freerdp_channels_load_plugin(channels, instance->settings,
|
if (freerdp_channels_load_plugin(channels, instance->settings,
|
||||||
"cliprdr", NULL))
|
"cliprdr", NULL))
|
||||||
guac_client_log_error(client, "Failed to load cliprdr plugin.");
|
guac_client_log_error(client, "Failed to load cliprdr plugin.");
|
||||||
|
|
||||||
|
/* Choose an encoding */
|
||||||
|
for (i=0; client->info.audio_mimetypes[i] != NULL; i++) {
|
||||||
|
|
||||||
|
const char* mimetype = client->info.audio_mimetypes[i];
|
||||||
|
|
||||||
|
// If Ogg is supported, done.
|
||||||
|
if (strcmp(mimetype, "audio/ogg") == 0) {
|
||||||
|
guac_client_log_info(client, "Loading Ogg Vorbis encoder.");
|
||||||
|
guac_client_data->audio = audio_stream_alloc(client, ogg_encoder);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* If an encoding is available, load the sound plugin */
|
||||||
|
if (guac_client_data->audio != NULL) {
|
||||||
|
|
||||||
/* Load sound plugin */
|
/* Load sound plugin */
|
||||||
if (freerdp_channels_load_plugin(channels, instance->settings,
|
if (freerdp_channels_load_plugin(channels, instance->settings,
|
||||||
"guac_rdpsnd", client))
|
"guac_rdpsnd", guac_client_data->audio))
|
||||||
guac_client_log_error(client, "Failed to load guac_rdpsnd plugin.");
|
guac_client_log_error(client,
|
||||||
|
"Failed to load guac_rdpsnd plugin.");
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
guac_client_log_info(client,
|
||||||
|
"No available audio encoding. Sound disabled.");
|
||||||
|
|
||||||
/* Init color conversion structure */
|
/* Init color conversion structure */
|
||||||
clrconv = xnew(CLRCONV);
|
clrconv = xnew(CLRCONV);
|
||||||
@ -425,6 +455,7 @@ int guac_client_init(guac_client* client, int argc, char** argv) {
|
|||||||
guac_client_data->mouse_button_mask = 0;
|
guac_client_data->mouse_button_mask = 0;
|
||||||
guac_client_data->current_surface = GUAC_DEFAULT_LAYER;
|
guac_client_data->current_surface = GUAC_DEFAULT_LAYER;
|
||||||
guac_client_data->clipboard = NULL;
|
guac_client_data->clipboard = NULL;
|
||||||
|
guac_client_data->audio = NULL;
|
||||||
|
|
||||||
/* Clear keysym state mapping and keymap */
|
/* Clear keysym state mapping and keymap */
|
||||||
memset(guac_client_data->keysym_state, 0,
|
memset(guac_client_data->keysym_state, 0,
|
||||||
|
Loading…
Reference in New Issue
Block a user