From c81037e7ca2409d6b591a53f206725ebd565ef73 Mon Sep 17 00:00:00 2001 From: Daniil Gentili Date: Tue, 10 Mar 2020 22:51:37 +0100 Subject: [PATCH] Small fixes --- VoIPController.h | 4 ++-- controller/PrivateDefines.h | 3 +++ controller/controller/PublicAPI.cpp | 7 +++---- controller/protocol/protocol/Extra.h | 4 ++-- tools/utils.h | 2 ++ 5 files changed, 12 insertions(+), 8 deletions(-) diff --git a/VoIPController.h b/VoIPController.h index be92728..7b62c5e 100755 --- a/VoIPController.h +++ b/VoIPController.h @@ -399,7 +399,7 @@ public: { int32_t userID; uint8_t id; - StreamInfo::StreamType type; + StreamInfo::Type type; uint32_t codec; bool enabled; bool extraECEnabled; @@ -443,7 +443,7 @@ protected: void InitializeTimers(); void ResetEndpointPingStats(); void ProcessIncomingVideoFrame(Buffer frame, uint32_t pts, bool keyframe, uint16_t rotation); - std::shared_ptr GetStreamByType(StreamInfo::StreamType type, bool outgoing); + std::shared_ptr GetStreamByType(StreamInfo::Type type, bool outgoing); std::shared_ptr GetStreamByID(unsigned char id, bool outgoing); Endpoint *GetEndpointForPacket(const PendingOutgoingPacket &pkt); Endpoint *GetEndpointById(const int64_t id); diff --git a/controller/PrivateDefines.h b/controller/PrivateDefines.h index bd71e67..cbbd410 100644 --- a/controller/PrivateDefines.h +++ b/controller/PrivateDefines.h @@ -133,3 +133,6 @@ enum ProtocolVersions #define LEGACY_PFLAG_HAS_SEQ 16 #define LEGACY_PFLAG_HAS_RECENT_RECV 32 #define LEGACY_PFLAG_HAS_SENDER_TAG_HASH 64 + + +#include "protocol/protocol/Extra.h" \ No newline at end of file diff --git a/controller/controller/PublicAPI.cpp b/controller/controller/PublicAPI.cpp index 938f00c..6e85ca8 100644 --- a/controller/controller/PublicAPI.cpp +++ b/controller/controller/PublicAPI.cpp @@ -16,9 +16,8 @@ VoIPController::~VoIPController() abort(); } - for (auto _stm = incomingStreams.begin(); _stm != incomingStreams.end(); ++_stm) + for (auto &stm : incomingStreams) { - shared_ptr stm = *_stm; LOGD("before stop decoder"); if (stm->decoder) { @@ -153,7 +152,7 @@ void VoIPController::SetMicMute(bool mute) messageThread.Post([this] { for (shared_ptr &s : outgoingStreams) { - if (s->type == STREAM_TYPE_AUDIO) + if (s->type == StreamInfo::Type::Audio) { s->enabled = !micMuted; if (peerVersion < 6) @@ -203,7 +202,7 @@ string VoIPController::GetDebugString() snprintf(buffer, sizeof(buffer), "%s:%u %dms %d 0x%" PRIx64 " [%s%s]\n", endpoint.address.IsEmpty() ? ("[" + endpoint.v6address.ToString() + "]").c_str() : endpoint.address.ToString().c_str(), endpoint.port, (int)(endpoint.averageRTT * 1000), endpoint.udpPongCount, (uint64_t)endpoint.id, type, currentEndpoint == endpoint.id ? ", IN_USE" : ""); r += buffer; } - AudioPacketSender *sender = dynamic_cast(GetStreamByType(STREAM_TYPE_AUDIO, true)->packetSender.get()); + AudioPacketSender *sender = dynamic_cast(GetStreamByType(StreamInfo::Type::Audio, true)->packetSender.get()); if (sender->getShittyInternetMode()) { snprintf(buffer, sizeof(buffer), "ShittyInternetMode: level %u\n", sender->getExtraEcLevel()); diff --git a/controller/protocol/protocol/Extra.h b/controller/protocol/protocol/Extra.h index ea8fd0f..6bfccd9 100644 --- a/controller/protocol/protocol/Extra.h +++ b/controller/protocol/protocol/Extra.h @@ -34,14 +34,14 @@ public: bool parse(const BufferInputStream &in, const VersionInfo &ver) override; void serialize(BufferOutputStream &out, const VersionInfo &ver) const override; - enum StreamType : uint8_t + enum Type : uint8_t { Audio = 1, Video }; uint8_t streamId = 0; - StreamType type = StreamType::Audio; + Type type = Type::Audio; Codec codec; uint16_t frameDuration = 0; bool enabled = false; diff --git a/tools/utils.h b/tools/utils.h index 9fa2102..92655ce 100644 --- a/tools/utils.h +++ b/tools/utils.h @@ -5,6 +5,8 @@ // #pragma once +#include +#include #define TGVOIP_DISALLOW_COPY_AND_ASSIGN(TypeName) \ TypeName(const TypeName&) = delete; \