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

Side by Side Diff: webrtc/video/video_send_stream_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
« no previous file with comments | « webrtc/video/video_receive_stream.cc ('k') | webrtc/voice_engine/channel.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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> // max 10 #include <algorithm> // max
11 #include <memory> 11 #include <memory>
12 #include <vector> 12 #include <vector>
13 13
14 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
15 15
16 #include "webrtc/base/bind.h" 16 #include "webrtc/base/bind.h"
17 #include "webrtc/base/checks.h" 17 #include "webrtc/base/checks.h"
18 #include "webrtc/base/criticalsection.h" 18 #include "webrtc/base/criticalsection.h"
19 #include "webrtc/base/event.h" 19 #include "webrtc/base/event.h"
20 #include "webrtc/base/logging.h" 20 #include "webrtc/base/logging.h"
21 #include "webrtc/base/platform_thread.h" 21 #include "webrtc/base/platform_thread.h"
22 #include "webrtc/base/rate_limiter.h"
22 #include "webrtc/call.h" 23 #include "webrtc/call.h"
23 #include "webrtc/call/transport_adapter.h" 24 #include "webrtc/call/transport_adapter.h"
24 #include "webrtc/common_video/include/frame_callback.h" 25 #include "webrtc/common_video/include/frame_callback.h"
25 #include "webrtc/modules/rtp_rtcp/include/rtp_header_parser.h" 26 #include "webrtc/modules/rtp_rtcp/include/rtp_header_parser.h"
26 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h" 27 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h"
27 #include "webrtc/modules/rtp_rtcp/source/rtcp_sender.h" 28 #include "webrtc/modules/rtp_rtcp/source/rtcp_sender.h"
28 #include "webrtc/modules/rtp_rtcp/source/rtcp_utility.h" 29 #include "webrtc/modules/rtp_rtcp/source/rtcp_utility.h"
29 #include "webrtc/modules/rtp_rtcp/source/rtp_format_vp9.h" 30 #include "webrtc/modules/rtp_rtcp/source/rtp_format_vp9.h"
30 #include "webrtc/modules/video_coding/codecs/vp9/include/vp9.h" 31 #include "webrtc/modules/video_coding/codecs/vp9/include/vp9.h"
31 #include "webrtc/system_wrappers/include/sleep.h" 32 #include "webrtc/system_wrappers/include/sleep.h"
(...skipping 780 matching lines...) Expand 10 before | Expand all | Expand 10 after
812 // is no longer suspended, the test ends. 813 // is no longer suspended, the test ends.
813 TEST_F(VideoSendStreamTest, SuspendBelowMinBitrate) { 814 TEST_F(VideoSendStreamTest, SuspendBelowMinBitrate) {
814 static const int kSuspendTimeFrames = 60; // Suspend for 2 seconds @ 30 fps. 815 static const int kSuspendTimeFrames = 60; // Suspend for 2 seconds @ 30 fps.
815 816
816 class RembObserver : public test::SendTest, 817 class RembObserver : public test::SendTest,
817 public rtc::VideoSinkInterface<VideoFrame> { 818 public rtc::VideoSinkInterface<VideoFrame> {
818 public: 819 public:
819 RembObserver() 820 RembObserver()
820 : SendTest(kDefaultTimeoutMs), 821 : SendTest(kDefaultTimeoutMs),
821 clock_(Clock::GetRealTimeClock()), 822 clock_(Clock::GetRealTimeClock()),
823 stream_(nullptr),
822 test_state_(kBeforeSuspend), 824 test_state_(kBeforeSuspend),
823 rtp_count_(0), 825 rtp_count_(0),
824 last_sequence_number_(0), 826 last_sequence_number_(0),
825 suspended_frame_count_(0), 827 suspended_frame_count_(0),
826 low_remb_bps_(0), 828 low_remb_bps_(0),
827 high_remb_bps_(0) { 829 high_remb_bps_(0) {}
828 }
829 830
830 private: 831 private:
831 Action OnSendRtp(const uint8_t* packet, size_t length) override { 832 Action OnSendRtp(const uint8_t* packet, size_t length) override {
832 rtc::CritScope lock(&crit_); 833 rtc::CritScope lock(&crit_);
833 ++rtp_count_; 834 ++rtp_count_;
834 RTPHeader header; 835 RTPHeader header;
835 EXPECT_TRUE(parser_->Parse(packet, length, &header)); 836 EXPECT_TRUE(parser_->Parse(packet, length, &header));
836 last_sequence_number_ = header.sequenceNumber; 837 last_sequence_number_ = header.sequenceNumber;
837 838
838 if (test_state_ == kBeforeSuspend) { 839 if (test_state_ == kBeforeSuspend) {
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
1042 // bitrate since no receiver block or remb is sent in the initial phase. 1043 // bitrate since no receiver block or remb is sent in the initial phase.
1043 TEST_F(VideoSendStreamTest, MinTransmitBitrateRespectsRemb) { 1044 TEST_F(VideoSendStreamTest, MinTransmitBitrateRespectsRemb) {
1044 static const int kMinTransmitBitrateBps = 400000; 1045 static const int kMinTransmitBitrateBps = 400000;
1045 static const int kHighBitrateBps = 150000; 1046 static const int kHighBitrateBps = 150000;
1046 static const int kRembBitrateBps = 80000; 1047 static const int kRembBitrateBps = 80000;
1047 static const int kRembRespectedBitrateBps = 100000; 1048 static const int kRembRespectedBitrateBps = 100000;
1048 class BitrateObserver : public test::SendTest { 1049 class BitrateObserver : public test::SendTest {
1049 public: 1050 public:
1050 BitrateObserver() 1051 BitrateObserver()
1051 : SendTest(kDefaultTimeoutMs), 1052 : SendTest(kDefaultTimeoutMs),
1052 bitrate_capped_(false) { 1053 retranmission_rate_limiter_(Clock::GetRealTimeClock(), 1000),
1053 } 1054 stream_(nullptr),
1055 bitrate_capped_(false) {}
1054 1056
1055 private: 1057 private:
1056 Action OnSendRtp(const uint8_t* packet, size_t length) override { 1058 Action OnSendRtp(const uint8_t* packet, size_t length) override {
1057 if (RtpHeaderParser::IsRtcp(packet, length)) 1059 if (RtpHeaderParser::IsRtcp(packet, length))
1058 return DROP_PACKET; 1060 return DROP_PACKET;
1059 1061
1060 RTPHeader header; 1062 RTPHeader header;
1061 if (!parser_->Parse(packet, length, &header)) 1063 if (!parser_->Parse(packet, length, &header))
1062 return DROP_PACKET; 1064 return DROP_PACKET;
1063 RTC_DCHECK(stream_); 1065 RTC_DCHECK(stream_);
(...skipping 21 matching lines...) Expand all
1085 // Packets don't have to be delivered since the test is the receiver. 1087 // Packets don't have to be delivered since the test is the receiver.
1086 return DROP_PACKET; 1088 return DROP_PACKET;
1087 } 1089 }
1088 1090
1089 void OnVideoStreamsCreated( 1091 void OnVideoStreamsCreated(
1090 VideoSendStream* send_stream, 1092 VideoSendStream* send_stream,
1091 const std::vector<VideoReceiveStream*>& receive_streams) override { 1093 const std::vector<VideoReceiveStream*>& receive_streams) override {
1092 stream_ = send_stream; 1094 stream_ = send_stream;
1093 RtpRtcp::Configuration config; 1095 RtpRtcp::Configuration config;
1094 config.outgoing_transport = feedback_transport_.get(); 1096 config.outgoing_transport = feedback_transport_.get();
1097 config.retransmission_rate_limiter = &retranmission_rate_limiter_;
1095 rtp_rtcp_.reset(RtpRtcp::CreateRtpRtcp(config)); 1098 rtp_rtcp_.reset(RtpRtcp::CreateRtpRtcp(config));
1096 rtp_rtcp_->SetREMBStatus(true); 1099 rtp_rtcp_->SetREMBStatus(true);
1097 rtp_rtcp_->SetRTCPStatus(RtcpMode::kReducedSize); 1100 rtp_rtcp_->SetRTCPStatus(RtcpMode::kReducedSize);
1098 } 1101 }
1099 1102
1100 void ModifyVideoConfigs( 1103 void ModifyVideoConfigs(
1101 VideoSendStream::Config* send_config, 1104 VideoSendStream::Config* send_config,
1102 std::vector<VideoReceiveStream::Config>* receive_configs, 1105 std::vector<VideoReceiveStream::Config>* receive_configs,
1103 VideoEncoderConfig* encoder_config) override { 1106 VideoEncoderConfig* encoder_config) override {
1104 feedback_transport_.reset( 1107 feedback_transport_.reset(
1105 new internal::TransportAdapter(send_config->send_transport)); 1108 new internal::TransportAdapter(send_config->send_transport));
1106 feedback_transport_->Enable(); 1109 feedback_transport_->Enable();
1107 encoder_config->min_transmit_bitrate_bps = kMinTransmitBitrateBps; 1110 encoder_config->min_transmit_bitrate_bps = kMinTransmitBitrateBps;
1108 } 1111 }
1109 1112
1110 void PerformTest() override { 1113 void PerformTest() override {
1111 EXPECT_TRUE(Wait()) 1114 EXPECT_TRUE(Wait())
1112 << "Timeout while waiting for low bitrate stats after REMB."; 1115 << "Timeout while waiting for low bitrate stats after REMB.";
1113 } 1116 }
1114 1117
1115 std::unique_ptr<RtpRtcp> rtp_rtcp_; 1118 std::unique_ptr<RtpRtcp> rtp_rtcp_;
1116 std::unique_ptr<internal::TransportAdapter> feedback_transport_; 1119 std::unique_ptr<internal::TransportAdapter> feedback_transport_;
1120 RateLimiter retranmission_rate_limiter_;
1117 VideoSendStream* stream_; 1121 VideoSendStream* stream_;
1118 bool bitrate_capped_; 1122 bool bitrate_capped_;
1119 } test; 1123 } test;
1120 1124
1121 RunBaseTest(&test); 1125 RunBaseTest(&test);
1122 } 1126 }
1123 1127
1124 TEST_F(VideoSendStreamTest, ChangingNetworkRoute) { 1128 TEST_F(VideoSendStreamTest, ChangingNetworkRoute) {
1125 class ChangingNetworkRouteTest : public test::EndToEndTest { 1129 class ChangingNetworkRouteTest : public test::EndToEndTest {
1126 public: 1130 public:
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after
1497 frame.set_timestamp(data); 1501 frame.set_timestamp(data);
1498 frame.set_render_time_ms(data); 1502 frame.set_render_time_ms(data);
1499 return frame; 1503 return frame;
1500 } 1504 }
1501 1505
1502 TEST_F(VideoSendStreamTest, EncoderIsProperlyInitializedAndDestroyed) { 1506 TEST_F(VideoSendStreamTest, EncoderIsProperlyInitializedAndDestroyed) {
1503 class EncoderStateObserver : public test::SendTest, public VideoEncoder { 1507 class EncoderStateObserver : public test::SendTest, public VideoEncoder {
1504 public: 1508 public:
1505 EncoderStateObserver() 1509 EncoderStateObserver()
1506 : SendTest(kDefaultTimeoutMs), 1510 : SendTest(kDefaultTimeoutMs),
1511 stream_(nullptr),
1507 initialized_(false), 1512 initialized_(false),
1508 callback_registered_(false), 1513 callback_registered_(false),
1509 num_releases_(0), 1514 num_releases_(0),
1510 released_(false) {} 1515 released_(false) {}
1511 1516
1512 bool IsReleased() { 1517 bool IsReleased() {
1513 rtc::CritScope lock(&crit_); 1518 rtc::CritScope lock(&crit_);
1514 return released_; 1519 return released_;
1515 } 1520 }
1516 1521
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
1617 } 1622 }
1618 1623
1619 TEST_F(VideoSendStreamTest, EncoderSetupPropagatesCommonEncoderConfigValues) { 1624 TEST_F(VideoSendStreamTest, EncoderSetupPropagatesCommonEncoderConfigValues) {
1620 class VideoCodecConfigObserver : public test::SendTest, 1625 class VideoCodecConfigObserver : public test::SendTest,
1621 public test::FakeEncoder { 1626 public test::FakeEncoder {
1622 public: 1627 public:
1623 VideoCodecConfigObserver() 1628 VideoCodecConfigObserver()
1624 : SendTest(kDefaultTimeoutMs), 1629 : SendTest(kDefaultTimeoutMs),
1625 FakeEncoder(Clock::GetRealTimeClock()), 1630 FakeEncoder(Clock::GetRealTimeClock()),
1626 init_encode_event_(false, false), 1631 init_encode_event_(false, false),
1627 num_initializations_(0) {} 1632 num_initializations_(0),
1633 stream_(nullptr) {}
1628 1634
1629 private: 1635 private:
1630 void ModifyVideoConfigs( 1636 void ModifyVideoConfigs(
1631 VideoSendStream::Config* send_config, 1637 VideoSendStream::Config* send_config,
1632 std::vector<VideoReceiveStream::Config>* receive_configs, 1638 std::vector<VideoReceiveStream::Config>* receive_configs,
1633 VideoEncoderConfig* encoder_config) override { 1639 VideoEncoderConfig* encoder_config) override {
1634 send_config->encoder_settings.encoder = this; 1640 send_config->encoder_settings.encoder = this;
1635 encoder_config_ = *encoder_config; 1641 encoder_config_ = *encoder_config;
1636 } 1642 }
1637 1643
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
1682 class VideoCodecConfigObserver : public test::SendTest, 1688 class VideoCodecConfigObserver : public test::SendTest,
1683 public test::FakeEncoder { 1689 public test::FakeEncoder {
1684 public: 1690 public:
1685 VideoCodecConfigObserver(VideoCodecType video_codec_type, 1691 VideoCodecConfigObserver(VideoCodecType video_codec_type,
1686 const char* codec_name) 1692 const char* codec_name)
1687 : SendTest(VideoSendStreamTest::kDefaultTimeoutMs), 1693 : SendTest(VideoSendStreamTest::kDefaultTimeoutMs),
1688 FakeEncoder(Clock::GetRealTimeClock()), 1694 FakeEncoder(Clock::GetRealTimeClock()),
1689 video_codec_type_(video_codec_type), 1695 video_codec_type_(video_codec_type),
1690 codec_name_(codec_name), 1696 codec_name_(codec_name),
1691 init_encode_event_(false, false), 1697 init_encode_event_(false, false),
1692 num_initializations_(0) { 1698 num_initializations_(0),
1699 stream_(nullptr) {
1693 memset(&encoder_settings_, 0, sizeof(encoder_settings_)); 1700 memset(&encoder_settings_, 0, sizeof(encoder_settings_));
1694 } 1701 }
1695 1702
1696 private: 1703 private:
1697 void ModifyVideoConfigs( 1704 void ModifyVideoConfigs(
1698 VideoSendStream::Config* send_config, 1705 VideoSendStream::Config* send_config,
1699 std::vector<VideoReceiveStream::Config>* receive_configs, 1706 std::vector<VideoReceiveStream::Config>* receive_configs,
1700 VideoEncoderConfig* encoder_config) override { 1707 VideoEncoderConfig* encoder_config) override {
1701 send_config->encoder_settings.encoder = this; 1708 send_config->encoder_settings.encoder = this;
1702 send_config->encoder_settings.payload_name = codec_name_; 1709 send_config->encoder_settings.payload_name = codec_name_;
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
1924 static const int kMaxBitrateKbps = 413; 1931 static const int kMaxBitrateKbps = 413;
1925 static const int kIncreasedStartBitrateKbps = 451; 1932 static const int kIncreasedStartBitrateKbps = 451;
1926 static const int kIncreasedMaxBitrateKbps = 597; 1933 static const int kIncreasedMaxBitrateKbps = 597;
1927 class EncoderBitrateThresholdObserver : public test::SendTest, 1934 class EncoderBitrateThresholdObserver : public test::SendTest,
1928 public test::FakeEncoder { 1935 public test::FakeEncoder {
1929 public: 1936 public:
1930 EncoderBitrateThresholdObserver() 1937 EncoderBitrateThresholdObserver()
1931 : SendTest(kDefaultTimeoutMs), 1938 : SendTest(kDefaultTimeoutMs),
1932 FakeEncoder(Clock::GetRealTimeClock()), 1939 FakeEncoder(Clock::GetRealTimeClock()),
1933 init_encode_event_(false, false), 1940 init_encode_event_(false, false),
1934 num_initializations_(0) {} 1941 num_initializations_(0),
1942 call_(nullptr),
1943 send_stream_(nullptr) {}
1935 1944
1936 private: 1945 private:
1937 int32_t InitEncode(const VideoCodec* codecSettings, 1946 int32_t InitEncode(const VideoCodec* codecSettings,
1938 int32_t numberOfCores, 1947 int32_t numberOfCores,
1939 size_t maxPayloadSize) override { 1948 size_t maxPayloadSize) override {
1940 if (num_initializations_ == 0) { 1949 if (num_initializations_ == 0) {
1941 EXPECT_EQ(static_cast<unsigned int>(kMinBitrateKbps), 1950 EXPECT_EQ(static_cast<unsigned int>(kMinBitrateKbps),
1942 codecSettings->minBitrate); 1951 codecSettings->minBitrate);
1943 EXPECT_EQ(static_cast<unsigned int>(kStartBitrateKbps), 1952 EXPECT_EQ(static_cast<unsigned int>(kStartBitrateKbps),
1944 codecSettings->startBitrate); 1953 codecSettings->startBitrate);
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
2038 static const struct { 2047 static const struct {
2039 int width; 2048 int width;
2040 int height; 2049 int height;
2041 } kEncodedResolution[kNumStreams] = { 2050 } kEncodedResolution[kNumStreams] = {
2042 {241, 181}, {300, 121}, {121, 221}}; 2051 {241, 181}, {300, 121}, {121, 221}};
2043 class ScreencastTargetBitrateTest : public test::SendTest, 2052 class ScreencastTargetBitrateTest : public test::SendTest,
2044 public test::FakeEncoder { 2053 public test::FakeEncoder {
2045 public: 2054 public:
2046 ScreencastTargetBitrateTest() 2055 ScreencastTargetBitrateTest()
2047 : SendTest(kDefaultTimeoutMs), 2056 : SendTest(kDefaultTimeoutMs),
2048 test::FakeEncoder(Clock::GetRealTimeClock()) {} 2057 test::FakeEncoder(Clock::GetRealTimeClock()),
2058 send_stream_(nullptr) {}
2049 2059
2050 private: 2060 private:
2051 int32_t Encode(const VideoFrame& input_image, 2061 int32_t Encode(const VideoFrame& input_image,
2052 const CodecSpecificInfo* codecSpecificInfo, 2062 const CodecSpecificInfo* codecSpecificInfo,
2053 const std::vector<FrameType>* frame_types) override { 2063 const std::vector<FrameType>* frame_types) override {
2054 CodecSpecificInfo specifics; 2064 CodecSpecificInfo specifics;
2055 specifics.codecType = kVideoCodecGeneric; 2065 specifics.codecType = kVideoCodecGeneric;
2056 2066
2057 uint8_t buffer[16] = {0}; 2067 uint8_t buffer[16] = {0};
2058 EncodedImage encoded(buffer, sizeof(buffer), sizeof(buffer)); 2068 EncodedImage encoded(buffer, sizeof(buffer), sizeof(buffer));
(...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after
2515 observation_complete_.Set(); 2525 observation_complete_.Set();
2516 } 2526 }
2517 } 2527 }
2518 } test; 2528 } test;
2519 2529
2520 RunBaseTest(&test); 2530 RunBaseTest(&test);
2521 } 2531 }
2522 #endif // !defined(RTC_DISABLE_VP9) 2532 #endif // !defined(RTC_DISABLE_VP9)
2523 2533
2524 } // namespace webrtc 2534 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/video/video_receive_stream.cc ('k') | webrtc/voice_engine/channel.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698