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> | 10 #include <algorithm> |
11 #include <map> | 11 #include <map> |
12 #include <sstream> | 12 #include <sstream> |
13 #include <string> | 13 #include <string> |
14 | 14 |
15 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
16 | 16 |
17 #include "webrtc/base/checks.h" | 17 #include "webrtc/base/checks.h" |
18 #include "webrtc/base/event.h" | 18 #include "webrtc/base/event.h" |
19 #include "webrtc/base/scoped_ptr.h" | 19 #include "webrtc/base/scoped_ptr.h" |
20 #include "webrtc/call.h" | 20 #include "webrtc/call.h" |
21 #include "webrtc/call/transport_adapter.h" | 21 #include "webrtc/call/transport_adapter.h" |
22 #include "webrtc/frame_callback.h" | 22 #include "webrtc/frame_callback.h" |
| 23 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h" |
23 #include "webrtc/modules/rtp_rtcp/source/byte_io.h" | 24 #include "webrtc/modules/rtp_rtcp/source/byte_io.h" |
24 #include "webrtc/modules/rtp_rtcp/source/rtcp_utility.h" | 25 #include "webrtc/modules/rtp_rtcp/source/rtcp_utility.h" |
25 #include "webrtc/modules/video_coding/codecs/vp8/include/vp8.h" | 26 #include "webrtc/modules/video_coding/codecs/vp8/include/vp8.h" |
26 #include "webrtc/modules/video_coding/codecs/vp9/include/vp9.h" | 27 #include "webrtc/modules/video_coding/codecs/vp9/include/vp9.h" |
27 #include "webrtc/modules/video_coding/include/video_coding_defines.h" | 28 #include "webrtc/modules/video_coding/include/video_coding_defines.h" |
28 #include "webrtc/system_wrappers/include/critical_section_wrapper.h" | 29 #include "webrtc/system_wrappers/include/critical_section_wrapper.h" |
29 #include "webrtc/system_wrappers/include/metrics.h" | 30 #include "webrtc/system_wrappers/include/metrics.h" |
30 #include "webrtc/system_wrappers/include/sleep.h" | 31 #include "webrtc/system_wrappers/include/sleep.h" |
31 #include "webrtc/test/call_test.h" | 32 #include "webrtc/test/call_test.h" |
32 #include "webrtc/test/direct_transport.h" | 33 #include "webrtc/test/direct_transport.h" |
(...skipping 1767 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1800 | 1801 |
1801 private: | 1802 private: |
1802 Call* sender_call_; | 1803 Call* sender_call_; |
1803 Call* receiver_call_; | 1804 Call* receiver_call_; |
1804 bool has_seen_pacer_delay_; | 1805 bool has_seen_pacer_delay_; |
1805 } test; | 1806 } test; |
1806 | 1807 |
1807 RunBaseTest(&test); | 1808 RunBaseTest(&test); |
1808 } | 1809 } |
1809 | 1810 |
| 1811 |
| 1812 // Verifies that it's possible to limit the send BWE by sending a REMB. |
| 1813 // This is verified by allowing the send BWE to ramp-up to >1000 kbps, |
| 1814 // then have the test generate a REMB of 500 kbps and verify that the send BWE |
| 1815 // is reduced to exactly 500 kbps. Then a REMB of 1000 kbps is generated and the |
| 1816 // test verifies that the send BWE ramps back up to exactly 1000 kbps. |
| 1817 TEST_F(EndToEndTest, RembWithSendSideBwe) { |
| 1818 class BweObserver : public test::EndToEndTest { |
| 1819 public: |
| 1820 BweObserver() |
| 1821 : EndToEndTest(kDefaultTimeoutMs), |
| 1822 sender_call_(nullptr), |
| 1823 clock_(Clock::GetRealTimeClock()), |
| 1824 sender_ssrc_(0), |
| 1825 remb_bitrate_bps_(1000000), |
| 1826 receive_transport_(nullptr), |
| 1827 event_(false, false), |
| 1828 poller_thread_(&BitrateStatsPollingThread, |
| 1829 this, |
| 1830 "BitrateStatsPollingThread"), |
| 1831 state_(kWaitForFirstRampUp) {} |
| 1832 |
| 1833 ~BweObserver() {} |
| 1834 |
| 1835 test::PacketTransport* CreateReceiveTransport() { |
| 1836 receive_transport_ = new test::PacketTransport( |
| 1837 nullptr, this, test::PacketTransport::kReceiver, |
| 1838 FakeNetworkPipe::Config()); |
| 1839 return receive_transport_; |
| 1840 } |
| 1841 |
| 1842 Call::Config GetSenderCallConfig() override { |
| 1843 Call::Config config; |
| 1844 // Set a high start bitrate to reduce the test completion time. |
| 1845 config.bitrate_config.start_bitrate_bps = remb_bitrate_bps_; |
| 1846 return config; |
| 1847 } |
| 1848 |
| 1849 void ModifyVideoConfigs( |
| 1850 VideoSendStream::Config* send_config, |
| 1851 std::vector<VideoReceiveStream::Config>* receive_configs, |
| 1852 VideoEncoderConfig* encoder_config) override { |
| 1853 ASSERT_EQ(1u, send_config->rtp.ssrcs.size()); |
| 1854 send_config->rtp.extensions.clear(); |
| 1855 send_config->rtp.extensions.push_back( |
| 1856 RtpExtension(RtpExtension::kTransportSequenceNumber, |
| 1857 test::kTransportSequenceNumberExtensionId)); |
| 1858 sender_ssrc_ = send_config->rtp.ssrcs[0]; |
| 1859 |
| 1860 encoder_config->streams[0].max_bitrate_bps = |
| 1861 encoder_config->streams[0].target_bitrate_bps = 2000000; |
| 1862 |
| 1863 ASSERT_EQ(1u, receive_configs->size()); |
| 1864 (*receive_configs)[0].rtp.remb = false; |
| 1865 (*receive_configs)[0].rtp.transport_cc = true; |
| 1866 (*receive_configs)[0].rtp.extensions = send_config->rtp.extensions; |
| 1867 RtpRtcp::Configuration config; |
| 1868 config.receiver_only = true; |
| 1869 config.clock = clock_; |
| 1870 config.outgoing_transport = receive_transport_; |
| 1871 rtp_rtcp_.reset(RtpRtcp::CreateRtpRtcp(config)); |
| 1872 rtp_rtcp_->SetRemoteSSRC((*receive_configs)[0].rtp.remote_ssrc); |
| 1873 rtp_rtcp_->SetSSRC((*receive_configs)[0].rtp.local_ssrc); |
| 1874 rtp_rtcp_->SetREMBStatus(true); |
| 1875 rtp_rtcp_->SetSendingStatus(true); |
| 1876 rtp_rtcp_->SetRTCPStatus(RtcpMode::kReducedSize); |
| 1877 } |
| 1878 |
| 1879 void OnCallsCreated(Call* sender_call, Call* receiver_call) override { |
| 1880 sender_call_ = sender_call; |
| 1881 } |
| 1882 |
| 1883 static bool BitrateStatsPollingThread(void* obj) { |
| 1884 return static_cast<BweObserver*>(obj)->PollStats(); |
| 1885 } |
| 1886 |
| 1887 bool PollStats() { |
| 1888 if (sender_call_) { |
| 1889 Call::Stats stats = sender_call_->GetStats(); |
| 1890 switch (state_) { |
| 1891 case kWaitForFirstRampUp: |
| 1892 if (stats.send_bandwidth_bps >= remb_bitrate_bps_) { |
| 1893 state_ = kWaitForRemb; |
| 1894 remb_bitrate_bps_ /= 2; |
| 1895 rtp_rtcp_->SetREMBData( |
| 1896 remb_bitrate_bps_, |
| 1897 std::vector<uint32_t>(&sender_ssrc_, &sender_ssrc_ + 1)); |
| 1898 rtp_rtcp_->SendRTCP(kRtcpRr); |
| 1899 } |
| 1900 break; |
| 1901 |
| 1902 case kWaitForRemb: |
| 1903 if (stats.send_bandwidth_bps == remb_bitrate_bps_) { |
| 1904 state_ = kWaitForSecondRampUp; |
| 1905 remb_bitrate_bps_ *= 2; |
| 1906 rtp_rtcp_->SetREMBData( |
| 1907 remb_bitrate_bps_, |
| 1908 std::vector<uint32_t>(&sender_ssrc_, &sender_ssrc_ + 1)); |
| 1909 rtp_rtcp_->SendRTCP(kRtcpRr); |
| 1910 } |
| 1911 break; |
| 1912 |
| 1913 case kWaitForSecondRampUp: |
| 1914 if (stats.send_bandwidth_bps == remb_bitrate_bps_) { |
| 1915 observation_complete_.Set(); |
| 1916 } |
| 1917 break; |
| 1918 } |
| 1919 } |
| 1920 |
| 1921 return !event_.Wait(1000); |
| 1922 } |
| 1923 |
| 1924 void PerformTest() override { |
| 1925 poller_thread_.Start(); |
| 1926 EXPECT_TRUE(Wait()) |
| 1927 << "Timed out while waiting for bitrate to change according to REMB."; |
| 1928 poller_thread_.Stop(); |
| 1929 } |
| 1930 |
| 1931 private: |
| 1932 enum TestState { kWaitForFirstRampUp, kWaitForRemb, kWaitForSecondRampUp }; |
| 1933 |
| 1934 Call* sender_call_; |
| 1935 Clock* const clock_; |
| 1936 uint32_t sender_ssrc_; |
| 1937 int remb_bitrate_bps_; |
| 1938 rtc::scoped_ptr<RtpRtcp> rtp_rtcp_; |
| 1939 test::PacketTransport* receive_transport_; |
| 1940 rtc::Event event_; |
| 1941 rtc::PlatformThread poller_thread_; |
| 1942 TestState state_; |
| 1943 } test; |
| 1944 |
| 1945 RunBaseTest(&test); |
| 1946 } |
| 1947 |
1810 TEST_F(EndToEndTest, VerifyNackStats) { | 1948 TEST_F(EndToEndTest, VerifyNackStats) { |
1811 static const int kPacketNumberToDrop = 200; | 1949 static const int kPacketNumberToDrop = 200; |
1812 class NackObserver : public test::EndToEndTest { | 1950 class NackObserver : public test::EndToEndTest { |
1813 public: | 1951 public: |
1814 NackObserver() | 1952 NackObserver() |
1815 : EndToEndTest(kLongTimeoutMs), | 1953 : EndToEndTest(kLongTimeoutMs), |
1816 sent_rtp_packets_(0), | 1954 sent_rtp_packets_(0), |
1817 dropped_rtp_packet_(0), | 1955 dropped_rtp_packet_(0), |
1818 dropped_rtp_packet_requested_(false), | 1956 dropped_rtp_packet_requested_(false), |
1819 send_stream_(nullptr), | 1957 send_stream_(nullptr), |
(...skipping 1536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3356 private: | 3494 private: |
3357 bool video_observed_; | 3495 bool video_observed_; |
3358 bool audio_observed_; | 3496 bool audio_observed_; |
3359 SequenceNumberUnwrapper unwrapper_; | 3497 SequenceNumberUnwrapper unwrapper_; |
3360 std::set<int64_t> received_packet_ids_; | 3498 std::set<int64_t> received_packet_ids_; |
3361 } test; | 3499 } test; |
3362 | 3500 |
3363 RunBaseTest(&test); | 3501 RunBaseTest(&test); |
3364 } | 3502 } |
3365 } // namespace webrtc | 3503 } // namespace webrtc |
OLD | NEW |