Remove hard-coded values.
This commit is contained in:
parent
9207d7c89e
commit
c5e4dcabf2
@ -97,21 +97,43 @@ 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(audio->client,
|
/* If can fit another format, accept it */
|
||||||
"Accepted format: %i-bit PCM with %i channels at "
|
if (rdpsnd->format_count < GUAC_RDP_MAX_FORMATS) {
|
||||||
"%i Hz",
|
|
||||||
format->wBitsPerSample,
|
/* Add channel */
|
||||||
format->nChannels,
|
int current = rdpsnd->format_count++;
|
||||||
format->nSamplesPerSec);
|
rdpsnd->formats[current].rate = format->nSamplesPerSec;
|
||||||
|
rdpsnd->formats[current].channels = format->nChannels;
|
||||||
|
rdpsnd->formats[current].bps = format->wBitsPerSample;
|
||||||
|
|
||||||
|
/* Log format */
|
||||||
|
guac_client_log_info(audio->client,
|
||||||
|
"Accepted format: %i-bit PCM with %i channels at "
|
||||||
|
"%i Hz",
|
||||||
|
format->wBitsPerSample,
|
||||||
|
format->nChannels,
|
||||||
|
format->nSamplesPerSec);
|
||||||
|
|
||||||
|
/* Store as accepted for future response */
|
||||||
|
stream_check_size(output_stream, 18 + format->cbSize);
|
||||||
|
stream_write(output_stream, format_mark, 18 + format->cbSize);
|
||||||
|
if (format->cbSize > 0) {
|
||||||
|
format->data = xmalloc(format->cbSize);
|
||||||
|
memcpy(format->data, data_mark, format->cbSize);
|
||||||
|
}
|
||||||
|
n_out_formats++;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Otherwise, log that we dropped one */
|
||||||
|
else
|
||||||
|
guac_client_log_info(audio->client,
|
||||||
|
"Dropped valid format: %i-bit PCM with %i channels at "
|
||||||
|
"%i Hz",
|
||||||
|
format->wBitsPerSample,
|
||||||
|
format->nChannels,
|
||||||
|
format->nSamplesPerSec);
|
||||||
|
|
||||||
stream_check_size(output_stream, 18 + format->cbSize);
|
|
||||||
stream_write(output_stream, format_mark, 18 + format->cbSize);
|
|
||||||
if (format->cbSize > 0)
|
|
||||||
{
|
|
||||||
format->data = xmalloc(format->cbSize);
|
|
||||||
memcpy(format->data, data_mark, format->cbSize);
|
|
||||||
}
|
|
||||||
n_out_formats++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -181,7 +203,11 @@ void guac_rdpsnd_process_message_wave_info(guac_rdpsndPlugin* rdpsnd, audio_stre
|
|||||||
rdpsnd->waveDataSize = BodySize - 8;
|
rdpsnd->waveDataSize = BodySize - 8;
|
||||||
rdpsnd->expectingWave = true;
|
rdpsnd->expectingWave = true;
|
||||||
|
|
||||||
audio_stream_begin(audio, 22050, 2, 16); /* FIXME: Hard-coding rates */
|
/* Init stream with requested format */
|
||||||
|
audio_stream_begin(audio,
|
||||||
|
rdpsnd->formats[wFormatNo].rate,
|
||||||
|
rdpsnd->formats[wFormatNo].channels,
|
||||||
|
rdpsnd->formats[wFormatNo].bps);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,6 +20,21 @@
|
|||||||
#ifndef __GUAC_RDPSND_SERVICE_H
|
#ifndef __GUAC_RDPSND_SERVICE_H
|
||||||
#define __GUAC_RDPSND_SERVICE_H
|
#define __GUAC_RDPSND_SERVICE_H
|
||||||
|
|
||||||
|
|
||||||
|
#define GUAC_RDP_MAX_FORMATS 16
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct guac_pcm_format {
|
||||||
|
|
||||||
|
int rate;
|
||||||
|
|
||||||
|
int channels;
|
||||||
|
|
||||||
|
int bps;
|
||||||
|
|
||||||
|
} guac_pcm_format;
|
||||||
|
|
||||||
|
|
||||||
typedef struct guac_rdpsndPlugin {
|
typedef struct guac_rdpsndPlugin {
|
||||||
|
|
||||||
rdpSvcPlugin plugin;
|
rdpSvcPlugin plugin;
|
||||||
@ -31,7 +46,11 @@ typedef struct guac_rdpsndPlugin {
|
|||||||
uint16 waveDataSize;
|
uint16 waveDataSize;
|
||||||
uint32 wTimeStamp; /* server timestamp */
|
uint32 wTimeStamp; /* server timestamp */
|
||||||
|
|
||||||
} guac_rdpsndPlugin ;
|
guac_pcm_format formats[GUAC_RDP_MAX_FORMATS];
|
||||||
|
|
||||||
|
int format_count;
|
||||||
|
|
||||||
|
} guac_rdpsndPlugin;
|
||||||
|
|
||||||
void guac_rdpsnd_process_connect(rdpSvcPlugin* plugin);
|
void guac_rdpsnd_process_connect(rdpSvcPlugin* plugin);
|
||||||
|
|
||||||
|
@ -64,6 +64,12 @@ typedef void audio_encoder_write_handler(audio_stream* audio,
|
|||||||
*/
|
*/
|
||||||
typedef struct audio_encoder {
|
typedef struct audio_encoder {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The mimetype of the audio data encoded by this audio
|
||||||
|
* encoder.
|
||||||
|
*/
|
||||||
|
const char* mimetype;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handler which will be called when the audio stream is opened.
|
* Handler which will be called when the audio stream is opened.
|
||||||
*/
|
*/
|
||||||
|
@ -103,7 +103,7 @@ void audio_stream_end(audio_stream* audio) {
|
|||||||
|
|
||||||
/* Send audio */
|
/* Send audio */
|
||||||
guac_protocol_send_audio(audio->stream->socket,
|
guac_protocol_send_audio(audio->stream->socket,
|
||||||
0, "audio/ogg" /* FIXME: Hard-coded mimetype */,
|
0, audio->encoder->mimetype,
|
||||||
duration, audio->encoded_data, audio->encoded_data_used);
|
duration, audio->encoded_data, audio->encoded_data_used);
|
||||||
|
|
||||||
pthread_mutex_unlock(&(data->update_lock));
|
pthread_mutex_unlock(&(data->update_lock));
|
||||||
|
@ -200,6 +200,7 @@ void ogg_encoder_write_handler(audio_stream* audio,
|
|||||||
|
|
||||||
/* Encoder handlers */
|
/* Encoder handlers */
|
||||||
audio_encoder _ogg_encoder = {
|
audio_encoder _ogg_encoder = {
|
||||||
|
.mimetype = "audio/ogg",
|
||||||
.begin_handler = ogg_encoder_begin_handler,
|
.begin_handler = ogg_encoder_begin_handler,
|
||||||
.write_handler = ogg_encoder_write_handler,
|
.write_handler = ogg_encoder_write_handler,
|
||||||
.end_handler = ogg_encoder_end_handler
|
.end_handler = ogg_encoder_end_handler
|
||||||
|
Loading…
Reference in New Issue
Block a user