| 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 "base/values.h" | 10 #include "base/values.h" |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 base::SimpleTestTickClock receiver_clock_; | 60 base::SimpleTestTickClock receiver_clock_; |
| 61 scoped_refptr<test::FakeSingleThreadTaskRunner> task_runner_; | 61 scoped_refptr<test::FakeSingleThreadTaskRunner> task_runner_; |
| 62 scoped_refptr<CastEnvironment> cast_environment_; | 62 scoped_refptr<CastEnvironment> cast_environment_; |
| 63 test::FakeReceiverTimeOffsetEstimator fake_offset_estimator_; | 63 test::FakeReceiverTimeOffsetEstimator fake_offset_estimator_; |
| 64 scoped_ptr<StatsEventSubscriber> subscriber_; | 64 scoped_ptr<StatsEventSubscriber> subscriber_; |
| 65 }; | 65 }; |
| 66 | 66 |
| 67 TEST_F(StatsEventSubscriberTest, CaptureEncode) { | 67 TEST_F(StatsEventSubscriberTest, CaptureEncode) { |
| 68 Init(VIDEO_EVENT); | 68 Init(VIDEO_EVENT); |
| 69 | 69 |
| 70 uint32 rtp_timestamp = 0; | 70 RtpTimeTicks rtp_timestamp; |
| 71 uint32 frame_id = 0; | 71 uint32 frame_id = 0; |
| 72 int extra_frames = 50; | 72 int extra_frames = 50; |
| 73 // Only the first |extra_frames| frames logged will be taken into account | 73 // Only the first |extra_frames| frames logged will be taken into account |
| 74 // when computing dropped frames. | 74 // when computing dropped frames. |
| 75 int num_frames = StatsEventSubscriber::kMaxFrameInfoMapSize + 50; | 75 int num_frames = StatsEventSubscriber::kMaxFrameInfoMapSize + 50; |
| 76 int dropped_frames = 0; | 76 int dropped_frames = 0; |
| 77 base::TimeTicks start_time = sender_clock_->NowTicks(); | 77 base::TimeTicks start_time = sender_clock_->NowTicks(); |
| 78 // Drop half the frames during the encode step. | 78 // Drop half the frames during the encode step. |
| 79 for (int i = 0; i < num_frames; i++) { | 79 for (int i = 0; i < num_frames; i++) { |
| 80 scoped_ptr<FrameEvent> capture_begin_event(new FrameEvent()); | 80 scoped_ptr<FrameEvent> capture_begin_event(new FrameEvent()); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 103 encode_event->size = 1024; | 103 encode_event->size = 1024; |
| 104 encode_event->key_frame = true; | 104 encode_event->key_frame = true; |
| 105 encode_event->target_bitrate = 5678; | 105 encode_event->target_bitrate = 5678; |
| 106 encode_event->encoder_cpu_utilization = 9.10; | 106 encode_event->encoder_cpu_utilization = 9.10; |
| 107 encode_event->idealized_bitrate_utilization = 11.12; | 107 encode_event->idealized_bitrate_utilization = 11.12; |
| 108 cast_environment_->logger()->DispatchFrameEvent(encode_event.Pass()); | 108 cast_environment_->logger()->DispatchFrameEvent(encode_event.Pass()); |
| 109 } else if (i < extra_frames) { | 109 } else if (i < extra_frames) { |
| 110 dropped_frames++; | 110 dropped_frames++; |
| 111 } | 111 } |
| 112 AdvanceClocks(base::TimeDelta::FromMicroseconds(34567)); | 112 AdvanceClocks(base::TimeDelta::FromMicroseconds(34567)); |
| 113 rtp_timestamp += 90; | 113 rtp_timestamp += RtpTimeDelta::FromTicks(90); |
| 114 frame_id++; | 114 frame_id++; |
| 115 } | 115 } |
| 116 | 116 |
| 117 base::TimeTicks end_time = sender_clock_->NowTicks(); | 117 base::TimeTicks end_time = sender_clock_->NowTicks(); |
| 118 | 118 |
| 119 StatsEventSubscriber::StatsMap stats_map; | 119 StatsEventSubscriber::StatsMap stats_map; |
| 120 subscriber_->GetStatsInternal(&stats_map); | 120 subscriber_->GetStatsInternal(&stats_map); |
| 121 | 121 |
| 122 StatsEventSubscriber::StatsMap::iterator it = | 122 StatsEventSubscriber::StatsMap::iterator it = |
| 123 stats_map.find(StatsEventSubscriber::CAPTURE_FPS); | 123 stats_map.find(StatsEventSubscriber::CAPTURE_FPS); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 140 | 140 |
| 141 it = stats_map.find(StatsEventSubscriber::AVG_CAPTURE_LATENCY_MS); | 141 it = stats_map.find(StatsEventSubscriber::AVG_CAPTURE_LATENCY_MS); |
| 142 ASSERT_TRUE(it != stats_map.end()); | 142 ASSERT_TRUE(it != stats_map.end()); |
| 143 | 143 |
| 144 EXPECT_DOUBLE_EQ(it->second, static_cast<double>(0.01)); | 144 EXPECT_DOUBLE_EQ(it->second, static_cast<double>(0.01)); |
| 145 } | 145 } |
| 146 | 146 |
| 147 TEST_F(StatsEventSubscriberTest, Encode) { | 147 TEST_F(StatsEventSubscriberTest, Encode) { |
| 148 Init(VIDEO_EVENT); | 148 Init(VIDEO_EVENT); |
| 149 | 149 |
| 150 uint32 rtp_timestamp = 0; | 150 RtpTimeTicks rtp_timestamp; |
| 151 uint32 frame_id = 0; | 151 uint32 frame_id = 0; |
| 152 int num_frames = 10; | 152 int num_frames = 10; |
| 153 base::TimeTicks start_time = sender_clock_->NowTicks(); | 153 base::TimeTicks start_time = sender_clock_->NowTicks(); |
| 154 AdvanceClocks(base::TimeDelta::FromMicroseconds(35678)); | 154 AdvanceClocks(base::TimeDelta::FromMicroseconds(35678)); |
| 155 base::TimeTicks first_event_time = sender_clock_->NowTicks(); | 155 base::TimeTicks first_event_time = sender_clock_->NowTicks(); |
| 156 base::TimeTicks last_event_time; | 156 base::TimeTicks last_event_time; |
| 157 int total_size = 0; | 157 int total_size = 0; |
| 158 for (int i = 0; i < num_frames; i++) { | 158 for (int i = 0; i < num_frames; i++) { |
| 159 int size = 1000 + base::RandInt(-100, 100); | 159 int size = 1000 + base::RandInt(-100, 100); |
| 160 total_size += size; | 160 total_size += size; |
| 161 scoped_ptr<FrameEvent> encode_event(new FrameEvent()); | 161 scoped_ptr<FrameEvent> encode_event(new FrameEvent()); |
| 162 encode_event->timestamp = sender_clock_->NowTicks(); | 162 encode_event->timestamp = sender_clock_->NowTicks(); |
| 163 encode_event->type = FRAME_ENCODED; | 163 encode_event->type = FRAME_ENCODED; |
| 164 encode_event->media_type = VIDEO_EVENT; | 164 encode_event->media_type = VIDEO_EVENT; |
| 165 encode_event->rtp_timestamp = rtp_timestamp; | 165 encode_event->rtp_timestamp = rtp_timestamp; |
| 166 encode_event->frame_id = frame_id; | 166 encode_event->frame_id = frame_id; |
| 167 encode_event->size = size; | 167 encode_event->size = size; |
| 168 encode_event->key_frame = true; | 168 encode_event->key_frame = true; |
| 169 encode_event->target_bitrate = 5678; | 169 encode_event->target_bitrate = 5678; |
| 170 encode_event->encoder_cpu_utilization = 9.10; | 170 encode_event->encoder_cpu_utilization = 9.10; |
| 171 encode_event->idealized_bitrate_utilization = 11.12; | 171 encode_event->idealized_bitrate_utilization = 11.12; |
| 172 cast_environment_->logger()->DispatchFrameEvent(encode_event.Pass()); | 172 cast_environment_->logger()->DispatchFrameEvent(encode_event.Pass()); |
| 173 last_event_time = sender_clock_->NowTicks(); | 173 last_event_time = sender_clock_->NowTicks(); |
| 174 | 174 |
| 175 AdvanceClocks(base::TimeDelta::FromMicroseconds(35678)); | 175 AdvanceClocks(base::TimeDelta::FromMicroseconds(35678)); |
| 176 rtp_timestamp += 90; | 176 rtp_timestamp += RtpTimeDelta::FromTicks(90); |
| 177 frame_id++; | 177 frame_id++; |
| 178 } | 178 } |
| 179 | 179 |
| 180 base::TimeTicks end_time = sender_clock_->NowTicks(); | 180 base::TimeTicks end_time = sender_clock_->NowTicks(); |
| 181 | 181 |
| 182 StatsEventSubscriber::StatsMap stats_map; | 182 StatsEventSubscriber::StatsMap stats_map; |
| 183 subscriber_->GetStatsInternal(&stats_map); | 183 subscriber_->GetStatsInternal(&stats_map); |
| 184 | 184 |
| 185 StatsEventSubscriber::StatsMap::iterator it = | 185 StatsEventSubscriber::StatsMap::iterator it = |
| 186 stats_map.find(StatsEventSubscriber::ENCODE_FPS); | 186 stats_map.find(StatsEventSubscriber::ENCODE_FPS); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 208 ASSERT_TRUE(it != stats_map.end()); | 208 ASSERT_TRUE(it != stats_map.end()); |
| 209 | 209 |
| 210 EXPECT_DOUBLE_EQ( | 210 EXPECT_DOUBLE_EQ( |
| 211 it->second, | 211 it->second, |
| 212 (last_event_time - base::TimeTicks::UnixEpoch()).InMillisecondsF()); | 212 (last_event_time - base::TimeTicks::UnixEpoch()).InMillisecondsF()); |
| 213 } | 213 } |
| 214 | 214 |
| 215 TEST_F(StatsEventSubscriberTest, Decode) { | 215 TEST_F(StatsEventSubscriberTest, Decode) { |
| 216 Init(VIDEO_EVENT); | 216 Init(VIDEO_EVENT); |
| 217 | 217 |
| 218 uint32 rtp_timestamp = 0; | 218 RtpTimeTicks rtp_timestamp; |
| 219 uint32 frame_id = 0; | 219 uint32 frame_id = 0; |
| 220 int num_frames = 10; | 220 int num_frames = 10; |
| 221 base::TimeTicks start_time = sender_clock_->NowTicks(); | 221 base::TimeTicks start_time = sender_clock_->NowTicks(); |
| 222 for (int i = 0; i < num_frames; i++) { | 222 for (int i = 0; i < num_frames; i++) { |
| 223 scoped_ptr<FrameEvent> decode_event(new FrameEvent()); | 223 scoped_ptr<FrameEvent> decode_event(new FrameEvent()); |
| 224 decode_event->timestamp = receiver_clock_.NowTicks(); | 224 decode_event->timestamp = receiver_clock_.NowTicks(); |
| 225 decode_event->type = FRAME_DECODED; | 225 decode_event->type = FRAME_DECODED; |
| 226 decode_event->media_type = VIDEO_EVENT; | 226 decode_event->media_type = VIDEO_EVENT; |
| 227 decode_event->rtp_timestamp = rtp_timestamp; | 227 decode_event->rtp_timestamp = rtp_timestamp; |
| 228 decode_event->frame_id = frame_id; | 228 decode_event->frame_id = frame_id; |
| 229 cast_environment_->logger()->DispatchFrameEvent(decode_event.Pass()); | 229 cast_environment_->logger()->DispatchFrameEvent(decode_event.Pass()); |
| 230 | 230 |
| 231 AdvanceClocks(base::TimeDelta::FromMicroseconds(36789)); | 231 AdvanceClocks(base::TimeDelta::FromMicroseconds(36789)); |
| 232 rtp_timestamp += 90; | 232 rtp_timestamp += RtpTimeDelta::FromTicks(90); |
| 233 frame_id++; | 233 frame_id++; |
| 234 } | 234 } |
| 235 | 235 |
| 236 base::TimeTicks end_time = sender_clock_->NowTicks(); | 236 base::TimeTicks end_time = sender_clock_->NowTicks(); |
| 237 | 237 |
| 238 StatsEventSubscriber::StatsMap stats_map; | 238 StatsEventSubscriber::StatsMap stats_map; |
| 239 subscriber_->GetStatsInternal(&stats_map); | 239 subscriber_->GetStatsInternal(&stats_map); |
| 240 | 240 |
| 241 StatsEventSubscriber::StatsMap::iterator it = | 241 StatsEventSubscriber::StatsMap::iterator it = |
| 242 stats_map.find(StatsEventSubscriber::DECODE_FPS); | 242 stats_map.find(StatsEventSubscriber::DECODE_FPS); |
| 243 ASSERT_TRUE(it != stats_map.end()); | 243 ASSERT_TRUE(it != stats_map.end()); |
| 244 | 244 |
| 245 base::TimeDelta duration = end_time - start_time; | 245 base::TimeDelta duration = end_time - start_time; |
| 246 EXPECT_DOUBLE_EQ( | 246 EXPECT_DOUBLE_EQ( |
| 247 it->second, | 247 it->second, |
| 248 static_cast<double>(num_frames) / duration.InMillisecondsF() * 1000); | 248 static_cast<double>(num_frames) / duration.InMillisecondsF() * 1000); |
| 249 } | 249 } |
| 250 | 250 |
| 251 TEST_F(StatsEventSubscriberTest, PlayoutDelay) { | 251 TEST_F(StatsEventSubscriberTest, PlayoutDelay) { |
| 252 Init(VIDEO_EVENT); | 252 Init(VIDEO_EVENT); |
| 253 | 253 |
| 254 uint32 rtp_timestamp = 0; | 254 RtpTimeTicks rtp_timestamp; |
| 255 uint32 frame_id = 0; | 255 uint32 frame_id = 0; |
| 256 int num_frames = 10; | 256 int num_frames = 10; |
| 257 int late_frames = 0; | 257 int late_frames = 0; |
| 258 for (int i = 0, delay_ms = -50; i < num_frames; i++, delay_ms += 10) { | 258 for (int i = 0, delay_ms = -50; i < num_frames; i++, delay_ms += 10) { |
| 259 base::TimeDelta delay = base::TimeDelta::FromMilliseconds(delay_ms); | 259 base::TimeDelta delay = base::TimeDelta::FromMilliseconds(delay_ms); |
| 260 if (delay_ms > 0) | 260 if (delay_ms > 0) |
| 261 late_frames++; | 261 late_frames++; |
| 262 scoped_ptr<FrameEvent> playout_event(new FrameEvent()); | 262 scoped_ptr<FrameEvent> playout_event(new FrameEvent()); |
| 263 playout_event->timestamp = receiver_clock_.NowTicks(); | 263 playout_event->timestamp = receiver_clock_.NowTicks(); |
| 264 playout_event->type = FRAME_PLAYOUT; | 264 playout_event->type = FRAME_PLAYOUT; |
| 265 playout_event->media_type = VIDEO_EVENT; | 265 playout_event->media_type = VIDEO_EVENT; |
| 266 playout_event->rtp_timestamp = rtp_timestamp; | 266 playout_event->rtp_timestamp = rtp_timestamp; |
| 267 playout_event->frame_id = frame_id; | 267 playout_event->frame_id = frame_id; |
| 268 playout_event->delay_delta = delay; | 268 playout_event->delay_delta = delay; |
| 269 cast_environment_->logger()->DispatchFrameEvent(playout_event.Pass()); | 269 cast_environment_->logger()->DispatchFrameEvent(playout_event.Pass()); |
| 270 | 270 |
| 271 AdvanceClocks(base::TimeDelta::FromMicroseconds(37890)); | 271 AdvanceClocks(base::TimeDelta::FromMicroseconds(37890)); |
| 272 rtp_timestamp += 90; | 272 rtp_timestamp += RtpTimeDelta::FromTicks(90); |
| 273 frame_id++; | 273 frame_id++; |
| 274 } | 274 } |
| 275 | 275 |
| 276 StatsEventSubscriber::StatsMap stats_map; | 276 StatsEventSubscriber::StatsMap stats_map; |
| 277 subscriber_->GetStatsInternal(&stats_map); | 277 subscriber_->GetStatsInternal(&stats_map); |
| 278 | 278 |
| 279 StatsEventSubscriber::StatsMap::iterator it = stats_map.find( | 279 StatsEventSubscriber::StatsMap::iterator it = stats_map.find( |
| 280 StatsEventSubscriber::NUM_FRAMES_LATE); | 280 StatsEventSubscriber::NUM_FRAMES_LATE); |
| 281 ASSERT_TRUE(it != stats_map.end()); | 281 ASSERT_TRUE(it != stats_map.end()); |
| 282 | 282 |
| 283 EXPECT_DOUBLE_EQ(it->second, late_frames); | 283 EXPECT_DOUBLE_EQ(it->second, late_frames); |
| 284 } | 284 } |
| 285 | 285 |
| 286 TEST_F(StatsEventSubscriberTest, E2ELatency) { | 286 TEST_F(StatsEventSubscriberTest, E2ELatency) { |
| 287 Init(VIDEO_EVENT); | 287 Init(VIDEO_EVENT); |
| 288 | 288 |
| 289 uint32 rtp_timestamp = 0; | 289 RtpTimeTicks rtp_timestamp; |
| 290 uint32 frame_id = 0; | 290 uint32 frame_id = 0; |
| 291 int num_frames = 10; | 291 int num_frames = 10; |
| 292 base::TimeDelta total_latency; | 292 base::TimeDelta total_latency; |
| 293 for (int i = 0; i < num_frames; i++) { | 293 for (int i = 0; i < num_frames; i++) { |
| 294 scoped_ptr<FrameEvent> capture_begin_event(new FrameEvent()); | 294 scoped_ptr<FrameEvent> capture_begin_event(new FrameEvent()); |
| 295 capture_begin_event->timestamp = sender_clock_->NowTicks(); | 295 capture_begin_event->timestamp = sender_clock_->NowTicks(); |
| 296 capture_begin_event->type = FRAME_CAPTURE_BEGIN; | 296 capture_begin_event->type = FRAME_CAPTURE_BEGIN; |
| 297 capture_begin_event->media_type = VIDEO_EVENT; | 297 capture_begin_event->media_type = VIDEO_EVENT; |
| 298 capture_begin_event->rtp_timestamp = rtp_timestamp; | 298 capture_begin_event->rtp_timestamp = rtp_timestamp; |
| 299 cast_environment_->logger()->DispatchFrameEvent(capture_begin_event.Pass()); | 299 cast_environment_->logger()->DispatchFrameEvent(capture_begin_event.Pass()); |
| 300 | 300 |
| 301 int latency_micros = 100000 + base::RandInt(-5000, 50000); | 301 int latency_micros = 100000 + base::RandInt(-5000, 50000); |
| 302 base::TimeDelta latency = base::TimeDelta::FromMicroseconds(latency_micros); | 302 base::TimeDelta latency = base::TimeDelta::FromMicroseconds(latency_micros); |
| 303 AdvanceClocks(latency); | 303 AdvanceClocks(latency); |
| 304 | 304 |
| 305 int delay_micros = base::RandInt(-50000, 50000); | 305 int delay_micros = base::RandInt(-50000, 50000); |
| 306 base::TimeDelta delay = base::TimeDelta::FromMilliseconds(delay_micros); | 306 base::TimeDelta delay = base::TimeDelta::FromMilliseconds(delay_micros); |
| 307 total_latency += latency; | 307 total_latency += latency; |
| 308 | 308 |
| 309 scoped_ptr<FrameEvent> playout_event(new FrameEvent()); | 309 scoped_ptr<FrameEvent> playout_event(new FrameEvent()); |
| 310 playout_event->timestamp = receiver_clock_.NowTicks(); | 310 playout_event->timestamp = receiver_clock_.NowTicks(); |
| 311 playout_event->type = FRAME_PLAYOUT; | 311 playout_event->type = FRAME_PLAYOUT; |
| 312 playout_event->media_type = VIDEO_EVENT; | 312 playout_event->media_type = VIDEO_EVENT; |
| 313 playout_event->rtp_timestamp = rtp_timestamp; | 313 playout_event->rtp_timestamp = rtp_timestamp; |
| 314 playout_event->frame_id = frame_id; | 314 playout_event->frame_id = frame_id; |
| 315 playout_event->delay_delta = delay; | 315 playout_event->delay_delta = delay; |
| 316 cast_environment_->logger()->DispatchFrameEvent(playout_event.Pass()); | 316 cast_environment_->logger()->DispatchFrameEvent(playout_event.Pass()); |
| 317 | 317 |
| 318 rtp_timestamp += 90; | 318 rtp_timestamp += RtpTimeDelta::FromTicks(90); |
| 319 frame_id++; | 319 frame_id++; |
| 320 } | 320 } |
| 321 | 321 |
| 322 StatsEventSubscriber::StatsMap stats_map; | 322 StatsEventSubscriber::StatsMap stats_map; |
| 323 subscriber_->GetStatsInternal(&stats_map); | 323 subscriber_->GetStatsInternal(&stats_map); |
| 324 | 324 |
| 325 StatsEventSubscriber::StatsMap::iterator it = | 325 StatsEventSubscriber::StatsMap::iterator it = |
| 326 stats_map.find(StatsEventSubscriber::AVG_E2E_LATENCY_MS); | 326 stats_map.find(StatsEventSubscriber::AVG_E2E_LATENCY_MS); |
| 327 ASSERT_TRUE(it != stats_map.end()); | 327 ASSERT_TRUE(it != stats_map.end()); |
| 328 | 328 |
| 329 EXPECT_DOUBLE_EQ( | 329 EXPECT_DOUBLE_EQ( |
| 330 it->second, total_latency.InMillisecondsF() / num_frames); | 330 it->second, total_latency.InMillisecondsF() / num_frames); |
| 331 } | 331 } |
| 332 | 332 |
| 333 TEST_F(StatsEventSubscriberTest, Packets) { | 333 TEST_F(StatsEventSubscriberTest, Packets) { |
| 334 Init(VIDEO_EVENT); | 334 Init(VIDEO_EVENT); |
| 335 | 335 |
| 336 uint32 rtp_timestamp = 0; | 336 RtpTimeTicks rtp_timestamp; |
| 337 int num_packets = 10; | 337 int num_packets = 10; |
| 338 int num_latency_recorded_packets = 0; | 338 int num_latency_recorded_packets = 0; |
| 339 base::TimeTicks start_time = sender_clock_->NowTicks(); | 339 base::TimeTicks start_time = sender_clock_->NowTicks(); |
| 340 int total_size = 0; | 340 int total_size = 0; |
| 341 int retransmit_total_size = 0; | 341 int retransmit_total_size = 0; |
| 342 base::TimeDelta total_network_latency; | 342 base::TimeDelta total_network_latency; |
| 343 base::TimeDelta total_queueing_latency; | 343 base::TimeDelta total_queueing_latency; |
| 344 base::TimeDelta total_packet_latency; | 344 base::TimeDelta total_packet_latency; |
| 345 int num_packets_transmitted = 0; | 345 int num_packets_transmitted = 0; |
| 346 int num_packets_received = 0; | 346 int num_packets_received = 0; |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 550 return false; | 550 return false; |
| 551 return bucket_count == expected_count; | 551 return bucket_count == expected_count; |
| 552 } | 552 } |
| 553 return false; | 553 return false; |
| 554 } | 554 } |
| 555 | 555 |
| 556 TEST_F(StatsEventSubscriberTest, Histograms) { | 556 TEST_F(StatsEventSubscriberTest, Histograms) { |
| 557 Init(VIDEO_EVENT); | 557 Init(VIDEO_EVENT); |
| 558 AdvanceClocks(base::TimeDelta::FromMilliseconds(123)); | 558 AdvanceClocks(base::TimeDelta::FromMilliseconds(123)); |
| 559 | 559 |
| 560 uint32 rtp_timestamp = 123; | 560 RtpTimeTicks rtp_timestamp = RtpTimeTicks().Expand(UINT32_C(123)); |
| 561 uint32 frame_id = 0; | 561 uint32 frame_id = 0; |
| 562 | 562 |
| 563 // 10 Frames with capture latency in the bucket of "10-14"ms. | 563 // 10 Frames with capture latency in the bucket of "10-14"ms. |
| 564 // 10 Frames with encode time in the bucket of "15-19"ms. | 564 // 10 Frames with encode time in the bucket of "15-19"ms. |
| 565 for (int i = 0; i < 10; ++i) { | 565 for (int i = 0; i < 10; ++i) { |
| 566 ++frame_id; | 566 ++frame_id; |
| 567 ++rtp_timestamp; | 567 rtp_timestamp += RtpTimeDelta::FromTicks(1); |
| 568 | 568 |
| 569 scoped_ptr<FrameEvent> capture_begin_event(new FrameEvent()); | 569 scoped_ptr<FrameEvent> capture_begin_event(new FrameEvent()); |
| 570 capture_begin_event->timestamp = sender_clock_->NowTicks(); | 570 capture_begin_event->timestamp = sender_clock_->NowTicks(); |
| 571 capture_begin_event->type = FRAME_CAPTURE_BEGIN; | 571 capture_begin_event->type = FRAME_CAPTURE_BEGIN; |
| 572 capture_begin_event->media_type = VIDEO_EVENT; | 572 capture_begin_event->media_type = VIDEO_EVENT; |
| 573 capture_begin_event->rtp_timestamp = rtp_timestamp; | 573 capture_begin_event->rtp_timestamp = rtp_timestamp; |
| 574 cast_environment_->logger()->DispatchFrameEvent(capture_begin_event.Pass()); | 574 cast_environment_->logger()->DispatchFrameEvent(capture_begin_event.Pass()); |
| 575 | 575 |
| 576 AdvanceClocks(base::TimeDelta::FromMilliseconds(10)); | 576 AdvanceClocks(base::TimeDelta::FromMilliseconds(10)); |
| 577 scoped_ptr<FrameEvent> capture_end_event(new FrameEvent()); | 577 scoped_ptr<FrameEvent> capture_end_event(new FrameEvent()); |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 677 | 677 |
| 678 histogram = subscriber_->GetHistogramForTesting( | 678 histogram = subscriber_->GetHistogramForTesting( |
| 679 StatsEventSubscriber::LATE_FRAME_MS_HISTO); | 679 StatsEventSubscriber::LATE_FRAME_MS_HISTO); |
| 680 ASSERT_TRUE(histogram); | 680 ASSERT_TRUE(histogram); |
| 681 values = histogram->GetHistogram().Pass(); | 681 values = histogram->GetHistogram().Pass(); |
| 682 EXPECT_TRUE(CheckHistogramHasValue(values.get(), "100-119", 1)); | 682 EXPECT_TRUE(CheckHistogramHasValue(values.get(), "100-119", 1)); |
| 683 } | 683 } |
| 684 | 684 |
| 685 } // namespace cast | 685 } // namespace cast |
| 686 } // namespace media | 686 } // namespace media |
| OLD | NEW |