Bug 1343691 - fix missing rtcp stats;r=jib

Omitting the RTT when it is not available breaks a lot of tests (as jesup warned).
I am going to fix the RTT behavior and the tests in bug 1344970, for now RTT will
be zero when unavailable.

MozReview-Commit-ID: 9x3eQfbM3ZT

--HG--
extra : rebase_source : f8d46d7232455a3038fd99ffb6cc14111c44a794
This commit is contained in:
Nico Grunbaum 2017-03-08 23:26:24 -08:00
parent 40c2227517
commit 194702d7ab
8 changed files with 65 additions and 44 deletions

View File

@ -205,10 +205,13 @@ bool WebrtcAudioConduit::GetRTCPReceiverReport(DOMHighResTimeStamp* timestamp,
fractionLost,
*cumulativeLost,
*rttMs);
if (result) {
*timestamp = NTPtoDOMHighResTimeStamp(ntpHigh, ntpLow);
if (!result) {
return false;
}
return result;
// Note: timestamp is not correct per the spec... should be time the rtcp
// was received (remote) or sent (local)
*timestamp = webrtc::Clock::GetRealTimeClock()->TimeInMilliseconds();
return true;
}
bool WebrtcAudioConduit::GetRTCPSenderReport(DOMHighResTimeStamp* timestamp,

View File

@ -821,24 +821,42 @@ bool WebrtcVideoConduit::GetRTCPReceiverReport(DOMHighResTimeStamp* timestamp,
{
CSFLogVerbose(logTag, "%s for VideoConduit:%p", __FUNCTION__, this);
MutexAutoLock lock(mCodecMutex);
if (!mRecvStream) {
if (!mSendStream) {
return false;
}
const webrtc::VideoReceiveStream::Stats &stats = mRecvStream->GetStats();
*jitterMs = stats.rtcp_stats.jitter;
*cumulativeLost = stats.rtcp_stats.cumulative_lost;
*bytesReceived = stats.rtp_stats.MediaPayloadBytes();
*packetsReceived = stats.rtp_stats.transmitted.packets;
// Note: timestamp is not correct per the spec... should be time the rtcp
// was received (remote) or sent (local)
*timestamp = webrtc::Clock::GetRealTimeClock()->TimeInMilliseconds();
int64_t rtt = mRecvStream->GetRtt();
const webrtc::VideoSendStream::Stats& sendStats = mSendStream->GetStats();
if (sendStats.substreams.size() == 0
|| mSendStreamConfig.rtp.ssrcs.size() == 0) {
return false;
}
uint32_t ssrc = mSendStreamConfig.rtp.ssrcs.front();
auto ind = sendStats.substreams.find(ssrc);
if (ind == sendStats.substreams.end()) {
CSFLogError(logTag,
"%s for VideoConduit:%p ssrc not found in SendStream stats.",
__FUNCTION__, this);
return false;
}
*jitterMs = ind->second.rtcp_stats.jitter;
*cumulativeLost = ind->second.rtcp_stats.cumulative_lost;
*bytesReceived = ind->second.rtp_stats.MediaPayloadBytes();
*packetsReceived = ind->second.rtp_stats.transmitted.packets;
int64_t rtt = mSendStream->GetRtt(); // TODO: BUG 1241066, mozRtt is 0 or 1
if (rtt >= 0) {
*rttMs = rtt;
} else {
*rttMs = 0;
}
#ifdef DEBUG
if (rtt > INT32_MAX) {
CSFLogError(logTag,
"%s for VideoConduit:%p mRecvStream->GetRtt() is larger than the"
" maximum size of an RTCP RTT.", __FUNCTION__, this);
}
#endif
// Note: timestamp is not correct per the spec... should be time the rtcp
// was received (remote) or sent (local)
*timestamp = webrtc::Clock::GetRealTimeClock()->TimeInMilliseconds();
}
return true;
}
@ -849,22 +867,16 @@ WebrtcVideoConduit::GetRTCPSenderReport(DOMHighResTimeStamp* timestamp,
uint64_t* bytesSent)
{
CSFLogVerbose(logTag, "%s for VideoConduit:%p", __FUNCTION__, this);
MutexAutoLock lock(mCodecMutex);
if (!mSendStream) {
return false;
webrtc::RTCPSenderInfo senderInfo;
{
MutexAutoLock lock(mCodecMutex);
if (!mRecvStream || !mRecvStream->GetRemoteRTCPSenderInfo(&senderInfo)) {
return false;
}
}
const webrtc::VideoSendStream::Stats& stats = mSendStream->GetStats();
*packetsSent = 0;
for (auto entry: stats.substreams){
*packetsSent += entry.second.rtp_stats.transmitted.packets;
// NG -- per https://www.w3.org/TR/webrtc-stats/ this is only payload bytes
*bytesSent += entry.second.rtp_stats.MediaPayloadBytes();
}
// Note: timestamp is not correct per the spec... should be time the rtcp
// was received (remote) or sent (local)
*timestamp = webrtc::Clock::GetRealTimeClock()->TimeInMilliseconds();
*packetsSent = senderInfo.sendPacketCount;
*bytesSent = senderInfo.sendOctetCount;
return true;
}

View File

@ -407,5 +407,10 @@ int64_t VideoReceiveStream::GetRtt() const {
return -1;
}
bool
VideoReceiveStream::GetRemoteRTCPSenderInfo(RTCPSenderInfo* sender_info) const {
return -1 != vie_channel_->GetRemoteRTCPSenderInfo(sender_info);
}
} // namespace internal
} // namespace webrtc

View File

@ -76,6 +76,7 @@ class VideoReceiveStream : public webrtc::VideoReceiveStream,
void SetSyncChannel(VoiceEngine* voice_engine, int audio_channel_id) override;
int64_t GetRtt() const override;
bool GetRemoteRTCPSenderInfo(RTCPSenderInfo* sender_info) const override;
private:
TransportAdapter transport_adapter_;
EncodedFrameCallbackAdapter encoded_frame_proxy_;

View File

@ -70,7 +70,7 @@ class VideoSendStream : public webrtc::VideoSendStream,
typedef std::map<uint32_t, RtpState> RtpStateMap;
RtpStateMap GetRtpStates() const;
int64_t GetRtt() const;
int64_t GetRtt() const override;
int GetPaddingNeededBps() const;
private:

View File

@ -891,21 +891,15 @@ int32_t ViEChannel::GetRemoteRTCPReceiverInfo(uint32_t& NTPHigh,
return 0;
}
//->@@NG // int32_t ViEChannel::GetRemoteRTCPSenderInfo(RTCPSenderInfo* sender_info) const {
//->@@NG // // Get the sender info from the latest received RTCP Sender Report.
//->@@NG // RTCPSenderInfo rtcp_sender_info;
//->@@NG // if (rtp_rtcp_->RemoteRTCPStat(&rtcp_sender_info) != 0) {
//->@@NG // LOG_F(LS_ERROR) << "failed to read RTCP SR sender info";
//->@@NG // return -1;
//->@@NG // }
//->@@NG //
//->@@NG // sender_info->NTP_timestamp_high = rtcp_sender_info.NTPseconds;
//->@@NG // sender_info->NTP_timestamp_low = rtcp_sender_info.NTPfraction;
//->@@NG // sender_info->RTP_timestamp = rtcp_sender_info.RTPtimeStamp;
//->@@NG // sender_info->sender_packet_count = rtcp_sender_info.sendPacketCount;
//->@@NG // sender_info->sender_octet_count = rtcp_sender_info.sendOctetCount;
//->@@NG // return 0;
//->@@NG // }
int32_t ViEChannel::GetRemoteRTCPSenderInfo(RTCPSenderInfo* sender_info) const {
// Get the sender info from the latest received RTCP Sender Report.
if (rtp_rtcp_modules_[0] &&
rtp_rtcp_modules_[0]->RemoteRTCPStat(sender_info) != 0) {
LOG_F(LS_ERROR) << "failed to read RTCP SR sender info";
return -1;
}
return 0;
}
void ViEChannel::RegisterSendChannelRtcpStatisticsCallback(
RtcpStatisticsCallback* callback) {

View File

@ -179,6 +179,10 @@ class VideoReceiveStream : public ReceiveStream {
// TODO(pbos): Add info on currently-received codec to Stats.
virtual Stats GetStats() const = 0;
virtual int64_t GetRtt() const = 0;
virtual bool
GetRemoteRTCPSenderInfo(RTCPSenderInfo* sender_info) const = 0;
virtual void SetSyncChannel(VoiceEngine* voice_engine, int audio_channel_id) = 0;
};

View File

@ -187,6 +187,8 @@ class VideoSendStream : public SendStream {
virtual bool ReconfigureVideoEncoder(const VideoEncoderConfig& config) = 0;
virtual Stats GetStats() = 0;
virtual int64_t GetRtt() const = 0;
};
} // namespace webrtc