Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(160)

Side by Side Diff: webrtc/video/end_to_end_tests.cc

Issue 2181383002: Add NACK rate throttling for audio channels. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Rebase Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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> 10 #include <algorithm>
11 #include <list> 11 #include <list>
12 #include <map> 12 #include <map>
13 #include <memory> 13 #include <memory>
14 #include <sstream> 14 #include <sstream>
15 #include <string> 15 #include <string>
16 #include <vector> 16 #include <vector>
17 17
18 #include "testing/gtest/include/gtest/gtest.h" 18 #include "testing/gtest/include/gtest/gtest.h"
19 19
20 #include "webrtc/base/checks.h" 20 #include "webrtc/base/checks.h"
21 #include "webrtc/base/event.h" 21 #include "webrtc/base/event.h"
22 #include "webrtc/base/optional.h"
23 #include "webrtc/base/rate_limiter.h"
22 #include "webrtc/call.h" 24 #include "webrtc/call.h"
23 #include "webrtc/call/transport_adapter.h" 25 #include "webrtc/call/transport_adapter.h"
24 #include "webrtc/common_video/include/frame_callback.h" 26 #include "webrtc/common_video/include/frame_callback.h"
25 #include "webrtc/modules/include/module_common_types.h" 27 #include "webrtc/modules/include/module_common_types.h"
26 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h" 28 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h"
27 #include "webrtc/modules/rtp_rtcp/source/byte_io.h" 29 #include "webrtc/modules/rtp_rtcp/source/byte_io.h"
30 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/nack.h"
28 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/rapid_resync_request.h" 31 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/rapid_resync_request.h"
29 #include "webrtc/modules/rtp_rtcp/source/rtcp_utility.h" 32 #include "webrtc/modules/rtp_rtcp/source/rtcp_utility.h"
30 #include "webrtc/modules/rtp_rtcp/source/rtp_utility.h" 33 #include "webrtc/modules/rtp_rtcp/source/rtp_utility.h"
31 #include "webrtc/modules/video_coding/codecs/h264/include/h264.h" 34 #include "webrtc/modules/video_coding/codecs/h264/include/h264.h"
32 #include "webrtc/modules/video_coding/codecs/vp8/include/vp8.h" 35 #include "webrtc/modules/video_coding/codecs/vp8/include/vp8.h"
33 #include "webrtc/modules/video_coding/codecs/vp9/include/vp9.h" 36 #include "webrtc/modules/video_coding/codecs/vp9/include/vp9.h"
34 #include "webrtc/modules/video_coding/include/video_coding_defines.h" 37 #include "webrtc/modules/video_coding/include/video_coding_defines.h"
35 #include "webrtc/system_wrappers/include/metrics.h" 38 #include "webrtc/system_wrappers/include/metrics.h"
36 #include "webrtc/system_wrappers/include/metrics_default.h" 39 #include "webrtc/system_wrappers/include/metrics_default.h"
37 #include "webrtc/system_wrappers/include/sleep.h" 40 #include "webrtc/system_wrappers/include/sleep.h"
(...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after
480 std::set<uint16_t> dropped_packets_; 483 std::set<uint16_t> dropped_packets_;
481 std::set<uint16_t> retransmitted_packets_; 484 std::set<uint16_t> retransmitted_packets_;
482 uint64_t sent_rtp_packets_; 485 uint64_t sent_rtp_packets_;
483 int packets_left_to_drop_; 486 int packets_left_to_drop_;
484 int nacks_left_ GUARDED_BY(&crit_); 487 int nacks_left_ GUARDED_BY(&crit_);
485 } test; 488 } test;
486 489
487 RunBaseTest(&test); 490 RunBaseTest(&test);
488 } 491 }
489 492
493 TEST_F(EndToEndTest, ReceivesNackAndRetransmitsAudio) {
494 class NackObserver : public test::EndToEndTest {
495 public:
496 NackObserver()
497 : EndToEndTest(kLongTimeoutMs),
498 local_ssrc_(0),
499 remote_ssrc_(0),
500 receive_transport_(nullptr) {}
501
502 private:
503 size_t GetNumVideoStreams() const override { return 0; }
504 size_t GetNumAudioStreams() const override { return 1; }
505
506 test::PacketTransport* CreateReceiveTransport() override {
507 test::PacketTransport* receive_transport = new test::PacketTransport(
508 nullptr, this, test::PacketTransport::kReceiver,
509 FakeNetworkPipe::Config());
510 receive_transport_ = receive_transport;
511 return receive_transport;
512 }
513
514 Action OnSendRtp(const uint8_t* packet, size_t length) override {
515 RTPHeader header;
516 EXPECT_TRUE(parser_->Parse(packet, length, &header));
517
518 if (!sequence_number_to_retransmit_) {
519 sequence_number_to_retransmit_ =
520 rtc::Optional<uint16_t>(header.sequenceNumber);
521
522 // Don't ask for retransmission straight away, may be deduped in pacer.
523 } else if (header.sequenceNumber == *sequence_number_to_retransmit_) {
524 observation_complete_.Set();
525 } else {
526 // Send a NACK as often as necessary until retransmission is received.
527 rtcp::Nack nack;
528 nack.From(local_ssrc_);
529 nack.To(remote_ssrc_);
530 uint16_t nack_list[] = {*sequence_number_to_retransmit_};
531 nack.WithList(nack_list, 1);
532 rtc::Buffer buffer = nack.Build();
533
534 EXPECT_TRUE(receive_transport_->SendRtcp(buffer.data(), buffer.size()));
535 }
536
537 return SEND_PACKET;
538 }
539
540 void ModifyAudioConfigs(
541 AudioSendStream::Config* send_config,
542 std::vector<AudioReceiveStream::Config>* receive_configs) override {
543 send_config->rtp.nack.rtp_history_ms = kNackRtpHistoryMs;
544 (*receive_configs)[0].rtp.nack.rtp_history_ms = kNackRtpHistoryMs;
545 local_ssrc_ = (*receive_configs)[0].rtp.local_ssrc;
546 remote_ssrc_ = (*receive_configs)[0].rtp.remote_ssrc;
547 }
548
549 void PerformTest() override {
550 EXPECT_TRUE(Wait())
551 << "Timed out waiting for packets to be NACKed, retransmitted and "
552 "rendered.";
553 }
554
555 uint32_t local_ssrc_;
556 uint32_t remote_ssrc_;
557 Transport* receive_transport_;
558 rtc::Optional<uint16_t> sequence_number_to_retransmit_;
559 } test;
560
561 RunBaseTest(&test);
562 }
563
490 TEST_F(EndToEndTest, CanReceiveFec) { 564 TEST_F(EndToEndTest, CanReceiveFec) {
491 class FecRenderObserver : public test::EndToEndTest, 565 class FecRenderObserver : public test::EndToEndTest,
492 public rtc::VideoSinkInterface<VideoFrame> { 566 public rtc::VideoSinkInterface<VideoFrame> {
493 public: 567 public:
494 FecRenderObserver() 568 FecRenderObserver()
495 : EndToEndTest(kDefaultTimeoutMs), state_(kFirstPacket) {} 569 : EndToEndTest(kDefaultTimeoutMs), state_(kFirstPacket) {}
496 570
497 private: 571 private:
498 Action OnSendRtp(const uint8_t* packet, size_t length) override { 572 Action OnSendRtp(const uint8_t* packet, size_t length) override {
499 rtc::CritScope lock(&crit_); 573 rtc::CritScope lock(&crit_);
(...skipping 1300 matching lines...) Expand 10 before | Expand all | Expand 10 after
1800 : EndToEndTest(kDefaultTimeoutMs), 1874 : EndToEndTest(kDefaultTimeoutMs),
1801 sender_call_(nullptr), 1875 sender_call_(nullptr),
1802 clock_(Clock::GetRealTimeClock()), 1876 clock_(Clock::GetRealTimeClock()),
1803 sender_ssrc_(0), 1877 sender_ssrc_(0),
1804 remb_bitrate_bps_(1000000), 1878 remb_bitrate_bps_(1000000),
1805 receive_transport_(nullptr), 1879 receive_transport_(nullptr),
1806 event_(false, false), 1880 event_(false, false),
1807 poller_thread_(&BitrateStatsPollingThread, 1881 poller_thread_(&BitrateStatsPollingThread,
1808 this, 1882 this,
1809 "BitrateStatsPollingThread"), 1883 "BitrateStatsPollingThread"),
1810 state_(kWaitForFirstRampUp) {} 1884 state_(kWaitForFirstRampUp),
1885 retransmission_rate_limiter_(clock_, 1000) {}
1811 1886
1812 ~BweObserver() {} 1887 ~BweObserver() {}
1813 1888
1814 test::PacketTransport* CreateReceiveTransport() override { 1889 test::PacketTransport* CreateReceiveTransport() override {
1815 receive_transport_ = new test::PacketTransport( 1890 receive_transport_ = new test::PacketTransport(
1816 nullptr, this, test::PacketTransport::kReceiver, 1891 nullptr, this, test::PacketTransport::kReceiver,
1817 FakeNetworkPipe::Config()); 1892 FakeNetworkPipe::Config());
1818 return receive_transport_; 1893 return receive_transport_;
1819 } 1894 }
1820 1895
(...skipping 19 matching lines...) Expand all
1840 encoder_config->streams[0].target_bitrate_bps = 2000000; 1915 encoder_config->streams[0].target_bitrate_bps = 2000000;
1841 1916
1842 ASSERT_EQ(1u, receive_configs->size()); 1917 ASSERT_EQ(1u, receive_configs->size());
1843 (*receive_configs)[0].rtp.remb = false; 1918 (*receive_configs)[0].rtp.remb = false;
1844 (*receive_configs)[0].rtp.transport_cc = true; 1919 (*receive_configs)[0].rtp.transport_cc = true;
1845 (*receive_configs)[0].rtp.extensions = send_config->rtp.extensions; 1920 (*receive_configs)[0].rtp.extensions = send_config->rtp.extensions;
1846 RtpRtcp::Configuration config; 1921 RtpRtcp::Configuration config;
1847 config.receiver_only = true; 1922 config.receiver_only = true;
1848 config.clock = clock_; 1923 config.clock = clock_;
1849 config.outgoing_transport = receive_transport_; 1924 config.outgoing_transport = receive_transport_;
1925 config.retransmission_rate_limiter = &retransmission_rate_limiter_;
1850 rtp_rtcp_.reset(RtpRtcp::CreateRtpRtcp(config)); 1926 rtp_rtcp_.reset(RtpRtcp::CreateRtpRtcp(config));
1851 rtp_rtcp_->SetRemoteSSRC((*receive_configs)[0].rtp.remote_ssrc); 1927 rtp_rtcp_->SetRemoteSSRC((*receive_configs)[0].rtp.remote_ssrc);
1852 rtp_rtcp_->SetSSRC((*receive_configs)[0].rtp.local_ssrc); 1928 rtp_rtcp_->SetSSRC((*receive_configs)[0].rtp.local_ssrc);
1853 rtp_rtcp_->SetREMBStatus(true); 1929 rtp_rtcp_->SetREMBStatus(true);
1854 rtp_rtcp_->SetSendingStatus(true); 1930 rtp_rtcp_->SetSendingStatus(true);
1855 rtp_rtcp_->SetRTCPStatus(RtcpMode::kReducedSize); 1931 rtp_rtcp_->SetRTCPStatus(RtcpMode::kReducedSize);
1856 } 1932 }
1857 1933
1858 void OnCallsCreated(Call* sender_call, Call* receiver_call) override { 1934 void OnCallsCreated(Call* sender_call, Call* receiver_call) override {
1859 sender_call_ = sender_call; 1935 sender_call_ = sender_call;
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
1912 1988
1913 Call* sender_call_; 1989 Call* sender_call_;
1914 Clock* const clock_; 1990 Clock* const clock_;
1915 uint32_t sender_ssrc_; 1991 uint32_t sender_ssrc_;
1916 int remb_bitrate_bps_; 1992 int remb_bitrate_bps_;
1917 std::unique_ptr<RtpRtcp> rtp_rtcp_; 1993 std::unique_ptr<RtpRtcp> rtp_rtcp_;
1918 test::PacketTransport* receive_transport_; 1994 test::PacketTransport* receive_transport_;
1919 rtc::Event event_; 1995 rtc::Event event_;
1920 rtc::PlatformThread poller_thread_; 1996 rtc::PlatformThread poller_thread_;
1921 TestState state_; 1997 TestState state_;
1998 RateLimiter retransmission_rate_limiter_;
1922 } test; 1999 } test;
1923 2000
1924 RunBaseTest(&test); 2001 RunBaseTest(&test);
1925 } 2002 }
1926 2003
1927 TEST_F(EndToEndTest, VerifyNackStats) { 2004 TEST_F(EndToEndTest, VerifyNackStats) {
1928 static const int kPacketNumberToDrop = 200; 2005 static const int kPacketNumberToDrop = 200;
1929 class NackObserver : public test::EndToEndTest { 2006 class NackObserver : public test::EndToEndTest {
1930 public: 2007 public:
1931 NackObserver() 2008 NackObserver()
(...skipping 1723 matching lines...) Expand 10 before | Expand all | Expand 10 after
3655 private: 3732 private:
3656 bool video_observed_; 3733 bool video_observed_;
3657 bool audio_observed_; 3734 bool audio_observed_;
3658 SequenceNumberUnwrapper unwrapper_; 3735 SequenceNumberUnwrapper unwrapper_;
3659 std::set<int64_t> received_packet_ids_; 3736 std::set<int64_t> received_packet_ids_;
3660 } test; 3737 } test;
3661 3738
3662 RunBaseTest(&test); 3739 RunBaseTest(&test);
3663 } 3740 }
3664 } // namespace webrtc 3741 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/rtp_rtcp/test/testAPI/test_api_video.cc ('k') | webrtc/video/rtp_stream_receiver.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698