sprang@webrtc.org | ccd4284 | 2014-01-07 09:54:34 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license |
| 5 | * that can be found in the LICENSE file in the root of the source |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
| 10 | |
| 11 | // This file includes unit tests for SendStatisticsProxy. |
| 12 | #include "webrtc/video/send_statistics_proxy.h" |
| 13 | |
| 14 | #include <map> |
| 15 | #include <string> |
| 16 | #include <vector> |
| 17 | |
| 18 | #include "testing/gtest/include/gtest/gtest.h" |
| 19 | |
| 20 | namespace webrtc { |
| 21 | |
stefan@webrtc.org | 168f23f | 2014-07-11 13:44:02 +0000 | [diff] [blame] | 22 | class SendStatisticsProxyTest : public ::testing::Test { |
sprang@webrtc.org | ccd4284 | 2014-01-07 09:54:34 +0000 | [diff] [blame] | 23 | public: |
| 24 | SendStatisticsProxyTest() : avg_delay_ms_(0), max_delay_ms_(0) {} |
| 25 | virtual ~SendStatisticsProxyTest() {} |
| 26 | |
| 27 | protected: |
| 28 | virtual void SetUp() { |
| 29 | statistics_proxy_.reset( |
stefan@webrtc.org | 168f23f | 2014-07-11 13:44:02 +0000 | [diff] [blame] | 30 | new SendStatisticsProxy(GetTestConfig())); |
sprang@webrtc.org | ccd4284 | 2014-01-07 09:54:34 +0000 | [diff] [blame] | 31 | config_ = GetTestConfig(); |
| 32 | expected_ = VideoSendStream::Stats(); |
| 33 | } |
| 34 | |
| 35 | VideoSendStream::Config GetTestConfig() { |
| 36 | VideoSendStream::Config config; |
| 37 | config.rtp.ssrcs.push_back(17); |
| 38 | config.rtp.ssrcs.push_back(42); |
stefan@webrtc.org | 58e2d26 | 2014-08-14 15:10:49 +0000 | [diff] [blame] | 39 | config.rtp.rtx.ssrcs.push_back(18); |
| 40 | config.rtp.rtx.ssrcs.push_back(43); |
sprang@webrtc.org | ccd4284 | 2014-01-07 09:54:34 +0000 | [diff] [blame] | 41 | return config; |
| 42 | } |
| 43 | |
sprang@webrtc.org | 0931570 | 2014-02-07 12:06:29 +0000 | [diff] [blame] | 44 | void ExpectEqual(VideoSendStream::Stats one, VideoSendStream::Stats other) { |
sprang@webrtc.org | 0931570 | 2014-02-07 12:06:29 +0000 | [diff] [blame] | 45 | EXPECT_EQ(one.input_frame_rate, other.input_frame_rate); |
| 46 | EXPECT_EQ(one.encode_frame_rate, other.encode_frame_rate); |
stefan@webrtc.org | 0bae1fa | 2014-11-05 14:05:29 +0000 | [diff] [blame^] | 47 | EXPECT_EQ(one.media_bitrate_bps, other.media_bitrate_bps); |
henrik.lundin@webrtc.org | b10363f | 2014-03-13 13:31:21 +0000 | [diff] [blame] | 48 | EXPECT_EQ(one.suspended, other.suspended); |
sprang@webrtc.org | 0931570 | 2014-02-07 12:06:29 +0000 | [diff] [blame] | 49 | |
| 50 | EXPECT_EQ(one.substreams.size(), other.substreams.size()); |
stefan@webrtc.org | 0bae1fa | 2014-11-05 14:05:29 +0000 | [diff] [blame^] | 51 | for (std::map<uint32_t, SsrcStats>::const_iterator it = |
sprang@webrtc.org | 0931570 | 2014-02-07 12:06:29 +0000 | [diff] [blame] | 52 | one.substreams.begin(); |
| 53 | it != one.substreams.end(); |
| 54 | ++it) { |
stefan@webrtc.org | 0bae1fa | 2014-11-05 14:05:29 +0000 | [diff] [blame^] | 55 | std::map<uint32_t, SsrcStats>::const_iterator corresponding_it = |
sprang@webrtc.org | 0931570 | 2014-02-07 12:06:29 +0000 | [diff] [blame] | 56 | other.substreams.find(it->first); |
| 57 | ASSERT_TRUE(corresponding_it != other.substreams.end()); |
stefan@webrtc.org | 0bae1fa | 2014-11-05 14:05:29 +0000 | [diff] [blame^] | 58 | const SsrcStats& a = it->second; |
| 59 | const SsrcStats& b = corresponding_it->second; |
sprang@webrtc.org | 0931570 | 2014-02-07 12:06:29 +0000 | [diff] [blame] | 60 | |
| 61 | EXPECT_EQ(a.key_frames, b.key_frames); |
| 62 | EXPECT_EQ(a.delta_frames, b.delta_frames); |
stefan@webrtc.org | 0bae1fa | 2014-11-05 14:05:29 +0000 | [diff] [blame^] | 63 | EXPECT_EQ(a.total_bitrate_bps, b.total_bitrate_bps); |
stefan@webrtc.org | 168f23f | 2014-07-11 13:44:02 +0000 | [diff] [blame] | 64 | EXPECT_EQ(a.avg_delay_ms, b.avg_delay_ms); |
| 65 | EXPECT_EQ(a.max_delay_ms, b.max_delay_ms); |
sprang@webrtc.org | 0931570 | 2014-02-07 12:06:29 +0000 | [diff] [blame] | 66 | |
| 67 | EXPECT_EQ(a.rtp_stats.bytes, b.rtp_stats.bytes); |
| 68 | EXPECT_EQ(a.rtp_stats.header_bytes, b.rtp_stats.header_bytes); |
| 69 | EXPECT_EQ(a.rtp_stats.padding_bytes, b.rtp_stats.padding_bytes); |
| 70 | EXPECT_EQ(a.rtp_stats.packets, b.rtp_stats.packets); |
| 71 | EXPECT_EQ(a.rtp_stats.retransmitted_packets, |
| 72 | b.rtp_stats.retransmitted_packets); |
| 73 | EXPECT_EQ(a.rtp_stats.fec_packets, b.rtp_stats.fec_packets); |
| 74 | |
| 75 | EXPECT_EQ(a.rtcp_stats.fraction_lost, b.rtcp_stats.fraction_lost); |
| 76 | EXPECT_EQ(a.rtcp_stats.cumulative_lost, b.rtcp_stats.cumulative_lost); |
| 77 | EXPECT_EQ(a.rtcp_stats.extended_max_sequence_number, |
| 78 | b.rtcp_stats.extended_max_sequence_number); |
| 79 | EXPECT_EQ(a.rtcp_stats.jitter, b.rtcp_stats.jitter); |
| 80 | } |
| 81 | } |
| 82 | |
sprang@webrtc.org | ccd4284 | 2014-01-07 09:54:34 +0000 | [diff] [blame] | 83 | scoped_ptr<SendStatisticsProxy> statistics_proxy_; |
| 84 | VideoSendStream::Config config_; |
| 85 | int avg_delay_ms_; |
| 86 | int max_delay_ms_; |
sprang@webrtc.org | ccd4284 | 2014-01-07 09:54:34 +0000 | [diff] [blame] | 87 | VideoSendStream::Stats expected_; |
stefan@webrtc.org | 0bae1fa | 2014-11-05 14:05:29 +0000 | [diff] [blame^] | 88 | typedef std::map<uint32_t, SsrcStats>::const_iterator StreamIterator; |
sprang@webrtc.org | ccd4284 | 2014-01-07 09:54:34 +0000 | [diff] [blame] | 89 | }; |
| 90 | |
| 91 | TEST_F(SendStatisticsProxyTest, RtcpStatistics) { |
| 92 | RtcpStatisticsCallback* callback = statistics_proxy_.get(); |
| 93 | for (std::vector<uint32_t>::const_iterator it = config_.rtp.ssrcs.begin(); |
| 94 | it != config_.rtp.ssrcs.end(); |
| 95 | ++it) { |
| 96 | const uint32_t ssrc = *it; |
stefan@webrtc.org | 0bae1fa | 2014-11-05 14:05:29 +0000 | [diff] [blame^] | 97 | SsrcStats& ssrc_stats = expected_.substreams[ssrc]; |
sprang@webrtc.org | ccd4284 | 2014-01-07 09:54:34 +0000 | [diff] [blame] | 98 | |
| 99 | // Add statistics with some arbitrary, but unique, numbers. |
| 100 | uint32_t offset = ssrc * sizeof(RtcpStatistics); |
| 101 | ssrc_stats.rtcp_stats.cumulative_lost = offset; |
| 102 | ssrc_stats.rtcp_stats.extended_max_sequence_number = offset + 1; |
| 103 | ssrc_stats.rtcp_stats.fraction_lost = offset + 2; |
| 104 | ssrc_stats.rtcp_stats.jitter = offset + 3; |
| 105 | callback->StatisticsUpdated(ssrc_stats.rtcp_stats, ssrc); |
| 106 | } |
stefan@webrtc.org | 58e2d26 | 2014-08-14 15:10:49 +0000 | [diff] [blame] | 107 | for (std::vector<uint32_t>::const_iterator it = config_.rtp.rtx.ssrcs.begin(); |
| 108 | it != config_.rtp.rtx.ssrcs.end(); |
| 109 | ++it) { |
| 110 | const uint32_t ssrc = *it; |
stefan@webrtc.org | 0bae1fa | 2014-11-05 14:05:29 +0000 | [diff] [blame^] | 111 | SsrcStats& ssrc_stats = expected_.substreams[ssrc]; |
sprang@webrtc.org | ccd4284 | 2014-01-07 09:54:34 +0000 | [diff] [blame] | 112 | |
stefan@webrtc.org | 58e2d26 | 2014-08-14 15:10:49 +0000 | [diff] [blame] | 113 | // Add statistics with some arbitrary, but unique, numbers. |
| 114 | uint32_t offset = ssrc * sizeof(RtcpStatistics); |
| 115 | ssrc_stats.rtcp_stats.cumulative_lost = offset; |
| 116 | ssrc_stats.rtcp_stats.extended_max_sequence_number = offset + 1; |
| 117 | ssrc_stats.rtcp_stats.fraction_lost = offset + 2; |
| 118 | ssrc_stats.rtcp_stats.jitter = offset + 3; |
| 119 | callback->StatisticsUpdated(ssrc_stats.rtcp_stats, ssrc); |
| 120 | } |
sprang@webrtc.org | ccd4284 | 2014-01-07 09:54:34 +0000 | [diff] [blame] | 121 | VideoSendStream::Stats stats = statistics_proxy_->GetStats(); |
sprang@webrtc.org | 0931570 | 2014-02-07 12:06:29 +0000 | [diff] [blame] | 122 | ExpectEqual(expected_, stats); |
sprang@webrtc.org | ccd4284 | 2014-01-07 09:54:34 +0000 | [diff] [blame] | 123 | } |
| 124 | |
stefan@webrtc.org | 0bae1fa | 2014-11-05 14:05:29 +0000 | [diff] [blame^] | 125 | TEST_F(SendStatisticsProxyTest, CaptureFramerate) { |
sprang@webrtc.org | ccd4284 | 2014-01-07 09:54:34 +0000 | [diff] [blame] | 126 | const int capture_fps = 31; |
sprang@webrtc.org | ccd4284 | 2014-01-07 09:54:34 +0000 | [diff] [blame] | 127 | |
| 128 | ViECaptureObserver* capture_observer = statistics_proxy_.get(); |
| 129 | capture_observer->CapturedFrameRate(0, capture_fps); |
sprang@webrtc.org | ccd4284 | 2014-01-07 09:54:34 +0000 | [diff] [blame] | 130 | |
| 131 | VideoSendStream::Stats stats = statistics_proxy_->GetStats(); |
| 132 | EXPECT_EQ(capture_fps, stats.input_frame_rate); |
stefan@webrtc.org | 0bae1fa | 2014-11-05 14:05:29 +0000 | [diff] [blame^] | 133 | } |
| 134 | |
| 135 | TEST_F(SendStatisticsProxyTest, EncodedBitrateAndFramerate) { |
| 136 | const int media_bitrate_bps = 500; |
| 137 | const int encode_fps = 29; |
| 138 | |
| 139 | ViEEncoderObserver* encoder_observer = statistics_proxy_.get(); |
| 140 | encoder_observer->OutgoingRate(0, encode_fps, media_bitrate_bps); |
| 141 | |
| 142 | VideoSendStream::Stats stats = statistics_proxy_->GetStats(); |
| 143 | EXPECT_EQ(media_bitrate_bps, stats.media_bitrate_bps); |
sprang@webrtc.org | ccd4284 | 2014-01-07 09:54:34 +0000 | [diff] [blame] | 144 | EXPECT_EQ(encode_fps, stats.encode_frame_rate); |
| 145 | } |
| 146 | |
henrik.lundin@webrtc.org | b10363f | 2014-03-13 13:31:21 +0000 | [diff] [blame] | 147 | TEST_F(SendStatisticsProxyTest, Suspended) { |
| 148 | // Verify that the value is false by default. |
| 149 | EXPECT_FALSE(statistics_proxy_->GetStats().suspended); |
| 150 | |
| 151 | // Verify that we can set it to true. |
| 152 | ViEEncoderObserver* encoder_observer = statistics_proxy_.get(); |
| 153 | encoder_observer->SuspendChange(0, true); |
| 154 | EXPECT_TRUE(statistics_proxy_->GetStats().suspended); |
| 155 | |
| 156 | // Verify that we can set it back to false again. |
| 157 | encoder_observer->SuspendChange(0, false); |
| 158 | EXPECT_FALSE(statistics_proxy_->GetStats().suspended); |
| 159 | } |
| 160 | |
sprang@webrtc.org | ccd4284 | 2014-01-07 09:54:34 +0000 | [diff] [blame] | 161 | TEST_F(SendStatisticsProxyTest, FrameCounts) { |
| 162 | FrameCountObserver* observer = statistics_proxy_.get(); |
| 163 | for (std::vector<uint32_t>::const_iterator it = config_.rtp.ssrcs.begin(); |
| 164 | it != config_.rtp.ssrcs.end(); |
| 165 | ++it) { |
| 166 | const uint32_t ssrc = *it; |
| 167 | // Add statistics with some arbitrary, but unique, numbers. |
stefan@webrtc.org | 0bae1fa | 2014-11-05 14:05:29 +0000 | [diff] [blame^] | 168 | SsrcStats& stats = expected_.substreams[ssrc]; |
| 169 | uint32_t offset = ssrc * sizeof(SsrcStats); |
sprang@webrtc.org | ccd4284 | 2014-01-07 09:54:34 +0000 | [diff] [blame] | 170 | stats.key_frames = offset; |
| 171 | stats.delta_frames = offset + 1; |
| 172 | observer->FrameCountUpdated(kVideoFrameKey, stats.key_frames, ssrc); |
| 173 | observer->FrameCountUpdated(kVideoFrameDelta, stats.delta_frames, ssrc); |
| 174 | } |
stefan@webrtc.org | 58e2d26 | 2014-08-14 15:10:49 +0000 | [diff] [blame] | 175 | for (std::vector<uint32_t>::const_iterator it = config_.rtp.rtx.ssrcs.begin(); |
| 176 | it != config_.rtp.rtx.ssrcs.end(); |
| 177 | ++it) { |
| 178 | const uint32_t ssrc = *it; |
| 179 | // Add statistics with some arbitrary, but unique, numbers. |
stefan@webrtc.org | 0bae1fa | 2014-11-05 14:05:29 +0000 | [diff] [blame^] | 180 | SsrcStats& stats = expected_.substreams[ssrc]; |
| 181 | uint32_t offset = ssrc * sizeof(SsrcStats); |
stefan@webrtc.org | 58e2d26 | 2014-08-14 15:10:49 +0000 | [diff] [blame] | 182 | stats.key_frames = offset; |
| 183 | stats.delta_frames = offset + 1; |
| 184 | observer->FrameCountUpdated(kVideoFrameKey, stats.key_frames, ssrc); |
| 185 | observer->FrameCountUpdated(kVideoFrameDelta, stats.delta_frames, ssrc); |
| 186 | } |
sprang@webrtc.org | ccd4284 | 2014-01-07 09:54:34 +0000 | [diff] [blame] | 187 | |
| 188 | VideoSendStream::Stats stats = statistics_proxy_->GetStats(); |
sprang@webrtc.org | 0931570 | 2014-02-07 12:06:29 +0000 | [diff] [blame] | 189 | ExpectEqual(expected_, stats); |
sprang@webrtc.org | ccd4284 | 2014-01-07 09:54:34 +0000 | [diff] [blame] | 190 | } |
| 191 | |
| 192 | TEST_F(SendStatisticsProxyTest, DataCounters) { |
| 193 | StreamDataCountersCallback* callback = statistics_proxy_.get(); |
| 194 | for (std::vector<uint32_t>::const_iterator it = config_.rtp.ssrcs.begin(); |
| 195 | it != config_.rtp.ssrcs.end(); |
| 196 | ++it) { |
| 197 | const uint32_t ssrc = *it; |
| 198 | StreamDataCounters& counters = expected_.substreams[ssrc].rtp_stats; |
| 199 | // Add statistics with some arbitrary, but unique, numbers. |
| 200 | uint32_t offset = ssrc * sizeof(StreamDataCounters); |
| 201 | counters.bytes = offset; |
| 202 | counters.header_bytes = offset + 1; |
| 203 | counters.fec_packets = offset + 2; |
| 204 | counters.padding_bytes = offset + 3; |
| 205 | counters.retransmitted_packets = offset + 4; |
| 206 | counters.packets = offset + 5; |
| 207 | callback->DataCountersUpdated(counters, ssrc); |
| 208 | } |
stefan@webrtc.org | 58e2d26 | 2014-08-14 15:10:49 +0000 | [diff] [blame] | 209 | for (std::vector<uint32_t>::const_iterator it = config_.rtp.rtx.ssrcs.begin(); |
| 210 | it != config_.rtp.rtx.ssrcs.end(); |
| 211 | ++it) { |
| 212 | const uint32_t ssrc = *it; |
| 213 | StreamDataCounters& counters = expected_.substreams[ssrc].rtp_stats; |
| 214 | // Add statistics with some arbitrary, but unique, numbers. |
| 215 | uint32_t offset = ssrc * sizeof(StreamDataCounters); |
| 216 | counters.bytes = offset; |
| 217 | counters.header_bytes = offset + 1; |
| 218 | counters.fec_packets = offset + 2; |
| 219 | counters.padding_bytes = offset + 3; |
| 220 | counters.retransmitted_packets = offset + 4; |
| 221 | counters.packets = offset + 5; |
| 222 | callback->DataCountersUpdated(counters, ssrc); |
| 223 | } |
sprang@webrtc.org | ccd4284 | 2014-01-07 09:54:34 +0000 | [diff] [blame] | 224 | |
| 225 | VideoSendStream::Stats stats = statistics_proxy_->GetStats(); |
sprang@webrtc.org | 0931570 | 2014-02-07 12:06:29 +0000 | [diff] [blame] | 226 | ExpectEqual(expected_, stats); |
sprang@webrtc.org | ccd4284 | 2014-01-07 09:54:34 +0000 | [diff] [blame] | 227 | } |
| 228 | |
| 229 | TEST_F(SendStatisticsProxyTest, Bitrate) { |
| 230 | BitrateStatisticsObserver* observer = statistics_proxy_.get(); |
| 231 | for (std::vector<uint32_t>::const_iterator it = config_.rtp.ssrcs.begin(); |
| 232 | it != config_.rtp.ssrcs.end(); |
| 233 | ++it) { |
| 234 | const uint32_t ssrc = *it; |
stefan@webrtc.org | 0bae1fa | 2014-11-05 14:05:29 +0000 | [diff] [blame^] | 235 | BitrateStatistics total; |
| 236 | BitrateStatistics retransmit; |
stefan@webrtc.org | 168f23f | 2014-07-11 13:44:02 +0000 | [diff] [blame] | 237 | // Use ssrc as bitrate_bps to get a unique value for each stream. |
stefan@webrtc.org | 0bae1fa | 2014-11-05 14:05:29 +0000 | [diff] [blame^] | 238 | total.bitrate_bps = ssrc; |
| 239 | retransmit.bitrate_bps = ssrc + 1; |
| 240 | observer->Notify(total, retransmit, ssrc); |
| 241 | expected_.substreams[ssrc].total_bitrate_bps = total.bitrate_bps; |
| 242 | expected_.substreams[ssrc].retransmit_bitrate_bps = retransmit.bitrate_bps; |
sprang@webrtc.org | ccd4284 | 2014-01-07 09:54:34 +0000 | [diff] [blame] | 243 | } |
stefan@webrtc.org | 58e2d26 | 2014-08-14 15:10:49 +0000 | [diff] [blame] | 244 | for (std::vector<uint32_t>::const_iterator it = config_.rtp.rtx.ssrcs.begin(); |
| 245 | it != config_.rtp.rtx.ssrcs.end(); |
| 246 | ++it) { |
| 247 | const uint32_t ssrc = *it; |
stefan@webrtc.org | 0bae1fa | 2014-11-05 14:05:29 +0000 | [diff] [blame^] | 248 | BitrateStatistics total; |
| 249 | BitrateStatistics retransmit; |
stefan@webrtc.org | 58e2d26 | 2014-08-14 15:10:49 +0000 | [diff] [blame] | 250 | // Use ssrc as bitrate_bps to get a unique value for each stream. |
stefan@webrtc.org | 0bae1fa | 2014-11-05 14:05:29 +0000 | [diff] [blame^] | 251 | total.bitrate_bps = ssrc; |
| 252 | retransmit.bitrate_bps = ssrc + 1; |
| 253 | observer->Notify(total, retransmit, ssrc); |
| 254 | expected_.substreams[ssrc].total_bitrate_bps = total.bitrate_bps; |
| 255 | expected_.substreams[ssrc].retransmit_bitrate_bps = retransmit.bitrate_bps; |
stefan@webrtc.org | 58e2d26 | 2014-08-14 15:10:49 +0000 | [diff] [blame] | 256 | } |
sprang@webrtc.org | ccd4284 | 2014-01-07 09:54:34 +0000 | [diff] [blame] | 257 | |
| 258 | VideoSendStream::Stats stats = statistics_proxy_->GetStats(); |
sprang@webrtc.org | 0931570 | 2014-02-07 12:06:29 +0000 | [diff] [blame] | 259 | ExpectEqual(expected_, stats); |
sprang@webrtc.org | ccd4284 | 2014-01-07 09:54:34 +0000 | [diff] [blame] | 260 | } |
| 261 | |
stefan@webrtc.org | 168f23f | 2014-07-11 13:44:02 +0000 | [diff] [blame] | 262 | TEST_F(SendStatisticsProxyTest, SendSideDelay) { |
| 263 | SendSideDelayObserver* observer = statistics_proxy_.get(); |
| 264 | for (std::vector<uint32_t>::const_iterator it = config_.rtp.ssrcs.begin(); |
| 265 | it != config_.rtp.ssrcs.end(); |
| 266 | ++it) { |
| 267 | const uint32_t ssrc = *it; |
| 268 | // Use ssrc as avg_delay_ms and max_delay_ms to get a unique value for each |
| 269 | // stream. |
| 270 | int avg_delay_ms = ssrc; |
| 271 | int max_delay_ms = ssrc + 1; |
| 272 | observer->SendSideDelayUpdated(avg_delay_ms, max_delay_ms, ssrc); |
| 273 | expected_.substreams[ssrc].avg_delay_ms = avg_delay_ms; |
| 274 | expected_.substreams[ssrc].max_delay_ms = max_delay_ms; |
| 275 | } |
stefan@webrtc.org | 58e2d26 | 2014-08-14 15:10:49 +0000 | [diff] [blame] | 276 | for (std::vector<uint32_t>::const_iterator it = config_.rtp.rtx.ssrcs.begin(); |
| 277 | it != config_.rtp.rtx.ssrcs.end(); |
| 278 | ++it) { |
| 279 | const uint32_t ssrc = *it; |
| 280 | // Use ssrc as avg_delay_ms and max_delay_ms to get a unique value for each |
| 281 | // stream. |
| 282 | int avg_delay_ms = ssrc; |
| 283 | int max_delay_ms = ssrc + 1; |
| 284 | observer->SendSideDelayUpdated(avg_delay_ms, max_delay_ms, ssrc); |
| 285 | expected_.substreams[ssrc].avg_delay_ms = avg_delay_ms; |
| 286 | expected_.substreams[ssrc].max_delay_ms = max_delay_ms; |
| 287 | } |
sprang@webrtc.org | ccd4284 | 2014-01-07 09:54:34 +0000 | [diff] [blame] | 288 | VideoSendStream::Stats stats = statistics_proxy_->GetStats(); |
stefan@webrtc.org | 168f23f | 2014-07-11 13:44:02 +0000 | [diff] [blame] | 289 | ExpectEqual(expected_, stats); |
sprang@webrtc.org | ccd4284 | 2014-01-07 09:54:34 +0000 | [diff] [blame] | 290 | } |
| 291 | |
| 292 | TEST_F(SendStatisticsProxyTest, NoSubstreams) { |
| 293 | uint32_t exluded_ssrc = |
stefan@webrtc.org | 58e2d26 | 2014-08-14 15:10:49 +0000 | [diff] [blame] | 294 | std::max( |
| 295 | *std::max_element(config_.rtp.ssrcs.begin(), config_.rtp.ssrcs.end()), |
| 296 | *std::max_element(config_.rtp.rtx.ssrcs.begin(), |
| 297 | config_.rtp.rtx.ssrcs.end())) + |
| 298 | 1; |
sprang@webrtc.org | ccd4284 | 2014-01-07 09:54:34 +0000 | [diff] [blame] | 299 | // From RtcpStatisticsCallback. |
| 300 | RtcpStatistics rtcp_stats; |
| 301 | RtcpStatisticsCallback* rtcp_callback = statistics_proxy_.get(); |
| 302 | rtcp_callback->StatisticsUpdated(rtcp_stats, exluded_ssrc); |
| 303 | |
| 304 | // From StreamDataCountersCallback. |
| 305 | StreamDataCounters rtp_stats; |
| 306 | StreamDataCountersCallback* rtp_callback = statistics_proxy_.get(); |
| 307 | rtp_callback->DataCountersUpdated(rtp_stats, exluded_ssrc); |
| 308 | |
| 309 | // From BitrateStatisticsObserver. |
stefan@webrtc.org | 0bae1fa | 2014-11-05 14:05:29 +0000 | [diff] [blame^] | 310 | BitrateStatistics total; |
| 311 | BitrateStatistics retransmit; |
sprang@webrtc.org | ccd4284 | 2014-01-07 09:54:34 +0000 | [diff] [blame] | 312 | BitrateStatisticsObserver* bitrate_observer = statistics_proxy_.get(); |
stefan@webrtc.org | 0bae1fa | 2014-11-05 14:05:29 +0000 | [diff] [blame^] | 313 | bitrate_observer->Notify(total, retransmit, exluded_ssrc); |
sprang@webrtc.org | ccd4284 | 2014-01-07 09:54:34 +0000 | [diff] [blame] | 314 | |
| 315 | // From FrameCountObserver. |
| 316 | FrameCountObserver* fps_observer = statistics_proxy_.get(); |
| 317 | fps_observer->FrameCountUpdated(kVideoFrameKey, 1, exluded_ssrc); |
| 318 | |
| 319 | VideoSendStream::Stats stats = statistics_proxy_->GetStats(); |
| 320 | EXPECT_TRUE(stats.substreams.empty()); |
| 321 | } |
| 322 | |
| 323 | } // namespace webrtc |