diff options
author | Benjamin Franzke <benjaminfranzke@googlemail.com> | 2011-05-28 12:19:42 +0200 |
---|---|---|
committer | Benjamin Franzke <benjaminfranzke@googlemail.com> | 2011-05-28 12:19:42 +0200 |
commit | e53a88dc800fd6796b2d833844e5bd0c08580b7f (patch) | |
tree | d1a8e8d1e9bbb62b3ca770284c28f817288a7903 /src | |
parent | b5ef2a60d91b1370cf945a6d69afa18c54712eec (diff) | |
download | cmumble-e53a88dc800fd6796b2d833844e5bd0c08580b7f.tar.gz cmumble-e53a88dc800fd6796b2d833844e5bd0c08580b7f.tar.bz2 cmumble-e53a88dc800fd6796b2d833844e5bd0c08580b7f.zip |
Pass UDPTunnel msg as regular protobufcmessage to sendmsg
Diffstat (limited to 'src')
-rw-r--r-- | src/cmumble.c | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/src/cmumble.c b/src/cmumble.c index a0069d4..3e98eed 100644 --- a/src/cmumble.c +++ b/src/cmumble.c @@ -119,6 +119,9 @@ get_preamble(uint8_t *buffer, int *type, int *len) GStaticMutex write_mutex = G_STATIC_MUTEX_INIT; +static void +send_msg(struct context *ctx, ProtobufCMessage *msg); + static GstFlowReturn pull_buffer(GstAppSink *sink, gpointer user_data) { @@ -128,11 +131,8 @@ pull_buffer(GstAppSink *sink, gpointer user_data) uint32_t write = 0; uint32_t pos = 0; GOutputStream *output = g_io_stream_get_output_stream(ctx->iostream); - - static uint64_t seq = 0; - - /* header will be written at the end */ - pos = PREAMBLE_SIZE; + MumbleProto__UDPTunnel tunnel; + static int seq = 0; buf = gst_app_sink_pull_buffer(ctx->sink); @@ -157,11 +157,10 @@ pull_buffer(GstAppSink *sink, gpointer user_data) gst_buffer_unref(buf); - add_preamble(&data[0], UDPTunnel, pos-PREAMBLE_SIZE); - g_static_mutex_lock(&write_mutex); - g_output_stream_write(output, data, PREAMBLE_SIZE, NULL, NULL); - g_output_stream_write(output, &data[PREAMBLE_SIZE], pos-PREAMBLE_SIZE, NULL, NULL); - g_static_mutex_unlock(&write_mutex); + mumble_proto__udptunnel__init(&tunnel); + tunnel.packet.data = data; + tunnel.packet.len = pos; + send_msg(ctx, &tunnel.base); return GST_FLOW_OK; } @@ -333,7 +332,15 @@ send_msg(struct context *ctx, ProtobufCMessage *msg) type = i; assert(type >= 0); - protobuf_c_message_pack_to_buffer(msg, &buffer.base); + if (type == UDPTunnel) { + MumbleProto__UDPTunnel *tunnel = (MumbleProto__UDPTunnel *) msg; + buffer.data = tunnel->packet.data; + buffer.len = tunnel->packet.len; + buffer.must_free_data = 0; + } else { + protobuf_c_message_pack_to_buffer(msg, &buffer.base); + } + add_preamble(preamble, type, buffer.len); g_static_mutex_lock(&write_mutex); |