1
0
mirror of https://github.com/danog/libtgvoip.git synced 2024-12-02 17:51:06 +01:00
libtgvoip/controller/protocol/VersionInfo.h

39 lines
992 B
C
Raw Normal View History

2020-03-25 12:37:40 +01:00
#pragma once
2020-03-21 15:08:03 +01:00
#include <cstdint>
// Protocol name/version
enum ProtocolVersions : int
{
PROTOCOL_OLD = 9,
PROTOCOL_RELIABLE = 10
};
#define PROTOCOL_NAME 0x50567247 // "GrVP" in little endian (reversed here)
2020-03-22 20:09:44 +01:00
#define PROTOCOL_VERSION 10
2020-03-21 15:08:03 +01:00
#define MIN_PROTOCOL_VERSION 3
namespace tgvoip
{
struct VersionInfo
{
2020-03-21 21:33:51 +01:00
VersionInfo() = default;
2020-03-21 15:08:03 +01:00
VersionInfo(int _peerVersion, int32_t _connectionMaxLayer) : peerVersion(_peerVersion), connectionMaxLayer(_connectionMaxLayer){};
2020-03-21 21:33:51 +01:00
int peerVersion = 0;
int32_t connectionMaxLayer = 0;
2020-03-21 15:08:03 +01:00
2020-03-22 20:09:44 +01:00
uint32_t maxVideoResolution;
2020-03-21 15:08:03 +01:00
inline bool isNew() const
{
return peerVersion >= PROTOCOL_RELIABLE || connectionMaxLayer >= 110;
}
2020-03-22 20:09:44 +01:00
inline bool isLegacy() const
{
return !isNew() && (peerVersion >= 8 || (!peerVersion && connectionMaxLayer >= 92));
}
2020-03-21 15:08:03 +01:00
inline bool isLegacyLegacy() const
{
return !(peerVersion >= 8 || (!peerVersion && connectionMaxLayer >= 92));
}
};
} // namespace tgvoip