- find total number of received RTP (not RTCP) bytes
This commit is contained in:
@@ -528,6 +528,9 @@ void AgentImpl::processGetMediaStats(JsonCpp::Value& request, JsonCpp::Value& an
|
|||||||
answer["rtp_sent"] = result[SessionInfo_SentRtp].asInt();
|
answer["rtp_sent"] = result[SessionInfo_SentRtp].asInt();
|
||||||
if (result.exists(SessionInfo_ReceivedRtp))
|
if (result.exists(SessionInfo_ReceivedRtp))
|
||||||
answer["rtp_received"] = result[SessionInfo_ReceivedRtp].asInt();
|
answer["rtp_received"] = result[SessionInfo_ReceivedRtp].asInt();
|
||||||
|
// Raw byte total; consumers divide by rtp_received for the average packet size.
|
||||||
|
if (result.exists(SessionInfo_ReceivedRtpTraffic))
|
||||||
|
answer["rtp_received_bytes"] = result[SessionInfo_ReceivedRtpTraffic].asInt();
|
||||||
if (result.exists(SessionInfo_Duration))
|
if (result.exists(SessionInfo_Duration))
|
||||||
answer["duration"] = result[SessionInfo_Duration].asInt();
|
answer["duration"] = result[SessionInfo_Duration].asInt();
|
||||||
if (result.exists(SessionInfo_Jitter))
|
if (result.exists(SessionInfo_Jitter))
|
||||||
|
|||||||
@@ -466,6 +466,7 @@ void Session::getSessionInfo(Session::InfoOptions options, VariantMap& info)
|
|||||||
info[SessionInfo_ReceivedTraffic] = static_cast<int>(stat.mReceived);
|
info[SessionInfo_ReceivedTraffic] = static_cast<int>(stat.mReceived);
|
||||||
info[SessionInfo_SentTraffic] = static_cast<int>(stat.mSent);
|
info[SessionInfo_SentTraffic] = static_cast<int>(stat.mSent);
|
||||||
info[SessionInfo_ReceivedRtp] = static_cast<int>(stat.mReceivedRtp);
|
info[SessionInfo_ReceivedRtp] = static_cast<int>(stat.mReceivedRtp);
|
||||||
|
info[SessionInfo_ReceivedRtpTraffic] = static_cast<int>(stat.mReceivedRtpBytes);
|
||||||
info[SessionInfo_ReceivedRtcp] = static_cast<int>(stat.mReceivedRtcp);
|
info[SessionInfo_ReceivedRtcp] = static_cast<int>(stat.mReceivedRtcp);
|
||||||
info[SessionInfo_LostRtp] = static_cast<int>(stat.mPacketLoss);
|
info[SessionInfo_LostRtp] = static_cast<int>(stat.mPacketLoss);
|
||||||
info[SessionInfo_DroppedRtp] = static_cast<int>(stat.mPacketDropped);
|
info[SessionInfo_DroppedRtp] = static_cast<int>(stat.mPacketDropped);
|
||||||
|
|||||||
@@ -72,7 +72,8 @@ enum SessionInfo
|
|||||||
SessionInfo_BitrateSwitchCounter, // It is for AMR codecs only
|
SessionInfo_BitrateSwitchCounter, // It is for AMR codecs only
|
||||||
SessionInfo_RemotePeer,
|
SessionInfo_RemotePeer,
|
||||||
SessionInfo_SSRC,
|
SessionInfo_SSRC,
|
||||||
SessionInfo_CngCounter // For AMR codecs only
|
SessionInfo_CngCounter, // For AMR codecs only
|
||||||
|
SessionInfo_ReceivedRtpTraffic // amount of received RTP traffic in bytes, RTCP excluded
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -359,6 +359,7 @@ void AudioStream::dataArrived(PDatagramSocket s, const void* buffer, int length,
|
|||||||
if (!mStat.mFirstRtpTime)
|
if (!mStat.mFirstRtpTime)
|
||||||
mStat.mFirstRtpTime = std::chrono::steady_clock::now();
|
mStat.mFirstRtpTime = std::chrono::steady_clock::now();
|
||||||
mStat.mReceivedRtp++;
|
mStat.mReceivedRtp++;
|
||||||
|
mStat.mReceivedRtpBytes += length;
|
||||||
perDst.mReceivedRtp++;
|
perDst.mReceivedRtp++;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -262,6 +262,7 @@ Statistics& Statistics::operator += (const Statistics& src)
|
|||||||
{
|
{
|
||||||
mReceived += src.mReceived;
|
mReceived += src.mReceived;
|
||||||
mSent += src.mSent;
|
mSent += src.mSent;
|
||||||
|
mReceivedRtpBytes += src.mReceivedRtpBytes;
|
||||||
mReceivedRtp += src.mReceivedRtp;
|
mReceivedRtp += src.mReceivedRtp;
|
||||||
mSentRtp += src.mSentRtp;
|
mSentRtp += src.mSentRtp;
|
||||||
mReceivedRtcp += src.mReceivedRtcp;
|
mReceivedRtcp += src.mReceivedRtcp;
|
||||||
@@ -324,6 +325,7 @@ Statistics& Statistics::operator -= (const Statistics& src)
|
|||||||
{
|
{
|
||||||
mReceived -= src.mReceived;
|
mReceived -= src.mReceived;
|
||||||
mSent -= src.mSent;
|
mSent -= src.mSent;
|
||||||
|
mReceivedRtpBytes -= src.mReceivedRtpBytes;
|
||||||
mReceivedRtp -= src.mReceivedRtp;
|
mReceivedRtp -= src.mReceivedRtp;
|
||||||
mIllegalRtp -= src.mIllegalRtp;
|
mIllegalRtp -= src.mIllegalRtp;
|
||||||
mSentRtp -= src.mSentRtp;
|
mSentRtp -= src.mSentRtp;
|
||||||
@@ -362,6 +364,8 @@ std::string Statistics::toString() const
|
|||||||
{
|
{
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
oss << "Received: " << mReceivedRtp
|
oss << "Received: " << mReceivedRtp
|
||||||
|
<< ", received bytes: " << mReceivedRtpBytes
|
||||||
|
<< ", avg rtp size: " << (mReceivedRtp ? mReceivedRtpBytes / mReceivedRtp : 0)
|
||||||
<< ", lost: " << mPacketLoss
|
<< ", lost: " << mPacketLoss
|
||||||
<< ", dropped: " << mPacketDropped
|
<< ", dropped: " << mPacketDropped
|
||||||
<< ", sent: " << mSentRtp
|
<< ", sent: " << mSentRtp
|
||||||
|
|||||||
@@ -91,6 +91,11 @@ class Statistics
|
|||||||
public:
|
public:
|
||||||
size_t mReceived = 0, // Received traffic in bytes
|
size_t mReceived = 0, // Received traffic in bytes
|
||||||
mSent = 0, // Sent traffic in bytes
|
mSent = 0, // Sent traffic in bytes
|
||||||
|
// Received RTP traffic in bytes. Unlike mReceived this excludes
|
||||||
|
// RTCP, so mReceivedRtpBytes / mReceivedRtp is the true average
|
||||||
|
// on-the-wire RTP packet size (UDP payload: RTP header + payload
|
||||||
|
// + SRTP auth tag; IP/UDP headers are not counted).
|
||||||
|
mReceivedRtpBytes = 0,
|
||||||
mReceivedRtp = 0, // Number of received rtp packets
|
mReceivedRtp = 0, // Number of received rtp packets
|
||||||
mSentRtp = 0, // Number of sent rtp packets
|
mSentRtp = 0, // Number of sent rtp packets
|
||||||
mReceivedRtcp = 0, // Number of received rtcp packets
|
mReceivedRtcp = 0, // Number of received rtcp packets
|
||||||
|
|||||||
Reference in New Issue
Block a user