OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 // This test generate synthetic data. For audio it's a sinusoid waveform with | 5 // This test generate synthetic data. For audio it's a sinusoid waveform with |
6 // frequency kSoundFrequency and different amplitudes. For video it's a pattern | 6 // frequency kSoundFrequency and different amplitudes. For video it's a pattern |
7 // that is shifting by one pixel per frame, each pixels neighbors right and down | 7 // that is shifting by one pixel per frame, each pixels neighbors right and down |
8 // is this pixels value +1, since the pixel value is 8 bit it will wrap | 8 // is this pixels value +1, since the pixel value is 8 bit it will wrap |
9 // frequently within the image. Visually this will create diagonally color bands | 9 // frequently within the image. Visually this will create diagonally color bands |
10 // that moves across the screen | 10 // that moves across the screen |
(...skipping 26 matching lines...) Expand all Loading... | |
37 | 37 |
38 namespace media { | 38 namespace media { |
39 namespace cast { | 39 namespace cast { |
40 | 40 |
41 namespace { | 41 namespace { |
42 | 42 |
43 static const int64 kStartMillisecond = GG_INT64_C(1245); | 43 static const int64 kStartMillisecond = GG_INT64_C(1245); |
44 static const int kAudioChannels = 2; | 44 static const int kAudioChannels = 2; |
45 static const double kSoundFrequency = 314.15926535897; // Freq of sine wave. | 45 static const double kSoundFrequency = 314.15926535897; // Freq of sine wave. |
46 static const float kSoundVolume = 0.5f; | 46 static const float kSoundVolume = 0.5f; |
47 static const int kVideoWidth = 1280; | 47 static const int kVideoHdWidth = 1280; |
48 static const int kVideoHeight = 720; | 48 static const int kVideoHdHeight = 720; |
49 static const int kVideoQcifWidth = 176; | |
50 static const int kVideoQcifHeight = 144; | |
49 static const int kCommonRtpHeaderLength = 12; | 51 static const int kCommonRtpHeaderLength = 12; |
50 static const uint8 kCastReferenceFrameIdBitReset = 0xDF; // Mask is 0x40. | 52 static const uint8 kCastReferenceFrameIdBitReset = 0xDF; // Mask is 0x40. |
51 | 53 |
52 // Since the video encoded and decoded an error will be introduced; when | 54 // Since the video encoded and decoded an error will be introduced; when |
53 // comparing individual pixels the error can be quite large; we allow a PSNR of | 55 // comparing individual pixels the error can be quite large; we allow a PSNR of |
54 // at least |kVideoAcceptedPSNR|. | 56 // at least |kVideoAcceptedPSNR|. |
55 static const double kVideoAcceptedPSNR = 38.0; | 57 static const double kVideoAcceptedPSNR = 38.0; |
56 | 58 |
57 // The tests are commonly implemented with |kFrameTimerMs| RunTask function; | 59 // The tests are commonly implemented with |kFrameTimerMs| RunTask function; |
58 // a normal video is 30 fps hence the 33 ms between frames. | 60 // a normal video is 30 fps hence the 33 ms between frames. |
59 static const int kFrameTimerMs = 33; | 61 static const int kFrameTimerMs = 33; |
60 | 62 |
61 // The packets pass through the pacer which can delay the beginning of the | 63 // The packets pass through the pacer which can delay the beginning of the |
62 // frame by 10 ms if there is packets belonging to the previous frame being | 64 // frame by 10 ms if there is packets belonging to the previous frame being |
63 // retransmitted. | 65 // retransmitted. |
64 static const int kTimerErrorMs = 15; | 66 static const int kTimerErrorMs = 20; |
pwestin
2014/02/12 21:16:43
please add your findings to where these 20 ms orig
mikhal1
2014/02/12 23:21:05
Done.
| |
67 | |
68 // Start the video synthetic start value to medium range value, to avoid edge | |
69 // effects cause by encoding and quantization. | |
70 static const int kVideoStart = 100; | |
65 | 71 |
66 std::string ConvertFromBase16String(const std::string base_16) { | 72 std::string ConvertFromBase16String(const std::string base_16) { |
67 std::string compressed; | 73 std::string compressed; |
68 DCHECK_EQ(base_16.size() % 2, 0u) << "Must be a multiple of 2"; | 74 DCHECK_EQ(base_16.size() % 2, 0u) << "Must be a multiple of 2"; |
69 compressed.reserve(base_16.size() / 2); | 75 compressed.reserve(base_16.size() / 2); |
70 | 76 |
71 std::vector<uint8> v; | 77 std::vector<uint8> v; |
72 if (!base::HexStringToBytes(base_16, &v)) { | 78 if (!base::HexStringToBytes(base_16, &v)) { |
73 NOTREACHED(); | 79 NOTREACHED(); |
74 } | 80 } |
(...skipping 13 matching lines...) Expand all Loading... | |
88 typedef struct { | 94 typedef struct { |
89 int counter[kNumOfLoggingEvents]; | 95 int counter[kNumOfLoggingEvents]; |
90 } LoggingEventCounts; | 96 } LoggingEventCounts; |
91 | 97 |
92 // Constructs a map from each frame (RTP timestamp) to counts of each event | 98 // Constructs a map from each frame (RTP timestamp) to counts of each event |
93 // type logged for that frame. | 99 // type logged for that frame. |
94 std::map<RtpTimestamp, LoggingEventCounts> GetEventCountForFrameEvents( | 100 std::map<RtpTimestamp, LoggingEventCounts> GetEventCountForFrameEvents( |
95 const std::vector<FrameEvent>& frame_events) { | 101 const std::vector<FrameEvent>& frame_events) { |
96 std::map<RtpTimestamp, LoggingEventCounts> event_counter_for_frame; | 102 std::map<RtpTimestamp, LoggingEventCounts> event_counter_for_frame; |
97 for (std::vector<FrameEvent>::const_iterator it = frame_events.begin(); | 103 for (std::vector<FrameEvent>::const_iterator it = frame_events.begin(); |
98 it != frame_events.end(); ++it) { | 104 it != frame_events.end(); |
105 ++it) { | |
99 std::map<RtpTimestamp, LoggingEventCounts>::iterator map_it = | 106 std::map<RtpTimestamp, LoggingEventCounts>::iterator map_it = |
100 event_counter_for_frame.find(it->rtp_timestamp); | 107 event_counter_for_frame.find(it->rtp_timestamp); |
101 if (map_it == event_counter_for_frame.end()) { | 108 if (map_it == event_counter_for_frame.end()) { |
102 LoggingEventCounts new_counter; | 109 LoggingEventCounts new_counter; |
103 memset(&new_counter, 0, sizeof(new_counter)); | 110 memset(&new_counter, 0, sizeof(new_counter)); |
104 ++(new_counter.counter[it->type]); | 111 ++(new_counter.counter[it->type]); |
105 event_counter_for_frame.insert( | 112 event_counter_for_frame.insert( |
106 std::make_pair(it->rtp_timestamp, new_counter)); | 113 std::make_pair(it->rtp_timestamp, new_counter)); |
107 } else { | 114 } else { |
108 ++(map_it->second.counter[it->type]); | 115 ++(map_it->second.counter[it->type]); |
109 } | 116 } |
110 } | 117 } |
111 return event_counter_for_frame; | 118 return event_counter_for_frame; |
112 } | 119 } |
113 | 120 |
114 // Constructs a map from each packet (Packet ID) to counts of each event | 121 // Constructs a map from each packet (Packet ID) to counts of each event |
115 // type logged for that packet. | 122 // type logged for that packet. |
116 std::map<uint16, LoggingEventCounts> GetEventCountForPacketEvents( | 123 std::map<uint16, LoggingEventCounts> GetEventCountForPacketEvents( |
117 const std::vector<PacketEvent>& packet_events) { | 124 const std::vector<PacketEvent>& packet_events) { |
118 std::map<uint16, LoggingEventCounts> event_counter_for_packet; | 125 std::map<uint16, LoggingEventCounts> event_counter_for_packet; |
119 for (std::vector<PacketEvent>::const_iterator it = packet_events.begin(); | 126 for (std::vector<PacketEvent>::const_iterator it = packet_events.begin(); |
120 it != packet_events.end(); ++it) { | 127 it != packet_events.end(); |
128 ++it) { | |
121 std::map<uint16, LoggingEventCounts>::iterator map_it = | 129 std::map<uint16, LoggingEventCounts>::iterator map_it = |
122 event_counter_for_packet.find(it->packet_id); | 130 event_counter_for_packet.find(it->packet_id); |
123 if (map_it == event_counter_for_packet.end()) { | 131 if (map_it == event_counter_for_packet.end()) { |
124 LoggingEventCounts new_counter; | 132 LoggingEventCounts new_counter; |
125 memset(&new_counter, 0, sizeof(new_counter)); | 133 memset(&new_counter, 0, sizeof(new_counter)); |
126 ++(new_counter.counter[it->type]); | 134 ++(new_counter.counter[it->type]); |
127 event_counter_for_packet.insert( | 135 event_counter_for_packet.insert( |
128 std::make_pair(it->packet_id, new_counter)); | 136 std::make_pair(it->packet_id, new_counter)); |
129 } else { | 137 } else { |
130 ++(map_it->second.counter[it->type]); | 138 ++(map_it->second.counter[it->type]); |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
246 const base::TimeTicks& playout_time) { | 254 const base::TimeTicks& playout_time) { |
247 ++num_called_; | 255 ++num_called_; |
248 | 256 |
249 CheckBasicAudioFrame(audio_frame, playout_time); | 257 CheckBasicAudioFrame(audio_frame, playout_time); |
250 ExpectedAudioFrame expected_audio_frame = expected_frame_.front(); | 258 ExpectedAudioFrame expected_audio_frame = expected_frame_.front(); |
251 expected_frame_.pop_front(); | 259 expected_frame_.pop_front(); |
252 if (audio_frame->samples.size() == 0) | 260 if (audio_frame->samples.size() == 0) |
253 return; // No more checks needed. | 261 return; // No more checks needed. |
254 | 262 |
255 EXPECT_NEAR(CountZeroCrossings(expected_audio_frame.audio_frame.samples), | 263 EXPECT_NEAR(CountZeroCrossings(expected_audio_frame.audio_frame.samples), |
256 CountZeroCrossings(audio_frame->samples), 1); | 264 CountZeroCrossings(audio_frame->samples), |
265 1); | |
257 } | 266 } |
258 | 267 |
259 void CheckCodedPcmAudioFrame( | 268 void CheckCodedPcmAudioFrame( |
260 scoped_ptr<transport::EncodedAudioFrame> audio_frame, | 269 scoped_ptr<transport::EncodedAudioFrame> audio_frame, |
261 const base::TimeTicks& playout_time) { | 270 const base::TimeTicks& playout_time) { |
262 ++num_called_; | 271 ++num_called_; |
263 | 272 |
264 EXPECT_FALSE(expected_frame_.empty()); // Test for bug in test code. | 273 EXPECT_FALSE(expected_frame_.empty()); // Test for bug in test code. |
265 ExpectedAudioFrame expected_audio_frame = expected_frame_.front(); | 274 ExpectedAudioFrame expected_audio_frame = expected_frame_.front(); |
266 expected_frame_.pop_front(); | 275 expected_frame_.pop_front(); |
(...skipping 17 matching lines...) Expand all Loading... | |
284 size_t number_of_samples = audio_frame->data.size() / 2; | 293 size_t number_of_samples = audio_frame->data.size() / 2; |
285 | 294 |
286 for (size_t i = 0; i < number_of_samples; ++i) { | 295 for (size_t i = 0; i < number_of_samples; ++i) { |
287 uint16 sample = | 296 uint16 sample = |
288 static_cast<uint8>(audio_frame->data[1 + i * sizeof(uint16)]) + | 297 static_cast<uint8>(audio_frame->data[1 + i * sizeof(uint16)]) + |
289 (static_cast<uint16>(audio_frame->data[i * sizeof(uint16)]) << 8); | 298 (static_cast<uint16>(audio_frame->data[i * sizeof(uint16)]) << 8); |
290 output_audio_samples.push_back(static_cast<int16>(sample)); | 299 output_audio_samples.push_back(static_cast<int16>(sample)); |
291 } | 300 } |
292 | 301 |
293 EXPECT_NEAR(CountZeroCrossings(expected_audio_frame.audio_frame.samples), | 302 EXPECT_NEAR(CountZeroCrossings(expected_audio_frame.audio_frame.samples), |
294 CountZeroCrossings(output_audio_samples), 1); | 303 CountZeroCrossings(output_audio_samples), |
304 1); | |
295 } | 305 } |
296 | 306 |
297 int number_times_called() const { return num_called_; } | 307 int number_times_called() const { return num_called_; } |
298 | 308 |
299 protected: | 309 protected: |
300 virtual ~TestReceiverAudioCallback() {} | 310 virtual ~TestReceiverAudioCallback() {} |
301 | 311 |
302 private: | 312 private: |
303 friend class base::RefCountedThreadSafe<TestReceiverAudioCallback>; | 313 friend class base::RefCountedThreadSafe<TestReceiverAudioCallback>; |
304 | 314 |
305 int num_called_; | 315 int num_called_; |
306 int expected_sampling_frequency_; | 316 int expected_sampling_frequency_; |
307 std::list<ExpectedAudioFrame> expected_frame_; | 317 std::list<ExpectedAudioFrame> expected_frame_; |
308 }; | 318 }; |
309 | 319 |
310 // Class that verifies the video frames coming out of the receiver. | 320 // Class that verifies the video frames coming out of the receiver. |
311 class TestReceiverVideoCallback | 321 class TestReceiverVideoCallback |
312 : public base::RefCountedThreadSafe<TestReceiverVideoCallback> { | 322 : public base::RefCountedThreadSafe<TestReceiverVideoCallback> { |
313 public: | 323 public: |
314 struct ExpectedVideoFrame { | 324 struct ExpectedVideoFrame { |
315 int start_value; | 325 int start_value; |
316 int width; | 326 int width; |
317 int height; | 327 int height; |
318 base::TimeTicks capture_time; | 328 base::TimeTicks capture_time; |
319 }; | 329 }; |
320 | 330 |
321 TestReceiverVideoCallback() : num_called_(0) {} | 331 TestReceiverVideoCallback() : num_called_(0) {} |
322 | 332 |
323 void AddExpectedResult(int start_value, int width, int height, | 333 void AddExpectedResult(int start_value, |
334 int width, | |
335 int height, | |
324 const base::TimeTicks& capture_time) { | 336 const base::TimeTicks& capture_time) { |
325 ExpectedVideoFrame expected_video_frame; | 337 ExpectedVideoFrame expected_video_frame; |
326 expected_video_frame.start_value = start_value; | 338 expected_video_frame.start_value = start_value; |
327 expected_video_frame.capture_time = capture_time; | 339 expected_video_frame.capture_time = capture_time; |
328 expected_video_frame.width = width; | 340 expected_video_frame.width = width; |
329 expected_video_frame.height = height; | 341 expected_video_frame.height = height; |
330 expected_frame_.push_back(expected_video_frame); | 342 expected_frame_.push_back(expected_video_frame); |
331 } | 343 } |
332 | 344 |
333 void CheckVideoFrame(const scoped_refptr<media::VideoFrame>& video_frame, | 345 void CheckVideoFrame(const scoped_refptr<media::VideoFrame>& video_frame, |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
372 }; | 384 }; |
373 | 385 |
374 // The actual test class, generate synthetic data for both audio and video and | 386 // The actual test class, generate synthetic data for both audio and video and |
375 // send those through the sender and receiver and analyzes the result. | 387 // send those through the sender and receiver and analyzes the result. |
376 class End2EndTest : public ::testing::Test { | 388 class End2EndTest : public ::testing::Test { |
377 protected: | 389 protected: |
378 End2EndTest() | 390 End2EndTest() |
379 : start_time_(), | 391 : start_time_(), |
380 testing_clock_(new base::SimpleTestTickClock()), | 392 testing_clock_(new base::SimpleTestTickClock()), |
381 task_runner_(new test::FakeSingleThreadTaskRunner(testing_clock_)), | 393 task_runner_(new test::FakeSingleThreadTaskRunner(testing_clock_)), |
382 transport_task_runner_( | |
383 new test::FakeSingleThreadTaskRunner(testing_clock_)), | |
384 cast_environment_(new CastEnvironment( | 394 cast_environment_(new CastEnvironment( |
385 scoped_ptr<base::TickClock>(testing_clock_).Pass(), | 395 scoped_ptr<base::TickClock>(testing_clock_).Pass(), |
386 task_runner_, | 396 task_runner_, |
387 task_runner_, | 397 task_runner_, |
388 task_runner_, | 398 task_runner_, |
389 task_runner_, | 399 task_runner_, |
390 task_runner_, | 400 task_runner_, |
391 task_runner_, | 401 task_runner_, |
392 GetLoggingConfigWithRawEventsAndStatsEnabled())), | 402 GetLoggingConfigWithRawEventsAndStatsEnabled())), |
393 receiver_to_sender_(cast_environment_), | 403 receiver_to_sender_(cast_environment_), |
(...skipping 30 matching lines...) Expand all Loading... | |
424 audio_receiver_config_.channels = kAudioChannels; | 434 audio_receiver_config_.channels = kAudioChannels; |
425 audio_receiver_config_.codec = audio_sender_config_.codec; | 435 audio_receiver_config_.codec = audio_sender_config_.codec; |
426 | 436 |
427 test_receiver_audio_callback_->SetExpectedSamplingFrequency( | 437 test_receiver_audio_callback_->SetExpectedSamplingFrequency( |
428 audio_receiver_config_.frequency); | 438 audio_receiver_config_.frequency); |
429 | 439 |
430 video_sender_config_.sender_ssrc = 3; | 440 video_sender_config_.sender_ssrc = 3; |
431 video_sender_config_.incoming_feedback_ssrc = 4; | 441 video_sender_config_.incoming_feedback_ssrc = 4; |
432 video_sender_config_.rtp_config.payload_type = 97; | 442 video_sender_config_.rtp_config.payload_type = 97; |
433 video_sender_config_.use_external_encoder = false; | 443 video_sender_config_.use_external_encoder = false; |
434 video_sender_config_.width = kVideoWidth; | 444 video_sender_config_.width = kVideoHdWidth; |
435 video_sender_config_.height = kVideoHeight; | 445 video_sender_config_.height = kVideoHdHeight; |
436 video_sender_config_.max_bitrate = 5000000; | 446 video_sender_config_.max_bitrate = 5000000; |
437 video_sender_config_.min_bitrate = 1000000; | 447 video_sender_config_.min_bitrate = 1000000; |
438 video_sender_config_.start_bitrate = 5000000; | 448 video_sender_config_.start_bitrate = 5000000; |
439 video_sender_config_.max_qp = 30; | 449 video_sender_config_.max_qp = 30; |
440 video_sender_config_.min_qp = 4; | 450 video_sender_config_.min_qp = 4; |
441 video_sender_config_.max_frame_rate = 30; | 451 video_sender_config_.max_frame_rate = 30; |
442 video_sender_config_.max_number_of_video_buffers_used = | 452 video_sender_config_.max_number_of_video_buffers_used = |
443 max_number_of_video_buffers_used; | 453 max_number_of_video_buffers_used; |
444 video_sender_config_.codec = transport::kVp8; | 454 video_sender_config_.codec = transport::kVp8; |
445 video_sender_config_.number_of_cores = 1; | 455 video_sender_config_.number_of_cores = 1; |
(...skipping 19 matching lines...) Expand all Loading... | |
465 void Create() { | 475 void Create() { |
466 cast_receiver_.reset( | 476 cast_receiver_.reset( |
467 CastReceiver::CreateCastReceiver(cast_environment_, | 477 CastReceiver::CreateCastReceiver(cast_environment_, |
468 audio_receiver_config_, | 478 audio_receiver_config_, |
469 video_receiver_config_, | 479 video_receiver_config_, |
470 &receiver_to_sender_)); | 480 &receiver_to_sender_)); |
471 transport_sender_.reset(new transport::CastTransportSenderImpl( | 481 transport_sender_.reset(new transport::CastTransportSenderImpl( |
472 testing_clock_, | 482 testing_clock_, |
473 transport_config_, | 483 transport_config_, |
474 base::Bind(&UpdateCastTransportStatus), | 484 base::Bind(&UpdateCastTransportStatus), |
475 transport_task_runner_, | 485 task_runner_, |
476 &sender_to_receiver_)); | 486 &sender_to_receiver_)); |
477 | 487 |
478 cast_sender_.reset(CastSender::CreateCastSender( | 488 cast_sender_.reset(CastSender::CreateCastSender( |
479 cast_environment_, | 489 cast_environment_, |
480 &audio_sender_config_, | 490 &audio_sender_config_, |
481 &video_sender_config_, | 491 &video_sender_config_, |
482 NULL, | 492 NULL, |
483 base::Bind(&End2EndTest::InitializationResult, base::Unretained(this)), | 493 base::Bind(&End2EndTest::InitializationResult, base::Unretained(this)), |
484 transport_sender_.get())); | 494 transport_sender_.get())); |
485 | 495 |
(...skipping 16 matching lines...) Expand all Loading... | |
502 | 512 |
503 virtual void TearDown() OVERRIDE { | 513 virtual void TearDown() OVERRIDE { |
504 | 514 |
505 cast_sender_.reset(); | 515 cast_sender_.reset(); |
506 cast_receiver_.reset(); | 516 cast_receiver_.reset(); |
507 task_runner_->RunTasks(); | 517 task_runner_->RunTasks(); |
508 } | 518 } |
509 | 519 |
510 void SendVideoFrame(int start_value, const base::TimeTicks& capture_time) { | 520 void SendVideoFrame(int start_value, const base::TimeTicks& capture_time) { |
511 if (start_time_.is_null()) | 521 if (start_time_.is_null()) |
512 start_time_ = testing_clock_->NowTicks(); | 522 start_time_ = capture_time; |
513 start_time_ = testing_clock_->NowTicks(); | 523 base::TimeDelta time_diff = capture_time - start_time_; |
514 base::TimeDelta time_diff = testing_clock_->NowTicks() - start_time_; | 524 gfx::Size size(video_sender_config_.width, video_sender_config_.height); |
515 gfx::Size size(kVideoWidth, kVideoHeight); | |
516 EXPECT_TRUE(VideoFrame::IsValidConfig( | 525 EXPECT_TRUE(VideoFrame::IsValidConfig( |
517 VideoFrame::I420, size, gfx::Rect(size), size)); | 526 VideoFrame::I420, size, gfx::Rect(size), size)); |
518 scoped_refptr<media::VideoFrame> video_frame = | 527 scoped_refptr<media::VideoFrame> video_frame = |
519 media::VideoFrame::CreateFrame( | 528 media::VideoFrame::CreateFrame( |
520 VideoFrame::I420, size, gfx::Rect(size), size, time_diff); | 529 VideoFrame::I420, size, gfx::Rect(size), size, time_diff); |
521 PopulateVideoFrame(video_frame, start_value); | 530 PopulateVideoFrame(video_frame, start_value); |
522 frame_input_->InsertRawVideoFrame(video_frame, capture_time); | 531 frame_input_->InsertRawVideoFrame(video_frame, capture_time); |
523 } | 532 } |
524 | 533 |
525 void RunTasks(int during_ms) { | 534 void RunTasks(int during_ms) { |
526 for (int i = 0; i < during_ms; ++i) { | 535 for (int i = 0; i < during_ms; ++i) { |
527 // Call process the timers every 1 ms. | 536 // Call process the timers every 1 ms. |
528 testing_clock_->Advance(base::TimeDelta::FromMilliseconds(1)); | 537 testing_clock_->Advance(base::TimeDelta::FromMilliseconds(1)); |
529 task_runner_->RunTasks(); | 538 task_runner_->RunTasks(); |
530 transport_task_runner_->RunTasks(); | |
531 } | 539 } |
532 } | 540 } |
533 | 541 |
534 void InitializationResult(CastInitializationStatus result) { | 542 void InitializationResult(CastInitializationStatus result) { |
535 EXPECT_EQ(result, STATUS_INITIALIZED); | 543 EXPECT_EQ(result, STATUS_INITIALIZED); |
536 } | 544 } |
537 | 545 |
538 AudioReceiverConfig audio_receiver_config_; | 546 AudioReceiverConfig audio_receiver_config_; |
539 VideoReceiverConfig video_receiver_config_; | 547 VideoReceiverConfig video_receiver_config_; |
540 AudioSenderConfig audio_sender_config_; | 548 AudioSenderConfig audio_sender_config_; |
541 VideoSenderConfig video_sender_config_; | 549 VideoSenderConfig video_sender_config_; |
542 transport::CastTransportConfig transport_config_; | 550 transport::CastTransportConfig transport_config_; |
543 | 551 |
544 base::TimeTicks start_time_; | 552 base::TimeTicks start_time_; |
545 base::SimpleTestTickClock* testing_clock_; // Owned by CastEnvironment. | 553 base::SimpleTestTickClock* testing_clock_; |
546 scoped_refptr<test::FakeSingleThreadTaskRunner> task_runner_; | 554 scoped_refptr<test::FakeSingleThreadTaskRunner> task_runner_; |
547 scoped_refptr<test::FakeSingleThreadTaskRunner> transport_task_runner_; | |
548 scoped_refptr<CastEnvironment> cast_environment_; | 555 scoped_refptr<CastEnvironment> cast_environment_; |
549 | 556 |
550 LoopBackTransport receiver_to_sender_; | 557 LoopBackTransport receiver_to_sender_; |
551 LoopBackTransport sender_to_receiver_; | 558 LoopBackTransport sender_to_receiver_; |
552 scoped_ptr<transport::CastTransportSenderImpl> transport_sender_; | 559 scoped_ptr<transport::CastTransportSenderImpl> transport_sender_; |
553 | 560 |
554 scoped_ptr<CastReceiver> cast_receiver_; | 561 scoped_ptr<CastReceiver> cast_receiver_; |
555 scoped_ptr<CastSender> cast_sender_; | 562 scoped_ptr<CastSender> cast_sender_; |
556 scoped_refptr<FrameInput> frame_input_; | 563 scoped_refptr<FrameInput> frame_input_; |
557 scoped_refptr<FrameReceiver> frame_receiver_; | 564 scoped_refptr<FrameReceiver> frame_receiver_; |
558 | 565 |
559 scoped_refptr<TestReceiverAudioCallback> test_receiver_audio_callback_; | 566 scoped_refptr<TestReceiverAudioCallback> test_receiver_audio_callback_; |
560 scoped_refptr<TestReceiverVideoCallback> test_receiver_video_callback_; | 567 scoped_refptr<TestReceiverVideoCallback> test_receiver_video_callback_; |
561 | 568 |
562 scoped_ptr<TestAudioBusFactory> audio_bus_factory_; | 569 scoped_ptr<TestAudioBusFactory> audio_bus_factory_; |
563 | 570 |
564 SimpleEventSubscriber event_subscriber_; | 571 SimpleEventSubscriber event_subscriber_; |
565 std::vector<FrameEvent> frame_events_; | 572 std::vector<FrameEvent> frame_events_; |
566 std::vector<PacketEvent> packet_events_; | 573 std::vector<PacketEvent> packet_events_; |
567 std::vector<GenericEvent> generic_events_; | 574 std::vector<GenericEvent> generic_events_; |
568 }; | 575 }; |
569 | 576 |
570 // Audio and video test without packet loss using raw PCM 16 audio "codec"; | 577 #if defined(OS_WIN) |
571 // This test is too slow. Disabled for now: crbug.com/329333. | 578 #define MAYBE_LoopNoLossPcm16 DISABLED_LoopNoLossPcm16 |
572 TEST_F(End2EndTest, DISABLED_LoopNoLossPcm16) { | 579 #else |
580 #define MAYBE_LoopNoLossPcm16 LoopNoLossPcm16 | |
581 #endif | |
582 // TODO(mikhal): Crashes in win bots (http://crbug.com/329563) | |
583 TEST_F(End2EndTest, MAYBE_LoopNoLossPcm16) { | |
573 SetupConfig(transport::kPcm16, 32000, false, 1); | 584 SetupConfig(transport::kPcm16, 32000, false, 1); |
585 // Reduce video resolution to allow processing multiple frames within a | |
586 // reasonable time frame. | |
587 video_sender_config_.width = kVideoQcifWidth; | |
588 video_sender_config_.height = kVideoQcifHeight; | |
574 Create(); | 589 Create(); |
575 | 590 |
576 int video_start = 1; | 591 int video_start = kVideoStart; |
577 int audio_diff = kFrameTimerMs; | 592 int audio_diff = kFrameTimerMs; |
578 int i = 0; | 593 int i = 0; |
579 | 594 |
580 for (; i < 10; ++i) { | 595 for (; i < 300; ++i) { |
581 int num_10ms_blocks = audio_diff / 10; | 596 int num_10ms_blocks = audio_diff / 10; |
582 audio_diff -= num_10ms_blocks * 10; | 597 audio_diff -= num_10ms_blocks * 10; |
583 base::TimeTicks send_time = testing_clock_->NowTicks(); | |
584 | |
585 test_receiver_video_callback_->AddExpectedResult( | |
586 video_start, | |
587 video_sender_config_.width, | |
588 video_sender_config_.height, | |
589 send_time); | |
590 | 598 |
591 scoped_ptr<AudioBus> audio_bus(audio_bus_factory_->NextAudioBus( | 599 scoped_ptr<AudioBus> audio_bus(audio_bus_factory_->NextAudioBus( |
592 base::TimeDelta::FromMilliseconds(10) * num_10ms_blocks)); | 600 base::TimeDelta::FromMilliseconds(10) * num_10ms_blocks)); |
593 | 601 |
602 base::TimeTicks send_time = testing_clock_->NowTicks(); | |
594 if (i != 0) { | 603 if (i != 0) { |
595 // Due to the re-sampler and NetEq in the webrtc AudioCodingModule the | 604 // Due to the re-sampler and NetEq in the webrtc AudioCodingModule the |
596 // first samples will be 0 and then slowly ramp up to its real amplitude; | 605 // first samples will be 0 and then slowly ramp up to its real |
606 // amplitude; | |
597 // ignore the first frame. | 607 // ignore the first frame. |
598 test_receiver_audio_callback_->AddExpectedResult( | 608 test_receiver_audio_callback_->AddExpectedResult( |
599 ToPcmAudioFrame(*audio_bus, audio_sender_config_.frequency), | 609 ToPcmAudioFrame(*audio_bus, audio_sender_config_.frequency), |
600 num_10ms_blocks, | 610 num_10ms_blocks, |
601 send_time); | 611 send_time); |
602 } | 612 } |
603 | 613 |
604 AudioBus* const audio_bus_ptr = audio_bus.get(); | 614 AudioBus* const audio_bus_ptr = audio_bus.get(); |
605 frame_input_->InsertAudio( | 615 frame_input_->InsertAudio( |
606 audio_bus_ptr, | 616 audio_bus_ptr, |
607 send_time, | 617 send_time, |
608 base::Bind(&OwnThatAudioBus, base::Passed(&audio_bus))); | 618 base::Bind(&OwnThatAudioBus, base::Passed(&audio_bus))); |
609 | 619 |
620 test_receiver_video_callback_->AddExpectedResult( | |
621 video_start, | |
622 video_sender_config_.width, | |
623 video_sender_config_.height, | |
624 send_time); | |
610 SendVideoFrame(video_start, send_time); | 625 SendVideoFrame(video_start, send_time); |
611 | 626 |
612 RunTasks(kFrameTimerMs); | |
613 audio_diff += kFrameTimerMs; | |
614 | |
615 if (i == 0) { | 627 if (i == 0) { |
616 frame_receiver_->GetRawAudioFrame( | 628 frame_receiver_->GetRawAudioFrame( |
617 num_10ms_blocks, | 629 num_10ms_blocks, |
618 audio_sender_config_.frequency, | 630 audio_sender_config_.frequency, |
619 base::Bind(&TestReceiverAudioCallback::IgnoreAudioFrame, | 631 base::Bind(&TestReceiverAudioCallback::IgnoreAudioFrame, |
620 test_receiver_audio_callback_)); | 632 test_receiver_audio_callback_)); |
621 } else { | 633 } else { |
622 frame_receiver_->GetRawAudioFrame( | 634 frame_receiver_->GetRawAudioFrame( |
623 num_10ms_blocks, | 635 num_10ms_blocks, |
624 audio_sender_config_.frequency, | 636 audio_sender_config_.frequency, |
625 base::Bind(&TestReceiverAudioCallback::CheckPcmAudioFrame, | 637 base::Bind(&TestReceiverAudioCallback::CheckPcmAudioFrame, |
626 test_receiver_audio_callback_)); | 638 test_receiver_audio_callback_)); |
627 } | 639 } |
628 | 640 |
629 frame_receiver_->GetRawVideoFrame( | 641 frame_receiver_->GetRawVideoFrame( |
630 base::Bind(&TestReceiverVideoCallback::CheckVideoFrame, | 642 base::Bind(&TestReceiverVideoCallback::CheckVideoFrame, |
631 test_receiver_video_callback_)); | 643 test_receiver_video_callback_)); |
632 | 644 |
645 RunTasks(kFrameTimerMs); | |
646 audio_diff += kFrameTimerMs; | |
633 video_start++; | 647 video_start++; |
634 } | 648 } |
635 | 649 |
636 RunTasks(2 * kFrameTimerMs + 1); // Empty the receiver pipeline. | 650 RunTasks(2 * kFrameTimerMs + 1); // Empty the receiver pipeline. |
637 EXPECT_EQ(i - 1, test_receiver_audio_callback_->number_times_called()); | 651 EXPECT_EQ(i - 1, test_receiver_audio_callback_->number_times_called()); |
638 EXPECT_EQ(i, test_receiver_video_callback_->number_times_called()); | 652 EXPECT_EQ(i, test_receiver_video_callback_->number_times_called()); |
639 } | 653 } |
640 | 654 |
641 // TODO(mikhal): Crashes on the Win7 x64 bots. Re-enable. | 655 // TODO(mikhal): Crashes on the Win7 x64 bots. Re-enable. |
642 // http://crbug.com/329563 | 656 // http://crbug.com/329563 |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
730 } | 744 } |
731 | 745 |
732 // This tests start sending audio and video before the receiver is ready. | 746 // This tests start sending audio and video before the receiver is ready. |
733 // | 747 // |
734 // TODO(miu): Test disabled because of non-determinism. | 748 // TODO(miu): Test disabled because of non-determinism. |
735 // http://crbug.com/314233 | 749 // http://crbug.com/314233 |
736 TEST_F(End2EndTest, DISABLED_StartSenderBeforeReceiver) { | 750 TEST_F(End2EndTest, DISABLED_StartSenderBeforeReceiver) { |
737 SetupConfig(transport::kOpus, kDefaultAudioSamplingRate, false, 1); | 751 SetupConfig(transport::kOpus, kDefaultAudioSamplingRate, false, 1); |
738 Create(); | 752 Create(); |
739 | 753 |
740 int video_start = 1; | 754 int video_start = kVideoStart; |
741 int audio_diff = kFrameTimerMs; | 755 int audio_diff = kFrameTimerMs; |
742 | 756 |
743 sender_to_receiver_.SetSendPackets(false); | 757 sender_to_receiver_.SetSendPackets(false); |
744 | 758 |
745 for (int i = 0; i < 3; ++i) { | 759 for (int i = 0; i < 3; ++i) { |
746 int num_10ms_blocks = audio_diff / 10; | 760 int num_10ms_blocks = audio_diff / 10; |
747 audio_diff -= num_10ms_blocks * 10; | 761 audio_diff -= num_10ms_blocks * 10; |
748 | 762 |
749 base::TimeTicks send_time = testing_clock_->NowTicks(); | 763 base::TimeTicks send_time = testing_clock_->NowTicks(); |
750 scoped_ptr<AudioBus> audio_bus(audio_bus_factory_->NextAudioBus( | 764 scoped_ptr<AudioBus> audio_bus(audio_bus_factory_->NextAudioBus( |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
821 EXPECT_EQ(j, test_receiver_video_callback_->number_times_called()); | 835 EXPECT_EQ(j, test_receiver_video_callback_->number_times_called()); |
822 } | 836 } |
823 | 837 |
824 // This tests a network glitch lasting for 10 video frames. | 838 // This tests a network glitch lasting for 10 video frames. |
825 TEST_F(End2EndTest, GlitchWith3Buffers) { | 839 TEST_F(End2EndTest, GlitchWith3Buffers) { |
826 SetupConfig(transport::kOpus, kDefaultAudioSamplingRate, false, 3); | 840 SetupConfig(transport::kOpus, kDefaultAudioSamplingRate, false, 3); |
827 video_sender_config_.rtp_config.max_delay_ms = 67; | 841 video_sender_config_.rtp_config.max_delay_ms = 67; |
828 video_receiver_config_.rtp_max_delay_ms = 67; | 842 video_receiver_config_.rtp_max_delay_ms = 67; |
829 Create(); | 843 Create(); |
830 | 844 |
831 int video_start = 50; | 845 int video_start = kVideoStart; |
832 base::TimeTicks send_time = testing_clock_->NowTicks(); | 846 base::TimeTicks send_time = testing_clock_->NowTicks(); |
833 SendVideoFrame(video_start, send_time); | 847 SendVideoFrame(video_start, send_time); |
834 RunTasks(kFrameTimerMs); | 848 RunTasks(kFrameTimerMs); |
835 | 849 |
836 test_receiver_video_callback_->AddExpectedResult(video_start, | 850 test_receiver_video_callback_->AddExpectedResult(video_start, |
837 video_sender_config_.width, | 851 video_sender_config_.width, |
838 video_sender_config_.height, | 852 video_sender_config_.height, |
839 send_time); | 853 send_time); |
840 frame_receiver_->GetRawVideoFrame( | 854 frame_receiver_->GetRawVideoFrame( |
841 base::Bind(&TestReceiverVideoCallback::CheckVideoFrame, | 855 base::Bind(&TestReceiverVideoCallback::CheckVideoFrame, |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
877 EXPECT_EQ(2, test_receiver_video_callback_->number_times_called()); | 891 EXPECT_EQ(2, test_receiver_video_callback_->number_times_called()); |
878 } | 892 } |
879 | 893 |
880 TEST_F(End2EndTest, DropEveryOtherFrame3Buffers) { | 894 TEST_F(End2EndTest, DropEveryOtherFrame3Buffers) { |
881 SetupConfig(transport::kOpus, kDefaultAudioSamplingRate, false, 3); | 895 SetupConfig(transport::kOpus, kDefaultAudioSamplingRate, false, 3); |
882 video_sender_config_.rtp_config.max_delay_ms = 67; | 896 video_sender_config_.rtp_config.max_delay_ms = 67; |
883 video_receiver_config_.rtp_max_delay_ms = 67; | 897 video_receiver_config_.rtp_max_delay_ms = 67; |
884 Create(); | 898 Create(); |
885 sender_to_receiver_.DropAllPacketsBelongingToOddFrames(); | 899 sender_to_receiver_.DropAllPacketsBelongingToOddFrames(); |
886 | 900 |
887 int video_start = 50; | 901 int video_start = kVideoStart; |
888 base::TimeTicks send_time; | 902 base::TimeTicks send_time; |
889 | 903 |
890 int i = 0; | 904 int i = 0; |
891 for (; i < 20; ++i) { | 905 for (; i < 20; ++i) { |
892 send_time = testing_clock_->NowTicks(); | 906 send_time = testing_clock_->NowTicks(); |
893 SendVideoFrame(video_start, send_time); | 907 SendVideoFrame(video_start, send_time); |
894 | 908 |
895 if (i % 2 == 0) { | 909 if (i % 2 == 0) { |
896 test_receiver_video_callback_->AddExpectedResult( | 910 test_receiver_video_callback_->AddExpectedResult( |
897 video_start, | 911 video_start, |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1003 for (; frames_counter < 3; ++frames_counter) { | 1017 for (; frames_counter < 3; ++frames_counter) { |
1004 int num_10ms_blocks = 2; | 1018 int num_10ms_blocks = 2; |
1005 | 1019 |
1006 const base::TimeTicks send_time = testing_clock_->NowTicks(); | 1020 const base::TimeTicks send_time = testing_clock_->NowTicks(); |
1007 | 1021 |
1008 scoped_ptr<AudioBus> audio_bus(audio_bus_factory_->NextAudioBus( | 1022 scoped_ptr<AudioBus> audio_bus(audio_bus_factory_->NextAudioBus( |
1009 base::TimeDelta::FromMilliseconds(10) * num_10ms_blocks)); | 1023 base::TimeDelta::FromMilliseconds(10) * num_10ms_blocks)); |
1010 | 1024 |
1011 if (frames_counter != 0) { | 1025 if (frames_counter != 0) { |
1012 // Due to the re-sampler and NetEq in the webrtc AudioCodingModule the | 1026 // Due to the re-sampler and NetEq in the webrtc AudioCodingModule the |
1013 // first samples will be 0 and then slowly ramp up to its real amplitude; | 1027 // first samples will be 0 and then slowly ramp up to its real |
1028 // amplitude; | |
1014 // ignore the first frame. | 1029 // ignore the first frame. |
1015 test_receiver_audio_callback_->AddExpectedResult( | 1030 test_receiver_audio_callback_->AddExpectedResult( |
1016 ToPcmAudioFrame(*audio_bus, audio_sender_config_.frequency), | 1031 ToPcmAudioFrame(*audio_bus, audio_sender_config_.frequency), |
1017 num_10ms_blocks, | 1032 num_10ms_blocks, |
1018 send_time); | 1033 send_time); |
1019 } | 1034 } |
1020 AudioBus* const audio_bus_ptr = audio_bus.get(); | 1035 AudioBus* const audio_bus_ptr = audio_bus.get(); |
1021 frame_input_->InsertAudio( | 1036 frame_input_->InsertAudio( |
1022 audio_bus_ptr, | 1037 audio_bus_ptr, |
1023 send_time, | 1038 send_time, |
(...skipping 13 matching lines...) Expand all Loading... | |
1037 32000, | 1052 32000, |
1038 base::Bind(&TestReceiverAudioCallback::CheckPcmAudioFrame, | 1053 base::Bind(&TestReceiverAudioCallback::CheckPcmAudioFrame, |
1039 test_receiver_audio_callback_)); | 1054 test_receiver_audio_callback_)); |
1040 } | 1055 } |
1041 } | 1056 } |
1042 RunTasks(2 * kFrameTimerMs + 1); // Empty the pipeline. | 1057 RunTasks(2 * kFrameTimerMs + 1); // Empty the pipeline. |
1043 EXPECT_EQ(frames_counter - 1, | 1058 EXPECT_EQ(frames_counter - 1, |
1044 test_receiver_audio_callback_->number_times_called()); | 1059 test_receiver_audio_callback_->number_times_called()); |
1045 } | 1060 } |
1046 | 1061 |
1047 // Video test without packet loss; This test is targeted at testing the logging | 1062 // Video test without packet loss; This test is targeted at testing the |
1063 // logging | |
1048 // aspects of the end2end, but is basically equivalent to LoopNoLossPcm16. | 1064 // aspects of the end2end, but is basically equivalent to LoopNoLossPcm16. |
1049 TEST_F(End2EndTest, VideoLogging) { | 1065 TEST_F(End2EndTest, VideoLogging) { |
1050 SetupConfig(transport::kPcm16, 32000, false, 1); | 1066 SetupConfig(transport::kPcm16, 32000, false, 1); |
1051 Create(); | 1067 Create(); |
1052 | 1068 |
1053 int video_start = 1; | 1069 int video_start = kVideoStart; |
1054 const int num_frames = 1; | 1070 const int num_frames = 1; |
1055 for (int i = 0; i < num_frames; ++i) { | 1071 for (int i = 0; i < num_frames; ++i) { |
1056 base::TimeTicks send_time = testing_clock_->NowTicks(); | 1072 base::TimeTicks send_time = testing_clock_->NowTicks(); |
1057 test_receiver_video_callback_->AddExpectedResult( | 1073 test_receiver_video_callback_->AddExpectedResult( |
1058 video_start, | 1074 video_start, |
1059 video_sender_config_.width, | 1075 video_sender_config_.width, |
1060 video_sender_config_.height, | 1076 video_sender_config_.height, |
1061 send_time); | 1077 send_time); |
1062 | 1078 |
1063 SendVideoFrame(video_start, send_time); | 1079 SendVideoFrame(video_start, send_time); |
(...skipping 23 matching lines...) Expand all Loading... | |
1087 // for that frame. | 1103 // for that frame. |
1088 std::map<RtpTimestamp, LoggingEventCounts> event_counter_for_frame = | 1104 std::map<RtpTimestamp, LoggingEventCounts> event_counter_for_frame = |
1089 GetEventCountForFrameEvents(frame_events_); | 1105 GetEventCountForFrameEvents(frame_events_); |
1090 | 1106 |
1091 // Verify that there are logs for expected number of frames. | 1107 // Verify that there are logs for expected number of frames. |
1092 EXPECT_EQ(num_frames, static_cast<int>(event_counter_for_frame.size())); | 1108 EXPECT_EQ(num_frames, static_cast<int>(event_counter_for_frame.size())); |
1093 | 1109 |
1094 // Verify that each frame have the expected types of events logged. | 1110 // Verify that each frame have the expected types of events logged. |
1095 for (std::map<RtpTimestamp, LoggingEventCounts>::iterator map_it = | 1111 for (std::map<RtpTimestamp, LoggingEventCounts>::iterator map_it = |
1096 event_counter_for_frame.begin(); | 1112 event_counter_for_frame.begin(); |
1097 map_it != event_counter_for_frame.end(); ++map_it) { | 1113 map_it != event_counter_for_frame.end(); |
1114 ++map_it) { | |
1098 int total_event_count_for_frame = 0; | 1115 int total_event_count_for_frame = 0; |
1099 for (int i = 0; i < kNumOfLoggingEvents; ++i) { | 1116 for (int i = 0; i < kNumOfLoggingEvents; ++i) { |
1100 total_event_count_for_frame += map_it->second.counter[i]; | 1117 total_event_count_for_frame += map_it->second.counter[i]; |
1101 } | 1118 } |
1102 | 1119 |
1103 int expected_event_count_for_frame = 0; | 1120 int expected_event_count_for_frame = 0; |
1104 | 1121 |
1105 EXPECT_GT(map_it->second.counter[kVideoFrameSentToEncoder], 0); | 1122 EXPECT_GT(map_it->second.counter[kVideoFrameSentToEncoder], 0); |
1106 expected_event_count_for_frame += | 1123 expected_event_count_for_frame += |
1107 map_it->second.counter[kVideoFrameSentToEncoder]; | 1124 map_it->second.counter[kVideoFrameSentToEncoder]; |
1108 | 1125 |
1109 EXPECT_GT(map_it->second.counter[kVideoFrameEncoded], 0); | 1126 EXPECT_GT(map_it->second.counter[kVideoFrameEncoded], 0); |
1110 expected_event_count_for_frame += | 1127 expected_event_count_for_frame += |
1111 map_it->second.counter[kVideoFrameEncoded]; | 1128 map_it->second.counter[kVideoFrameEncoded]; |
1112 | 1129 |
1113 EXPECT_GT(map_it->second.counter[kVideoFrameReceived], 0); | 1130 EXPECT_GT(map_it->second.counter[kVideoFrameReceived], 0); |
1114 expected_event_count_for_frame += | 1131 expected_event_count_for_frame += |
1115 map_it->second.counter[kVideoFrameReceived]; | 1132 map_it->second.counter[kVideoFrameReceived]; |
1116 | 1133 |
1117 EXPECT_GT(map_it->second.counter[kVideoRenderDelay], 0); | 1134 EXPECT_GT(map_it->second.counter[kVideoRenderDelay], 0); |
1118 expected_event_count_for_frame += map_it->second.counter[kVideoRenderDelay]; | 1135 expected_event_count_for_frame += map_it->second.counter[kVideoRenderDelay]; |
1119 | 1136 |
1120 EXPECT_GT(map_it->second.counter[kVideoFrameDecoded], 0); | 1137 EXPECT_GT(map_it->second.counter[kVideoFrameDecoded], 0); |
1121 expected_event_count_for_frame += | 1138 expected_event_count_for_frame += |
1122 map_it->second.counter[kVideoFrameDecoded]; | 1139 map_it->second.counter[kVideoFrameDecoded]; |
1123 | 1140 |
1124 // Verify that there were no other events logged with respect to this frame. | 1141 // Verify that there were no other events logged with respect to this |
1142 // frame. | |
1125 // (i.e. Total event count = expected event count) | 1143 // (i.e. Total event count = expected event count) |
1126 EXPECT_EQ(total_event_count_for_frame, expected_event_count_for_frame); | 1144 EXPECT_EQ(total_event_count_for_frame, expected_event_count_for_frame); |
1127 } | 1145 } |
1128 | 1146 |
1129 // Packet logging. | 1147 // Packet logging. |
1130 // Verify that all packet related events were logged. | 1148 // Verify that all packet related events were logged. |
1131 event_subscriber_.GetPacketEventsAndReset(&packet_events_); | 1149 event_subscriber_.GetPacketEventsAndReset(&packet_events_); |
1132 std::map<uint16, LoggingEventCounts> event_count_for_packet = | 1150 std::map<uint16, LoggingEventCounts> event_count_for_packet = |
1133 GetEventCountForPacketEvents(packet_events_); | 1151 GetEventCountForPacketEvents(packet_events_); |
1134 | 1152 |
1135 // Verify that each packet have the expected types of events logged. | 1153 // Verify that each packet have the expected types of events logged. |
1136 for (std::map<uint16, LoggingEventCounts>::iterator map_it = | 1154 for (std::map<uint16, LoggingEventCounts>::iterator map_it = |
1137 event_count_for_packet.begin(); | 1155 event_count_for_packet.begin(); |
1138 map_it != event_count_for_packet.end(); ++map_it) { | 1156 map_it != event_count_for_packet.end(); |
1157 ++map_it) { | |
1139 int total_event_count_for_packet = 0; | 1158 int total_event_count_for_packet = 0; |
1140 for (int i = 0; i < kNumOfLoggingEvents; ++i) { | 1159 for (int i = 0; i < kNumOfLoggingEvents; ++i) { |
1141 total_event_count_for_packet += map_it->second.counter[i]; | 1160 total_event_count_for_packet += map_it->second.counter[i]; |
1142 } | 1161 } |
1143 | 1162 |
1144 int expected_event_count_for_packet = 0; | 1163 int expected_event_count_for_packet = 0; |
1145 EXPECT_GT(map_it->second.counter[kVideoPacketReceived], 0); | 1164 EXPECT_GT(map_it->second.counter[kVideoPacketReceived], 0); |
1146 expected_event_count_for_packet += | 1165 expected_event_count_for_packet += |
1147 map_it->second.counter[kVideoPacketReceived]; | 1166 map_it->second.counter[kVideoPacketReceived]; |
1148 | 1167 |
1149 // Verify that there were no other events logged with respect to this | 1168 // Verify that there were no other events logged with respect to this |
1150 // packet. (i.e. Total event count = expected event count) | 1169 // packet. (i.e. Total event count = expected event count) |
1151 EXPECT_EQ(total_event_count_for_packet, expected_event_count_for_packet); | 1170 EXPECT_EQ(total_event_count_for_packet, expected_event_count_for_packet); |
1152 } | 1171 } |
1153 } | 1172 } |
1154 | 1173 |
1155 // TODO(mikhal): Crashes on the bots. Re-enable. http://crbug.com/329563 | 1174 // TODO(mikhal): Crashes on the bots. Re-enable. http://crbug.com/329563 |
1156 #if defined(OS_WIN) | 1175 #if defined(OS_WIN) |
1157 #define MAYBE_AudioLogging DISABLED_AudioLogging | 1176 #define MAYBE_AudioLogging DISABLED_AudioLogging |
1158 #else | 1177 #else |
1159 #define MAYBE_AudioLogging AudioLogging | 1178 #define MAYBE_AudioLogging AudioLogging |
1160 #endif | 1179 #endif |
1161 // Audio test without packet loss; This test is targeted at testing the logging | 1180 // Audio test without packet loss; This test is targeted at testing the |
1181 // logging | |
1162 // aspects of the end2end, but is basically equivalent to LoopNoLossPcm16. | 1182 // aspects of the end2end, but is basically equivalent to LoopNoLossPcm16. |
pwestin
2014/02/12 21:16:43
weird sentence break
mikhal1
2014/02/12 23:21:05
Done.
| |
1163 TEST_F(End2EndTest, MAYBE_AudioLogging) { | 1183 TEST_F(End2EndTest, MAYBE_AudioLogging) { |
1164 SetupConfig(transport::kPcm16, 32000, false, 1); | 1184 SetupConfig(transport::kPcm16, 32000, false, 1); |
1165 Create(); | 1185 Create(); |
1166 | 1186 |
1167 int audio_diff = kFrameTimerMs; | 1187 int audio_diff = kFrameTimerMs; |
1168 const int num_frames = 10; | 1188 const int num_frames = 10; |
1169 for (int i = 0; i < num_frames; ++i) { | 1189 for (int i = 0; i < num_frames; ++i) { |
1170 int num_10ms_blocks = audio_diff / 10; | 1190 int num_10ms_blocks = audio_diff / 10; |
1171 audio_diff -= num_10ms_blocks * 10; | 1191 audio_diff -= num_10ms_blocks * 10; |
1172 base::TimeTicks send_time = testing_clock_->NowTicks(); | 1192 base::TimeTicks send_time = testing_clock_->NowTicks(); |
1173 | 1193 |
1174 scoped_ptr<AudioBus> audio_bus(audio_bus_factory_->NextAudioBus( | 1194 scoped_ptr<AudioBus> audio_bus(audio_bus_factory_->NextAudioBus( |
1175 base::TimeDelta::FromMilliseconds(10) * num_10ms_blocks)); | 1195 base::TimeDelta::FromMilliseconds(10) * num_10ms_blocks)); |
1176 | 1196 |
1177 if (i != 0) { | 1197 if (i != 0) { |
1178 // Due to the re-sampler and NetEq in the webrtc AudioCodingModule the | 1198 // Due to the re-sampler and NetEq in the webrtc AudioCodingModule the |
1179 // first samples will be 0 and then slowly ramp up to its real amplitude; | 1199 // first samples will be 0 and then slowly ramp up to its real |
1200 // amplitude; | |
1180 // ignore the first frame. | 1201 // ignore the first frame. |
1181 test_receiver_audio_callback_->AddExpectedResult( | 1202 test_receiver_audio_callback_->AddExpectedResult( |
1182 ToPcmAudioFrame(*audio_bus, audio_sender_config_.frequency), | 1203 ToPcmAudioFrame(*audio_bus, audio_sender_config_.frequency), |
1183 num_10ms_blocks, | 1204 num_10ms_blocks, |
1184 send_time); | 1205 send_time); |
1185 } | 1206 } |
1186 | 1207 |
1187 AudioBus* const audio_bus_ptr = audio_bus.get(); | 1208 AudioBus* const audio_bus_ptr = audio_bus.get(); |
1188 frame_input_->InsertAudio( | 1209 frame_input_->InsertAudio( |
1189 audio_bus_ptr, | 1210 audio_bus_ptr, |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1222 // type logged for that frame. | 1243 // type logged for that frame. |
1223 std::map<RtpTimestamp, LoggingEventCounts> event_counter_for_frame = | 1244 std::map<RtpTimestamp, LoggingEventCounts> event_counter_for_frame = |
1224 GetEventCountForFrameEvents(frame_events_); | 1245 GetEventCountForFrameEvents(frame_events_); |
1225 | 1246 |
1226 // Verify that each frame have the expected types of events logged. | 1247 // Verify that each frame have the expected types of events logged. |
1227 std::map<RtpTimestamp, LoggingEventCounts>::iterator map_it = | 1248 std::map<RtpTimestamp, LoggingEventCounts>::iterator map_it = |
1228 event_counter_for_frame.begin(); | 1249 event_counter_for_frame.begin(); |
1229 | 1250 |
1230 // TODO(imcheng): This only checks the first frame. This doesn't work | 1251 // TODO(imcheng): This only checks the first frame. This doesn't work |
1231 // properly for all frames for two reasons: | 1252 // properly for all frames for two reasons: |
1232 // 1. There is a loopback of kAudioPlayoutDelay and kAudioFrameDecoded events | 1253 // 1. There is a loopback of kAudioPlayoutDelay and kAudioFrameDecoded |
1254 // events | |
pwestin
2014/02/12 21:16:43
weird sentence break
mikhal1
2014/02/12 23:21:05
Done.
| |
1233 // due to shared CastEnvironment between sender and | 1255 // due to shared CastEnvironment between sender and |
1234 // receiver in the test setup. We will need to create separate CastEnvironment | 1256 // receiver in the test setup. We will need to create separate |
1257 // CastEnvironment | |
pwestin
2014/02/12 21:16:43
weird sentence break
mikhal1
2014/02/12 23:21:05
Done.
| |
1235 // once again to fix this. | 1258 // once again to fix this. |
1236 // 2. kAudioPlayoutDelay and kAudioFrameDecoded RTP timestamps aren't exactly | 1259 // 2. kAudioPlayoutDelay and kAudioFrameDecoded RTP timestamps aren't |
1237 // aligned with those of kAudioFrameReceived and kAudioFrameEncoded. Note that | 1260 // exactly |
1261 // aligned with those of kAudioFrameReceived and kAudioFrameEncoded. Note | |
1262 // that | |
pwestin
2014/02/12 21:16:43
weird sentence break
mikhal1
2014/02/12 23:21:05
Done.
| |
1238 // these RTP timestamps are output from webrtc::AudioCodingModule which are | 1263 // these RTP timestamps are output from webrtc::AudioCodingModule which are |
1239 // different from RTP timestamps that the cast library generates during the | 1264 // different from RTP timestamps that the cast library generates during the |
1240 // encode step (and which are sent to receiver). The first frame just happen | 1265 // encode step (and which are sent to receiver). The first frame just happen |
1241 // to be aligned. | 1266 // to be aligned. |
1242 int total_event_count_for_frame = 0; | 1267 int total_event_count_for_frame = 0; |
1243 for (int j = 0; j < kNumOfLoggingEvents; ++j) | 1268 for (int j = 0; j < kNumOfLoggingEvents; ++j) |
1244 total_event_count_for_frame += map_it->second.counter[j]; | 1269 total_event_count_for_frame += map_it->second.counter[j]; |
1245 | 1270 |
1246 | |
1247 int expected_event_count_for_frame = 0; | 1271 int expected_event_count_for_frame = 0; |
1248 | 1272 |
1249 EXPECT_GT(map_it->second.counter[kAudioFrameReceived], 0); | 1273 EXPECT_GT(map_it->second.counter[kAudioFrameReceived], 0); |
1250 expected_event_count_for_frame += | 1274 expected_event_count_for_frame += map_it->second.counter[kAudioFrameReceived]; |
1251 map_it->second.counter[kAudioFrameReceived]; | |
1252 | 1275 |
1253 EXPECT_GT(map_it->second.counter[kAudioFrameEncoded], 0); | 1276 EXPECT_GT(map_it->second.counter[kAudioFrameEncoded], 0); |
1254 expected_event_count_for_frame += | 1277 expected_event_count_for_frame += map_it->second.counter[kAudioFrameEncoded]; |
1255 map_it->second.counter[kAudioFrameEncoded]; | |
1256 | 1278 |
1257 // Note that this is a big positive number instead of just 1 due to loopback | 1279 // Note that this is a big positive number instead of just 1 due to loopback |
1258 // described in TODO above. | 1280 // described in TODO above. |
1259 EXPECT_GT(map_it->second.counter[kAudioPlayoutDelay], 0); | 1281 EXPECT_GT(map_it->second.counter[kAudioPlayoutDelay], 0); |
1260 expected_event_count_for_frame += | 1282 expected_event_count_for_frame += map_it->second.counter[kAudioPlayoutDelay]; |
1261 map_it->second.counter[kAudioPlayoutDelay]; | |
1262 EXPECT_GT(map_it->second.counter[kAudioFrameDecoded], 0); | 1283 EXPECT_GT(map_it->second.counter[kAudioFrameDecoded], 0); |
1263 expected_event_count_for_frame += | 1284 expected_event_count_for_frame += map_it->second.counter[kAudioFrameDecoded]; |
1264 map_it->second.counter[kAudioFrameDecoded]; | |
1265 | 1285 |
1266 // Verify that there were no other events logged with respect to this frame. | 1286 // Verify that there were no other events logged with respect to this frame. |
1267 // (i.e. Total event count = expected event count) | 1287 // (i.e. Total event count = expected event count) |
1268 EXPECT_EQ(total_event_count_for_frame, expected_event_count_for_frame); | 1288 EXPECT_EQ(total_event_count_for_frame, expected_event_count_for_frame); |
1269 } | 1289 } |
1270 | 1290 |
1271 // TODO(pwestin): Add repeatable packet loss test. | 1291 // TODO(pwestin): Add repeatable packet loss test. |
1272 // TODO(pwestin): Add test for misaligned send get calls. | 1292 // TODO(pwestin): Add test for misaligned send get calls. |
1273 // TODO(pwestin): Add more tests that does not resample. | 1293 // TODO(pwestin): Add more tests that does not resample. |
1274 // TODO(pwestin): Add test when we have starvation for our RunTask. | 1294 // TODO(pwestin): Add test when we have starvation for our RunTask. |
1275 | 1295 |
1276 } // namespace cast | 1296 } // namespace cast |
1277 } // namespace media | 1297 } // namespace media |
OLD | NEW |