| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 VideoSendStream::Config config_; | 103 VideoSendStream::Config config_; |
| 104 int avg_delay_ms_; | 104 int avg_delay_ms_; |
| 105 int max_delay_ms_; | 105 int max_delay_ms_; |
| 106 VideoSendStream::Stats expected_; | 106 VideoSendStream::Stats expected_; |
| 107 typedef std::map<uint32_t, VideoSendStream::StreamStats>::const_iterator | 107 typedef std::map<uint32_t, VideoSendStream::StreamStats>::const_iterator |
| 108 StreamIterator; | 108 StreamIterator; |
| 109 }; | 109 }; |
| 110 | 110 |
| 111 TEST_F(SendStatisticsProxyTest, RtcpStatistics) { | 111 TEST_F(SendStatisticsProxyTest, RtcpStatistics) { |
| 112 RtcpStatisticsCallback* callback = statistics_proxy_.get(); | 112 RtcpStatisticsCallback* callback = statistics_proxy_.get(); |
| 113 for (std::vector<uint32_t>::const_iterator it = config_.rtp.ssrcs.begin(); | 113 for (const auto& ssrc : config_.rtp.ssrcs) { |
| 114 it != config_.rtp.ssrcs.end(); | |
| 115 ++it) { | |
| 116 const uint32_t ssrc = *it; | |
| 117 VideoSendStream::StreamStats& ssrc_stats = expected_.substreams[ssrc]; | 114 VideoSendStream::StreamStats& ssrc_stats = expected_.substreams[ssrc]; |
| 118 | 115 |
| 119 // Add statistics with some arbitrary, but unique, numbers. | 116 // Add statistics with some arbitrary, but unique, numbers. |
| 120 uint32_t offset = ssrc * sizeof(RtcpStatistics); | 117 uint32_t offset = ssrc * sizeof(RtcpStatistics); |
| 121 ssrc_stats.rtcp_stats.cumulative_lost = offset; | 118 ssrc_stats.rtcp_stats.cumulative_lost = offset; |
| 122 ssrc_stats.rtcp_stats.extended_max_sequence_number = offset + 1; | 119 ssrc_stats.rtcp_stats.extended_max_sequence_number = offset + 1; |
| 123 ssrc_stats.rtcp_stats.fraction_lost = offset + 2; | 120 ssrc_stats.rtcp_stats.fraction_lost = offset + 2; |
| 124 ssrc_stats.rtcp_stats.jitter = offset + 3; | 121 ssrc_stats.rtcp_stats.jitter = offset + 3; |
| 125 callback->StatisticsUpdated(ssrc_stats.rtcp_stats, ssrc); | 122 callback->StatisticsUpdated(ssrc_stats.rtcp_stats, ssrc); |
| 126 } | 123 } |
| 127 for (std::vector<uint32_t>::const_iterator it = config_.rtp.rtx.ssrcs.begin(); | 124 for (const auto& ssrc : config_.rtp.rtx.ssrcs) { |
| 128 it != config_.rtp.rtx.ssrcs.end(); | |
| 129 ++it) { | |
| 130 const uint32_t ssrc = *it; | |
| 131 VideoSendStream::StreamStats& ssrc_stats = expected_.substreams[ssrc]; | 125 VideoSendStream::StreamStats& ssrc_stats = expected_.substreams[ssrc]; |
| 132 | 126 |
| 133 // Add statistics with some arbitrary, but unique, numbers. | 127 // Add statistics with some arbitrary, but unique, numbers. |
| 134 uint32_t offset = ssrc * sizeof(RtcpStatistics); | 128 uint32_t offset = ssrc * sizeof(RtcpStatistics); |
| 135 ssrc_stats.rtcp_stats.cumulative_lost = offset; | 129 ssrc_stats.rtcp_stats.cumulative_lost = offset; |
| 136 ssrc_stats.rtcp_stats.extended_max_sequence_number = offset + 1; | 130 ssrc_stats.rtcp_stats.extended_max_sequence_number = offset + 1; |
| 137 ssrc_stats.rtcp_stats.fraction_lost = offset + 2; | 131 ssrc_stats.rtcp_stats.fraction_lost = offset + 2; |
| 138 ssrc_stats.rtcp_stats.jitter = offset + 3; | 132 ssrc_stats.rtcp_stats.jitter = offset + 3; |
| 139 callback->StatisticsUpdated(ssrc_stats.rtcp_stats, ssrc); | 133 callback->StatisticsUpdated(ssrc_stats.rtcp_stats, ssrc); |
| 140 } | 134 } |
| (...skipping 20 matching lines...) Expand all Loading... |
| 161 statistics_proxy_->OnSuspendChange(true); | 155 statistics_proxy_->OnSuspendChange(true); |
| 162 EXPECT_TRUE(statistics_proxy_->GetStats().suspended); | 156 EXPECT_TRUE(statistics_proxy_->GetStats().suspended); |
| 163 | 157 |
| 164 // Verify that we can set it back to false again. | 158 // Verify that we can set it back to false again. |
| 165 statistics_proxy_->OnSuspendChange(false); | 159 statistics_proxy_->OnSuspendChange(false); |
| 166 EXPECT_FALSE(statistics_proxy_->GetStats().suspended); | 160 EXPECT_FALSE(statistics_proxy_->GetStats().suspended); |
| 167 } | 161 } |
| 168 | 162 |
| 169 TEST_F(SendStatisticsProxyTest, FrameCounts) { | 163 TEST_F(SendStatisticsProxyTest, FrameCounts) { |
| 170 FrameCountObserver* observer = statistics_proxy_.get(); | 164 FrameCountObserver* observer = statistics_proxy_.get(); |
| 171 for (std::vector<uint32_t>::const_iterator it = config_.rtp.ssrcs.begin(); | 165 for (const auto& ssrc : config_.rtp.ssrcs) { |
| 172 it != config_.rtp.ssrcs.end(); | |
| 173 ++it) { | |
| 174 const uint32_t ssrc = *it; | |
| 175 // Add statistics with some arbitrary, but unique, numbers. | 166 // Add statistics with some arbitrary, but unique, numbers. |
| 176 VideoSendStream::StreamStats& stats = expected_.substreams[ssrc]; | 167 VideoSendStream::StreamStats& stats = expected_.substreams[ssrc]; |
| 177 uint32_t offset = ssrc * sizeof(VideoSendStream::StreamStats); | 168 uint32_t offset = ssrc * sizeof(VideoSendStream::StreamStats); |
| 178 FrameCounts frame_counts; | 169 FrameCounts frame_counts; |
| 179 frame_counts.key_frames = offset; | 170 frame_counts.key_frames = offset; |
| 180 frame_counts.delta_frames = offset + 1; | 171 frame_counts.delta_frames = offset + 1; |
| 181 stats.frame_counts = frame_counts; | 172 stats.frame_counts = frame_counts; |
| 182 observer->FrameCountUpdated(frame_counts, ssrc); | 173 observer->FrameCountUpdated(frame_counts, ssrc); |
| 183 } | 174 } |
| 184 for (std::vector<uint32_t>::const_iterator it = config_.rtp.rtx.ssrcs.begin(); | 175 for (const auto& ssrc : config_.rtp.rtx.ssrcs) { |
| 185 it != config_.rtp.rtx.ssrcs.end(); | |
| 186 ++it) { | |
| 187 const uint32_t ssrc = *it; | |
| 188 // Add statistics with some arbitrary, but unique, numbers. | 176 // Add statistics with some arbitrary, but unique, numbers. |
| 189 VideoSendStream::StreamStats& stats = expected_.substreams[ssrc]; | 177 VideoSendStream::StreamStats& stats = expected_.substreams[ssrc]; |
| 190 uint32_t offset = ssrc * sizeof(VideoSendStream::StreamStats); | 178 uint32_t offset = ssrc * sizeof(VideoSendStream::StreamStats); |
| 191 FrameCounts frame_counts; | 179 FrameCounts frame_counts; |
| 192 frame_counts.key_frames = offset; | 180 frame_counts.key_frames = offset; |
| 193 frame_counts.delta_frames = offset + 1; | 181 frame_counts.delta_frames = offset + 1; |
| 194 stats.frame_counts = frame_counts; | 182 stats.frame_counts = frame_counts; |
| 195 observer->FrameCountUpdated(frame_counts, ssrc); | 183 observer->FrameCountUpdated(frame_counts, ssrc); |
| 196 } | 184 } |
| 197 | 185 |
| 198 VideoSendStream::Stats stats = statistics_proxy_->GetStats(); | 186 VideoSendStream::Stats stats = statistics_proxy_->GetStats(); |
| 199 ExpectEqual(expected_, stats); | 187 ExpectEqual(expected_, stats); |
| 200 } | 188 } |
| 201 | 189 |
| 202 TEST_F(SendStatisticsProxyTest, DataCounters) { | 190 TEST_F(SendStatisticsProxyTest, DataCounters) { |
| 203 StreamDataCountersCallback* callback = statistics_proxy_.get(); | 191 StreamDataCountersCallback* callback = statistics_proxy_.get(); |
| 204 for (std::vector<uint32_t>::const_iterator it = config_.rtp.ssrcs.begin(); | 192 for (const auto& ssrc : config_.rtp.ssrcs) { |
| 205 it != config_.rtp.ssrcs.end(); | |
| 206 ++it) { | |
| 207 const uint32_t ssrc = *it; | |
| 208 StreamDataCounters& counters = expected_.substreams[ssrc].rtp_stats; | 193 StreamDataCounters& counters = expected_.substreams[ssrc].rtp_stats; |
| 209 // Add statistics with some arbitrary, but unique, numbers. | 194 // Add statistics with some arbitrary, but unique, numbers. |
| 210 size_t offset = ssrc * sizeof(StreamDataCounters); | 195 size_t offset = ssrc * sizeof(StreamDataCounters); |
| 211 uint32_t offset_uint32 = static_cast<uint32_t>(offset); | 196 uint32_t offset_uint32 = static_cast<uint32_t>(offset); |
| 212 counters.transmitted.payload_bytes = offset; | 197 counters.transmitted.payload_bytes = offset; |
| 213 counters.transmitted.header_bytes = offset + 1; | 198 counters.transmitted.header_bytes = offset + 1; |
| 214 counters.fec.packets = offset_uint32 + 2; | 199 counters.fec.packets = offset_uint32 + 2; |
| 215 counters.transmitted.padding_bytes = offset + 3; | 200 counters.transmitted.padding_bytes = offset + 3; |
| 216 counters.retransmitted.packets = offset_uint32 + 4; | 201 counters.retransmitted.packets = offset_uint32 + 4; |
| 217 counters.transmitted.packets = offset_uint32 + 5; | 202 counters.transmitted.packets = offset_uint32 + 5; |
| 218 callback->DataCountersUpdated(counters, ssrc); | 203 callback->DataCountersUpdated(counters, ssrc); |
| 219 } | 204 } |
| 220 for (std::vector<uint32_t>::const_iterator it = config_.rtp.rtx.ssrcs.begin(); | 205 for (const auto& ssrc : config_.rtp.rtx.ssrcs) { |
| 221 it != config_.rtp.rtx.ssrcs.end(); | |
| 222 ++it) { | |
| 223 const uint32_t ssrc = *it; | |
| 224 StreamDataCounters& counters = expected_.substreams[ssrc].rtp_stats; | 206 StreamDataCounters& counters = expected_.substreams[ssrc].rtp_stats; |
| 225 // Add statistics with some arbitrary, but unique, numbers. | 207 // Add statistics with some arbitrary, but unique, numbers. |
| 226 size_t offset = ssrc * sizeof(StreamDataCounters); | 208 size_t offset = ssrc * sizeof(StreamDataCounters); |
| 227 uint32_t offset_uint32 = static_cast<uint32_t>(offset); | 209 uint32_t offset_uint32 = static_cast<uint32_t>(offset); |
| 228 counters.transmitted.payload_bytes = offset; | 210 counters.transmitted.payload_bytes = offset; |
| 229 counters.transmitted.header_bytes = offset + 1; | 211 counters.transmitted.header_bytes = offset + 1; |
| 230 counters.fec.packets = offset_uint32 + 2; | 212 counters.fec.packets = offset_uint32 + 2; |
| 231 counters.transmitted.padding_bytes = offset + 3; | 213 counters.transmitted.padding_bytes = offset + 3; |
| 232 counters.retransmitted.packets = offset_uint32 + 4; | 214 counters.retransmitted.packets = offset_uint32 + 4; |
| 233 counters.transmitted.packets = offset_uint32 + 5; | 215 counters.transmitted.packets = offset_uint32 + 5; |
| 234 callback->DataCountersUpdated(counters, ssrc); | 216 callback->DataCountersUpdated(counters, ssrc); |
| 235 } | 217 } |
| 236 | 218 |
| 237 VideoSendStream::Stats stats = statistics_proxy_->GetStats(); | 219 VideoSendStream::Stats stats = statistics_proxy_->GetStats(); |
| 238 ExpectEqual(expected_, stats); | 220 ExpectEqual(expected_, stats); |
| 239 } | 221 } |
| 240 | 222 |
| 241 TEST_F(SendStatisticsProxyTest, Bitrate) { | 223 TEST_F(SendStatisticsProxyTest, Bitrate) { |
| 242 BitrateStatisticsObserver* observer = statistics_proxy_.get(); | 224 BitrateStatisticsObserver* observer = statistics_proxy_.get(); |
| 243 for (std::vector<uint32_t>::const_iterator it = config_.rtp.ssrcs.begin(); | 225 for (const auto& ssrc : config_.rtp.ssrcs) { |
| 244 it != config_.rtp.ssrcs.end(); | |
| 245 ++it) { | |
| 246 const uint32_t ssrc = *it; | |
| 247 BitrateStatistics total; | 226 BitrateStatistics total; |
| 248 BitrateStatistics retransmit; | 227 BitrateStatistics retransmit; |
| 249 // Use ssrc as bitrate_bps to get a unique value for each stream. | 228 // Use ssrc as bitrate_bps to get a unique value for each stream. |
| 250 total.bitrate_bps = ssrc; | 229 total.bitrate_bps = ssrc; |
| 251 retransmit.bitrate_bps = ssrc + 1; | 230 retransmit.bitrate_bps = ssrc + 1; |
| 252 observer->Notify(total, retransmit, ssrc); | 231 observer->Notify(total, retransmit, ssrc); |
| 253 expected_.substreams[ssrc].total_bitrate_bps = total.bitrate_bps; | 232 expected_.substreams[ssrc].total_bitrate_bps = total.bitrate_bps; |
| 254 expected_.substreams[ssrc].retransmit_bitrate_bps = retransmit.bitrate_bps; | 233 expected_.substreams[ssrc].retransmit_bitrate_bps = retransmit.bitrate_bps; |
| 255 } | 234 } |
| 256 for (std::vector<uint32_t>::const_iterator it = config_.rtp.rtx.ssrcs.begin(); | 235 for (const auto& ssrc : config_.rtp.rtx.ssrcs) { |
| 257 it != config_.rtp.rtx.ssrcs.end(); | |
| 258 ++it) { | |
| 259 const uint32_t ssrc = *it; | |
| 260 BitrateStatistics total; | 236 BitrateStatistics total; |
| 261 BitrateStatistics retransmit; | 237 BitrateStatistics retransmit; |
| 262 // Use ssrc as bitrate_bps to get a unique value for each stream. | 238 // Use ssrc as bitrate_bps to get a unique value for each stream. |
| 263 total.bitrate_bps = ssrc; | 239 total.bitrate_bps = ssrc; |
| 264 retransmit.bitrate_bps = ssrc + 1; | 240 retransmit.bitrate_bps = ssrc + 1; |
| 265 observer->Notify(total, retransmit, ssrc); | 241 observer->Notify(total, retransmit, ssrc); |
| 266 expected_.substreams[ssrc].total_bitrate_bps = total.bitrate_bps; | 242 expected_.substreams[ssrc].total_bitrate_bps = total.bitrate_bps; |
| 267 expected_.substreams[ssrc].retransmit_bitrate_bps = retransmit.bitrate_bps; | 243 expected_.substreams[ssrc].retransmit_bitrate_bps = retransmit.bitrate_bps; |
| 268 } | 244 } |
| 269 | 245 |
| 270 VideoSendStream::Stats stats = statistics_proxy_->GetStats(); | 246 VideoSendStream::Stats stats = statistics_proxy_->GetStats(); |
| 271 ExpectEqual(expected_, stats); | 247 ExpectEqual(expected_, stats); |
| 272 } | 248 } |
| 273 | 249 |
| 274 TEST_F(SendStatisticsProxyTest, SendSideDelay) { | 250 TEST_F(SendStatisticsProxyTest, SendSideDelay) { |
| 275 SendSideDelayObserver* observer = statistics_proxy_.get(); | 251 SendSideDelayObserver* observer = statistics_proxy_.get(); |
| 276 for (std::vector<uint32_t>::const_iterator it = config_.rtp.ssrcs.begin(); | 252 for (const auto& ssrc : config_.rtp.ssrcs) { |
| 277 it != config_.rtp.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 | 253 // Use ssrc as avg_delay_ms and max_delay_ms to get a unique value for each |
| 281 // stream. | 254 // stream. |
| 282 int avg_delay_ms = ssrc; | 255 int avg_delay_ms = ssrc; |
| 283 int max_delay_ms = ssrc + 1; | 256 int max_delay_ms = ssrc + 1; |
| 284 observer->SendSideDelayUpdated(avg_delay_ms, max_delay_ms, ssrc); | 257 observer->SendSideDelayUpdated(avg_delay_ms, max_delay_ms, ssrc); |
| 285 expected_.substreams[ssrc].avg_delay_ms = avg_delay_ms; | 258 expected_.substreams[ssrc].avg_delay_ms = avg_delay_ms; |
| 286 expected_.substreams[ssrc].max_delay_ms = max_delay_ms; | 259 expected_.substreams[ssrc].max_delay_ms = max_delay_ms; |
| 287 } | 260 } |
| 288 for (std::vector<uint32_t>::const_iterator it = config_.rtp.rtx.ssrcs.begin(); | 261 for (const auto& ssrc : config_.rtp.rtx.ssrcs) { |
| 289 it != config_.rtp.rtx.ssrcs.end(); | |
| 290 ++it) { | |
| 291 const uint32_t ssrc = *it; | |
| 292 // Use ssrc as avg_delay_ms and max_delay_ms to get a unique value for each | 262 // Use ssrc as avg_delay_ms and max_delay_ms to get a unique value for each |
| 293 // stream. | 263 // stream. |
| 294 int avg_delay_ms = ssrc; | 264 int avg_delay_ms = ssrc; |
| 295 int max_delay_ms = ssrc + 1; | 265 int max_delay_ms = ssrc + 1; |
| 296 observer->SendSideDelayUpdated(avg_delay_ms, max_delay_ms, ssrc); | 266 observer->SendSideDelayUpdated(avg_delay_ms, max_delay_ms, ssrc); |
| 297 expected_.substreams[ssrc].avg_delay_ms = avg_delay_ms; | 267 expected_.substreams[ssrc].avg_delay_ms = avg_delay_ms; |
| 298 expected_.substreams[ssrc].max_delay_ms = max_delay_ms; | 268 expected_.substreams[ssrc].max_delay_ms = max_delay_ms; |
| 299 } | 269 } |
| 300 VideoSendStream::Stats stats = statistics_proxy_->GetStats(); | 270 VideoSendStream::Stats stats = statistics_proxy_->GetStats(); |
| 301 ExpectEqual(expected_, stats); | 271 ExpectEqual(expected_, stats); |
| (...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 748 | 718 |
| 749 EXPECT_EQ(1, test::NumHistogramSamples( | 719 EXPECT_EQ(1, test::NumHistogramSamples( |
| 750 "WebRTC.Video.Screenshare.FecBitrateSentInKbps")); | 720 "WebRTC.Video.Screenshare.FecBitrateSentInKbps")); |
| 751 EXPECT_EQ(static_cast<int>((rtx_counters.fec.TotalBytes() * 2 * 8) / | 721 EXPECT_EQ(static_cast<int>((rtx_counters.fec.TotalBytes() * 2 * 8) / |
| 752 metrics::kMinRunTimeInSeconds / 1000), | 722 metrics::kMinRunTimeInSeconds / 1000), |
| 753 test::LastHistogramSample( | 723 test::LastHistogramSample( |
| 754 "WebRTC.Video.Screenshare.FecBitrateSentInKbps")); | 724 "WebRTC.Video.Screenshare.FecBitrateSentInKbps")); |
| 755 } | 725 } |
| 756 | 726 |
| 757 } // namespace webrtc | 727 } // namespace webrtc |
| OLD | NEW |