diff --git a/pc/BUILD.gn b/pc/BUILD.gn index a7a7c56d58..61aa750341 100644 --- a/pc/BUILD.gn +++ b/pc/BUILD.gn @@ -84,6 +84,7 @@ rtc_static_library("rtc_pc_base") { "../rtc_base:rtc_base", "../rtc_base:rtc_task_queue", "../rtc_base:stringutils", + "../system_wrappers:metrics_api", ] if (rtc_build_libsrtp) { diff --git a/pc/srtpsession.cc b/pc/srtpsession.cc index c0d05b74f4..3b33f85c34 100644 --- a/pc/srtpsession.cc +++ b/pc/srtpsession.cc @@ -15,11 +15,17 @@ #include "rtc_base/criticalsection.h" #include "rtc_base/logging.h" #include "rtc_base/sslstreamadapter.h" +#include "system_wrappers/include/metrics.h" #include "third_party/libsrtp/include/srtp.h" #include "third_party/libsrtp/include/srtp_priv.h" namespace cricket { +// One more than the maximum libsrtp error code. Required by +// RTC_HISTOGRAM_ENUMERATION. Keep this in sync with srtp_error_status_t defined +// in srtp.h. +constexpr int kSrtpErrorCodeBoundary = 28; + SrtpSession::SrtpSession() {} SrtpSession::~SrtpSession() { @@ -137,6 +143,8 @@ bool SrtpSession::UnprotectRtp(void* p, int in_len, int* out_len) { metrics_observer_->IncrementSparseEnumCounter( webrtc::kEnumCounterSrtpUnprotectError, err); } + RTC_HISTOGRAM_ENUMERATION("WebRTC.PeerConnection.UnprotectSrtpError", + static_cast(err), kSrtpErrorCodeBoundary); return false; } return true; @@ -157,6 +165,8 @@ bool SrtpSession::UnprotectRtcp(void* p, int in_len, int* out_len) { metrics_observer_->IncrementSparseEnumCounter( webrtc::kEnumCounterSrtcpUnprotectError, err); } + RTC_HISTOGRAM_ENUMERATION("WebRTC.PeerConnection.UnprotectSrtcpError", + static_cast(err), kSrtpErrorCodeBoundary); return false; } return true;