GUACAMOLE-25: Store audio format within common structure.

This commit is contained in:
Michael Jumper 2016-05-25 14:38:22 -07:00
parent 260d0cd340
commit ad00cce0ad
2 changed files with 36 additions and 38 deletions

View File

@ -242,9 +242,9 @@ void guac_rdp_audio_buffer_set_stream(guac_rdp_audio_buffer* audio_buffer,
/* Associate received stream */ /* Associate received stream */
audio_buffer->user = user; audio_buffer->user = user;
audio_buffer->stream = stream; audio_buffer->stream = stream;
audio_buffer->in_rate = rate; audio_buffer->in_format.rate = rate;
audio_buffer->in_channels = channels; audio_buffer->in_format.channels = channels;
audio_buffer->in_bps = bps; audio_buffer->in_format.bps = bps;
/* Acknowledge stream creation (if buffer is ready to receive) */ /* Acknowledge stream creation (if buffer is ready to receive) */
guac_rdp_audio_buffer_ack(audio_buffer, guac_rdp_audio_buffer_ack(audio_buffer,
@ -262,9 +262,9 @@ void guac_rdp_audio_buffer_begin(guac_rdp_audio_buffer* audio_buffer,
/* Reset buffer state to provided values */ /* Reset buffer state to provided values */
audio_buffer->bytes_written = 0; audio_buffer->bytes_written = 0;
audio_buffer->out_rate = rate; audio_buffer->out_format.rate = rate;
audio_buffer->out_channels = channels; audio_buffer->out_format.channels = channels;
audio_buffer->out_bps = bps; audio_buffer->out_format.bps = bps;
audio_buffer->packet_size = packet_size; audio_buffer->packet_size = packet_size;
audio_buffer->flush_handler = flush_handler; audio_buffer->flush_handler = flush_handler;
audio_buffer->data = data; audio_buffer->data = data;

View File

@ -48,6 +48,29 @@
typedef void guac_rdp_audio_buffer_flush_handler(char* buffer, int length, typedef void guac_rdp_audio_buffer_flush_handler(char* buffer, int length,
void* data); void* data);
/**
* A description of an arbitrary PCM audio format.
*/
typedef struct guac_rdp_audio_format {
/**
* The rate of the audio data in samples per second.
*/
int rate;
/**
* The number of channels included in the audio data. This will be 1 for
* monaural audio and 2 for stereo.
*/
int channels;
/**
* The size of each sample within the audio data, in bytes.
*/
int bps;
} guac_rdp_audio_format;
/** /**
* A buffer of arbitrary audio data. Received audio data can be written to this * A buffer of arbitrary audio data. Received audio data can be written to this
* buffer, and will automatically be flushed via a given handler once the * buffer, and will automatically be flushed via a given handler once the
@ -74,43 +97,18 @@ typedef struct guac_rdp_audio_buffer {
guac_stream* stream; guac_stream* stream;
/** /**
* The rate of the audio stream being received from the user, if any, in * The PCM format of the audio stream being received from the user, if any.
* samples per second. If no stream is yet associated, this value is * If no stream is yet associated, the values stored within this format are
* undefined. * undefined.
*/ */
int in_rate; guac_rdp_audio_format in_format;
/** /**
* The number of channels included in the audio stream being received from * The PCM format of the audio stream expected by RDP, if any. If no audio
* the user, if any. If no stream is yet associated, this value is * stream has yet been requested by the RDP server, the values stored
* undefined. * within this format are undefined.
*/ */
int in_channels; guac_rdp_audio_format out_format;
/**
* The size of each sample within the audio stream being received from the
* user, if any, in bytes. If no stream is yet associated, this value is
* undefined.
*/
int in_bps;
/**
* The rate of the audio stream expected by RDP, if any, in samples per
* second. If no stream is yet associated, this value is undefined.
*/
int out_rate;
/**
* The number of channels included in the audio stream expected by RDP, if
* any. If no stream is yet associated, this value is undefined.
*/
int out_channels;
/**
* The size of each sample within the audio stream expected by RDP, if any,
* in bytes. If no stream is yet associated, this value is undefined.
*/
int out_bps;
/** /**
* The size that each audio packet must be, in bytes. The packet buffer * The size that each audio packet must be, in bytes. The packet buffer