提交 a9dd2429 authored 作者: Iñaki Baz Castillo's avatar Iñaki Baz Castillo

Add RtcpParameters.

上级 890bcb7b
......@@ -67,7 +67,13 @@ tap.test('rtpReceiver.receive() with valid `rtpParameters` must succeed', { time
{
ssrc : 111222331
}
]
],
rtcp :
{
cname : 'a7sdihkj3sdsdflqwkejl98ujk',
ssrc : 88888888,
reducedSize : true
}
};
let expectedRtpParameters =
{
......@@ -117,7 +123,13 @@ tap.test('rtpReceiver.receive() with valid `rtpParameters` must succeed', { time
{
ssrc : 111222331
}
]
],
rtcp :
{
cname : 'a7sdihkj3sdsdflqwkejl98ujk',
ssrc : 88888888,
reducedSize : true
}
};
t.equal(rtpReceiver.transport, transport, 'rtpReceiver.transport must retrieve the given `transport`');
......
......@@ -41,7 +41,13 @@ tap.test('alice, bob and carol create RtpReceivers and expect RtpSenders', { tim
{
ssrc : 100000001
}
]
],
rtcp :
{
cname : 'ALICEAUDIO',
ssrc : 50000001,
reducedSize : false
}
};
let aliceVideoParameters =
{
......@@ -59,7 +65,13 @@ tap.test('alice, bob and carol create RtpReceivers and expect RtpSenders', { tim
{
ssrc : 100000002
}
]
],
rtcp :
{
cname : 'ALICEVIDEO',
ssrc : 50000002,
reducedSize : true
}
};
let bobVideoParameters =
{
......@@ -82,7 +94,13 @@ tap.test('alice, bob and carol create RtpReceivers and expect RtpSenders', { tim
{
ssrc : 200000002
}
]
],
rtcp :
{
cname : 'BOBVIDEO',
ssrc : 50000003,
reducedSize : true
}
};
let carolAudioParameters =
{
......@@ -100,7 +118,13 @@ tap.test('alice, bob and carol create RtpReceivers and expect RtpSenders', { tim
{
ssrc : 300000001
}
]
],
rtcp :
{
cname : 'CAROLAUDIO',
ssrc : 50000004,
reducedSize : false
}
};
let carolVideoParameters =
{
......@@ -118,7 +142,13 @@ tap.test('alice, bob and carol create RtpReceivers and expect RtpSenders', { tim
{
ssrc : 300000002
}
]
],
rtcp :
{
cname : 'CAROLVIDEO',
ssrc : 50000005,
reducedSize : true
}
};
Promise.all(
......
......@@ -84,6 +84,21 @@ namespace RTC
RtpRtxParameters rtx;
};
class RtcpParameters
{
public:
RtcpParameters() {};
RtcpParameters(Json::Value& data);
virtual ~RtcpParameters();
Json::Value toJson();
public:
std::string cname;
uint32_t ssrc = 0;
bool reducedSize = false;
};
class RtpParameters
{
public:
......@@ -97,7 +112,12 @@ namespace RTC
// TODO: not sure if 1 or 2 bytes or what.
std::string muxId;
std::vector<RtpCodecParameters> codecs;
// TODO:
// std::vector<RtpHeaderExtensionParameters> headerExtensions;
std::vector<RtpEncodingParameters> encodings;
RtcpParameters rtcp;
// TODO:
// DegradationPreference degradationPreference = "balanced";
};
}
......
......@@ -15,6 +15,7 @@ namespace RTC
static const Json::StaticString k_muxId("muxId");
static const Json::StaticString k_codecs("codecs");
static const Json::StaticString k_encodings("encodings");
static const Json::StaticString k_rtcp("rtcp");
// `muxId` is optional.
if (data[k_muxId].isString())
......@@ -57,6 +58,16 @@ namespace RTC
{
MS_THROW_ERROR("missing `encodings`");
}
// `rtcp` is mandatory.
if (data[k_rtcp].isObject())
{
this->rtcp = RtcpParameters(data[k_rtcp]);
}
else
{
MS_THROW_ERROR("missing `rtcp`");
}
}
RtpParameters::RtpParameters(const RtpParameters* rtpParameters)
......@@ -66,6 +77,7 @@ namespace RTC
this->muxId = rtpParameters->muxId;
this->codecs = rtpParameters->codecs;
this->encodings = rtpParameters->encodings;
this->rtcp = rtpParameters->rtcp;
}
RtpParameters::~RtpParameters()
......@@ -80,6 +92,7 @@ namespace RTC
static const Json::StaticString k_muxId("muxId");
static const Json::StaticString k_codecs("codecs");
static const Json::StaticString k_encodings("encodings");
static const Json::StaticString k_rtcp("rtcp");
Json::Value json(Json::objectValue);
......@@ -104,6 +117,9 @@ namespace RTC
json[k_encodings].append(encoding->toJson());
}
// Add `rtcp`.
json[k_rtcp] = this->rtcp.toJson();
return json;
}
}
#define MS_CLASS "RTC::RtcpParameters"
#include "RTC/RtpParameters.h"
#include "MediaSoupError.h"
#include "Logger.h"
namespace RTC
{
/* Instance methods. */
RtcpParameters::RtcpParameters(Json::Value& data)
{
MS_TRACE();
static const Json::StaticString k_cname("cname");
static const Json::StaticString k_ssrc("ssrc");
static const Json::StaticString k_reducedSize("reducedSize");
if (!data.isObject())
MS_THROW_ERROR("RtcpParameters is not an object");
// `cname` is mandatory.
if (!data[k_cname].isString())
MS_THROW_ERROR("missing `RtcpParameters.cname`");
this->cname = data[k_cname].asString();
if (this->cname.empty())
MS_THROW_ERROR("empty `RtcpParameters.cname`");
// `ssrc` is optional.
if (data[k_ssrc].isUInt())
this->ssrc = (uint32_t)data[k_ssrc].asUInt();
// `reducedSize` is optional.
if (data[k_reducedSize].isBool())
this->reducedSize = data[k_reducedSize].asBool();
}
RtcpParameters::~RtcpParameters()
{
MS_TRACE();
}
Json::Value RtcpParameters::toJson()
{
MS_TRACE();
static const Json::StaticString k_cname("cname");
static const Json::StaticString k_ssrc("ssrc");
static const Json::StaticString k_reducedSize("reducedSize");
Json::Value json(Json::objectValue);
// Add `cname`.
json[k_cname] = this->cname;
// Add `ssrc`.
if (this->ssrc)
json[k_ssrc] = (Json::UInt)this->ssrc;
// Add `reducedSize`.
json[k_reducedSize] = this->reducedSize;
return json;
}
}
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论