Only fill send/recv stats if there are send/receive streams

optimizing for the fairly common case of many recv-only
mediasections.

BUG=webrtc:14808

Change-Id: Iae68c5bb7a5516d77f908f1effbb50a5ed750f92
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/290984
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Philipp Hancke <phancke@microsoft.com>
Reviewed-by: Henrik Boström <hbos@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#39122}
This commit is contained in:
Philipp Hancke 2023-01-17 10:38:56 +01:00 committed by WebRTC LUCI CQ
parent 9b239001bc
commit 94b05599ec

View File

@ -1658,6 +1658,11 @@ bool WebRtcVideoChannel::GetSendStats(VideoMediaSendInfo* info) {
RTC_DCHECK_RUN_ON(&thread_checker_); RTC_DCHECK_RUN_ON(&thread_checker_);
TRACE_EVENT0("webrtc", "WebRtcVideoChannel::GetSendStats"); TRACE_EVENT0("webrtc", "WebRtcVideoChannel::GetSendStats");
info->Clear();
if (send_streams_.empty()) {
return true;
}
// Log stats periodically. // Log stats periodically.
bool log_stats = false; bool log_stats = false;
int64_t now_ms = rtc::TimeMillis(); int64_t now_ms = rtc::TimeMillis();
@ -1667,7 +1672,6 @@ bool WebRtcVideoChannel::GetSendStats(VideoMediaSendInfo* info) {
log_stats = true; log_stats = true;
} }
info->Clear();
FillSenderStats(info, log_stats); FillSenderStats(info, log_stats);
FillSendCodecStats(info); FillSendCodecStats(info);
// TODO(holmer): We should either have rtt available as a metric on // TODO(holmer): We should either have rtt available as a metric on
@ -1691,6 +1695,11 @@ bool WebRtcVideoChannel::GetReceiveStats(VideoMediaReceiveInfo* info) {
RTC_DCHECK_RUN_ON(&thread_checker_); RTC_DCHECK_RUN_ON(&thread_checker_);
TRACE_EVENT0("webrtc", "WebRtcVideoChannel::GetReceiveStats"); TRACE_EVENT0("webrtc", "WebRtcVideoChannel::GetReceiveStats");
info->Clear();
if (receive_streams_.empty()) {
return true;
}
// Log stats periodically. // Log stats periodically.
bool log_stats = false; bool log_stats = false;
int64_t now_ms = rtc::TimeMillis(); int64_t now_ms = rtc::TimeMillis();
@ -1700,7 +1709,6 @@ bool WebRtcVideoChannel::GetReceiveStats(VideoMediaReceiveInfo* info) {
log_stats = true; log_stats = true;
} }
info->Clear();
FillReceiverStats(info, log_stats); FillReceiverStats(info, log_stats);
FillReceiveCodecStats(info); FillReceiveCodecStats(info);