| 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 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 301 | 301 |
| 302 std::unique_ptr<LossyStatistician> lossy_stats_; | 302 std::unique_ptr<LossyStatistician> lossy_stats_; |
| 303 StatisticianMap stats_map_; | 303 StatisticianMap stats_map_; |
| 304 }; | 304 }; |
| 305 | 305 |
| 306 class FecObserver : public test::EndToEndTest { | 306 class FecObserver : public test::EndToEndTest { |
| 307 public: | 307 public: |
| 308 FecObserver(bool header_extensions_enabled, | 308 FecObserver(bool header_extensions_enabled, |
| 309 bool use_nack, | 309 bool use_nack, |
| 310 bool expect_red, | 310 bool expect_red, |
| 311 bool expect_fec, |
| 311 const std::string& codec) | 312 const std::string& codec) |
| 312 : EndToEndTest(VideoSendStreamTest::kDefaultTimeoutMs), | 313 : EndToEndTest(VideoSendStreamTest::kDefaultTimeoutMs), |
| 313 payload_name_(codec), | 314 payload_name_(codec), |
| 314 use_nack_(use_nack), | 315 use_nack_(use_nack), |
| 315 expect_red_(expect_red), | 316 expect_red_(expect_red), |
| 317 expect_fec_(expect_fec), |
| 316 send_count_(0), | 318 send_count_(0), |
| 317 received_media_(false), | 319 received_media_(false), |
| 318 received_fec_(false), | 320 received_fec_(false), |
| 319 header_extensions_enabled_(header_extensions_enabled) { | 321 header_extensions_enabled_(header_extensions_enabled) { |
| 320 if (codec == "H264") { | 322 if (codec == "H264") { |
| 321 encoder_.reset(new test::FakeH264Encoder(Clock::GetRealTimeClock())); | 323 encoder_.reset(new test::FakeH264Encoder(Clock::GetRealTimeClock())); |
| 322 } else if (codec == "VP8") { | 324 } else if (codec == "VP8") { |
| 323 encoder_.reset(VideoEncoder::Create(VideoEncoder::EncoderType::kVp8)); | 325 encoder_.reset(VideoEncoder::Create(VideoEncoder::EncoderType::kVp8)); |
| 324 } else if (codec == "VP9") { | 326 } else if (codec == "VP9") { |
| 325 encoder_.reset(VideoEncoder::Create(VideoEncoder::EncoderType::kVp9)); | 327 encoder_.reset(VideoEncoder::Create(VideoEncoder::EncoderType::kVp9)); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 368 } | 370 } |
| 369 EXPECT_TRUE(header.extension.hasTransportSequenceNumber); | 371 EXPECT_TRUE(header.extension.hasTransportSequenceNumber); |
| 370 uint16_t seq_num_diff = header.extension.transportSequenceNumber - | 372 uint16_t seq_num_diff = header.extension.transportSequenceNumber - |
| 371 prev_header_.extension.transportSequenceNumber; | 373 prev_header_.extension.transportSequenceNumber; |
| 372 EXPECT_EQ(1, seq_num_diff); | 374 EXPECT_EQ(1, seq_num_diff); |
| 373 } | 375 } |
| 374 | 376 |
| 375 if (encapsulated_payload_type != -1) { | 377 if (encapsulated_payload_type != -1) { |
| 376 if (encapsulated_payload_type == | 378 if (encapsulated_payload_type == |
| 377 VideoSendStreamTest::kUlpfecPayloadType) { | 379 VideoSendStreamTest::kUlpfecPayloadType) { |
| 380 EXPECT_TRUE(expect_fec_); |
| 378 received_fec_ = true; | 381 received_fec_ = true; |
| 379 } else { | 382 } else { |
| 380 received_media_ = true; | 383 received_media_ = true; |
| 381 } | 384 } |
| 382 } | 385 } |
| 383 | 386 |
| 384 if (send_count_ > 100 && received_media_) { | 387 if (send_count_ > 100 && received_media_) { |
| 385 if (received_fec_ || !expect_red_) | 388 if (received_fec_ || !expect_fec_) |
| 386 observation_complete_.Set(); | 389 observation_complete_.Set(); |
| 387 } | 390 } |
| 388 | 391 |
| 389 prev_header_ = header; | 392 prev_header_ = header; |
| 390 | 393 |
| 391 return SEND_PACKET; | 394 return SEND_PACKET; |
| 392 } | 395 } |
| 393 | 396 |
| 394 test::PacketTransport* CreateSendTransport(Call* sender_call) override { | 397 test::PacketTransport* CreateSendTransport(Call* sender_call) override { |
| 395 // At low RTT (< kLowRttNackMs) -> NACK only, no FEC. | 398 // At low RTT (< kLowRttNackMs) -> NACK only, no FEC. |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 435 | 438 |
| 436 void PerformTest() override { | 439 void PerformTest() override { |
| 437 EXPECT_TRUE(Wait()) << "Timed out waiting for FEC and media packets."; | 440 EXPECT_TRUE(Wait()) << "Timed out waiting for FEC and media packets."; |
| 438 } | 441 } |
| 439 | 442 |
| 440 std::unique_ptr<internal::TransportAdapter> transport_adapter_; | 443 std::unique_ptr<internal::TransportAdapter> transport_adapter_; |
| 441 std::unique_ptr<VideoEncoder> encoder_; | 444 std::unique_ptr<VideoEncoder> encoder_; |
| 442 const std::string payload_name_; | 445 const std::string payload_name_; |
| 443 const bool use_nack_; | 446 const bool use_nack_; |
| 444 const bool expect_red_; | 447 const bool expect_red_; |
| 448 const bool expect_fec_; |
| 445 int send_count_; | 449 int send_count_; |
| 446 bool received_media_; | 450 bool received_media_; |
| 447 bool received_fec_; | 451 bool received_fec_; |
| 448 bool header_extensions_enabled_; | 452 bool header_extensions_enabled_; |
| 449 RTPHeader prev_header_; | 453 RTPHeader prev_header_; |
| 450 }; | 454 }; |
| 451 | 455 |
| 452 TEST_F(VideoSendStreamTest, SupportsFecWithExtensions) { | 456 TEST_F(VideoSendStreamTest, SupportsFecWithExtensions) { |
| 453 FecObserver test(true, false, true, "VP8"); | 457 FecObserver test(true, false, true, true, "VP8"); |
| 454 RunBaseTest(&test); | 458 RunBaseTest(&test); |
| 455 } | 459 } |
| 456 | 460 |
| 457 TEST_F(VideoSendStreamTest, SupportsFecWithoutExtensions) { | 461 TEST_F(VideoSendStreamTest, SupportsFecWithoutExtensions) { |
| 458 FecObserver test(false, false, true, "VP8"); | 462 FecObserver test(false, false, true, true, "VP8"); |
| 459 RunBaseTest(&test); | 463 RunBaseTest(&test); |
| 460 } | 464 } |
| 461 | 465 |
| 462 // The FEC scheme used is not efficient for H264, so we should not use RED/FEC | 466 // The FEC scheme used is not efficient for H264, so we should not use RED/FEC |
| 463 // since we'll still have to re-request FEC packets, effectively wasting | 467 // since we'll still have to re-request FEC packets, effectively wasting |
| 464 // bandwidth since the receiver has to wait for FEC retransmissions to determine | 468 // bandwidth since the receiver has to wait for FEC retransmissions to determine |
| 465 // that the received state is actually decodable. | 469 // that the received state is actually decodable. |
| 466 TEST_F(VideoSendStreamTest, DoesNotUtilizeRedForH264WithNackEnabled) { | 470 TEST_F(VideoSendStreamTest, DoesNotUtilizeFecForH264WithNackEnabled) { |
| 467 FecObserver test(false, true, false, "H264"); | 471 FecObserver test(false, true, true, false, "H264"); |
| 468 RunBaseTest(&test); | 472 RunBaseTest(&test); |
| 469 } | 473 } |
| 470 | 474 |
| 471 // Without retransmissions FEC for H264 is fine. | 475 // Without retransmissions FEC for H264 is fine. |
| 472 TEST_F(VideoSendStreamTest, DoesUtilizeRedForH264WithoutNackEnabled) { | 476 TEST_F(VideoSendStreamTest, DoesUtilizeRedForH264WithoutNackEnabled) { |
| 473 FecObserver test(false, false, true, "H264"); | 477 FecObserver test(false, false, true, true, "H264"); |
| 474 RunBaseTest(&test); | 478 RunBaseTest(&test); |
| 475 } | 479 } |
| 476 | 480 |
| 477 TEST_F(VideoSendStreamTest, DoesUtilizeRedForVp8WithNackEnabled) { | 481 TEST_F(VideoSendStreamTest, DoesUtilizeRedForVp8WithNackEnabled) { |
| 478 FecObserver test(false, true, true, "VP8"); | 482 FecObserver test(false, true, true, true, "VP8"); |
| 479 RunBaseTest(&test); | 483 RunBaseTest(&test); |
| 480 } | 484 } |
| 481 | 485 |
| 482 #if !defined(RTC_DISABLE_VP9) | 486 #if !defined(RTC_DISABLE_VP9) |
| 483 TEST_F(VideoSendStreamTest, DoesUtilizeRedForVp9WithNackEnabled) { | 487 TEST_F(VideoSendStreamTest, DoesUtilizeRedForVp9WithNackEnabled) { |
| 484 FecObserver test(false, true, true, "VP9"); | 488 FecObserver test(false, true, true, true, "VP9"); |
| 485 RunBaseTest(&test); | 489 RunBaseTest(&test); |
| 486 } | 490 } |
| 487 #endif // !defined(RTC_DISABLE_VP9) | 491 #endif // !defined(RTC_DISABLE_VP9) |
| 488 | 492 |
| 489 void VideoSendStreamTest::TestNackRetransmission( | 493 void VideoSendStreamTest::TestNackRetransmission( |
| 490 uint32_t retransmit_ssrc, | 494 uint32_t retransmit_ssrc, |
| 491 uint8_t retransmit_payload_type) { | 495 uint8_t retransmit_payload_type) { |
| 492 class NackObserver : public test::SendTest { | 496 class NackObserver : public test::SendTest { |
| 493 public: | 497 public: |
| 494 explicit NackObserver(uint32_t retransmit_ssrc, | 498 explicit NackObserver(uint32_t retransmit_ssrc, |
| (...skipping 1797 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2292 observation_complete_.Set(); | 2296 observation_complete_.Set(); |
| 2293 } | 2297 } |
| 2294 } | 2298 } |
| 2295 } test; | 2299 } test; |
| 2296 | 2300 |
| 2297 RunBaseTest(&test); | 2301 RunBaseTest(&test); |
| 2298 } | 2302 } |
| 2299 #endif // !defined(RTC_DISABLE_VP9) | 2303 #endif // !defined(RTC_DISABLE_VP9) |
| 2300 | 2304 |
| 2301 } // namespace webrtc | 2305 } // namespace webrtc |
| OLD | NEW |