| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/memory/ref_counted.h" | 5 #include "base/memory/ref_counted.h" |
| 6 #include "base/memory/scoped_ptr.h" | 6 #include "base/memory/scoped_ptr.h" |
| 7 #include "base/rand_util.h" | 7 #include "base/rand_util.h" |
| 8 #include "base/test/simple_test_tick_clock.h" | 8 #include "base/test/simple_test_tick_clock.h" |
| 9 #include "base/time/tick_clock.h" | 9 #include "base/time/tick_clock.h" |
| 10 #include "media/cast/cast_environment.h" | 10 #include "media/cast/cast_environment.h" |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 frame_id++; | 84 frame_id++; |
| 85 } | 85 } |
| 86 | 86 |
| 87 base::TimeTicks end_time = sender_clock_->NowTicks(); | 87 base::TimeTicks end_time = sender_clock_->NowTicks(); |
| 88 | 88 |
| 89 StatsEventSubscriber::StatsMap stats_map; | 89 StatsEventSubscriber::StatsMap stats_map; |
| 90 subscriber_->GetStatsInternal(&stats_map); | 90 subscriber_->GetStatsInternal(&stats_map); |
| 91 | 91 |
| 92 StatsEventSubscriber::StatsMap::iterator it = | 92 StatsEventSubscriber::StatsMap::iterator it = |
| 93 stats_map.find(StatsEventSubscriber::CAPTURE_FPS); | 93 stats_map.find(StatsEventSubscriber::CAPTURE_FPS); |
| 94 ASSERT_NE(it, stats_map.end()); | 94 ASSERT_TRUE(it != stats_map.end()); |
| 95 | 95 |
| 96 base::TimeDelta duration = end_time - start_time; | 96 base::TimeDelta duration = end_time - start_time; |
| 97 EXPECT_DOUBLE_EQ( | 97 EXPECT_DOUBLE_EQ( |
| 98 it->second, | 98 it->second, |
| 99 static_cast<double>(num_frames) / duration.InMillisecondsF() * 1000); | 99 static_cast<double>(num_frames) / duration.InMillisecondsF() * 1000); |
| 100 } | 100 } |
| 101 | 101 |
| 102 TEST_F(StatsEventSubscriberTest, Encode) { | 102 TEST_F(StatsEventSubscriberTest, Encode) { |
| 103 Init(VIDEO_EVENT); | 103 Init(VIDEO_EVENT); |
| 104 | 104 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 124 frame_id++; | 124 frame_id++; |
| 125 } | 125 } |
| 126 | 126 |
| 127 base::TimeTicks end_time = sender_clock_->NowTicks(); | 127 base::TimeTicks end_time = sender_clock_->NowTicks(); |
| 128 | 128 |
| 129 StatsEventSubscriber::StatsMap stats_map; | 129 StatsEventSubscriber::StatsMap stats_map; |
| 130 subscriber_->GetStatsInternal(&stats_map); | 130 subscriber_->GetStatsInternal(&stats_map); |
| 131 | 131 |
| 132 StatsEventSubscriber::StatsMap::iterator it = | 132 StatsEventSubscriber::StatsMap::iterator it = |
| 133 stats_map.find(StatsEventSubscriber::ENCODE_FPS); | 133 stats_map.find(StatsEventSubscriber::ENCODE_FPS); |
| 134 ASSERT_NE(it, stats_map.end()); | 134 ASSERT_TRUE(it != stats_map.end()); |
| 135 | 135 |
| 136 base::TimeDelta duration = end_time - start_time; | 136 base::TimeDelta duration = end_time - start_time; |
| 137 EXPECT_DOUBLE_EQ( | 137 EXPECT_DOUBLE_EQ( |
| 138 it->second, | 138 it->second, |
| 139 static_cast<double>(num_frames) / duration.InMillisecondsF() * 1000); | 139 static_cast<double>(num_frames) / duration.InMillisecondsF() * 1000); |
| 140 | 140 |
| 141 it = stats_map.find(StatsEventSubscriber::ENCODE_KBPS); | 141 it = stats_map.find(StatsEventSubscriber::ENCODE_KBPS); |
| 142 ASSERT_NE(it, stats_map.end()); | 142 ASSERT_TRUE(it != stats_map.end()); |
| 143 | 143 |
| 144 EXPECT_DOUBLE_EQ(it->second, | 144 EXPECT_DOUBLE_EQ(it->second, |
| 145 static_cast<double>(total_size) / duration.InMillisecondsF() * 8); | 145 static_cast<double>(total_size) / duration.InMillisecondsF() * 8); |
| 146 } | 146 } |
| 147 | 147 |
| 148 TEST_F(StatsEventSubscriberTest, Decode) { | 148 TEST_F(StatsEventSubscriberTest, Decode) { |
| 149 Init(VIDEO_EVENT); | 149 Init(VIDEO_EVENT); |
| 150 | 150 |
| 151 uint32 rtp_timestamp = 0; | 151 uint32 rtp_timestamp = 0; |
| 152 uint32 frame_id = 0; | 152 uint32 frame_id = 0; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 163 frame_id++; | 163 frame_id++; |
| 164 } | 164 } |
| 165 | 165 |
| 166 base::TimeTicks end_time = sender_clock_->NowTicks(); | 166 base::TimeTicks end_time = sender_clock_->NowTicks(); |
| 167 | 167 |
| 168 StatsEventSubscriber::StatsMap stats_map; | 168 StatsEventSubscriber::StatsMap stats_map; |
| 169 subscriber_->GetStatsInternal(&stats_map); | 169 subscriber_->GetStatsInternal(&stats_map); |
| 170 | 170 |
| 171 StatsEventSubscriber::StatsMap::iterator it = | 171 StatsEventSubscriber::StatsMap::iterator it = |
| 172 stats_map.find(StatsEventSubscriber::DECODE_FPS); | 172 stats_map.find(StatsEventSubscriber::DECODE_FPS); |
| 173 ASSERT_NE(it, stats_map.end()); | 173 ASSERT_TRUE(it != stats_map.end()); |
| 174 | 174 |
| 175 base::TimeDelta duration = end_time - start_time; | 175 base::TimeDelta duration = end_time - start_time; |
| 176 EXPECT_DOUBLE_EQ( | 176 EXPECT_DOUBLE_EQ( |
| 177 it->second, | 177 it->second, |
| 178 static_cast<double>(num_frames) / duration.InMillisecondsF() * 1000); | 178 static_cast<double>(num_frames) / duration.InMillisecondsF() * 1000); |
| 179 } | 179 } |
| 180 | 180 |
| 181 TEST_F(StatsEventSubscriberTest, PlayoutDelay) { | 181 TEST_F(StatsEventSubscriberTest, PlayoutDelay) { |
| 182 Init(VIDEO_EVENT); | 182 Init(VIDEO_EVENT); |
| 183 | 183 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 200 AdvanceClocks(base::TimeDelta::FromMicroseconds(37890)); | 200 AdvanceClocks(base::TimeDelta::FromMicroseconds(37890)); |
| 201 rtp_timestamp += 90; | 201 rtp_timestamp += 90; |
| 202 frame_id++; | 202 frame_id++; |
| 203 } | 203 } |
| 204 | 204 |
| 205 StatsEventSubscriber::StatsMap stats_map; | 205 StatsEventSubscriber::StatsMap stats_map; |
| 206 subscriber_->GetStatsInternal(&stats_map); | 206 subscriber_->GetStatsInternal(&stats_map); |
| 207 | 207 |
| 208 StatsEventSubscriber::StatsMap::iterator it = | 208 StatsEventSubscriber::StatsMap::iterator it = |
| 209 stats_map.find(StatsEventSubscriber::AVG_PLAYOUT_DELAY_MS); | 209 stats_map.find(StatsEventSubscriber::AVG_PLAYOUT_DELAY_MS); |
| 210 ASSERT_NE(it, stats_map.end()); | 210 ASSERT_TRUE(it != stats_map.end()); |
| 211 | 211 |
| 212 EXPECT_DOUBLE_EQ( | 212 EXPECT_DOUBLE_EQ( |
| 213 it->second, static_cast<double>(total_delay_ms) / num_frames); | 213 it->second, static_cast<double>(total_delay_ms) / num_frames); |
| 214 } | 214 } |
| 215 | 215 |
| 216 TEST_F(StatsEventSubscriberTest, E2ELatency) { | 216 TEST_F(StatsEventSubscriberTest, E2ELatency) { |
| 217 Init(VIDEO_EVENT); | 217 Init(VIDEO_EVENT); |
| 218 | 218 |
| 219 uint32 rtp_timestamp = 0; | 219 uint32 rtp_timestamp = 0; |
| 220 uint32 frame_id = 0; | 220 uint32 frame_id = 0; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 245 | 245 |
| 246 rtp_timestamp += 90; | 246 rtp_timestamp += 90; |
| 247 frame_id++; | 247 frame_id++; |
| 248 } | 248 } |
| 249 | 249 |
| 250 StatsEventSubscriber::StatsMap stats_map; | 250 StatsEventSubscriber::StatsMap stats_map; |
| 251 subscriber_->GetStatsInternal(&stats_map); | 251 subscriber_->GetStatsInternal(&stats_map); |
| 252 | 252 |
| 253 StatsEventSubscriber::StatsMap::iterator it = | 253 StatsEventSubscriber::StatsMap::iterator it = |
| 254 stats_map.find(StatsEventSubscriber::AVG_E2E_LATENCY_MS); | 254 stats_map.find(StatsEventSubscriber::AVG_E2E_LATENCY_MS); |
| 255 ASSERT_NE(it, stats_map.end()); | 255 ASSERT_TRUE(it != stats_map.end()); |
| 256 | 256 |
| 257 EXPECT_DOUBLE_EQ( | 257 EXPECT_DOUBLE_EQ( |
| 258 it->second, total_latency.InMillisecondsF() / num_frames); | 258 it->second, total_latency.InMillisecondsF() / num_frames); |
| 259 } | 259 } |
| 260 | 260 |
| 261 TEST_F(StatsEventSubscriberTest, Packets) { | 261 TEST_F(StatsEventSubscriberTest, Packets) { |
| 262 Init(VIDEO_EVENT); | 262 Init(VIDEO_EVENT); |
| 263 | 263 |
| 264 uint32 rtp_timestamp = 0; | 264 uint32 rtp_timestamp = 0; |
| 265 int num_packets = 10; | 265 int num_packets = 10; |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 363 base::TimeTicks end_time = sender_clock_->NowTicks(); | 363 base::TimeTicks end_time = sender_clock_->NowTicks(); |
| 364 base::TimeDelta duration = end_time - start_time; | 364 base::TimeDelta duration = end_time - start_time; |
| 365 | 365 |
| 366 StatsEventSubscriber::StatsMap stats_map; | 366 StatsEventSubscriber::StatsMap stats_map; |
| 367 subscriber_->GetStatsInternal(&stats_map); | 367 subscriber_->GetStatsInternal(&stats_map); |
| 368 | 368 |
| 369 // Measure AVG_NETWORK_LATENCY_MS, TRANSMISSION_KBPS, RETRANSMISSION_KBPS, | 369 // Measure AVG_NETWORK_LATENCY_MS, TRANSMISSION_KBPS, RETRANSMISSION_KBPS, |
| 370 // and PACKET_LOSS_FRACTION. | 370 // and PACKET_LOSS_FRACTION. |
| 371 StatsEventSubscriber::StatsMap::iterator it = | 371 StatsEventSubscriber::StatsMap::iterator it = |
| 372 stats_map.find(StatsEventSubscriber::AVG_NETWORK_LATENCY_MS); | 372 stats_map.find(StatsEventSubscriber::AVG_NETWORK_LATENCY_MS); |
| 373 ASSERT_NE(it, stats_map.end()); | 373 ASSERT_TRUE(it != stats_map.end()); |
| 374 | 374 |
| 375 EXPECT_DOUBLE_EQ( | 375 EXPECT_DOUBLE_EQ( |
| 376 it->second, | 376 it->second, |
| 377 total_latency.InMillisecondsF() / num_latency_recorded_packets); | 377 total_latency.InMillisecondsF() / num_latency_recorded_packets); |
| 378 | 378 |
| 379 it = stats_map.find(StatsEventSubscriber::TRANSMISSION_KBPS); | 379 it = stats_map.find(StatsEventSubscriber::TRANSMISSION_KBPS); |
| 380 ASSERT_NE(it, stats_map.end()); | 380 ASSERT_TRUE(it != stats_map.end()); |
| 381 | 381 |
| 382 EXPECT_DOUBLE_EQ(it->second, | 382 EXPECT_DOUBLE_EQ(it->second, |
| 383 static_cast<double>(total_size) / duration.InMillisecondsF() * 8); | 383 static_cast<double>(total_size) / duration.InMillisecondsF() * 8); |
| 384 | 384 |
| 385 it = stats_map.find(StatsEventSubscriber::RETRANSMISSION_KBPS); | 385 it = stats_map.find(StatsEventSubscriber::RETRANSMISSION_KBPS); |
| 386 ASSERT_NE(it, stats_map.end()); | 386 ASSERT_TRUE(it != stats_map.end()); |
| 387 | 387 |
| 388 EXPECT_DOUBLE_EQ(it->second, | 388 EXPECT_DOUBLE_EQ(it->second, |
| 389 static_cast<double>(retransmit_total_size) / | 389 static_cast<double>(retransmit_total_size) / |
| 390 duration.InMillisecondsF() * 8); | 390 duration.InMillisecondsF() * 8); |
| 391 | 391 |
| 392 it = stats_map.find(StatsEventSubscriber::PACKET_LOSS_FRACTION); | 392 it = stats_map.find(StatsEventSubscriber::PACKET_LOSS_FRACTION); |
| 393 ASSERT_NE(it, stats_map.end()); | 393 ASSERT_TRUE(it != stats_map.end()); |
| 394 | 394 |
| 395 EXPECT_DOUBLE_EQ( | 395 EXPECT_DOUBLE_EQ( |
| 396 it->second, | 396 it->second, |
| 397 static_cast<double>(num_packets_retransmitted) / num_packets_sent); | 397 static_cast<double>(num_packets_retransmitted) / num_packets_sent); |
| 398 } | 398 } |
| 399 | 399 |
| 400 } // namespace cast | 400 } // namespace cast |
| 401 } // namespace media | 401 } // namespace media |
| OLD | NEW |