Use RTC_HISTOGRAM_ENUMERATION to report SRTP/SRTCP unprotect error.

Besides using the MetricsObserverInterface, using RTC_HISTOGRAM_ENUMERATION
directly using RTC_HISTOGRAM_ENUMERATION to report the error which is
needed by internal projects.

Bug: b/110121202, webrtc:9409
Change-Id: I1aaece91200905ea0495229dc2b5e62b1d61279b
Reviewed-on: https://webrtc-review.googlesource.com/83565
Commit-Queue: Zhi Huang <zhihuang@webrtc.org>
Reviewed-by: Steve Anton <steveanton@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23616}
This commit is contained in:
Zhi Huang
2018-06-14 10:40:19 -07:00
committed by Commit Bot
parent 9eb38866cd
commit 0a5fdbb455
2 changed files with 11 additions and 0 deletions

View File

@ -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) {

View File

@ -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<int>(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<int>(err), kSrtpErrorCodeBoundary);
return false;
}
return true;