diff options
Diffstat (limited to 'src/discord')
-rw-r--r-- | src/discord/discord.cpp | 1 | ||||
-rw-r--r-- | src/discord/snowflake.hpp | 9 | ||||
-rw-r--r-- | src/discord/voiceclient.cpp | 13 | ||||
-rw-r--r-- | src/discord/voiceclient.hpp | 1 |
4 files changed, 16 insertions, 8 deletions
diff --git a/src/discord/discord.cpp b/src/discord/discord.cpp index 6a530cb..2a25a26 100644 --- a/src/discord/discord.cpp +++ b/src/discord/discord.cpp @@ -2813,7 +2813,6 @@ void DiscordClient::SetVoiceState(Snowflake user_id, const VoiceState &state) { spdlog::get("discord")->error("SetVoiceState called with missing channel ID"); return; } - spdlog::get("discord")->debug("SetVoiceState: {} -> {}", user_id, *state.ChannelID); auto flags = VoiceStateFlags::Clear; if (state.IsSelfMuted) flags |= VoiceStateFlags::SelfMute; diff --git a/src/discord/snowflake.hpp b/src/discord/snowflake.hpp index a5c0e6c..2ced46b 100644 --- a/src/discord/snowflake.hpp +++ b/src/discord/snowflake.hpp @@ -2,6 +2,8 @@ #include <cstdint> #include <nlohmann/json.hpp> #include <glibmm/ustring.h> +#include <spdlog/fmt/fmt.h> +#include <spdlog/fmt/ostr.h> struct Snowflake { Snowflake(); @@ -39,6 +41,13 @@ private: unsigned long long m_num; }; +template<> +struct fmt::formatter<Snowflake> : fmt::formatter<std::string> { + auto format(Snowflake id, format_context &ctx) -> decltype(ctx.out()) { + return format_to(ctx.out(), "[id: {}]", static_cast<uint64_t>(id)); + } +}; + namespace std { template<> struct hash<Snowflake> { diff --git a/src/discord/voiceclient.cpp b/src/discord/voiceclient.cpp index c37ba7b..524d930 100644 --- a/src/discord/voiceclient.cpp +++ b/src/discord/voiceclient.cpp @@ -49,17 +49,18 @@ void UDPSocket::SetSSRC(uint32_t ssrc) { void UDPSocket::SendEncrypted(const uint8_t *data, size_t len) { m_sequence++; - m_timestamp += 480; // this is important + + const uint32_t timestamp = Abaddon::Get().GetAudio().GetRTPTimestamp(); std::vector<uint8_t> rtp(12 + len + crypto_secretbox_MACBYTES, 0); rtp[0] = 0x80; // ver 2 rtp[1] = 0x78; // payload type 0x78 rtp[2] = (m_sequence >> 8) & 0xFF; rtp[3] = (m_sequence >> 0) & 0xFF; - rtp[4] = (m_timestamp >> 24) & 0xFF; - rtp[5] = (m_timestamp >> 16) & 0xFF; - rtp[6] = (m_timestamp >> 8) & 0xFF; - rtp[7] = (m_timestamp >> 0) & 0xFF; + rtp[4] = (timestamp >> 24) & 0xFF; + rtp[5] = (timestamp >> 16) & 0xFF; + rtp[6] = (timestamp >> 8) & 0xFF; + rtp[7] = (timestamp >> 0) & 0xFF; rtp[8] = (m_ssrc >> 24) & 0xFF; rtp[9] = (m_ssrc >> 16) & 0xFF; rtp[10] = (m_ssrc >> 8) & 0xFF; @@ -382,7 +383,7 @@ void DiscordVoiceClient::Discovery() { const auto response = m_udp.Receive(); if (response.size() >= 74 && response[0] == 0x00 && response[1] == 0x02) { const char *ip = reinterpret_cast<const char *>(response.data() + 8); - uint16_t port = (response[73] << 8) | response[74]; + uint16_t port = (response[72] << 8) | response[73]; m_log->info("Discovered IP and port: {}:{}", ip, port); SelectProtocol(ip, port); break; diff --git a/src/discord/voiceclient.hpp b/src/discord/voiceclient.hpp index 7bf4295..0112749 100644 --- a/src/discord/voiceclient.hpp +++ b/src/discord/voiceclient.hpp @@ -171,7 +171,6 @@ private: uint32_t m_ssrc; uint16_t m_sequence = 0; - uint32_t m_timestamp = 0; public: using type_signal_data = sigc::signal<void, std::vector<uint8_t>>; |