#define MS_CLASS "RTC::TransportTuple"
#include "RTC/TransportTuple.hpp"
#include "Logger.hpp"
#include <string>
namespace RTC
{
void TransportTuple::FillJson(json& jsonObject) const
{
MS_TRACE();
int family;
std::string ip;
uint16_t port;
Utils::IP::GetAddressInfo(GetLocalAddress(), family, ip, port);
if (this->localAnnouncedIp.empty())
jsonObject["localIp"] = ip;
else
jsonObject["localIp"] = this->localAnnouncedIp;
jsonObject["localPort"] = port;
Utils::IP::GetAddressInfo(GetRemoteAddress(), family, ip, port);
jsonObject["remoteIp"] = ip;
jsonObject["remotePort"] = port;
switch (GetProtocol())
{
case Protocol::UDP:
jsonObject["protocol"] = "udp";
break;
case Protocol::TCP:
jsonObject["protocol"] = "tcp";
break;
}
}
void TransportTuple::Dump() const
{
MS_TRACE();
MS_DUMP("<TransportTuple>");
int family;
std::string ip;
uint16_t port;
Utils::IP::GetAddressInfo(GetLocalAddress(), family, ip, port);
MS_DUMP(" localIp : %s", ip.c_str());
MS_DUMP(" localPort : %" PRIu16, port);
Utils::IP::GetAddressInfo(GetRemoteAddress(), family, ip, port);
MS_DUMP(" remoteIp : %s", ip.c_str());
MS_DUMP(" remotePort : %" PRIu16, port);
switch (GetProtocol())
{
case Protocol::UDP:
MS_DUMP(" protocol : udp");
break;
case Protocol::TCP:
MS_DUMP(" protocol : tcp");
break;
}
MS_DUMP("</TransportTuple>");
}
}