- 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();
|
||||
if (result.exists(SessionInfo_ReceivedRtp))
|
||||
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))
|
||||
answer["duration"] = result[SessionInfo_Duration].asInt();
|
||||
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_SentTraffic] = static_cast<int>(stat.mSent);
|
||||
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_LostRtp] = static_cast<int>(stat.mPacketLoss);
|
||||
info[SessionInfo_DroppedRtp] = static_cast<int>(stat.mPacketDropped);
|
||||
|
||||
@@ -72,7 +72,8 @@ enum SessionInfo
|
||||
SessionInfo_BitrateSwitchCounter, // It is for AMR codecs only
|
||||
SessionInfo_RemotePeer,
|
||||
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)
|
||||
mStat.mFirstRtpTime = std::chrono::steady_clock::now();
|
||||
mStat.mReceivedRtp++;
|
||||
mStat.mReceivedRtpBytes += length;
|
||||
perDst.mReceivedRtp++;
|
||||
}
|
||||
else
|
||||
|
||||
@@ -262,6 +262,7 @@ Statistics& Statistics::operator += (const Statistics& src)
|
||||
{
|
||||
mReceived += src.mReceived;
|
||||
mSent += src.mSent;
|
||||
mReceivedRtpBytes += src.mReceivedRtpBytes;
|
||||
mReceivedRtp += src.mReceivedRtp;
|
||||
mSentRtp += src.mSentRtp;
|
||||
mReceivedRtcp += src.mReceivedRtcp;
|
||||
@@ -324,6 +325,7 @@ Statistics& Statistics::operator -= (const Statistics& src)
|
||||
{
|
||||
mReceived -= src.mReceived;
|
||||
mSent -= src.mSent;
|
||||
mReceivedRtpBytes -= src.mReceivedRtpBytes;
|
||||
mReceivedRtp -= src.mReceivedRtp;
|
||||
mIllegalRtp -= src.mIllegalRtp;
|
||||
mSentRtp -= src.mSentRtp;
|
||||
@@ -362,6 +364,8 @@ std::string Statistics::toString() const
|
||||
{
|
||||
std::ostringstream oss;
|
||||
oss << "Received: " << mReceivedRtp
|
||||
<< ", received bytes: " << mReceivedRtpBytes
|
||||
<< ", avg rtp size: " << (mReceivedRtp ? mReceivedRtpBytes / mReceivedRtp : 0)
|
||||
<< ", lost: " << mPacketLoss
|
||||
<< ", dropped: " << mPacketDropped
|
||||
<< ", sent: " << mSentRtp
|
||||
|
||||
@@ -91,6 +91,11 @@ class Statistics
|
||||
public:
|
||||
size_t mReceived = 0, // Received 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
|
||||
mSentRtp = 0, // Number of sent rtp packets
|
||||
mReceivedRtcp = 0, // Number of received rtcp packets
|
||||
|
||||
Reference in New Issue
Block a user