Completely rewrite guac_rdpsnd based on knowledge gained from inspection and modification of the FreeRDP rdpsnd plugin (plus reading MS docs), update license.
This commit is contained in:
parent
fccec2e5e4
commit
6e3f04536b
@ -1,33 +1,47 @@
|
|||||||
/**
|
|
||||||
* FreeRDP: A Remote Desktop Protocol client.
|
/* ***** BEGIN LICENSE BLOCK *****
|
||||||
* Audio Output Virtual Channel
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||||
*
|
*
|
||||||
* Copyright 2009-2011 Jay Sorg
|
* The contents of this file are subject to the Mozilla Public License Version
|
||||||
* Copyright 2010-2011 Vic Lee
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||||
|
* the License. You may obtain a copy of the License at
|
||||||
|
* http://www.mozilla.org/MPL/
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||||
* you may not use this file except in compliance with the License.
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||||
* You may obtain a copy of the License at
|
* for the specific language governing rights and limitations under the
|
||||||
|
* License.
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* The Original Code is libguac-client-rdp.
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* The Initial Developer of the Original Code is
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* Michael Jumper.
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* Portions created by the Initial Developer are Copyright (C) 2011
|
||||||
* See the License for the specific language governing permissions and
|
* the Initial Developer. All Rights Reserved.
|
||||||
* limitations under the License.
|
*
|
||||||
*/
|
* Contributor(s):
|
||||||
|
*
|
||||||
|
* Alternatively, the contents of this file may be used under the terms of
|
||||||
|
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||||
|
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||||
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||||
|
* of those above. If you wish to allow use of your version of this file only
|
||||||
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||||
|
* use your version of this file under the terms of the MPL, indicate your
|
||||||
|
* decision by deleting the provisions above and replace them with the notice
|
||||||
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||||
|
* the provisions above, a recipient may use your version of this file under
|
||||||
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||||
|
*
|
||||||
|
* ***** END LICENSE BLOCK ***** */
|
||||||
|
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <freerdp/constants.h>
|
#include <freerdp/constants.h>
|
||||||
#include <freerdp/types.h>
|
#include <freerdp/types.h>
|
||||||
#include <freerdp/utils/memory.h>
|
#include <freerdp/utils/memory.h>
|
||||||
#include <freerdp/utils/stream.h>
|
#include <freerdp/utils/stream.h>
|
||||||
#include <freerdp/utils/list.h>
|
|
||||||
#include <freerdp/utils/load_plugin.h>
|
|
||||||
#include <freerdp/utils/svc_plugin.h>
|
#include <freerdp/utils/svc_plugin.h>
|
||||||
|
|
||||||
#include <guacamole/client.h>
|
#include <guacamole/client.h>
|
||||||
@ -39,94 +53,104 @@
|
|||||||
|
|
||||||
/* MESSAGE HANDLERS */
|
/* MESSAGE HANDLERS */
|
||||||
|
|
||||||
/* receives a list of server supported formats and returns a list
|
void guac_rdpsnd_formats_handler(guac_rdpsndPlugin* rdpsnd,
|
||||||
of client supported formats */
|
audio_stream* audio, STREAM* input_stream,
|
||||||
void guac_rdpsnd_process_message_formats(guac_rdpsndPlugin* rdpsnd,
|
guac_rdpsnd_pdu_header* header) {
|
||||||
audio_stream* audio, STREAM* input_stream) {
|
|
||||||
|
|
||||||
uint16 wNumberOfFormats;
|
int server_format_count;
|
||||||
uint16 nFormat;
|
int server_version;
|
||||||
uint16 wVersion;
|
int i;
|
||||||
STREAM* output_stream;
|
|
||||||
rdpsndFormat* out_formats;
|
STREAM* output_stream;
|
||||||
uint16 n_out_formats;
|
int output_body_size;
|
||||||
rdpsndFormat* format;
|
unsigned char* output_stream_end;
|
||||||
uint8* format_mark;
|
|
||||||
uint8* data_mark;
|
|
||||||
int pos;
|
|
||||||
|
|
||||||
rdp_guac_client_data* guac_client_data =
|
rdp_guac_client_data* guac_client_data =
|
||||||
(rdp_guac_client_data*) audio->client->data;
|
(rdp_guac_client_data*) audio->client->data;
|
||||||
|
|
||||||
stream_seek_uint32(input_stream); /* dwFlags */
|
/* Format header */
|
||||||
stream_seek_uint32(input_stream); /* dwVolume */
|
stream_seek(input_stream, 14);
|
||||||
stream_seek_uint32(input_stream); /* dwPitch */
|
stream_read_uint16(input_stream, server_format_count);
|
||||||
stream_seek_uint16(input_stream); /* wDGramPort */
|
stream_seek_uint8(input_stream);
|
||||||
stream_read_uint16(input_stream, wNumberOfFormats);
|
stream_read_uint16(input_stream, server_version);
|
||||||
stream_read_uint8(input_stream, rdpsnd->cBlockNo); /* cLastBlockConfirmed */
|
stream_seek_uint8(input_stream);
|
||||||
stream_read_uint16(input_stream, wVersion);
|
|
||||||
stream_seek_uint8(input_stream); /* bPad */
|
|
||||||
|
|
||||||
out_formats = (rdpsndFormat*)
|
/* Initialize Client Audio Formats and Version PDU */
|
||||||
xzalloc(wNumberOfFormats * sizeof(rdpsndFormat));
|
output_stream = stream_new(24);
|
||||||
|
stream_write_uint8(output_stream, SNDC_FORMATS);
|
||||||
|
stream_write_uint8(output_stream, 0);
|
||||||
|
|
||||||
n_out_formats = 0;
|
/* Fill in body size later */
|
||||||
|
stream_seek_uint16(output_stream); /* offset = 0x02 */
|
||||||
|
|
||||||
output_stream = stream_new(24);
|
/* Flags, volume, and pitch */
|
||||||
stream_write_uint8(output_stream, SNDC_FORMATS); /* msgType */
|
stream_write_uint32(output_stream, TSSNDCAPS_ALIVE);
|
||||||
stream_write_uint8(output_stream, 0); /* bPad */
|
stream_write_uint32(output_stream, 0);
|
||||||
stream_seek_uint16(output_stream); /* BodySize */
|
stream_write_uint32(output_stream, 0);
|
||||||
stream_write_uint32(output_stream, TSSNDCAPS_ALIVE); /* dwFlags */
|
|
||||||
stream_write_uint32(output_stream, 0); /* dwVolume */
|
|
||||||
stream_write_uint32(output_stream, 0); /* dwPitch */
|
|
||||||
stream_write_uint16_be(output_stream, 0); /* wDGramPort */
|
|
||||||
stream_seek_uint16(output_stream); /* wNumberOfFormats */
|
|
||||||
stream_write_uint8(output_stream, 0); /* cLastBlockConfirmed */
|
|
||||||
stream_write_uint16(output_stream, 6); /* wVersion */
|
|
||||||
stream_write_uint8(output_stream, 0); /* bPad */
|
|
||||||
|
|
||||||
for (nFormat = 0; nFormat < wNumberOfFormats; nFormat++) {
|
/* Datagram port (UDP) */
|
||||||
|
stream_write_uint16(output_stream, 0);
|
||||||
|
|
||||||
stream_get_mark(input_stream, format_mark);
|
/* Fill in format count later */
|
||||||
format = &out_formats[n_out_formats];
|
stream_seek_uint16(output_stream); /* offset = 0x12 */
|
||||||
stream_read_uint16(input_stream, format->wFormatTag);
|
|
||||||
stream_read_uint16(input_stream, format->nChannels);
|
|
||||||
stream_read_uint32(input_stream, format->nSamplesPerSec);
|
|
||||||
stream_seek_uint32(input_stream); /* nAvgBytesPerSec */
|
|
||||||
stream_read_uint16(input_stream, format->nBlockAlign);
|
|
||||||
stream_read_uint16(input_stream, format->wBitsPerSample);
|
|
||||||
stream_read_uint16(input_stream, format->cbSize);
|
|
||||||
stream_get_mark(input_stream, data_mark);
|
|
||||||
stream_seek(input_stream, format->cbSize);
|
|
||||||
format->data = NULL;
|
|
||||||
|
|
||||||
if (format->wFormatTag == WAVE_FORMAT_PCM) {
|
/* Version and padding */
|
||||||
|
stream_write_uint8(output_stream, 0);
|
||||||
|
stream_write_uint16(output_stream, 6);
|
||||||
|
stream_write_uint8(output_stream, 0);
|
||||||
|
|
||||||
|
/* Check each server format, respond if supported */
|
||||||
|
for (i=0; i < server_format_count; i++) {
|
||||||
|
|
||||||
|
unsigned char* format_start;
|
||||||
|
|
||||||
|
int format_tag;
|
||||||
|
int channels;
|
||||||
|
int rate;
|
||||||
|
int bps;
|
||||||
|
int body_size;
|
||||||
|
|
||||||
|
/* Remember position in stream */
|
||||||
|
stream_get_mark(input_stream, format_start);
|
||||||
|
|
||||||
|
/* Read format */
|
||||||
|
stream_read_uint16(input_stream, format_tag);
|
||||||
|
stream_read_uint16(input_stream, channels);
|
||||||
|
stream_read_uint32(input_stream, rate);
|
||||||
|
stream_seek_uint32(input_stream);
|
||||||
|
stream_seek_uint16(input_stream);
|
||||||
|
stream_read_uint16(input_stream, bps);
|
||||||
|
|
||||||
|
/* Skip past extra data */
|
||||||
|
stream_read_uint16(input_stream, body_size);
|
||||||
|
stream_seek(input_stream, body_size);
|
||||||
|
|
||||||
|
/* If PCM, accept */
|
||||||
|
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 = format->nSamplesPerSec;
|
rdpsnd->formats[current].rate = rate;
|
||||||
rdpsnd->formats[current].channels = format->nChannels;
|
rdpsnd->formats[current].channels = channels;
|
||||||
rdpsnd->formats[current].bps = format->wBitsPerSample;
|
rdpsnd->formats[current].bps = bps;
|
||||||
|
|
||||||
/* Log format */
|
/* Log format */
|
||||||
guac_client_log_info(audio->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,
|
bps, channels, rate);
|
||||||
format->nChannels,
|
|
||||||
format->nSamplesPerSec);
|
|
||||||
|
|
||||||
/* Store as accepted for future response */
|
/* Queue format for sending as accepted */
|
||||||
stream_check_size(output_stream, 18 + format->cbSize);
|
stream_check_size(output_stream, 18 + body_size);
|
||||||
stream_write(output_stream, format_mark, 18 + format->cbSize);
|
stream_write(output_stream, format_start, 18 + body_size);
|
||||||
if (format->cbSize > 0) {
|
|
||||||
format->data = xmalloc(format->cbSize);
|
/*
|
||||||
memcpy(format->data, data_mark, format->cbSize);
|
* BEWARE that using stream_check_size means that any "marks"
|
||||||
}
|
* set via stream_set_mark on output_stream are invalid.
|
||||||
n_out_formats++;
|
*/
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -135,141 +159,155 @@ void guac_rdpsnd_process_message_formats(guac_rdpsndPlugin* rdpsnd,
|
|||||||
guac_client_log_info(audio->client,
|
guac_client_log_info(audio->client,
|
||||||
"Dropped valid format: %i-bit PCM with %i channels at "
|
"Dropped valid format: %i-bit PCM with %i channels at "
|
||||||
"%i Hz",
|
"%i Hz",
|
||||||
format->wBitsPerSample,
|
bps, channels, rate);
|
||||||
format->nChannels,
|
|
||||||
format->nSamplesPerSec);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
xfree(out_formats);
|
/* Calculate size of PDU */
|
||||||
|
output_body_size = stream_get_length(output_stream) - 4;
|
||||||
|
stream_get_mark(output_stream, output_stream_end);
|
||||||
|
|
||||||
pos = stream_get_pos(output_stream);
|
/* Set body size */
|
||||||
stream_set_pos(output_stream, 2);
|
stream_set_pos(output_stream, 0x02);
|
||||||
stream_write_uint16(output_stream, pos - 4);
|
stream_write_uint16(output_stream, output_body_size);
|
||||||
stream_set_pos(output_stream, 18);
|
|
||||||
stream_write_uint16(output_stream, n_out_formats);
|
|
||||||
stream_set_pos(output_stream, pos);
|
|
||||||
|
|
||||||
|
/* Set format count */
|
||||||
|
stream_set_pos(output_stream, 0x12);
|
||||||
|
stream_write_uint16(output_stream, rdpsnd->format_count);
|
||||||
|
|
||||||
|
/* Reposition cursor at end (necessary for message send) */
|
||||||
|
stream_set_mark(output_stream, output_stream_end);
|
||||||
|
|
||||||
|
/* Send accepted formats */
|
||||||
pthread_mutex_lock(&(guac_client_data->rdp_lock));
|
pthread_mutex_lock(&(guac_client_data->rdp_lock));
|
||||||
svc_plugin_send((rdpSvcPlugin*)rdpsnd, output_stream);
|
svc_plugin_send((rdpSvcPlugin*)rdpsnd, output_stream);
|
||||||
|
|
||||||
if (wVersion >= 6) {
|
/* If version greater than 6, must send Quality Mode PDU */
|
||||||
|
if (server_version >= 6) {
|
||||||
|
|
||||||
/* Respond with guality mode */
|
/* Always send High Quality for now */
|
||||||
output_stream = stream_new(8);
|
output_stream = stream_new(8);
|
||||||
stream_write_uint8(output_stream, SNDC_QUALITYMODE); /* msgType */
|
stream_write_uint8(output_stream, SNDC_QUALITYMODE);
|
||||||
stream_write_uint8(output_stream, 0); /* bPad */
|
stream_write_uint8(output_stream, 0);
|
||||||
stream_write_uint16(output_stream, 4); /* BodySize */
|
stream_write_uint16(output_stream, 4);
|
||||||
stream_write_uint16(output_stream, HIGH_QUALITY); /* wQualityMode */
|
stream_write_uint16(output_stream, HIGH_QUALITY);
|
||||||
stream_write_uint16(output_stream, 0); /* Reserved */
|
stream_write_uint16(output_stream, 0);
|
||||||
|
|
||||||
svc_plugin_send((rdpSvcPlugin*)rdpsnd, output_stream);
|
svc_plugin_send((rdpSvcPlugin*)rdpsnd, output_stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
pthread_mutex_unlock(&(guac_client_data->rdp_lock));
|
pthread_mutex_unlock(&(guac_client_data->rdp_lock));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 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_training_handler(guac_rdpsndPlugin* rdpsnd,
|
||||||
audio_stream* audio, STREAM* input_stream) {
|
audio_stream* audio, STREAM* input_stream,
|
||||||
|
guac_rdpsnd_pdu_header* header) {
|
||||||
|
|
||||||
uint16 wTimeStamp;
|
int data_size;
|
||||||
uint16 wPackSize;
|
STREAM* output_stream;
|
||||||
STREAM* output_stream;
|
|
||||||
|
|
||||||
rdp_guac_client_data* guac_client_data =
|
rdp_guac_client_data* guac_client_data =
|
||||||
(rdp_guac_client_data*) audio->client->data;
|
(rdp_guac_client_data*) audio->client->data;
|
||||||
|
|
||||||
/* Read timestamp */
|
/* Read timestamp and data size */
|
||||||
stream_read_uint16(input_stream, wTimeStamp);
|
stream_read_uint16(input_stream, rdpsnd->server_timestamp);
|
||||||
stream_read_uint16(input_stream, wPackSize);
|
stream_read_uint16(input_stream, data_size);
|
||||||
|
|
||||||
/* Send training response */
|
/* Send training response */
|
||||||
output_stream = stream_new(8);
|
output_stream = stream_new(8);
|
||||||
stream_write_uint8(output_stream, SNDC_TRAINING); /* msgType */
|
stream_write_uint8(output_stream, SNDC_TRAINING);
|
||||||
stream_write_uint8(output_stream, 0); /* bPad */
|
stream_write_uint8(output_stream, 0);
|
||||||
stream_write_uint16(output_stream, 4); /* BodySize */
|
stream_write_uint16(output_stream, 4);
|
||||||
stream_write_uint16(output_stream, wTimeStamp);
|
stream_write_uint16(output_stream, rdpsnd->server_timestamp);
|
||||||
stream_write_uint16(output_stream, wPackSize);
|
stream_write_uint16(output_stream, data_size);
|
||||||
|
|
||||||
pthread_mutex_lock(&(guac_client_data->rdp_lock));
|
pthread_mutex_lock(&(guac_client_data->rdp_lock));
|
||||||
svc_plugin_send((rdpSvcPlugin*) rdpsnd, output_stream);
|
svc_plugin_send((rdpSvcPlugin*) rdpsnd, output_stream);
|
||||||
pthread_mutex_unlock(&(guac_client_data->rdp_lock));
|
pthread_mutex_unlock(&(guac_client_data->rdp_lock));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void guac_rdpsnd_process_message_wave_info(guac_rdpsndPlugin* rdpsnd, audio_stream* audio, STREAM* input_stream, uint16 BodySize) {
|
void guac_rdpsnd_wave_info_handler(guac_rdpsndPlugin* rdpsnd,
|
||||||
|
audio_stream* audio, STREAM* input_stream,
|
||||||
|
guac_rdpsnd_pdu_header* header) {
|
||||||
|
|
||||||
uint16 wFormatNo;
|
unsigned char buffer[4];
|
||||||
|
int format;
|
||||||
|
|
||||||
/* Read wave information */
|
/* Read wave information */
|
||||||
stream_read_uint16(input_stream, rdpsnd->wTimeStamp);
|
stream_read_uint16(input_stream, rdpsnd->server_timestamp);
|
||||||
stream_read_uint16(input_stream, wFormatNo);
|
stream_read_uint16(input_stream, format);
|
||||||
stream_read_uint8(input_stream, rdpsnd->cBlockNo);
|
stream_read_uint8(input_stream, rdpsnd->waveinfo_block_number);
|
||||||
stream_seek(input_stream, 3); /* bPad */
|
stream_seek(input_stream, 3);
|
||||||
stream_read(input_stream, rdpsnd->waveData, 4);
|
stream_read(input_stream, buffer, 4);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Size of incoming wave data is equal to the body size field of this
|
||||||
|
* header, less the size of a WaveInfo PDU (not including the header),
|
||||||
|
* thus body_size - 12.
|
||||||
|
*/
|
||||||
|
rdpsnd->incoming_wave_size = header->body_size - 12;
|
||||||
|
|
||||||
/* Read wave in next iteration */
|
/* Read wave in next iteration */
|
||||||
rdpsnd->waveDataSize = BodySize - 8;
|
rdpsnd->next_pdu_is_wave = true;
|
||||||
rdpsnd->expectingWave = true;
|
|
||||||
|
|
||||||
/* Init stream with requested format */
|
/* Init stream with requested format */
|
||||||
audio_stream_begin(audio,
|
audio_stream_begin(audio,
|
||||||
rdpsnd->formats[wFormatNo].rate,
|
rdpsnd->formats[format].rate,
|
||||||
rdpsnd->formats[wFormatNo].channels,
|
rdpsnd->formats[format].channels,
|
||||||
rdpsnd->formats[wFormatNo].bps);
|
rdpsnd->formats[format].bps);
|
||||||
|
|
||||||
|
/* Write initial 4 bytes of data */
|
||||||
|
audio_stream_write_pcm(audio, buffer, 4);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* header is not removed from data in this function */
|
void guac_rdpsnd_wave_handler(guac_rdpsndPlugin* rdpsnd,
|
||||||
void rdpsnd_process_message_wave(guac_rdpsndPlugin* rdpsnd,
|
audio_stream* audio, STREAM* input_stream,
|
||||||
audio_stream* audio, STREAM* input_stream) {
|
guac_rdpsnd_pdu_header* header) {
|
||||||
|
|
||||||
rdpSvcPlugin* plugin = (rdpSvcPlugin*)rdpsnd;
|
rdpSvcPlugin* plugin = (rdpSvcPlugin*)rdpsnd;
|
||||||
|
|
||||||
STREAM* output_stream;
|
|
||||||
|
|
||||||
unsigned char* buffer = stream_get_head(input_stream);
|
|
||||||
|
|
||||||
rdp_guac_client_data* guac_client_data =
|
rdp_guac_client_data* guac_client_data =
|
||||||
(rdp_guac_client_data*) audio->client->data;
|
(rdp_guac_client_data*) audio->client->data;
|
||||||
|
|
||||||
rdpsnd->expectingWave = 0;
|
/* Wave Confirmation PDU */
|
||||||
memcpy(buffer, rdpsnd->waveData, 4);
|
STREAM* output_stream = stream_new(8);
|
||||||
|
|
||||||
|
/* Get wave data */
|
||||||
|
unsigned char* buffer = stream_get_head(input_stream) + 4;
|
||||||
|
|
||||||
/* Write rest of audio packet */
|
/* Write rest of audio packet */
|
||||||
audio_stream_write_pcm(audio, buffer, rdpsnd->waveDataSize);
|
audio_stream_write_pcm(audio, buffer, rdpsnd->incoming_wave_size);
|
||||||
audio_stream_end(audio);
|
audio_stream_end(audio);
|
||||||
|
|
||||||
output_stream = stream_new(8);
|
/* Write Wave Confirmation PDU */
|
||||||
stream_write_uint8(output_stream, SNDC_WAVECONFIRM);
|
stream_write_uint8(output_stream, SNDC_WAVECONFIRM);
|
||||||
stream_write_uint8(output_stream, 0);
|
stream_write_uint8(output_stream, 0);
|
||||||
stream_write_uint16(output_stream, 4);
|
stream_write_uint16(output_stream, 4);
|
||||||
stream_write_uint16(output_stream, rdpsnd->wTimeStamp);
|
stream_write_uint16(output_stream, rdpsnd->server_timestamp);
|
||||||
stream_write_uint8(output_stream, rdpsnd->cBlockNo); /* cConfirmedBlockNo */
|
stream_write_uint8(output_stream, rdpsnd->waveinfo_block_number);
|
||||||
stream_write_uint8(output_stream, 0); /* bPad */
|
stream_write_uint8(output_stream, 0);
|
||||||
|
|
||||||
|
/* Send Wave Confirmation PDU */
|
||||||
pthread_mutex_lock(&(guac_client_data->rdp_lock));
|
pthread_mutex_lock(&(guac_client_data->rdp_lock));
|
||||||
svc_plugin_send(plugin, output_stream);
|
svc_plugin_send(plugin, output_stream);
|
||||||
pthread_mutex_unlock(&(guac_client_data->rdp_lock));
|
pthread_mutex_unlock(&(guac_client_data->rdp_lock));
|
||||||
|
|
||||||
rdpsnd->plugin.interval_ms = 10;
|
/* We no longer expect to receive wave data */
|
||||||
}
|
rdpsnd->next_pdu_is_wave = false;
|
||||||
|
|
||||||
void guac_rdpsnd_process_message_setvolume(guac_rdpsndPlugin* rdpsnd,
|
|
||||||
audio_stream* audio, STREAM* input_stream) {
|
|
||||||
|
|
||||||
/* Ignored for now */
|
|
||||||
uint32 dwVolume;
|
|
||||||
stream_read_uint32(input_stream, dwVolume);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void guac_rdpsnd_process_message_close(guac_rdpsndPlugin* rdpsnd,
|
void guac_rdpsnd_close_handler(guac_rdpsndPlugin* rdpsnd,
|
||||||
audio_stream* audio) {
|
audio_stream* audio, STREAM* input_stream,
|
||||||
rdpsnd->plugin.interval_ms = 10;
|
guac_rdpsnd_pdu_header* header) {
|
||||||
|
|
||||||
|
/* STUB: Do nothing for now */
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,75 +1,162 @@
|
|||||||
/**
|
|
||||||
* FreeRDP: A Remote Desktop Protocol client.
|
/* ***** BEGIN LICENSE BLOCK *****
|
||||||
* Audio Output Virtual Channel
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||||
*
|
*
|
||||||
* Copyright 2010-2011 Vic Lee
|
* The contents of this file are subject to the Mozilla Public License Version
|
||||||
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||||
|
* the License. You may obtain a copy of the License at
|
||||||
|
* http://www.mozilla.org/MPL/
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||||
* you may not use this file except in compliance with the License.
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||||
* You may obtain a copy of the License at
|
* for the specific language governing rights and limitations under the
|
||||||
|
* License.
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* The Original Code is libguac-client-rdp.
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* The Initial Developer of the Original Code is
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* Michael Jumper.
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* Portions created by the Initial Developer are Copyright (C) 2011
|
||||||
* See the License for the specific language governing permissions and
|
* the Initial Developer. All Rights Reserved.
|
||||||
* limitations under the License.
|
*
|
||||||
*/
|
* Contributor(s):
|
||||||
|
*
|
||||||
|
* Alternatively, the contents of this file may be used under the terms of
|
||||||
|
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||||
|
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||||
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||||
|
* of those above. If you wish to allow use of your version of this file only
|
||||||
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||||
|
* use your version of this file under the terms of the MPL, indicate your
|
||||||
|
* decision by deleting the provisions above and replace them with the notice
|
||||||
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||||
|
* the provisions above, a recipient may use your version of this file under
|
||||||
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||||
|
*
|
||||||
|
* ***** END LICENSE BLOCK ***** */
|
||||||
|
|
||||||
#ifndef __GUAC_RDPSND_MESSAGES_H
|
#ifndef __GUAC_RDPSND_MESSAGES_H
|
||||||
#define __GUAC_RDPSND_MESSAGES_H
|
#define __GUAC_RDPSND_MESSAGES_H
|
||||||
|
|
||||||
|
/*
|
||||||
|
* PDU Message Types
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Close PDU
|
||||||
|
*/
|
||||||
#define SNDC_CLOSE 1
|
#define SNDC_CLOSE 1
|
||||||
|
|
||||||
|
/**
|
||||||
|
* WaveInfo PDU. This PDU is sent just before wave data is sent.
|
||||||
|
*/
|
||||||
#define SNDC_WAVE 2
|
#define SNDC_WAVE 2
|
||||||
#define SNDC_SETVOLUME 3
|
|
||||||
#define SNDC_SETPITCH 4
|
/**
|
||||||
|
* Wave Confirm PDU. This PDU is sent in response to the WaveInfo PDU,
|
||||||
|
* confirming it has been received and played.
|
||||||
|
*/
|
||||||
#define SNDC_WAVECONFIRM 5
|
#define SNDC_WAVECONFIRM 5
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Training PDU. This PDU is sent by the server occasionally and must be
|
||||||
|
* responded to with another training PDU, similar to Guac's sync message.
|
||||||
|
*/
|
||||||
#define SNDC_TRAINING 6
|
#define SNDC_TRAINING 6
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Server Audio Formats and Version PDU. This PDU is sent by the server to
|
||||||
|
* advertise to the client which audio formats are supported.
|
||||||
|
*/
|
||||||
#define SNDC_FORMATS 7
|
#define SNDC_FORMATS 7
|
||||||
#define SNDC_CRYPTKEY 8
|
|
||||||
#define SNDC_WAVEENCRYPT 9
|
/**
|
||||||
#define SNDC_UDPWAVE 10
|
* Quality Mode PDU. This PDU must be sent by the client to select an audio
|
||||||
#define SNDC_UDPWAVELAST 11
|
* quality mode if the server is at least version 6.
|
||||||
|
*/
|
||||||
#define SNDC_QUALITYMODE 12
|
#define SNDC_QUALITYMODE 12
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Quality Modes
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Dynamic Quality. The server will choose the audio quality based on its
|
||||||
|
* perception of latency.
|
||||||
|
*/
|
||||||
|
#define DYNAMIC_QUALITY 0x0000
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Medium Quality. The server prioritizes bandwidth over quality.
|
||||||
|
*/
|
||||||
|
#define MEDIUM_QUALITY 0x0001
|
||||||
|
|
||||||
|
/**
|
||||||
|
* High Quality. The server prioritizes quality over bandwidth.
|
||||||
|
*/
|
||||||
|
#define HIGH_QUALITY 0x0002
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Capabilities
|
||||||
|
*/
|
||||||
#define TSSNDCAPS_ALIVE 1
|
#define TSSNDCAPS_ALIVE 1
|
||||||
#define TSSNDCAPS_VOLUME 2
|
|
||||||
#define TSSNDCAPS_PITCH 4
|
|
||||||
|
|
||||||
#define DYNAMIC_QUALITY 0x0000
|
|
||||||
#define MEDIUM_QUALITY 0x0001
|
|
||||||
#define HIGH_QUALITY 0x0002
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Sound Formats
|
||||||
|
*/
|
||||||
#define WAVE_FORMAT_PCM 1
|
#define WAVE_FORMAT_PCM 1
|
||||||
|
|
||||||
typedef struct rdpsndFormat {
|
/**
|
||||||
uint16 wFormatTag;
|
* The header common to all RDPSND PDUs.
|
||||||
uint16 nChannels;
|
*/
|
||||||
uint32 nSamplesPerSec;
|
typedef struct guac_rdpsnd_pdu_header {
|
||||||
uint16 nBlockAlign;
|
|
||||||
uint16 wBitsPerSample;
|
|
||||||
uint16 cbSize;
|
|
||||||
uint8* data;
|
|
||||||
} rdpsndFormat;
|
|
||||||
|
|
||||||
void guac_rdpsnd_process_message_formats(guac_rdpsndPlugin* rdpsnd,
|
/**
|
||||||
audio_stream* audio, STREAM* data_in);
|
* The type of message represented by this PDU (SNDC_WAVE, etc.)
|
||||||
|
*/
|
||||||
|
int message_type;
|
||||||
|
|
||||||
void guac_rdpsnd_process_message_training(guac_rdpsndPlugin* rdpsnd,
|
/**
|
||||||
audio_stream* audio, STREAM* data_in);
|
* The size of the remainder of the message.
|
||||||
|
*/
|
||||||
|
int body_size;
|
||||||
|
|
||||||
void guac_rdpsnd_process_message_wave_info(guac_rdpsndPlugin* rdpsnd,
|
} guac_rdpsnd_pdu_header;
|
||||||
audio_stream* audio, STREAM* data_in, uint16 BodySize);
|
|
||||||
|
|
||||||
void rdpsnd_process_message_wave(guac_rdpsndPlugin* rdpsnd,
|
/**
|
||||||
audio_stream* audio, STREAM* data_in);
|
* Handler for the SNDC_FORMATS (Server Audio Formats and Version) PDU.
|
||||||
|
*/
|
||||||
|
void guac_rdpsnd_formats_handler(guac_rdpsndPlugin* rdpsnd,
|
||||||
|
audio_stream* audio, STREAM* input_stream,
|
||||||
|
guac_rdpsnd_pdu_header* header);
|
||||||
|
|
||||||
void guac_rdpsnd_process_message_setvolume(guac_rdpsndPlugin* rdpsnd,
|
/**
|
||||||
audio_stream* audio, STREAM* data_in);
|
* Handler for the SNDC_TRAINING (Training) PDU.
|
||||||
|
*/
|
||||||
|
void guac_rdpsnd_training_handler(guac_rdpsndPlugin* rdpsnd,
|
||||||
|
audio_stream* audio, STREAM* input_stream,
|
||||||
|
guac_rdpsnd_pdu_header* header);
|
||||||
|
|
||||||
void guac_rdpsnd_process_message_close(guac_rdpsndPlugin* rdpsnd,
|
/**
|
||||||
audio_stream* audio);
|
* Handler for the SNDC_WAVE (WaveInfo) PDU.
|
||||||
|
*/
|
||||||
|
void guac_rdpsnd_wave_info_handler(guac_rdpsndPlugin* rdpsnd,
|
||||||
|
audio_stream* audio, STREAM* 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,
|
||||||
|
audio_stream* audio, STREAM* input_stream,
|
||||||
|
guac_rdpsnd_pdu_header* header);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handler for the SNDC_CLOSE (Close) PDU.
|
||||||
|
*/
|
||||||
|
void guac_rdpsnd_close_handler(guac_rdpsndPlugin* rdpsnd,
|
||||||
|
audio_stream* audio, STREAM* input_stream,
|
||||||
|
guac_rdpsnd_pdu_header* header);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1,32 +1,47 @@
|
|||||||
/**
|
|
||||||
* FreeRDP: A Remote Desktop Protocol client.
|
|
||||||
* Audio Output Virtual Channel
|
|
||||||
*
|
|
||||||
* Copyright 2009-2011 Jay Sorg
|
|
||||||
* Copyright 2010-2011 Vic Lee
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stdio.h>
|
/* ***** BEGIN LICENSE BLOCK *****
|
||||||
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||||
|
*
|
||||||
|
* The contents of this file are subject to the Mozilla Public License Version
|
||||||
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||||
|
* the License. You may obtain a copy of the License at
|
||||||
|
* http://www.mozilla.org/MPL/
|
||||||
|
*
|
||||||
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||||
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||||
|
* for the specific language governing rights and limitations under the
|
||||||
|
* License.
|
||||||
|
*
|
||||||
|
* The Original Code is libguac-client-rdp.
|
||||||
|
*
|
||||||
|
* The Initial Developer of the Original Code is
|
||||||
|
* Michael Jumper.
|
||||||
|
* Portions created by the Initial Developer are Copyright (C) 2011
|
||||||
|
* the Initial Developer. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Contributor(s):
|
||||||
|
*
|
||||||
|
* Alternatively, the contents of this file may be used under the terms of
|
||||||
|
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||||
|
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||||
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||||
|
* of those above. If you wish to allow use of your version of this file only
|
||||||
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||||
|
* use your version of this file under the terms of the MPL, indicate your
|
||||||
|
* decision by deleting the provisions above and replace them with the notice
|
||||||
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||||
|
* the provisions above, a recipient may use your version of this file under
|
||||||
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||||
|
*
|
||||||
|
* ***** END LICENSE BLOCK ***** */
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include <freerdp/constants.h>
|
#include <freerdp/constants.h>
|
||||||
#include <freerdp/types.h>
|
#include <freerdp/types.h>
|
||||||
#include <freerdp/utils/memory.h>
|
#include <freerdp/utils/memory.h>
|
||||||
#include <freerdp/utils/stream.h>
|
#include <freerdp/utils/stream.h>
|
||||||
#include <freerdp/utils/list.h>
|
|
||||||
#include <freerdp/utils/load_plugin.h>
|
|
||||||
#include <freerdp/utils/svc_plugin.h>
|
#include <freerdp/utils/svc_plugin.h>
|
||||||
|
|
||||||
#include <guacamole/client.h>
|
#include <guacamole/client.h>
|
||||||
@ -35,10 +50,16 @@
|
|||||||
#include "service.h"
|
#include "service.h"
|
||||||
#include "messages.h"
|
#include "messages.h"
|
||||||
|
|
||||||
/* SVC DEFINITION */
|
|
||||||
|
/* Define service, associate with "rdpsnd" channel */
|
||||||
|
|
||||||
DEFINE_SVC_PLUGIN(guac_rdpsnd, "rdpsnd",
|
DEFINE_SVC_PLUGIN(guac_rdpsnd, "rdpsnd",
|
||||||
CHANNEL_OPTION_INITIALIZED | CHANNEL_OPTION_ENCRYPT_RDP)
|
CHANNEL_OPTION_INITIALIZED | CHANNEL_OPTION_ENCRYPT_RDP)
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Service Handlers
|
||||||
|
*/
|
||||||
|
|
||||||
void guac_rdpsnd_process_connect(rdpSvcPlugin* plugin) {
|
void guac_rdpsnd_process_connect(rdpSvcPlugin* plugin) {
|
||||||
|
|
||||||
@ -46,67 +67,74 @@ void guac_rdpsnd_process_connect(rdpSvcPlugin* plugin) {
|
|||||||
audio_stream* audio = (audio_stream*)
|
audio_stream* audio = (audio_stream*)
|
||||||
plugin->channel_entry_points.pExtendedData;
|
plugin->channel_entry_points.pExtendedData;
|
||||||
|
|
||||||
|
/* Update every 10 ms */
|
||||||
|
plugin->interval_ms = 10;
|
||||||
|
|
||||||
/* Log that sound has been loaded */
|
/* Log that sound has been loaded */
|
||||||
guac_client_log_info(audio->client, "guac_rdpsnd connected.");
|
guac_client_log_info(audio->client, "guac_rdpsnd connected.");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void guac_rdpsnd_process_terminate(rdpSvcPlugin* plugin) {
|
void guac_rdpsnd_process_terminate(rdpSvcPlugin* plugin) {
|
||||||
xfree(plugin);
|
xfree(plugin);
|
||||||
}
|
}
|
||||||
|
|
||||||
void guac_rdpsnd_process_event(rdpSvcPlugin* plugin, RDP_EVENT* event) {
|
void guac_rdpsnd_process_event(rdpSvcPlugin* plugin, RDP_EVENT* event) {
|
||||||
freerdp_event_free(event);
|
freerdp_event_free(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
void guac_rdpsnd_process_receive(rdpSvcPlugin* plugin,
|
void guac_rdpsnd_process_receive(rdpSvcPlugin* plugin,
|
||||||
STREAM* input_stream) {
|
STREAM* input_stream) {
|
||||||
|
|
||||||
guac_rdpsndPlugin* rdpsnd = (guac_rdpsndPlugin*) plugin;
|
guac_rdpsndPlugin* rdpsnd = (guac_rdpsndPlugin*) plugin;
|
||||||
|
guac_rdpsnd_pdu_header header;
|
||||||
|
|
||||||
/* Get audio stream from plugin */
|
/* Get audio stream from plugin */
|
||||||
audio_stream* audio = (audio_stream*)
|
audio_stream* audio = (audio_stream*)
|
||||||
plugin->channel_entry_points.pExtendedData;
|
plugin->channel_entry_points.pExtendedData;
|
||||||
|
|
||||||
uint8 msgType;
|
/* Read RDPSND PDU header */
|
||||||
uint16 BodySize;
|
stream_read_uint8(input_stream, header.message_type);
|
||||||
|
stream_seek_uint8(input_stream);
|
||||||
|
stream_read_uint16(input_stream, header.body_size);
|
||||||
|
|
||||||
if (rdpsnd->expectingWave) {
|
/*
|
||||||
rdpsnd_process_message_wave(rdpsnd, audio, input_stream);
|
* If next PDU is SNDWAVE (due to receiving WaveInfo PDU previously),
|
||||||
return;
|
* ignore the header and parse as a Wave PDU.
|
||||||
}
|
*/
|
||||||
|
if (rdpsnd->next_pdu_is_wave) {
|
||||||
|
guac_rdpsnd_wave_handler(rdpsnd, audio, input_stream, &header);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/* Read event */
|
/* Dispatch message to standard handlers */
|
||||||
stream_read_uint8(input_stream, msgType); /* msgType */
|
switch (header.message_type) {
|
||||||
stream_seek_uint8(input_stream); /* bPad */
|
|
||||||
stream_read_uint16(input_stream, BodySize);
|
|
||||||
|
|
||||||
switch (msgType) {
|
/* Server Audio Formats and Version PDU */
|
||||||
|
case SNDC_FORMATS:
|
||||||
|
guac_rdpsnd_formats_handler(rdpsnd, audio,
|
||||||
|
input_stream, &header);
|
||||||
|
break;
|
||||||
|
|
||||||
case SNDC_FORMATS:
|
/* Training PDU */
|
||||||
guac_rdpsnd_process_message_formats(rdpsnd, audio, input_stream);
|
case SNDC_TRAINING:
|
||||||
break;
|
guac_rdpsnd_training_handler(rdpsnd, audio,
|
||||||
|
input_stream, &header);
|
||||||
|
break;
|
||||||
|
|
||||||
case SNDC_TRAINING:
|
/* WaveInfo PDU */
|
||||||
guac_rdpsnd_process_message_training(rdpsnd, audio, input_stream);
|
case SNDC_WAVE:
|
||||||
break;
|
guac_rdpsnd_wave_info_handler(rdpsnd, audio,
|
||||||
|
input_stream, &header);
|
||||||
|
break;
|
||||||
|
|
||||||
case SNDC_WAVE:
|
/* Close PDU */
|
||||||
guac_rdpsnd_process_message_wave_info(rdpsnd, audio, input_stream, BodySize);
|
case SNDC_CLOSE:
|
||||||
break;
|
guac_rdpsnd_close_handler(rdpsnd, audio,
|
||||||
|
input_stream, &header);
|
||||||
|
break;
|
||||||
|
|
||||||
case SNDC_CLOSE:
|
}
|
||||||
guac_rdpsnd_process_message_close(rdpsnd, audio);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SNDC_SETVOLUME:
|
|
||||||
guac_rdpsnd_process_message_setvolume(rdpsnd, audio, input_stream);
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
/*DEBUG_WARN("unknown msgType %d", msgType);*/
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,64 +1,145 @@
|
|||||||
/**
|
|
||||||
* FreeRDP: A Remote Desktop Protocol client.
|
/* ***** BEGIN LICENSE BLOCK *****
|
||||||
* Audio Output Virtual Channel
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||||
*
|
*
|
||||||
* Copyright 2010-2011 Vic Lee
|
* The contents of this file are subject to the Mozilla Public License Version
|
||||||
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||||
|
* the License. You may obtain a copy of the License at
|
||||||
|
* http://www.mozilla.org/MPL/
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||||
* you may not use this file except in compliance with the License.
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||||
* You may obtain a copy of the License at
|
* for the specific language governing rights and limitations under the
|
||||||
|
* License.
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* The Original Code is libguac-client-rdp.
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* The Initial Developer of the Original Code is
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* Michael Jumper.
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* Portions created by the Initial Developer are Copyright (C) 2011
|
||||||
* See the License for the specific language governing permissions and
|
* the Initial Developer. All Rights Reserved.
|
||||||
* limitations under the License.
|
*
|
||||||
*/
|
* Contributor(s):
|
||||||
|
*
|
||||||
|
* Alternatively, the contents of this file may be used under the terms of
|
||||||
|
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||||
|
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||||
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||||
|
* of those above. If you wish to allow use of your version of this file only
|
||||||
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||||
|
* use your version of this file under the terms of the MPL, indicate your
|
||||||
|
* decision by deleting the provisions above and replace them with the notice
|
||||||
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||||
|
* the provisions above, a recipient may use your version of this file under
|
||||||
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||||
|
*
|
||||||
|
* ***** END LICENSE BLOCK ***** */
|
||||||
|
|
||||||
#ifndef __GUAC_RDPSND_SERVICE_H
|
#ifndef __GUAC_RDPSND_SERVICE_H
|
||||||
#define __GUAC_RDPSND_SERVICE_H
|
#define __GUAC_RDPSND_SERVICE_H
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The maximum number of PCM formats to accept during the initial RDPSND
|
||||||
|
* handshake with the RDP server.
|
||||||
|
*/
|
||||||
#define GUAC_RDP_MAX_FORMATS 16
|
#define GUAC_RDP_MAX_FORMATS 16
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Abstract representation of a PCM format, including the sample rate, number
|
||||||
|
* of channels, and bits per sample.
|
||||||
|
*/
|
||||||
typedef struct guac_pcm_format {
|
typedef struct guac_pcm_format {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The sample rate of this PCM format.
|
||||||
|
*/
|
||||||
int rate;
|
int rate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The number off channels used by this PCM format. This will typically
|
||||||
|
* be 1 or 2.
|
||||||
|
*/
|
||||||
int channels;
|
int channels;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The number of bits per sample within this PCM format. This should be
|
||||||
|
* either 8 or 16.
|
||||||
|
*/
|
||||||
int bps;
|
int bps;
|
||||||
|
|
||||||
} guac_pcm_format;
|
} guac_pcm_format;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Structure representing the current state of the Guacamole RDPSND plugin for
|
||||||
|
* FreeRDP.
|
||||||
|
*/
|
||||||
typedef struct guac_rdpsndPlugin {
|
typedef struct guac_rdpsndPlugin {
|
||||||
|
|
||||||
rdpSvcPlugin plugin;
|
/**
|
||||||
|
* The FreeRDP parts of this plugin. This absolutely MUST be first.
|
||||||
|
* FreeRDP depends on accessing this structure as if it were an instance
|
||||||
|
* of rdpSvcPlugin.
|
||||||
|
*/
|
||||||
|
rdpSvcPlugin plugin;
|
||||||
|
|
||||||
uint8 cBlockNo;
|
/**
|
||||||
|
* The block number of the last SNDC_WAVE (WaveInfo) PDU received.
|
||||||
|
*/
|
||||||
|
int waveinfo_block_number;
|
||||||
|
|
||||||
boolean expectingWave;
|
/**
|
||||||
uint8 waveData[4];
|
* Whether the next PDU coming is a SNDWAVE (Wave) PDU. Wave PDUs do not
|
||||||
uint16 waveDataSize;
|
* have headers, and are indicated by the receipt of a WaveInfo PDU.
|
||||||
uint32 wTimeStamp; /* server timestamp */
|
*/
|
||||||
|
int next_pdu_is_wave;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The size, in bytes, of the wave data in the coming Wave PDU, if any.
|
||||||
|
*/
|
||||||
|
int incoming_wave_size;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The last received server timestamp.
|
||||||
|
*/
|
||||||
|
int server_timestamp;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* All formats agreed upon by server and client during the initial format
|
||||||
|
* exchange. All of these formats will be PCM, which is the only format
|
||||||
|
* guaranteed to be supported (based on the official RDP documentation).
|
||||||
|
*/
|
||||||
guac_pcm_format formats[GUAC_RDP_MAX_FORMATS];
|
guac_pcm_format formats[GUAC_RDP_MAX_FORMATS];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The total number of formats.
|
||||||
|
*/
|
||||||
int format_count;
|
int format_count;
|
||||||
|
|
||||||
} guac_rdpsndPlugin;
|
} guac_rdpsndPlugin;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handler called when this plugin is loaded by FreeRDP.
|
||||||
|
*/
|
||||||
void guac_rdpsnd_process_connect(rdpSvcPlugin* plugin);
|
void guac_rdpsnd_process_connect(rdpSvcPlugin* plugin);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handler called when this plugin receives data along its designated channel.
|
||||||
|
*/
|
||||||
void guac_rdpsnd_process_receive(rdpSvcPlugin* plugin,
|
void guac_rdpsnd_process_receive(rdpSvcPlugin* plugin,
|
||||||
STREAM* data_in);
|
STREAM* input_stream);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handler called when this plugin is being unloaded.
|
||||||
|
*/
|
||||||
void guac_rdpsnd_process_terminate(rdpSvcPlugin* plugin);
|
void guac_rdpsnd_process_terminate(rdpSvcPlugin* plugin);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handler called when this plugin receives an event. For the sake of RDPSND,
|
||||||
|
* all events will be ignored and simply free'd.
|
||||||
|
*/
|
||||||
void guac_rdpsnd_process_event(rdpSvcPlugin* plugin, RDP_EVENT* event);
|
void guac_rdpsnd_process_event(rdpSvcPlugin* plugin, RDP_EVENT* event);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user