提交 27a83dc8 authored 作者: José Luis Millán's avatar José Luis Millán

WebRtcTransport: show received and sent REMB on ToJson method

上级 65929f6e
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include "RTC/ProducerListener.hpp" #include "RTC/ProducerListener.hpp"
#include "RTC/RTCP/CompoundPacket.hpp" #include "RTC/RTCP/CompoundPacket.hpp"
#include "RTC/RTCP/FeedbackPsAfb.hpp" #include "RTC/RTCP/FeedbackPsAfb.hpp"
#include "RTC/RTCP/FeedbackPsRemb.hpp"
#include "RTC/RTCP/Packet.hpp" #include "RTC/RTCP/Packet.hpp"
#include "RTC/RTCP/ReceiverReport.hpp" #include "RTC/RTCP/ReceiverReport.hpp"
#include "RTC/RtpListener.hpp" #include "RTC/RtpListener.hpp"
...@@ -15,7 +16,9 @@ ...@@ -15,7 +16,9 @@
#include "RTC/UdpSocket.hpp" #include "RTC/UdpSocket.hpp"
#include "handles/Timer.hpp" #include "handles/Timer.hpp"
#include <json/json.h> #include <json/json.h>
#include <tuple>
#include <unordered_set> #include <unordered_set>
#include <vector>
namespace RTC namespace RTC
{ {
...@@ -78,6 +81,7 @@ namespace RTC ...@@ -78,6 +81,7 @@ namespace RTC
protected: protected:
void HandleRtcpPacket(RTC::RTCP::Packet* packet); void HandleRtcpPacket(RTC::RTCP::Packet* packet);
void ReceiveRtcpRemb(RTC::RTCP::FeedbackPsRembPacket* remb);
private: private:
virtual bool IsConnected() const = 0; virtual bool IsConnected() const = 0;
...@@ -140,6 +144,8 @@ namespace RTC ...@@ -140,6 +144,8 @@ namespace RTC
struct sockaddr_storage mirrorAddrStorage struct sockaddr_storage mirrorAddrStorage
{ {
}; };
// Others (REMB)
std::tuple<uint64_t, std::vector<uint32_t>> recvRemb;
}; };
} // namespace RTC } // namespace RTC
......
...@@ -130,7 +130,7 @@ namespace RTC ...@@ -130,7 +130,7 @@ namespace RTC
// Others (REMB and bitrate stuff). // Others (REMB and bitrate stuff).
std::unique_ptr<RTC::RemoteBitrateEstimatorAbsSendTime> remoteBitrateEstimator; std::unique_ptr<RTC::RemoteBitrateEstimatorAbsSendTime> remoteBitrateEstimator;
uint32_t maxBitrate{ 0 }; uint32_t maxBitrate{ 0 };
uint32_t effectiveMaxBitrate{ 0 }; std::tuple<uint64_t, std::vector<uint32_t>> sentRemb;
uint64_t lastEffectiveMaxBitrateAt{ 0 }; uint64_t lastEffectiveMaxBitrateAt{ 0 };
}; };
} // namespace RTC } // namespace RTC
......
...@@ -261,9 +261,14 @@ namespace RTC ...@@ -261,9 +261,14 @@ namespace RTC
{ {
auto* afb = dynamic_cast<RTCP::FeedbackPsAfbPacket*>(feedback); auto* afb = dynamic_cast<RTCP::FeedbackPsAfbPacket*>(feedback);
// Ignore REMB requests. // Store REMB info.
if (afb->GetApplication() == RTCP::FeedbackPsAfbPacket::Application::REMB) if (afb->GetApplication() == RTCP::FeedbackPsAfbPacket::Application::REMB)
{
auto* remb = dynamic_cast<RTCP::FeedbackPsRembPacket*>(afb);
this->recvRemb = std::make_tuple(remb->GetBitrate(), remb->GetSsrcs());
break; break;
}
} }
// [[fallthrough]]; (C++17) // [[fallthrough]]; (C++17)
......
...@@ -240,8 +240,13 @@ namespace RTC ...@@ -240,8 +240,13 @@ namespace RTC
static const Json::StaticString JsonStringHeaderExtensionIds{ "headerExtensionIds" }; static const Json::StaticString JsonStringHeaderExtensionIds{ "headerExtensionIds" };
static const Json::StaticString JsonStringAbsSendTime{ "absSendTime" }; static const Json::StaticString JsonStringAbsSendTime{ "absSendTime" };
static const Json::StaticString JsonStringRid{ "rid" }; static const Json::StaticString JsonStringRid{ "rid" };
static const Json::StaticString JsonStringMaxBitrate{ "maxBitrate" }; static const Json::StaticString JsonStringSentRemb{ "sentRemb" };
static const Json::StaticString JsonStringEffectiveMaxBitrate{ "effectiveMaxBitrate" }; static const Json::StaticString JsonStringSentRembMaxBitrate{ "maxBitrate" };
static const Json::StaticString JsonStringSentRembBitrate{ "bitrate" };
static const Json::StaticString JsonStringSentRembSsrcs{ "ssrcs" };
static const Json::StaticString JsonStringRecvRemb{ "recvRemb" };
static const Json::StaticString JsonStringRecvRembBitrate{ "bitrate" };
static const Json::StaticString JsonStringRecvRembSsrcs{ "ssrcs" };
static const Json::StaticString JsonStringRtpListener{ "rtpListener" }; static const Json::StaticString JsonStringRtpListener{ "rtpListener" };
Json::Value json(Json::objectValue); Json::Value json(Json::objectValue);
...@@ -336,11 +341,33 @@ namespace RTC ...@@ -336,11 +341,33 @@ namespace RTC
json[JsonStringHeaderExtensionIds] = jsonHeaderExtensionIds; json[JsonStringHeaderExtensionIds] = jsonHeaderExtensionIds;
// Add maxBitrate. // Add sendRemb
json[JsonStringMaxBitrate] = Json::UInt{ this->maxBitrate }; Json::Value jsonSentRemb(Json::objectValue);
Json::Value jsonSentRembSsrcs(Json::arrayValue);
// Add effectiveMaxBitrate. jsonSentRemb[JsonStringSentRembMaxBitrate] = Json::UInt{ this->maxBitrate };
json[JsonStringEffectiveMaxBitrate] = Json::UInt{ this->effectiveMaxBitrate };
jsonSentRemb[JsonStringSentRembBitrate] = Json::UInt64{ std::get<0>(this->sentRemb) };
for (auto ssrc : std::get<1>(this->sentRemb))
jsonSentRembSsrcs.append(ssrc);
jsonSentRemb[JsonStringSentRembSsrcs] = jsonSentRembSsrcs;
json[JsonStringSentRemb] = jsonSentRemb;
// Add recvRemb
Json::Value jsonRecvRemb(Json::objectValue);
Json::Value jsonRecvRembSsrcs(Json::arrayValue);
jsonRecvRemb[JsonStringRecvRembBitrate] = Json::UInt64{ std::get<0>(this->recvRemb) };
for (auto ssrc : std::get<1>(this->recvRemb))
jsonRecvRembSsrcs.append(ssrc);
jsonRecvRemb[JsonStringRecvRembSsrcs] = jsonRecvRembSsrcs;
json[JsonStringRecvRemb] = jsonRecvRemb;
// Add rtpListener. // Add rtpListener.
json[JsonStringRtpListener] = this->rtpListener.ToJson(); json[JsonStringRtpListener] = this->rtpListener.ToJson();
...@@ -1126,7 +1153,7 @@ namespace RTC ...@@ -1126,7 +1153,7 @@ namespace RTC
if (now - this->lastEffectiveMaxBitrateAt > EffectiveMaxBitrateCheckInterval) if (now - this->lastEffectiveMaxBitrateAt > EffectiveMaxBitrateCheckInterval)
{ {
this->lastEffectiveMaxBitrateAt = now; this->lastEffectiveMaxBitrateAt = now;
this->effectiveMaxBitrate = effectiveBitrate; this->sentRemb = std::make_tuple(effectiveBitrate, ssrcs);
} }
} }
} // namespace RTC } // namespace RTC
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论