OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 #include <algorithm> // max | 10 #include <algorithm> // max |
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
304 return true; | 304 return true; |
305 } | 305 } |
306 | 306 |
307 RtcpStatistics stats_; | 307 RtcpStatistics stats_; |
308 }; | 308 }; |
309 | 309 |
310 std::unique_ptr<LossyStatistician> lossy_stats_; | 310 std::unique_ptr<LossyStatistician> lossy_stats_; |
311 StatisticianMap stats_map_; | 311 StatisticianMap stats_map_; |
312 }; | 312 }; |
313 | 313 |
314 class FecObserver : public test::EndToEndTest { | 314 class UlpfecObserver : public test::EndToEndTest { |
315 public: | 315 public: |
316 FecObserver(bool header_extensions_enabled, | 316 UlpfecObserver(bool header_extensions_enabled, |
317 bool use_nack, | 317 bool use_nack, |
318 bool expect_red, | 318 bool expect_red, |
319 bool expect_fec, | 319 bool expect_ulpfec, |
320 const std::string& codec) | 320 const std::string& codec) |
321 : EndToEndTest(VideoSendStreamTest::kDefaultTimeoutMs), | 321 : EndToEndTest(VideoSendStreamTest::kDefaultTimeoutMs), |
322 payload_name_(codec), | 322 payload_name_(codec), |
323 use_nack_(use_nack), | 323 use_nack_(use_nack), |
324 expect_red_(expect_red), | 324 expect_red_(expect_red), |
325 expect_fec_(expect_fec), | 325 expect_ulpfec_(expect_ulpfec), |
326 send_count_(0), | 326 send_count_(0), |
327 received_media_(false), | 327 received_media_(false), |
328 received_fec_(false), | 328 received_fec_(false), |
329 header_extensions_enabled_(header_extensions_enabled) { | 329 header_extensions_enabled_(header_extensions_enabled) { |
330 if (codec == "H264") { | 330 if (codec == "H264") { |
331 encoder_.reset(new test::FakeH264Encoder(Clock::GetRealTimeClock())); | 331 encoder_.reset(new test::FakeH264Encoder(Clock::GetRealTimeClock())); |
332 } else if (codec == "VP8") { | 332 } else if (codec == "VP8") { |
333 encoder_.reset(VideoEncoder::Create(VideoEncoder::EncoderType::kVp8)); | 333 encoder_.reset(VideoEncoder::Create(VideoEncoder::EncoderType::kVp8)); |
334 } else if (codec == "VP9") { | 334 } else if (codec == "VP9") { |
335 encoder_.reset(VideoEncoder::Create(VideoEncoder::EncoderType::kVp9)); | 335 encoder_.reset(VideoEncoder::Create(VideoEncoder::EncoderType::kVp9)); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
378 } | 378 } |
379 EXPECT_TRUE(header.extension.hasTransportSequenceNumber); | 379 EXPECT_TRUE(header.extension.hasTransportSequenceNumber); |
380 uint16_t seq_num_diff = header.extension.transportSequenceNumber - | 380 uint16_t seq_num_diff = header.extension.transportSequenceNumber - |
381 prev_header_.extension.transportSequenceNumber; | 381 prev_header_.extension.transportSequenceNumber; |
382 EXPECT_EQ(1, seq_num_diff); | 382 EXPECT_EQ(1, seq_num_diff); |
383 } | 383 } |
384 | 384 |
385 if (encapsulated_payload_type != -1) { | 385 if (encapsulated_payload_type != -1) { |
386 if (encapsulated_payload_type == | 386 if (encapsulated_payload_type == |
387 VideoSendStreamTest::kUlpfecPayloadType) { | 387 VideoSendStreamTest::kUlpfecPayloadType) { |
388 EXPECT_TRUE(expect_fec_); | 388 EXPECT_TRUE(expect_ulpfec_); |
389 received_fec_ = true; | 389 received_fec_ = true; |
390 } else { | 390 } else { |
391 received_media_ = true; | 391 received_media_ = true; |
392 } | 392 } |
393 } | 393 } |
394 | 394 |
395 if (send_count_ > 100 && received_media_) { | 395 if (send_count_ > 100 && received_media_) { |
396 if (received_fec_ || !expect_fec_) | 396 if (received_fec_ || !expect_ulpfec_) |
397 observation_complete_.Set(); | 397 observation_complete_.Set(); |
398 } | 398 } |
399 | 399 |
400 prev_header_ = header; | 400 prev_header_ = header; |
401 | 401 |
402 return SEND_PACKET; | 402 return SEND_PACKET; |
403 } | 403 } |
404 | 404 |
405 test::PacketTransport* CreateSendTransport(Call* sender_call) override { | 405 test::PacketTransport* CreateSendTransport(Call* sender_call) override { |
406 // At low RTT (< kLowRttNackMs) -> NACK only, no FEC. | 406 // At low RTT (< kLowRttNackMs) -> NACK only, no FEC. |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
446 | 446 |
447 void PerformTest() override { | 447 void PerformTest() override { |
448 EXPECT_TRUE(Wait()) << "Timed out waiting for FEC and media packets."; | 448 EXPECT_TRUE(Wait()) << "Timed out waiting for FEC and media packets."; |
449 } | 449 } |
450 | 450 |
451 std::unique_ptr<internal::TransportAdapter> transport_adapter_; | 451 std::unique_ptr<internal::TransportAdapter> transport_adapter_; |
452 std::unique_ptr<VideoEncoder> encoder_; | 452 std::unique_ptr<VideoEncoder> encoder_; |
453 const std::string payload_name_; | 453 const std::string payload_name_; |
454 const bool use_nack_; | 454 const bool use_nack_; |
455 const bool expect_red_; | 455 const bool expect_red_; |
456 const bool expect_fec_; | 456 const bool expect_ulpfec_; |
457 int send_count_; | 457 int send_count_; |
458 bool received_media_; | 458 bool received_media_; |
459 bool received_fec_; | 459 bool received_fec_; |
460 bool header_extensions_enabled_; | 460 bool header_extensions_enabled_; |
461 RTPHeader prev_header_; | 461 RTPHeader prev_header_; |
462 }; | 462 }; |
463 | 463 |
464 TEST_F(VideoSendStreamTest, SupportsFecWithExtensions) { | 464 TEST_F(VideoSendStreamTest, SupportsUlpfecWithExtensions) { |
465 FecObserver test(true, false, true, true, "VP8"); | 465 UlpfecObserver test(true, false, true, true, "VP8"); |
466 RunBaseTest(&test); | 466 RunBaseTest(&test); |
467 } | 467 } |
468 | 468 |
469 TEST_F(VideoSendStreamTest, SupportsFecWithoutExtensions) { | 469 TEST_F(VideoSendStreamTest, SupportsUlpfecWithoutExtensions) { |
470 FecObserver test(false, false, true, true, "VP8"); | 470 UlpfecObserver test(false, false, true, true, "VP8"); |
471 RunBaseTest(&test); | 471 RunBaseTest(&test); |
472 } | 472 } |
473 | 473 |
474 // The FEC scheme used is not efficient for H264, so we should not use RED/FEC | 474 // The FEC scheme used is not efficient for H264, so we should not use RED/FEC |
475 // since we'll still have to re-request FEC packets, effectively wasting | 475 // since we'll still have to re-request FEC packets, effectively wasting |
476 // bandwidth since the receiver has to wait for FEC retransmissions to determine | 476 // bandwidth since the receiver has to wait for FEC retransmissions to determine |
477 // that the received state is actually decodable. | 477 // that the received state is actually decodable. |
478 TEST_F(VideoSendStreamTest, DoesNotUtilizeFecForH264WithNackEnabled) { | 478 TEST_F(VideoSendStreamTest, DoesNotUtilizeUlpfecForH264WithNackEnabled) { |
479 FecObserver test(false, true, true, false, "H264"); | 479 UlpfecObserver test(false, true, true, false, "H264"); |
480 RunBaseTest(&test); | 480 RunBaseTest(&test); |
481 } | 481 } |
482 | 482 |
483 // Without retransmissions FEC for H264 is fine. | 483 // Without retransmissions FEC for H264 is fine. |
484 TEST_F(VideoSendStreamTest, DoesUtilizeRedForH264WithoutNackEnabled) { | 484 TEST_F(VideoSendStreamTest, DoesUtilizeRedForH264WithoutNackEnabled) { |
485 FecObserver test(false, false, true, true, "H264"); | 485 UlpfecObserver test(false, false, true, true, "H264"); |
486 RunBaseTest(&test); | 486 RunBaseTest(&test); |
487 } | 487 } |
488 | 488 |
489 TEST_F(VideoSendStreamTest, DoesUtilizeRedForVp8WithNackEnabled) { | 489 TEST_F(VideoSendStreamTest, DoesUtilizeRedForVp8WithNackEnabled) { |
490 FecObserver test(false, true, true, true, "VP8"); | 490 UlpfecObserver test(false, true, true, true, "VP8"); |
491 RunBaseTest(&test); | 491 RunBaseTest(&test); |
492 } | 492 } |
493 | 493 |
494 #if !defined(RTC_DISABLE_VP9) | 494 #if !defined(RTC_DISABLE_VP9) |
495 TEST_F(VideoSendStreamTest, DoesUtilizeRedForVp9WithNackEnabled) { | 495 TEST_F(VideoSendStreamTest, DoesUtilizeRedForVp9WithNackEnabled) { |
496 FecObserver test(false, true, true, true, "VP9"); | 496 UlpfecObserver test(false, true, true, true, "VP9"); |
497 RunBaseTest(&test); | 497 RunBaseTest(&test); |
498 } | 498 } |
499 #endif // !defined(RTC_DISABLE_VP9) | 499 #endif // !defined(RTC_DISABLE_VP9) |
500 | 500 |
501 void VideoSendStreamTest::TestNackRetransmission( | 501 void VideoSendStreamTest::TestNackRetransmission( |
502 uint32_t retransmit_ssrc, | 502 uint32_t retransmit_ssrc, |
503 uint8_t retransmit_payload_type) { | 503 uint8_t retransmit_payload_type) { |
504 class NackObserver : public test::SendTest { | 504 class NackObserver : public test::SendTest { |
505 public: | 505 public: |
506 explicit NackObserver(uint32_t retransmit_ssrc, | 506 explicit NackObserver(uint32_t retransmit_ssrc, |
(...skipping 2381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2888 observation_complete_.Set(); | 2888 observation_complete_.Set(); |
2889 } | 2889 } |
2890 } | 2890 } |
2891 } test; | 2891 } test; |
2892 | 2892 |
2893 RunBaseTest(&test); | 2893 RunBaseTest(&test); |
2894 } | 2894 } |
2895 #endif // !defined(RTC_DISABLE_VP9) | 2895 #endif // !defined(RTC_DISABLE_VP9) |
2896 | 2896 |
2897 } // namespace webrtc | 2897 } // namespace webrtc |
OLD | NEW |