#define MS_CLASS "RTC::RtcpParameters"
#include "Logger.hpp"
#include "MediaSoupErrors.hpp"
#include "Utils.hpp"
#include "RTC/RtpDictionaries.hpp"
namespace RTC
{
RtcpParameters::RtcpParameters(json& data)
{
MS_TRACE();
if (!data.is_object())
MS_THROW_TYPE_ERROR("data is not an object");
auto jsonCnameIt = data.find("cname");
auto jsonSsrcIt = data.find("ssrc");
auto jsonRedicedSizeIt = data.find("reducedSize");
if (jsonCnameIt != data.end() && jsonCnameIt->is_string())
this->cname = jsonCnameIt->get<std::string>();
if (
jsonSsrcIt != data.end() &&
Utils::Json::IsPositiveInteger(*jsonSsrcIt)
)
{
this->ssrc = jsonSsrcIt->get<uint32_t>();
}
if (jsonRedicedSizeIt != data.end() && jsonRedicedSizeIt->is_boolean())
this->reducedSize = jsonRedicedSizeIt->get<bool>();
}
void RtcpParameters::FillJson(json& jsonObject) const
{
MS_TRACE();
if (!this->cname.empty())
jsonObject["cname"] = this->cname;
if (this->ssrc != 0u)
jsonObject["ssrc"] = this->ssrc;
jsonObject["reducedSize"] = this->reducedSize;
}
}