You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@guacamole.apache.org by jm...@apache.org on 2016/06/02 18:45:25 UTC
[18/26] incubator-guacamole-server git commit: GUACAMOLE-25: Store
input and output audio format.
GUACAMOLE-25: Store input and output audio format.
Project: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-server/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-server/commit/533a47f0
Tree: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-server/tree/533a47f0
Diff: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-server/diff/533a47f0
Branch: refs/heads/master
Commit: 533a47f06da3559ab66161fe8af8f431add167f0
Parents: 320f564
Author: Michael Jumper <mj...@apache.org>
Authored: Wed May 11 13:48:40 2016 -0700
Committer: Michael Jumper <mj...@apache.org>
Committed: Wed May 25 13:50:29 2016 -0700
----------------------------------------------------------------------
src/protocols/rdp/audio_input.c | 27 ++++++-----
src/protocols/rdp/audio_input.h | 69 ++++++++++++++++++++++++++--
src/protocols/rdp/guac_ai/ai_messages.c | 2 +-
3 files changed, 82 insertions(+), 16 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-guacamole-server/blob/533a47f0/src/protocols/rdp/audio_input.c
----------------------------------------------------------------------
diff --git a/src/protocols/rdp/audio_input.c b/src/protocols/rdp/audio_input.c
index b7f605d..b2f61bd 100644
--- a/src/protocols/rdp/audio_input.c
+++ b/src/protocols/rdp/audio_input.c
@@ -118,7 +118,7 @@ static int guac_rdp_audio_parse_mimetype(const char* mimetype,
} while (mimetype != NULL);
/* Mimetype is invalid if rate was not specified */
- if (rate == -1)
+ if (parsed_rate == -1)
return 1;
/* Parse success */
@@ -142,25 +142,20 @@ int guac_rdp_audio_handler(guac_user* user, guac_stream* stream,
/* Parse mimetype, abort on parse error */
if (guac_rdp_audio_parse_mimetype(mimetype, &rate, &channels, &bps)) {
- guac_user_log(user, GUAC_LOG_WARN, "Denying user audio stream with "
+ guac_user_log(user, GUAC_LOG_WARNING, "Denying user audio stream with "
"unsupported mimetype: \"%s\"", mimetype);
guac_protocol_send_ack(user->socket, stream, "Unsupported audio "
"mimetype", GUAC_PROTOCOL_STATUS_CLIENT_BAD_TYPE);
return 0;
}
- /* FIXME: Assuming mimetype of "audio/L16;rate=44100,channels=2" */
- else {
- guac_user_log(user, GUAC_LOG_DEBUG, "rate=%i, channels=%i, bps=%i",
- rate, channels, bps);
- }
-
/* Init stream data */
stream->blob_handler = guac_rdp_audio_blob_handler;
stream->end_handler = guac_rdp_audio_end_handler;
/* Associate stream with audio buffer */
- guac_rdp_audio_buffer_set_stream(rdp_client->audio_input, user, stream);
+ guac_rdp_audio_buffer_set_stream(rdp_client->audio_input, user, stream,
+ rate, channels, bps);
return 0;
@@ -240,13 +235,16 @@ static void guac_rdp_audio_buffer_ack(guac_rdp_audio_buffer* audio_buffer,
}
void guac_rdp_audio_buffer_set_stream(guac_rdp_audio_buffer* audio_buffer,
- guac_user* user, guac_stream* stream) {
+ guac_user* user, guac_stream* stream, int rate, int channels, int bps) {
pthread_mutex_lock(&(audio_buffer->lock));
/* Associate received stream */
audio_buffer->user = user;
audio_buffer->stream = stream;
+ audio_buffer->in_rate = rate;
+ audio_buffer->in_channels = channels;
+ audio_buffer->in_bps = bps;
/* Acknowledge stream creation (if buffer is ready to receive) */
guac_rdp_audio_buffer_ack(audio_buffer,
@@ -257,13 +255,16 @@ void guac_rdp_audio_buffer_set_stream(guac_rdp_audio_buffer* audio_buffer,
}
void guac_rdp_audio_buffer_begin(guac_rdp_audio_buffer* audio_buffer,
- int packet_size, guac_rdp_audio_buffer_flush_handler* flush_handler,
- void* data) {
+ int rate, int channels, int bps, int packet_size,
+ guac_rdp_audio_buffer_flush_handler* flush_handler, void* data) {
pthread_mutex_lock(&(audio_buffer->lock));
/* Reset buffer state to provided values */
audio_buffer->bytes_written = 0;
+ audio_buffer->out_rate = rate;
+ audio_buffer->out_channels = channels;
+ audio_buffer->out_bps = bps;
audio_buffer->packet_size = packet_size;
audio_buffer->flush_handler = flush_handler;
audio_buffer->data = data;
@@ -285,6 +286,8 @@ void guac_rdp_audio_buffer_write(guac_rdp_audio_buffer* audio_buffer,
pthread_mutex_lock(&(audio_buffer->lock));
+ /* FIXME: Assuming mimetype of "audio/L16;rate=44100,channels=2" */
+
/* Ignore packet if there is no buffer */
if (audio_buffer->packet_size == 0 || audio_buffer->packet == NULL) {
pthread_mutex_unlock(&(audio_buffer->lock));
http://git-wip-us.apache.org/repos/asf/incubator-guacamole-server/blob/533a47f0/src/protocols/rdp/audio_input.h
----------------------------------------------------------------------
diff --git a/src/protocols/rdp/audio_input.h b/src/protocols/rdp/audio_input.h
index e13b41e..2514b50 100644
--- a/src/protocols/rdp/audio_input.h
+++ b/src/protocols/rdp/audio_input.h
@@ -74,6 +74,45 @@ typedef struct guac_rdp_audio_buffer {
guac_stream* stream;
/**
+ * The rate of the audio stream being received from the user, if any, in
+ * samples per second. If no stream is yet associated, this value is
+ * undefined.
+ */
+ int in_rate;
+
+ /**
+ * The number of channels included in the audio stream being received from
+ * the user, if any. If no stream is yet associated, this value is
+ * undefined.
+ */
+ int in_channels;
+
+ /**
+ * 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
* within this structure will be at least this size.
*/
@@ -127,9 +166,21 @@ guac_rdp_audio_buffer* guac_rdp_audio_buffer_alloc();
*
* @param stream
* The guac_stream object representing the audio stream.
+ *
+ * @param rate
+ * The rate of the audio stream being received from the user, if any, in
+ * samples per second.
+ *
+ * @param channels
+ * The number of channels included in the audio stream being received from
+ * the user, if any.
+ *
+ * @param bps
+ * The size of each sample within the audio stream being received from the
+ * user, if any, in bytes.
*/
void guac_rdp_audio_buffer_set_stream(guac_rdp_audio_buffer* audio_buffer,
- guac_user* user, guac_stream* stream);
+ guac_user* user, guac_stream* stream, int rate, int channels, int bps);
/**
* Begins handling of audio data received via guac_rdp_audio_buffer_write() and
@@ -140,6 +191,18 @@ void guac_rdp_audio_buffer_set_stream(guac_rdp_audio_buffer* audio_buffer,
* @param audio_buffer
* The audio buffer to begin.
*
+ * @param rate
+ * The rate of the audio stream expected by RDP, if any, in samples per
+ * second.
+ *
+ * @param channels
+ * The number of channels included in the audio stream expected by RDP, if
+ * any.
+ *
+ * @param bps
+ * The size of each sample within the audio stream expected by RDP, if any,
+ * in bytes.
+ *
* @param packet_size
* The number of bytes to include in all audio packets provided to the
* given flush_handler.
@@ -152,8 +215,8 @@ void guac_rdp_audio_buffer_set_stream(guac_rdp_audio_buffer* audio_buffer,
* needs to be flushed.
*/
void guac_rdp_audio_buffer_begin(guac_rdp_audio_buffer* audio_buffer,
- int packet_size, guac_rdp_audio_buffer_flush_handler* flush_handler,
- void* data);
+ int rate, int channels, int bps, int packet_size,
+ guac_rdp_audio_buffer_flush_handler* flush_handler, void* data);
/**
* Writes the given buffer of audio data to the given audio buffer. A new
http://git-wip-us.apache.org/repos/asf/incubator-guacamole-server/blob/533a47f0/src/protocols/rdp/guac_ai/ai_messages.c
----------------------------------------------------------------------
diff --git a/src/protocols/rdp/guac_ai/ai_messages.c b/src/protocols/rdp/guac_ai/ai_messages.c
index b0eb6cf..520416c 100644
--- a/src/protocols/rdp/guac_ai/ai_messages.c
+++ b/src/protocols/rdp/guac_ai/ai_messages.c
@@ -312,7 +312,7 @@ void guac_rdp_ai_process_open(guac_client* client,
/* FIXME: Assuming mimetype of 16-bit 44100 Hz stereo PCM */
guac_rdp_audio_buffer_begin(audio_buffer, packet_frames * 2 * 2,
- guac_rdp_ai_flush_packet, channel);
+ 44100, 2, 2, guac_rdp_ai_flush_packet, channel);
}