Extract SDP bandwidth histogram reporting to a helper function Bug: chromium:501883592 Change-Id: Ie9c48d5683e2f3a72e91d4f2cb9471af1cbfe4b4 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/464023 Auto-Submit: Harald Alvestrand <hta@webrtc.org> Reviewed-by: Johannes Kron <kron@webrtc.org> Commit-Queue: Harald Alvestrand <hta@webrtc.org> Cr-Commit-Position: refs/heads/main@{#47434}
diff --git a/api/webrtc_sdp.cc b/api/webrtc_sdp.cc index 438ff66..4021775 100644 --- a/api/webrtc_sdp.cc +++ b/api/webrtc_sdp.cc
@@ -208,6 +208,11 @@ (ch >= 0x41 && ch <= 0x5a) || (ch >= 0x5e && ch <= 0x7e); } +void ReportSdpBandwidth(SdpBandwidthCategory category) { + RTC_HISTOGRAM_ENUMERATION("WebRTC.PeerConnection.SdpBandwidth", category, + kSdpBandwidthMax); +} + struct SsrcInfo { uint32_t ssrc_id; std::string cname; @@ -2607,25 +2612,19 @@ } int b = 0; if (!GetValueFromString(*line, bandwidth, &b, error)) { - RTC_HISTOGRAM_ENUMERATION("WebRTC.PeerConnection.SdpBandwidth", - kSdpBandwidthParseFailure, kSdpBandwidthMax); + ReportSdpBandwidth(kSdpBandwidthParseFailure); return false; } if (b == -1) { - RTC_HISTOGRAM_ENUMERATION("WebRTC.PeerConnection.SdpBandwidth", - kSdpBandwidthNegativeOne, kSdpBandwidthMax); + ReportSdpBandwidth(kSdpBandwidthNegativeOne); } else if (b == 0) { - RTC_HISTOGRAM_ENUMERATION("WebRTC.PeerConnection.SdpBandwidth", - kSdpBandwidthZero, kSdpBandwidthMax); + ReportSdpBandwidth(kSdpBandwidthZero); } else if (b > 0 && b <= INT_MAX / 1000) { - RTC_HISTOGRAM_ENUMERATION("WebRTC.PeerConnection.SdpBandwidth", - kSdpBandwidthSmall, kSdpBandwidthMax); + ReportSdpBandwidth(kSdpBandwidthSmall); } else if (b > INT_MAX / 1000) { - RTC_HISTOGRAM_ENUMERATION("WebRTC.PeerConnection.SdpBandwidth", - kSdpBandwidthLarge, kSdpBandwidthMax); + ReportSdpBandwidth(kSdpBandwidthLarge); } else { - RTC_HISTOGRAM_ENUMERATION("WebRTC.PeerConnection.SdpBandwidth", - kSdpBandwidthNegative, kSdpBandwidthMax); + ReportSdpBandwidth(kSdpBandwidthNegative); } // TODO(deadbeef): Historically, applications may be setting a value // of -1 to mean "unset any previously set bandwidth limit", even