Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3154)

Unified Diff: webrtc/video/send_statistics_proxy_unittest.cc

Issue 1478253002: Add histogram stats for send delay for a sent video stream. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webrtc/video/send_statistics_proxy_unittest.cc
diff --git a/webrtc/video/send_statistics_proxy_unittest.cc b/webrtc/video/send_statistics_proxy_unittest.cc
index f098ce2d239e309bc23ee64dc55429f572cdbcab..4e86af1cf299553f587aa9a6427a1d6a8d8a9b75 100644
--- a/webrtc/video/send_statistics_proxy_unittest.cc
+++ b/webrtc/video/send_statistics_proxy_unittest.cc
@@ -16,8 +16,12 @@
#include <vector>
#include "testing/gtest/include/gtest/gtest.h"
+#include "webrtc/test/histogram.h"
namespace webrtc {
+namespace {
+const int64_t kMaxPacketDelayMs = 11000;
+} // namespace
class SendStatisticsProxyTest : public ::testing::Test {
public:
@@ -288,6 +292,59 @@ TEST_F(SendStatisticsProxyTest, SendSideDelay) {
ExpectEqual(expected_, stats);
}
+TEST_F(SendStatisticsProxyTest, VerifySendDelayStats) {
+ const int64_t kSendDelayInMs = 5;
+ const size_t kMinRequiredSamples = 200;
+ test::ClearHistograms();
+ SendPacketObserver* observer = statistics_proxy_.get();
+ const uint32_t ssrc = *config_.rtp.ssrcs.begin();
+
+ uint16_t packet_id = 0;
+ for (size_t i = 0; i < kMinRequiredSamples; ++i) {
+ observer->OnSendPacket(++packet_id, fake_clock_.TimeInMilliseconds(), ssrc);
+ // Packet sent.
+ fake_clock_.AdvanceTimeMilliseconds(kSendDelayInMs);
+ EXPECT_TRUE(statistics_proxy_->OnSentPacket(packet_id));
+ }
+ statistics_proxy_.reset();
+ EXPECT_EQ(1, test::NumHistogramSamples("WebRTC.Video.SendDelayInMs"));
+ EXPECT_EQ(kSendDelayInMs,
+ test::LastHistogramSample("WebRTC.Video.SendDelayInMs"));
+}
+
+TEST_F(SendStatisticsProxyTest, OnSendPacket) {
+ const uint16_t kPacketId = 2345;
+ SendPacketObserver* observer = statistics_proxy_.get();
+ const uint32_t ssrc = *config_.rtp.ssrcs.begin();
+
+ observer->OnSendPacket(kPacketId, fake_clock_.TimeInMilliseconds(), ssrc);
+ fake_clock_.AdvanceTimeMilliseconds(kMaxPacketDelayMs - 1);
+ observer->OnSendPacket(kPacketId + 1, fake_clock_.TimeInMilliseconds(), ssrc);
+
+ EXPECT_TRUE(statistics_proxy_->OnSentPacket(kPacketId));
+ EXPECT_TRUE(statistics_proxy_->OnSentPacket(kPacketId + 1));
+ // Packets removed.
+ EXPECT_FALSE(statistics_proxy_->OnSentPacket(kPacketId));
+ EXPECT_FALSE(statistics_proxy_->OnSentPacket(kPacketId + 1));
+}
+
+TEST_F(SendStatisticsProxyTest, OnSendPacket_RemoveOldWithWrap) {
+ SendPacketObserver* observer = statistics_proxy_.get();
+ const uint32_t ssrc = *config_.rtp.ssrcs.begin();
+
+ int64_t capture_time_ms = fake_clock_.TimeInMilliseconds();
+ observer->OnSendPacket(0xFFFFu, capture_time_ms, ssrc);
+ observer->OnSendPacket(0u, capture_time_ms, ssrc);
+ observer->OnSendPacket(1u, capture_time_ms + 1, ssrc);
+ fake_clock_.AdvanceTimeMilliseconds(kMaxPacketDelayMs);
+ observer->OnSendPacket(2u, capture_time_ms + 2, ssrc);
+
+ EXPECT_FALSE(statistics_proxy_->OnSentPacket(0xFFFFu)); // Old removed.
+ EXPECT_FALSE(statistics_proxy_->OnSentPacket(0u)); // Old removed.
+ EXPECT_TRUE(statistics_proxy_->OnSentPacket(1u));
+ EXPECT_TRUE(statistics_proxy_->OnSentPacket(2u));
+}
+
TEST_F(SendStatisticsProxyTest, OnEncodedFrame) {
const int kEncodeTimeMs = 11;
statistics_proxy_->OnEncodedFrame(kEncodeTimeMs);

Powered by Google App Engine
This is Rietveld 408576698