aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorlatex <latex@disroot.org>2023-02-11 02:01:21 +0100
committerlatex <latex@disroot.org>2023-02-11 02:01:21 +0100
commit82ca959ff701832e96c869161adc5e179c2201dd (patch)
tree3a819f5b26cfd3703a229eaf2ea187c3fa60a0ef /src
parent79c59f93b7461082cf4aec3025257560fc788c69 (diff)
downloadlibumumble-master.tar.gz
restructure include and fix makefilesHEADmaster
* restructed include/ to have a umumble folder * fix the makefile to use the new include structure * tests makefile now builds inside root build folder * added TODO list for shit I gotta do * laid groundwork for packet parsing/packing: mumble_packet_gen_header
Diffstat (limited to 'src')
-rw-r--r--src/connection.c14
-rw-r--r--src/ctx.c4
-rw-r--r--src/message.c15
-rw-r--r--src/proto/MumbleTCP.proto (renamed from src/Mumble.proto)2
-rw-r--r--src/proto/MumbleUDP.proto85
5 files changed, 110 insertions, 10 deletions
diff --git a/src/connection.c b/src/connection.c
index c484163..2c2bfbd 100644
--- a/src/connection.c
+++ b/src/connection.c
@@ -1,10 +1,10 @@
#include <stdlib.h>
#include <assert.h>
+#include <string.h>
-#include <libumumble.h>
+#include <umumble/umumble.h>
#include <tlsuv/tlsuv.h>
#include <uv.h>
-#include "Mumble.pb.h"
void alloc_buffer(uv_handle_t *handle, size_t suggested_size, uv_buf_t *buf) {
buf->base = malloc(suggested_size);
@@ -37,10 +37,10 @@ void on_read_cb(uv_stream_t *client, ssize_t nread, const uv_buf_t *buf)
if (nread < 0) {
if (nread != UV_EOF) {
ctx->error = nread;
- ctx->status = DISCONNECTED;
+ ctx->status = MUMBLE_STATUS_DISCONNECTED;
}
tlsuv_stream_close((tlsuv_stream_t *) client, on_close_cb);
- ctx->status = DISCONNECTED;
+ ctx->status = MUMBLE_STATUS_DISCONNECTED;
free(buf->base);
free(client);
return;
@@ -62,11 +62,11 @@ void on_connect_cb(uv_connect_t *req, int status)
if (status < 0) {
ctx->error = status;
- ctx->status = DISCONNECTED;
+ ctx->status = MUMBLE_STATUS_DISCONNECTED;
tlsuv_stream_close((tlsuv_stream_t *) req->handle, on_close_cb);
return;
}
- ctx->status = CONNECTED;
+ ctx->status = MUMBLE_STATUS_CONNECTED;
tlsuv_stream_read(tls_stream, alloc_buffer, on_read_cb);
@@ -89,7 +89,7 @@ void on_resolve_cb(uv_getaddrinfo_t *resolver, int status, struct addrinfo *res)
assert(status >= 0);
if (status < 0) {
ctx->error = status;
- ctx->status = DISCONNECTED;
+ ctx->status = MUMBLE_STATUS_DISCONNECTED;
return;
}
diff --git a/src/ctx.c b/src/ctx.c
index 35864d1..2612ffb 100644
--- a/src/ctx.c
+++ b/src/ctx.c
@@ -1,7 +1,7 @@
#include <assert.h>
#include <string.h>
-#include <libumumble.h>
+#include <umumble/umumble.h>
#include <uv.h>
int mumble_ctx_init(mumble_ctx_t *ctx)
@@ -19,7 +19,7 @@ int mumble_ctx_init(mumble_ctx_t *ctx)
ctx->uv_connect_req.data = ctx;
ctx->uv_tcp_socket.data = ctx;
- ctx->status = READY;
+ ctx->status = MUMBLE_STATUS_READY;
return 0;
}
diff --git a/src/message.c b/src/message.c
new file mode 100644
index 0000000..8c066c2
--- /dev/null
+++ b/src/message.c
@@ -0,0 +1,15 @@
+#include <stdint.h>
+#include <string.h>
+#include <arpa/inet.h>
+
+static void mumble_packet_gen_header(uint8_t *buf, uint16_t type, uint32_t len)
+{
+ uint16_t type_be;
+ uint32_t len_be;
+
+ type_be = htons(type);
+ len_be = htonl(len);
+
+ memcpy(buf, &type_be, 2);
+ memcpy(buf+2, &len_be, 4);
+}
diff --git a/src/Mumble.proto b/src/proto/MumbleTCP.proto
index c3a23f2..4a86e10 100644
--- a/src/Mumble.proto
+++ b/src/proto/MumbleTCP.proto
@@ -5,7 +5,7 @@
syntax = "proto2";
-package MumbleProto;
+package MumbleTCP;
option optimize_for = SPEED;
diff --git a/src/proto/MumbleUDP.proto b/src/proto/MumbleUDP.proto
new file mode 100644
index 0000000..4f27390
--- /dev/null
+++ b/src/proto/MumbleUDP.proto
@@ -0,0 +1,85 @@
+// Copyright 2022 The Mumble Developers. All rights reserved.
+// Use of this source code is governed by a BSD-style license
+// that can be found in the LICENSE file at the root of the
+// Mumble source tree or at <https://www.mumble.info/LICENSE>.
+
+syntax = "proto3";
+
+package MumbleUDP;
+
+option optimize_for = SPEED;
+
+message Audio {
+ oneof Header {
+ // When this audio is sent by the client to the server, this is set to the target of the audio data. This target
+ // is a number in the range [0, 2^{32} - 1], where 0 means "normal talking", 2^{5} - 1 means "server loopback"
+ // and all other targets are understood as shout/whisper targets that have previously been registered via a
+ // VoiceTarget message (via TCP).
+ uint32 target = 1;
+ // When this audio is sent by the server to the client, this indicates the context in which the audio has been sent.
+ // 0: Normal speech
+ // 1: Shout to channel
+ // 2: Whisper to user
+ // 3: Received via channel listener
+ uint32 context = 2;
+ };
+
+ // The session of the client (sender) this audio was originally sent from. This field is not required when sending
+ // audio to the server, but will always be set when receiving audio from the server.
+ uint32 sender_session = 3;
+
+ // The number of the first contained audio frame (indicating the position of that frame in the overall audio stream)
+ uint64 frame_number = 4;
+
+ // The actual voice data payload in the Opus format.
+ bytes opus_data = 5;
+
+ // Optional positional data indicating the speaker's position in a virtual world (in meters). This "list" is really
+ // expected to be an array of size 3 containing the X, Y and Z coordinates of the position (in that order).
+ repeated float positional_data = 6;
+
+ // A volume adjustment determined by the server for this audio packet. It is up to the client to apply this adjustment to
+ // the resulting audio (or not). Note: A value of 0 means that this field is unset.
+ float volume_adjustment = 7;
+
+ // Note that we skip the field indices up to (including) 15 in order to have them available for future extensions of the
+ // protocol with fields that are encountered very often. The reason is that all field indices <= 15 require only a single
+ // byte of encoding overhead, whereas the once > 15 require (at least) two bytes. The reason lies in the Protobuf encoding
+ // scheme that uses 1 bit for a varint continuation flag, 3 bit to encode a field's type and the remaining 4 bit of the
+ // first byte are thus available for the field index. Therefore the first 2^4 = 16 field indices (aka values 0 to 15) can
+ // be encoded using only a single byte. For details see https://developers.google.com/protocol-buffers/docs/encoding
+
+ // A flag indicating whether this audio packet represents the end of transmission for the current audio stream
+ bool is_terminator = 16;
+}
+
+/**
+ * Ping message for checking UDP connectivity (and roundtrip ping) and potentially obtaining further server
+ * details (e.g. version).
+ */
+message Ping {
+ // Timestamp as encoded by the client. A server is not supposed to attempt to decode or modify this field. Therefore,
+ // clients may choose an arbitrary format for this timestamp (as long as it fits into a uint64 field).
+ uint64 timestamp = 1;
+
+ // A flag set by the sending client, if it wants to obtain additional information about the server.
+ bool request_extended_information = 2;
+
+
+ // Below are the fields for the "additional information" that are filled out by the server on request.
+
+ // The version of the server in the new version format.
+ // The new protobuf Ping packet introduced with 1.5 drops support for the legacy version format
+ // since both server and client have to support this new format.
+ // (See https://github.com/mumble-voip/mumble/issues/5827)
+ uint64 server_version_v2 = 3;
+
+ // The amount of users currently connected to the server
+ uint32 user_count = 4;
+
+ // The maximum amount of users permitted on this server
+ uint32 max_user_count = 5;
+
+ // The maximum bandwidth each user is allowed to use for sending audio to the server
+ uint32 max_bandwidth_per_user = 6;
+}