| 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 "media/cast/logging/stats_event_subscriber.h" | 5 #include "media/cast/logging/stats_event_subscriber.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 base::SimpleTestTickClock receiver_clock_; | 65 base::SimpleTestTickClock receiver_clock_; |
| 66 scoped_refptr<test::FakeSingleThreadTaskRunner> task_runner_; | 66 scoped_refptr<test::FakeSingleThreadTaskRunner> task_runner_; |
| 67 scoped_refptr<CastEnvironment> cast_environment_; | 67 scoped_refptr<CastEnvironment> cast_environment_; |
| 68 test::FakeReceiverTimeOffsetEstimator fake_offset_estimator_; | 68 test::FakeReceiverTimeOffsetEstimator fake_offset_estimator_; |
| 69 scoped_ptr<StatsEventSubscriber> subscriber_; | 69 scoped_ptr<StatsEventSubscriber> subscriber_; |
| 70 }; | 70 }; |
| 71 | 71 |
| 72 TEST_F(StatsEventSubscriberTest, CaptureEncode) { | 72 TEST_F(StatsEventSubscriberTest, CaptureEncode) { |
| 73 Init(VIDEO_EVENT); | 73 Init(VIDEO_EVENT); |
| 74 | 74 |
| 75 uint32_t rtp_timestamp = 0; | 75 RtpTimeTicks rtp_timestamp; |
| 76 uint32_t frame_id = 0; | 76 uint32_t frame_id = 0; |
| 77 int extra_frames = 50; | 77 int extra_frames = 50; |
| 78 // Only the first |extra_frames| frames logged will be taken into account | 78 // Only the first |extra_frames| frames logged will be taken into account |
| 79 // when computing dropped frames. | 79 // when computing dropped frames. |
| 80 int num_frames = StatsEventSubscriber::kMaxFrameInfoMapSize + 50; | 80 int num_frames = StatsEventSubscriber::kMaxFrameInfoMapSize + 50; |
| 81 int dropped_frames = 0; | 81 int dropped_frames = 0; |
| 82 base::TimeTicks start_time = sender_clock_->NowTicks(); | 82 base::TimeTicks start_time = sender_clock_->NowTicks(); |
| 83 // Drop half the frames during the encode step. | 83 // Drop half the frames during the encode step. |
| 84 for (int i = 0; i < num_frames; i++) { | 84 for (int i = 0; i < num_frames; i++) { |
| 85 scoped_ptr<FrameEvent> capture_begin_event(new FrameEvent()); | 85 scoped_ptr<FrameEvent> capture_begin_event(new FrameEvent()); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 110 encode_event->size = 1024; | 110 encode_event->size = 1024; |
| 111 encode_event->key_frame = true; | 111 encode_event->key_frame = true; |
| 112 encode_event->target_bitrate = 5678; | 112 encode_event->target_bitrate = 5678; |
| 113 encode_event->encoder_cpu_utilization = 9.10; | 113 encode_event->encoder_cpu_utilization = 9.10; |
| 114 encode_event->idealized_bitrate_utilization = 11.12; | 114 encode_event->idealized_bitrate_utilization = 11.12; |
| 115 cast_environment_->logger()->DispatchFrameEvent(std::move(encode_event)); | 115 cast_environment_->logger()->DispatchFrameEvent(std::move(encode_event)); |
| 116 } else if (i < extra_frames) { | 116 } else if (i < extra_frames) { |
| 117 dropped_frames++; | 117 dropped_frames++; |
| 118 } | 118 } |
| 119 AdvanceClocks(base::TimeDelta::FromMicroseconds(34567)); | 119 AdvanceClocks(base::TimeDelta::FromMicroseconds(34567)); |
| 120 rtp_timestamp += 90; | 120 rtp_timestamp += RtpTimeDelta::FromTicks(90); |
| 121 frame_id++; | 121 frame_id++; |
| 122 } | 122 } |
| 123 | 123 |
| 124 base::TimeTicks end_time = sender_clock_->NowTicks(); | 124 base::TimeTicks end_time = sender_clock_->NowTicks(); |
| 125 | 125 |
| 126 StatsEventSubscriber::StatsMap stats_map; | 126 StatsEventSubscriber::StatsMap stats_map; |
| 127 subscriber_->GetStatsInternal(&stats_map); | 127 subscriber_->GetStatsInternal(&stats_map); |
| 128 | 128 |
| 129 StatsEventSubscriber::StatsMap::iterator it = | 129 StatsEventSubscriber::StatsMap::iterator it = |
| 130 stats_map.find(StatsEventSubscriber::CAPTURE_FPS); | 130 stats_map.find(StatsEventSubscriber::CAPTURE_FPS); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 147 | 147 |
| 148 it = stats_map.find(StatsEventSubscriber::AVG_CAPTURE_LATENCY_MS); | 148 it = stats_map.find(StatsEventSubscriber::AVG_CAPTURE_LATENCY_MS); |
| 149 ASSERT_TRUE(it != stats_map.end()); | 149 ASSERT_TRUE(it != stats_map.end()); |
| 150 | 150 |
| 151 EXPECT_DOUBLE_EQ(it->second, static_cast<double>(0.01)); | 151 EXPECT_DOUBLE_EQ(it->second, static_cast<double>(0.01)); |
| 152 } | 152 } |
| 153 | 153 |
| 154 TEST_F(StatsEventSubscriberTest, Encode) { | 154 TEST_F(StatsEventSubscriberTest, Encode) { |
| 155 Init(VIDEO_EVENT); | 155 Init(VIDEO_EVENT); |
| 156 | 156 |
| 157 uint32_t rtp_timestamp = 0; | 157 RtpTimeTicks rtp_timestamp; |
| 158 uint32_t frame_id = 0; | 158 uint32_t frame_id = 0; |
| 159 int num_frames = 10; | 159 int num_frames = 10; |
| 160 base::TimeTicks start_time = sender_clock_->NowTicks(); | 160 base::TimeTicks start_time = sender_clock_->NowTicks(); |
| 161 AdvanceClocks(base::TimeDelta::FromMicroseconds(35678)); | 161 AdvanceClocks(base::TimeDelta::FromMicroseconds(35678)); |
| 162 base::TimeTicks first_event_time = sender_clock_->NowTicks(); | 162 base::TimeTicks first_event_time = sender_clock_->NowTicks(); |
| 163 base::TimeTicks last_event_time; | 163 base::TimeTicks last_event_time; |
| 164 int total_size = 0; | 164 int total_size = 0; |
| 165 for (int i = 0; i < num_frames; i++) { | 165 for (int i = 0; i < num_frames; i++) { |
| 166 int size = 1000 + base::RandInt(-100, 100); | 166 int size = 1000 + base::RandInt(-100, 100); |
| 167 total_size += size; | 167 total_size += size; |
| 168 scoped_ptr<FrameEvent> encode_event(new FrameEvent()); | 168 scoped_ptr<FrameEvent> encode_event(new FrameEvent()); |
| 169 encode_event->timestamp = sender_clock_->NowTicks(); | 169 encode_event->timestamp = sender_clock_->NowTicks(); |
| 170 encode_event->type = FRAME_ENCODED; | 170 encode_event->type = FRAME_ENCODED; |
| 171 encode_event->media_type = VIDEO_EVENT; | 171 encode_event->media_type = VIDEO_EVENT; |
| 172 encode_event->rtp_timestamp = rtp_timestamp; | 172 encode_event->rtp_timestamp = rtp_timestamp; |
| 173 encode_event->frame_id = frame_id; | 173 encode_event->frame_id = frame_id; |
| 174 encode_event->size = size; | 174 encode_event->size = size; |
| 175 encode_event->key_frame = true; | 175 encode_event->key_frame = true; |
| 176 encode_event->target_bitrate = 5678; | 176 encode_event->target_bitrate = 5678; |
| 177 encode_event->encoder_cpu_utilization = 9.10; | 177 encode_event->encoder_cpu_utilization = 9.10; |
| 178 encode_event->idealized_bitrate_utilization = 11.12; | 178 encode_event->idealized_bitrate_utilization = 11.12; |
| 179 cast_environment_->logger()->DispatchFrameEvent(std::move(encode_event)); | 179 cast_environment_->logger()->DispatchFrameEvent(std::move(encode_event)); |
| 180 last_event_time = sender_clock_->NowTicks(); | 180 last_event_time = sender_clock_->NowTicks(); |
| 181 | 181 |
| 182 AdvanceClocks(base::TimeDelta::FromMicroseconds(35678)); | 182 AdvanceClocks(base::TimeDelta::FromMicroseconds(35678)); |
| 183 rtp_timestamp += 90; | 183 rtp_timestamp += RtpTimeDelta::FromTicks(90); |
| 184 frame_id++; | 184 frame_id++; |
| 185 } | 185 } |
| 186 | 186 |
| 187 base::TimeTicks end_time = sender_clock_->NowTicks(); | 187 base::TimeTicks end_time = sender_clock_->NowTicks(); |
| 188 | 188 |
| 189 StatsEventSubscriber::StatsMap stats_map; | 189 StatsEventSubscriber::StatsMap stats_map; |
| 190 subscriber_->GetStatsInternal(&stats_map); | 190 subscriber_->GetStatsInternal(&stats_map); |
| 191 | 191 |
| 192 StatsEventSubscriber::StatsMap::iterator it = | 192 StatsEventSubscriber::StatsMap::iterator it = |
| 193 stats_map.find(StatsEventSubscriber::ENCODE_FPS); | 193 stats_map.find(StatsEventSubscriber::ENCODE_FPS); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 215 ASSERT_TRUE(it != stats_map.end()); | 215 ASSERT_TRUE(it != stats_map.end()); |
| 216 | 216 |
| 217 EXPECT_DOUBLE_EQ( | 217 EXPECT_DOUBLE_EQ( |
| 218 it->second, | 218 it->second, |
| 219 (last_event_time - base::TimeTicks::UnixEpoch()).InMillisecondsF()); | 219 (last_event_time - base::TimeTicks::UnixEpoch()).InMillisecondsF()); |
| 220 } | 220 } |
| 221 | 221 |
| 222 TEST_F(StatsEventSubscriberTest, Decode) { | 222 TEST_F(StatsEventSubscriberTest, Decode) { |
| 223 Init(VIDEO_EVENT); | 223 Init(VIDEO_EVENT); |
| 224 | 224 |
| 225 uint32_t rtp_timestamp = 0; | 225 RtpTimeTicks rtp_timestamp; |
| 226 uint32_t frame_id = 0; | 226 uint32_t frame_id = 0; |
| 227 int num_frames = 10; | 227 int num_frames = 10; |
| 228 base::TimeTicks start_time = sender_clock_->NowTicks(); | 228 base::TimeTicks start_time = sender_clock_->NowTicks(); |
| 229 for (int i = 0; i < num_frames; i++) { | 229 for (int i = 0; i < num_frames; i++) { |
| 230 scoped_ptr<FrameEvent> decode_event(new FrameEvent()); | 230 scoped_ptr<FrameEvent> decode_event(new FrameEvent()); |
| 231 decode_event->timestamp = receiver_clock_.NowTicks(); | 231 decode_event->timestamp = receiver_clock_.NowTicks(); |
| 232 decode_event->type = FRAME_DECODED; | 232 decode_event->type = FRAME_DECODED; |
| 233 decode_event->media_type = VIDEO_EVENT; | 233 decode_event->media_type = VIDEO_EVENT; |
| 234 decode_event->rtp_timestamp = rtp_timestamp; | 234 decode_event->rtp_timestamp = rtp_timestamp; |
| 235 decode_event->frame_id = frame_id; | 235 decode_event->frame_id = frame_id; |
| 236 cast_environment_->logger()->DispatchFrameEvent(std::move(decode_event)); | 236 cast_environment_->logger()->DispatchFrameEvent(std::move(decode_event)); |
| 237 | 237 |
| 238 AdvanceClocks(base::TimeDelta::FromMicroseconds(36789)); | 238 AdvanceClocks(base::TimeDelta::FromMicroseconds(36789)); |
| 239 rtp_timestamp += 90; | 239 rtp_timestamp += RtpTimeDelta::FromTicks(90); |
| 240 frame_id++; | 240 frame_id++; |
| 241 } | 241 } |
| 242 | 242 |
| 243 base::TimeTicks end_time = sender_clock_->NowTicks(); | 243 base::TimeTicks end_time = sender_clock_->NowTicks(); |
| 244 | 244 |
| 245 StatsEventSubscriber::StatsMap stats_map; | 245 StatsEventSubscriber::StatsMap stats_map; |
| 246 subscriber_->GetStatsInternal(&stats_map); | 246 subscriber_->GetStatsInternal(&stats_map); |
| 247 | 247 |
| 248 StatsEventSubscriber::StatsMap::iterator it = | 248 StatsEventSubscriber::StatsMap::iterator it = |
| 249 stats_map.find(StatsEventSubscriber::DECODE_FPS); | 249 stats_map.find(StatsEventSubscriber::DECODE_FPS); |
| 250 ASSERT_TRUE(it != stats_map.end()); | 250 ASSERT_TRUE(it != stats_map.end()); |
| 251 | 251 |
| 252 base::TimeDelta duration = end_time - start_time; | 252 base::TimeDelta duration = end_time - start_time; |
| 253 EXPECT_DOUBLE_EQ( | 253 EXPECT_DOUBLE_EQ( |
| 254 it->second, | 254 it->second, |
| 255 static_cast<double>(num_frames) / duration.InMillisecondsF() * 1000); | 255 static_cast<double>(num_frames) / duration.InMillisecondsF() * 1000); |
| 256 } | 256 } |
| 257 | 257 |
| 258 TEST_F(StatsEventSubscriberTest, PlayoutDelay) { | 258 TEST_F(StatsEventSubscriberTest, PlayoutDelay) { |
| 259 Init(VIDEO_EVENT); | 259 Init(VIDEO_EVENT); |
| 260 | 260 |
| 261 uint32_t rtp_timestamp = 0; | 261 RtpTimeTicks rtp_timestamp; |
| 262 uint32_t frame_id = 0; | 262 uint32_t frame_id = 0; |
| 263 int num_frames = 10; | 263 int num_frames = 10; |
| 264 int late_frames = 0; | 264 int late_frames = 0; |
| 265 for (int i = 0, delay_ms = -50; i < num_frames; i++, delay_ms += 10) { | 265 for (int i = 0, delay_ms = -50; i < num_frames; i++, delay_ms += 10) { |
| 266 base::TimeDelta delay = base::TimeDelta::FromMilliseconds(delay_ms); | 266 base::TimeDelta delay = base::TimeDelta::FromMilliseconds(delay_ms); |
| 267 if (delay_ms > 0) | 267 if (delay_ms > 0) |
| 268 late_frames++; | 268 late_frames++; |
| 269 scoped_ptr<FrameEvent> playout_event(new FrameEvent()); | 269 scoped_ptr<FrameEvent> playout_event(new FrameEvent()); |
| 270 playout_event->timestamp = receiver_clock_.NowTicks(); | 270 playout_event->timestamp = receiver_clock_.NowTicks(); |
| 271 playout_event->type = FRAME_PLAYOUT; | 271 playout_event->type = FRAME_PLAYOUT; |
| 272 playout_event->media_type = VIDEO_EVENT; | 272 playout_event->media_type = VIDEO_EVENT; |
| 273 playout_event->rtp_timestamp = rtp_timestamp; | 273 playout_event->rtp_timestamp = rtp_timestamp; |
| 274 playout_event->frame_id = frame_id; | 274 playout_event->frame_id = frame_id; |
| 275 playout_event->delay_delta = delay; | 275 playout_event->delay_delta = delay; |
| 276 cast_environment_->logger()->DispatchFrameEvent(std::move(playout_event)); | 276 cast_environment_->logger()->DispatchFrameEvent(std::move(playout_event)); |
| 277 | 277 |
| 278 AdvanceClocks(base::TimeDelta::FromMicroseconds(37890)); | 278 AdvanceClocks(base::TimeDelta::FromMicroseconds(37890)); |
| 279 rtp_timestamp += 90; | 279 rtp_timestamp += RtpTimeDelta::FromTicks(90); |
| 280 frame_id++; | 280 frame_id++; |
| 281 } | 281 } |
| 282 | 282 |
| 283 StatsEventSubscriber::StatsMap stats_map; | 283 StatsEventSubscriber::StatsMap stats_map; |
| 284 subscriber_->GetStatsInternal(&stats_map); | 284 subscriber_->GetStatsInternal(&stats_map); |
| 285 | 285 |
| 286 StatsEventSubscriber::StatsMap::iterator it = stats_map.find( | 286 StatsEventSubscriber::StatsMap::iterator it = stats_map.find( |
| 287 StatsEventSubscriber::NUM_FRAMES_LATE); | 287 StatsEventSubscriber::NUM_FRAMES_LATE); |
| 288 ASSERT_TRUE(it != stats_map.end()); | 288 ASSERT_TRUE(it != stats_map.end()); |
| 289 | 289 |
| 290 EXPECT_DOUBLE_EQ(it->second, late_frames); | 290 EXPECT_DOUBLE_EQ(it->second, late_frames); |
| 291 } | 291 } |
| 292 | 292 |
| 293 TEST_F(StatsEventSubscriberTest, E2ELatency) { | 293 TEST_F(StatsEventSubscriberTest, E2ELatency) { |
| 294 Init(VIDEO_EVENT); | 294 Init(VIDEO_EVENT); |
| 295 | 295 |
| 296 uint32_t rtp_timestamp = 0; | 296 RtpTimeTicks rtp_timestamp; |
| 297 uint32_t frame_id = 0; | 297 uint32_t frame_id = 0; |
| 298 int num_frames = 10; | 298 int num_frames = 10; |
| 299 base::TimeDelta total_latency; | 299 base::TimeDelta total_latency; |
| 300 for (int i = 0; i < num_frames; i++) { | 300 for (int i = 0; i < num_frames; i++) { |
| 301 scoped_ptr<FrameEvent> capture_begin_event(new FrameEvent()); | 301 scoped_ptr<FrameEvent> capture_begin_event(new FrameEvent()); |
| 302 capture_begin_event->timestamp = sender_clock_->NowTicks(); | 302 capture_begin_event->timestamp = sender_clock_->NowTicks(); |
| 303 capture_begin_event->type = FRAME_CAPTURE_BEGIN; | 303 capture_begin_event->type = FRAME_CAPTURE_BEGIN; |
| 304 capture_begin_event->media_type = VIDEO_EVENT; | 304 capture_begin_event->media_type = VIDEO_EVENT; |
| 305 capture_begin_event->rtp_timestamp = rtp_timestamp; | 305 capture_begin_event->rtp_timestamp = rtp_timestamp; |
| 306 cast_environment_->logger()->DispatchFrameEvent( | 306 cast_environment_->logger()->DispatchFrameEvent( |
| 307 std::move(capture_begin_event)); | 307 std::move(capture_begin_event)); |
| 308 | 308 |
| 309 int latency_micros = 100000 + base::RandInt(-5000, 50000); | 309 int latency_micros = 100000 + base::RandInt(-5000, 50000); |
| 310 base::TimeDelta latency = base::TimeDelta::FromMicroseconds(latency_micros); | 310 base::TimeDelta latency = base::TimeDelta::FromMicroseconds(latency_micros); |
| 311 AdvanceClocks(latency); | 311 AdvanceClocks(latency); |
| 312 | 312 |
| 313 int delay_micros = base::RandInt(-50000, 50000); | 313 int delay_micros = base::RandInt(-50000, 50000); |
| 314 base::TimeDelta delay = base::TimeDelta::FromMilliseconds(delay_micros); | 314 base::TimeDelta delay = base::TimeDelta::FromMilliseconds(delay_micros); |
| 315 total_latency += latency; | 315 total_latency += latency; |
| 316 | 316 |
| 317 scoped_ptr<FrameEvent> playout_event(new FrameEvent()); | 317 scoped_ptr<FrameEvent> playout_event(new FrameEvent()); |
| 318 playout_event->timestamp = receiver_clock_.NowTicks(); | 318 playout_event->timestamp = receiver_clock_.NowTicks(); |
| 319 playout_event->type = FRAME_PLAYOUT; | 319 playout_event->type = FRAME_PLAYOUT; |
| 320 playout_event->media_type = VIDEO_EVENT; | 320 playout_event->media_type = VIDEO_EVENT; |
| 321 playout_event->rtp_timestamp = rtp_timestamp; | 321 playout_event->rtp_timestamp = rtp_timestamp; |
| 322 playout_event->frame_id = frame_id; | 322 playout_event->frame_id = frame_id; |
| 323 playout_event->delay_delta = delay; | 323 playout_event->delay_delta = delay; |
| 324 cast_environment_->logger()->DispatchFrameEvent(std::move(playout_event)); | 324 cast_environment_->logger()->DispatchFrameEvent(std::move(playout_event)); |
| 325 | 325 |
| 326 rtp_timestamp += 90; | 326 rtp_timestamp += RtpTimeDelta::FromTicks(90); |
| 327 frame_id++; | 327 frame_id++; |
| 328 } | 328 } |
| 329 | 329 |
| 330 StatsEventSubscriber::StatsMap stats_map; | 330 StatsEventSubscriber::StatsMap stats_map; |
| 331 subscriber_->GetStatsInternal(&stats_map); | 331 subscriber_->GetStatsInternal(&stats_map); |
| 332 | 332 |
| 333 StatsEventSubscriber::StatsMap::iterator it = | 333 StatsEventSubscriber::StatsMap::iterator it = |
| 334 stats_map.find(StatsEventSubscriber::AVG_E2E_LATENCY_MS); | 334 stats_map.find(StatsEventSubscriber::AVG_E2E_LATENCY_MS); |
| 335 ASSERT_TRUE(it != stats_map.end()); | 335 ASSERT_TRUE(it != stats_map.end()); |
| 336 | 336 |
| 337 EXPECT_DOUBLE_EQ( | 337 EXPECT_DOUBLE_EQ( |
| 338 it->second, total_latency.InMillisecondsF() / num_frames); | 338 it->second, total_latency.InMillisecondsF() / num_frames); |
| 339 } | 339 } |
| 340 | 340 |
| 341 TEST_F(StatsEventSubscriberTest, Packets) { | 341 TEST_F(StatsEventSubscriberTest, Packets) { |
| 342 Init(VIDEO_EVENT); | 342 Init(VIDEO_EVENT); |
| 343 | 343 |
| 344 uint32_t rtp_timestamp = 0; | 344 RtpTimeTicks rtp_timestamp; |
| 345 int num_packets = 10; | 345 int num_packets = 10; |
| 346 int num_latency_recorded_packets = 0; | 346 int num_latency_recorded_packets = 0; |
| 347 base::TimeTicks start_time = sender_clock_->NowTicks(); | 347 base::TimeTicks start_time = sender_clock_->NowTicks(); |
| 348 int total_size = 0; | 348 int total_size = 0; |
| 349 int retransmit_total_size = 0; | 349 int retransmit_total_size = 0; |
| 350 base::TimeDelta total_network_latency; | 350 base::TimeDelta total_network_latency; |
| 351 base::TimeDelta total_queueing_latency; | 351 base::TimeDelta total_queueing_latency; |
| 352 base::TimeDelta total_packet_latency; | 352 base::TimeDelta total_packet_latency; |
| 353 int num_packets_transmitted = 0; | 353 int num_packets_transmitted = 0; |
| 354 int num_packets_received = 0; | 354 int num_packets_received = 0; |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 561 return false; | 561 return false; |
| 562 return bucket_count == expected_count; | 562 return bucket_count == expected_count; |
| 563 } | 563 } |
| 564 return false; | 564 return false; |
| 565 } | 565 } |
| 566 | 566 |
| 567 TEST_F(StatsEventSubscriberTest, Histograms) { | 567 TEST_F(StatsEventSubscriberTest, Histograms) { |
| 568 Init(VIDEO_EVENT); | 568 Init(VIDEO_EVENT); |
| 569 AdvanceClocks(base::TimeDelta::FromMilliseconds(123)); | 569 AdvanceClocks(base::TimeDelta::FromMilliseconds(123)); |
| 570 | 570 |
| 571 uint32_t rtp_timestamp = 123; | 571 RtpTimeTicks rtp_timestamp = RtpTimeTicks().Expand(UINT32_C(123)); |
| 572 uint32_t frame_id = 0; | 572 uint32_t frame_id = 0; |
| 573 | 573 |
| 574 // 10 Frames with capture latency in the bucket of "10-14"ms. | 574 // 10 Frames with capture latency in the bucket of "10-14"ms. |
| 575 // 10 Frames with encode time in the bucket of "15-19"ms. | 575 // 10 Frames with encode time in the bucket of "15-19"ms. |
| 576 for (int i = 0; i < 10; ++i) { | 576 for (int i = 0; i < 10; ++i) { |
| 577 ++frame_id; | 577 ++frame_id; |
| 578 ++rtp_timestamp; | 578 rtp_timestamp += RtpTimeDelta::FromTicks(1); |
| 579 | 579 |
| 580 scoped_ptr<FrameEvent> capture_begin_event(new FrameEvent()); | 580 scoped_ptr<FrameEvent> capture_begin_event(new FrameEvent()); |
| 581 capture_begin_event->timestamp = sender_clock_->NowTicks(); | 581 capture_begin_event->timestamp = sender_clock_->NowTicks(); |
| 582 capture_begin_event->type = FRAME_CAPTURE_BEGIN; | 582 capture_begin_event->type = FRAME_CAPTURE_BEGIN; |
| 583 capture_begin_event->media_type = VIDEO_EVENT; | 583 capture_begin_event->media_type = VIDEO_EVENT; |
| 584 capture_begin_event->rtp_timestamp = rtp_timestamp; | 584 capture_begin_event->rtp_timestamp = rtp_timestamp; |
| 585 cast_environment_->logger()->DispatchFrameEvent( | 585 cast_environment_->logger()->DispatchFrameEvent( |
| 586 std::move(capture_begin_event)); | 586 std::move(capture_begin_event)); |
| 587 | 587 |
| 588 AdvanceClocks(base::TimeDelta::FromMilliseconds(10)); | 588 AdvanceClocks(base::TimeDelta::FromMilliseconds(10)); |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 690 | 690 |
| 691 histogram = subscriber_->GetHistogramForTesting( | 691 histogram = subscriber_->GetHistogramForTesting( |
| 692 StatsEventSubscriber::LATE_FRAME_MS_HISTO); | 692 StatsEventSubscriber::LATE_FRAME_MS_HISTO); |
| 693 ASSERT_TRUE(histogram); | 693 ASSERT_TRUE(histogram); |
| 694 values = histogram->GetHistogram(); | 694 values = histogram->GetHistogram(); |
| 695 EXPECT_TRUE(CheckHistogramHasValue(values.get(), "100-119", 1)); | 695 EXPECT_TRUE(CheckHistogramHasValue(values.get(), "100-119", 1)); |
| 696 } | 696 } |
| 697 | 697 |
| 698 } // namespace cast | 698 } // namespace cast |
| 699 } // namespace media | 699 } // namespace media |
| OLD | NEW |