pbos@webrtc.org | 5ab7567 | 2013-12-16 12:24:44 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. |
| 3 | * |
| 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 |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
| 10 | #include <functional> |
| 11 | #include <list> |
kwiberg | b25345e | 2016-03-12 06:10:44 -0800 | [diff] [blame] | 12 | #include <memory> |
pbos@webrtc.org | 5ab7567 | 2013-12-16 12:24:44 +0000 | [diff] [blame] | 13 | #include <string> |
| 14 | |
Steve Anton | 40d5533 | 2019-01-07 10:21:47 -0800 | [diff] [blame] | 15 | #include "absl/memory/memory.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 16 | #include "call/call.h" |
Artem Titov | dd2eebe | 2018-08-20 13:27:45 +0200 | [diff] [blame] | 17 | #include "call/fake_network_pipe.h" |
| 18 | #include "call/simulated_network.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 19 | #include "rtc_base/checks.h" |
| 20 | #include "rtc_base/event.h" |
| 21 | #include "rtc_base/logging.h" |
| 22 | #include "rtc_base/thread_annotations.h" |
| 23 | #include "test/call_test.h" |
| 24 | #include "test/direct_transport.h" |
| 25 | #include "test/encoder_settings.h" |
| 26 | #include "test/fake_decoder.h" |
| 27 | #include "test/fake_encoder.h" |
| 28 | #include "test/frame_generator_capturer.h" |
| 29 | #include "test/gtest.h" |
pbos@webrtc.org | 5ab7567 | 2013-12-16 12:24:44 +0000 | [diff] [blame] | 30 | |
| 31 | namespace webrtc { |
andresp@webrtc.org | b941fe8 | 2014-07-07 08:50:48 +0000 | [diff] [blame] | 32 | namespace { |
Fredrik Solenberg | 23fba1f | 2015-04-29 15:24:01 +0200 | [diff] [blame] | 33 | // Note: If you consider to re-use this class, think twice and instead consider |
Peter Boström | 7c704b8 | 2015-12-04 16:13:05 +0100 | [diff] [blame] | 34 | // writing tests that don't depend on the logging system. |
| 35 | class LogObserver { |
andresp@webrtc.org | b941fe8 | 2014-07-07 08:50:48 +0000 | [diff] [blame] | 36 | public: |
Peter Boström | 7c704b8 | 2015-12-04 16:13:05 +0100 | [diff] [blame] | 37 | LogObserver() { rtc::LogMessage::AddLogToStream(&callback_, rtc::LS_INFO); } |
andresp@webrtc.org | b941fe8 | 2014-07-07 08:50:48 +0000 | [diff] [blame] | 38 | |
Peter Boström | 7c704b8 | 2015-12-04 16:13:05 +0100 | [diff] [blame] | 39 | ~LogObserver() { rtc::LogMessage::RemoveLogToStream(&callback_); } |
andresp@webrtc.org | b941fe8 | 2014-07-07 08:50:48 +0000 | [diff] [blame] | 40 | |
| 41 | void PushExpectedLogLine(const std::string& expected_log_line) { |
| 42 | callback_.PushExpectedLogLine(expected_log_line); |
| 43 | } |
| 44 | |
Peter Boström | 5811a39 | 2015-12-10 13:02:50 +0100 | [diff] [blame] | 45 | bool Wait() { return callback_.Wait(); } |
andresp@webrtc.org | b941fe8 | 2014-07-07 08:50:48 +0000 | [diff] [blame] | 46 | |
| 47 | private: |
Peter Boström | 7c704b8 | 2015-12-04 16:13:05 +0100 | [diff] [blame] | 48 | class Callback : public rtc::LogSink { |
andresp@webrtc.org | b941fe8 | 2014-07-07 08:50:48 +0000 | [diff] [blame] | 49 | public: |
Peter Boström | 7c704b8 | 2015-12-04 16:13:05 +0100 | [diff] [blame] | 50 | void OnLogMessage(const std::string& message) override { |
Peter Boström | f2f8283 | 2015-05-01 13:00:41 +0200 | [diff] [blame] | 51 | rtc::CritScope lock(&crit_sect_); |
Peter Boström | 7c704b8 | 2015-12-04 16:13:05 +0100 | [diff] [blame] | 52 | // Ignore log lines that are due to missing AST extensions, these are |
| 53 | // logged when we switch back from AST to TOF until the wrapping bitrate |
| 54 | // estimator gives up on using AST. |
| 55 | if (message.find("BitrateEstimator") != std::string::npos && |
| 56 | message.find("packet is missing") == std::string::npos) { |
| 57 | received_log_lines_.push_back(message); |
andresp@webrtc.org | b941fe8 | 2014-07-07 08:50:48 +0000 | [diff] [blame] | 58 | } |
Peter Boström | 7c704b8 | 2015-12-04 16:13:05 +0100 | [diff] [blame] | 59 | |
andresp@webrtc.org | b941fe8 | 2014-07-07 08:50:48 +0000 | [diff] [blame] | 60 | int num_popped = 0; |
| 61 | while (!received_log_lines_.empty() && !expected_log_lines_.empty()) { |
| 62 | std::string a = received_log_lines_.front(); |
| 63 | std::string b = expected_log_lines_.front(); |
| 64 | received_log_lines_.pop_front(); |
| 65 | expected_log_lines_.pop_front(); |
| 66 | num_popped++; |
Peter Boström | 7c704b8 | 2015-12-04 16:13:05 +0100 | [diff] [blame] | 67 | EXPECT_TRUE(a.find(b) != std::string::npos) << a << " != " << b; |
andresp@webrtc.org | b941fe8 | 2014-07-07 08:50:48 +0000 | [diff] [blame] | 68 | } |
Benjamin Wright | 41f9f2c | 2019-03-13 18:03:29 -0700 | [diff] [blame] | 69 | if (expected_log_lines_.empty()) { |
andresp@webrtc.org | b941fe8 | 2014-07-07 08:50:48 +0000 | [diff] [blame] | 70 | if (num_popped > 0) { |
Peter Boström | 5811a39 | 2015-12-10 13:02:50 +0100 | [diff] [blame] | 71 | done_.Set(); |
andresp@webrtc.org | b941fe8 | 2014-07-07 08:50:48 +0000 | [diff] [blame] | 72 | } |
| 73 | return; |
| 74 | } |
| 75 | } |
| 76 | |
Peter Boström | 5811a39 | 2015-12-10 13:02:50 +0100 | [diff] [blame] | 77 | bool Wait() { return done_.Wait(test::CallTest::kDefaultTimeoutMs); } |
andresp@webrtc.org | b941fe8 | 2014-07-07 08:50:48 +0000 | [diff] [blame] | 78 | |
| 79 | void PushExpectedLogLine(const std::string& expected_log_line) { |
Peter Boström | f2f8283 | 2015-05-01 13:00:41 +0200 | [diff] [blame] | 80 | rtc::CritScope lock(&crit_sect_); |
andresp@webrtc.org | b941fe8 | 2014-07-07 08:50:48 +0000 | [diff] [blame] | 81 | expected_log_lines_.push_back(expected_log_line); |
| 82 | } |
| 83 | |
| 84 | private: |
| 85 | typedef std::list<std::string> Strings; |
Peter Boström | f2f8283 | 2015-05-01 13:00:41 +0200 | [diff] [blame] | 86 | rtc::CriticalSection crit_sect_; |
danilchap | a37de39 | 2017-09-09 04:17:22 -0700 | [diff] [blame] | 87 | Strings received_log_lines_ RTC_GUARDED_BY(crit_sect_); |
| 88 | Strings expected_log_lines_ RTC_GUARDED_BY(crit_sect_); |
Peter Boström | 5811a39 | 2015-12-10 13:02:50 +0100 | [diff] [blame] | 89 | rtc::Event done_; |
andresp@webrtc.org | b941fe8 | 2014-07-07 08:50:48 +0000 | [diff] [blame] | 90 | }; |
| 91 | |
| 92 | Callback callback_; |
| 93 | }; |
| 94 | } // namespace |
pbos@webrtc.org | 5ab7567 | 2013-12-16 12:24:44 +0000 | [diff] [blame] | 95 | |
| 96 | static const int kTOFExtensionId = 4; |
| 97 | static const int kASTExtensionId = 5; |
| 98 | |
pbos@webrtc.org | 994d0b7 | 2014-06-27 08:47:52 +0000 | [diff] [blame] | 99 | class BitrateEstimatorTest : public test::CallTest { |
pbos@webrtc.org | 5ab7567 | 2013-12-16 12:24:44 +0000 | [diff] [blame] | 100 | public: |
aleloi | 5d78e8d | 2016-11-08 03:44:54 -0800 | [diff] [blame] | 101 | BitrateEstimatorTest() : receive_config_(nullptr) {} |
pbos@webrtc.org | 5ab7567 | 2013-12-16 12:24:44 +0000 | [diff] [blame] | 102 | |
Fredrik Solenberg | 0ccae13 | 2015-11-03 10:15:49 +0100 | [diff] [blame] | 103 | virtual ~BitrateEstimatorTest() { EXPECT_TRUE(streams_.empty()); } |
pbos@webrtc.org | 5ab7567 | 2013-12-16 12:24:44 +0000 | [diff] [blame] | 104 | |
| 105 | virtual void SetUp() { |
eladalon | 413ee9a | 2017-08-22 04:02:52 -0700 | [diff] [blame] | 106 | task_queue_.SendTask([this]() { |
Sebastian Jansson | 8e6602f | 2018-07-13 10:43:20 +0200 | [diff] [blame] | 107 | CreateCalls(); |
pbos@webrtc.org | 5ab7567 | 2013-12-16 12:24:44 +0000 | [diff] [blame] | 108 | |
eladalon | 413ee9a | 2017-08-22 04:02:52 -0700 | [diff] [blame] | 109 | send_transport_.reset(new test::DirectTransport( |
Artem Titov | dd2eebe | 2018-08-20 13:27:45 +0200 | [diff] [blame] | 110 | &task_queue_, |
| 111 | absl::make_unique<FakeNetworkPipe>( |
| 112 | Clock::GetRealTimeClock(), absl::make_unique<SimulatedNetwork>( |
Artem Titov | 75e3647 | 2018-10-08 12:28:56 +0200 | [diff] [blame] | 113 | BuiltInNetworkBehaviorConfig())), |
Artem Titov | dd2eebe | 2018-08-20 13:27:45 +0200 | [diff] [blame] | 114 | sender_call_.get(), payload_type_map_)); |
eladalon | 413ee9a | 2017-08-22 04:02:52 -0700 | [diff] [blame] | 115 | send_transport_->SetReceiver(receiver_call_->Receiver()); |
| 116 | receive_transport_.reset(new test::DirectTransport( |
Artem Titov | dd2eebe | 2018-08-20 13:27:45 +0200 | [diff] [blame] | 117 | &task_queue_, |
| 118 | absl::make_unique<FakeNetworkPipe>( |
| 119 | Clock::GetRealTimeClock(), absl::make_unique<SimulatedNetwork>( |
Artem Titov | 75e3647 | 2018-10-08 12:28:56 +0200 | [diff] [blame] | 120 | BuiltInNetworkBehaviorConfig())), |
Artem Titov | dd2eebe | 2018-08-20 13:27:45 +0200 | [diff] [blame] | 121 | receiver_call_.get(), payload_type_map_)); |
eladalon | 413ee9a | 2017-08-22 04:02:52 -0700 | [diff] [blame] | 122 | receive_transport_->SetReceiver(sender_call_->Receiver()); |
pbos@webrtc.org | 5ab7567 | 2013-12-16 12:24:44 +0000 | [diff] [blame] | 123 | |
Sebastian Jansson | f33905d | 2018-07-13 09:49:00 +0200 | [diff] [blame] | 124 | VideoSendStream::Config video_send_config(send_transport_.get()); |
| 125 | video_send_config.rtp.ssrcs.push_back(kVideoSendSsrcs[0]); |
| 126 | video_send_config.encoder_settings.encoder_factory = |
Niels Möller | 4db138e | 2018-04-19 09:04:13 +0200 | [diff] [blame] | 127 | &fake_encoder_factory_; |
Jiawei Ou | c2ebe21 | 2018-11-08 10:02:56 -0800 | [diff] [blame] | 128 | video_send_config.encoder_settings.bitrate_allocator_factory = |
| 129 | bitrate_allocator_factory_.get(); |
Sebastian Jansson | f33905d | 2018-07-13 09:49:00 +0200 | [diff] [blame] | 130 | video_send_config.rtp.payload_name = "FAKE"; |
| 131 | video_send_config.rtp.payload_type = kFakeVideoSendPayloadType; |
| 132 | SetVideoSendConfig(video_send_config); |
| 133 | VideoEncoderConfig video_encoder_config; |
| 134 | test::FillEncoderConfiguration(kVideoCodecVP8, 1, &video_encoder_config); |
| 135 | SetVideoEncoderConfig(video_encoder_config); |
pbos@webrtc.org | 5ab7567 | 2013-12-16 12:24:44 +0000 | [diff] [blame] | 136 | |
eladalon | 413ee9a | 2017-08-22 04:02:52 -0700 | [diff] [blame] | 137 | receive_config_ = VideoReceiveStream::Config(receive_transport_.get()); |
| 138 | // receive_config_.decoders will be set by every stream separately. |
Sebastian Jansson | f33905d | 2018-07-13 09:49:00 +0200 | [diff] [blame] | 139 | receive_config_.rtp.remote_ssrc = GetVideoSendConfig()->rtp.ssrcs[0]; |
eladalon | 413ee9a | 2017-08-22 04:02:52 -0700 | [diff] [blame] | 140 | receive_config_.rtp.local_ssrc = kReceiverLocalVideoSsrc; |
| 141 | receive_config_.rtp.remb = true; |
| 142 | receive_config_.rtp.extensions.push_back( |
| 143 | RtpExtension(RtpExtension::kTimestampOffsetUri, kTOFExtensionId)); |
| 144 | receive_config_.rtp.extensions.push_back( |
| 145 | RtpExtension(RtpExtension::kAbsSendTimeUri, kASTExtensionId)); |
| 146 | }); |
pbos@webrtc.org | 5ab7567 | 2013-12-16 12:24:44 +0000 | [diff] [blame] | 147 | } |
| 148 | |
| 149 | virtual void TearDown() { |
eladalon | 413ee9a | 2017-08-22 04:02:52 -0700 | [diff] [blame] | 150 | task_queue_.SendTask([this]() { |
Yusuke Suzuki | f8d8d6d | 2018-05-17 22:01:13 +0900 | [diff] [blame] | 151 | for (auto* stream : streams_) { |
| 152 | stream->StopSending(); |
| 153 | delete stream; |
eladalon | 413ee9a | 2017-08-22 04:02:52 -0700 | [diff] [blame] | 154 | } |
Yusuke Suzuki | f8d8d6d | 2018-05-17 22:01:13 +0900 | [diff] [blame] | 155 | streams_.clear(); |
pbos@webrtc.org | 5ab7567 | 2013-12-16 12:24:44 +0000 | [diff] [blame] | 156 | |
eladalon | 413ee9a | 2017-08-22 04:02:52 -0700 | [diff] [blame] | 157 | send_transport_.reset(); |
| 158 | receive_transport_.reset(); |
pbos@webrtc.org | 5ab7567 | 2013-12-16 12:24:44 +0000 | [diff] [blame] | 159 | |
Sebastian Jansson | 8e6602f | 2018-07-13 10:43:20 +0200 | [diff] [blame] | 160 | DestroyCalls(); |
eladalon | 413ee9a | 2017-08-22 04:02:52 -0700 | [diff] [blame] | 161 | }); |
pbos@webrtc.org | 5ab7567 | 2013-12-16 12:24:44 +0000 | [diff] [blame] | 162 | } |
| 163 | |
| 164 | protected: |
| 165 | friend class Stream; |
| 166 | |
pbos@webrtc.org | 5ab7567 | 2013-12-16 12:24:44 +0000 | [diff] [blame] | 167 | class Stream { |
| 168 | public: |
aleloi | 5d78e8d | 2016-11-08 03:44:54 -0800 | [diff] [blame] | 169 | explicit Stream(BitrateEstimatorTest* test) |
pbos@webrtc.org | 5ab7567 | 2013-12-16 12:24:44 +0000 | [diff] [blame] | 170 | : test_(test), |
| 171 | is_sending_receiving_(false), |
pbos@webrtc.org | 2b4ce3a | 2015-03-23 13:12:24 +0000 | [diff] [blame] | 172 | send_stream_(nullptr), |
pbos@webrtc.org | 5ab7567 | 2013-12-16 12:24:44 +0000 | [diff] [blame] | 173 | frame_generator_capturer_(), |
Niels Möller | cbcbc22 | 2018-09-28 09:07:24 +0200 | [diff] [blame] | 174 | decoder_factory_( |
| 175 | []() { return absl::make_unique<test::FakeDecoder>(); }) { |
Sebastian Jansson | f33905d | 2018-07-13 09:49:00 +0200 | [diff] [blame] | 176 | test_->GetVideoSendConfig()->rtp.ssrcs[0]++; |
pbos@webrtc.org | 6ae48c6 | 2014-06-06 10:49:19 +0000 | [diff] [blame] | 177 | send_stream_ = test_->sender_call_->CreateVideoSendStream( |
Sebastian Jansson | f33905d | 2018-07-13 09:49:00 +0200 | [diff] [blame] | 178 | test_->GetVideoSendConfig()->Copy(), |
| 179 | test_->GetVideoEncoderConfig()->Copy()); |
| 180 | RTC_DCHECK_EQ(1, test_->GetVideoEncoderConfig()->number_of_streams); |
pbos@webrtc.org | bbe0a85 | 2014-09-19 12:30:25 +0000 | [diff] [blame] | 181 | frame_generator_capturer_.reset(test::FrameGeneratorCapturer::Create( |
Danil Chapovalov | b9b146c | 2018-06-15 12:28:07 +0200 | [diff] [blame] | 182 | kDefaultWidth, kDefaultHeight, absl::nullopt, absl::nullopt, |
Emircan Uysaler | 03e6ec9 | 2018-03-09 15:03:26 -0800 | [diff] [blame] | 183 | kDefaultFramerate, Clock::GetRealTimeClock())); |
Taylor Brandstetter | 49fcc10 | 2018-05-16 14:20:41 -0700 | [diff] [blame] | 184 | send_stream_->SetSource(frame_generator_capturer_.get(), |
| 185 | DegradationPreference::MAINTAIN_FRAMERATE); |
pbos@webrtc.org | a5c8d2c | 2014-04-24 11:13:21 +0000 | [diff] [blame] | 186 | send_stream_->Start(); |
pbos@webrtc.org | 5ab7567 | 2013-12-16 12:24:44 +0000 | [diff] [blame] | 187 | |
aleloi | 5d78e8d | 2016-11-08 03:44:54 -0800 | [diff] [blame] | 188 | VideoReceiveStream::Decoder decoder; |
Niels Möller | cbcbc22 | 2018-09-28 09:07:24 +0200 | [diff] [blame] | 189 | decoder.decoder_factory = &decoder_factory_; |
Sebastian Jansson | f33905d | 2018-07-13 09:49:00 +0200 | [diff] [blame] | 190 | decoder.payload_type = test_->GetVideoSendConfig()->rtp.payload_type; |
Niels Möller | cb7e1d2 | 2018-09-11 15:56:04 +0200 | [diff] [blame] | 191 | decoder.video_format = |
| 192 | SdpVideoFormat(test_->GetVideoSendConfig()->rtp.payload_name); |
aleloi | 5d78e8d | 2016-11-08 03:44:54 -0800 | [diff] [blame] | 193 | test_->receive_config_.decoders.clear(); |
| 194 | test_->receive_config_.decoders.push_back(decoder); |
| 195 | test_->receive_config_.rtp.remote_ssrc = |
Sebastian Jansson | f33905d | 2018-07-13 09:49:00 +0200 | [diff] [blame] | 196 | test_->GetVideoSendConfig()->rtp.ssrcs[0]; |
aleloi | 5d78e8d | 2016-11-08 03:44:54 -0800 | [diff] [blame] | 197 | test_->receive_config_.rtp.local_ssrc++; |
| 198 | test_->receive_config_.renderer = &test->fake_renderer_; |
| 199 | video_receive_stream_ = test_->receiver_call_->CreateVideoReceiveStream( |
| 200 | test_->receive_config_.Copy()); |
| 201 | video_receive_stream_->Start(); |
pbos@webrtc.org | 5ab7567 | 2013-12-16 12:24:44 +0000 | [diff] [blame] | 202 | is_sending_receiving_ = true; |
| 203 | } |
| 204 | |
| 205 | ~Stream() { |
Fredrik Solenberg | 23fba1f | 2015-04-29 15:24:01 +0200 | [diff] [blame] | 206 | EXPECT_FALSE(is_sending_receiving_); |
perkj | 9fdbda6 | 2016-09-15 09:19:20 -0700 | [diff] [blame] | 207 | test_->sender_call_->DestroyVideoSendStream(send_stream_); |
perkj | a49cbd3 | 2016-09-16 07:53:41 -0700 | [diff] [blame] | 208 | frame_generator_capturer_.reset(nullptr); |
pbos@webrtc.org | 2b4ce3a | 2015-03-23 13:12:24 +0000 | [diff] [blame] | 209 | send_stream_ = nullptr; |
Fredrik Solenberg | 23fba1f | 2015-04-29 15:24:01 +0200 | [diff] [blame] | 210 | if (video_receive_stream_) { |
| 211 | test_->receiver_call_->DestroyVideoReceiveStream(video_receive_stream_); |
| 212 | video_receive_stream_ = nullptr; |
| 213 | } |
pbos@webrtc.org | 5ab7567 | 2013-12-16 12:24:44 +0000 | [diff] [blame] | 214 | } |
| 215 | |
| 216 | void StopSending() { |
| 217 | if (is_sending_receiving_) { |
pbos@webrtc.org | a5c8d2c | 2014-04-24 11:13:21 +0000 | [diff] [blame] | 218 | send_stream_->Stop(); |
Fredrik Solenberg | 23fba1f | 2015-04-29 15:24:01 +0200 | [diff] [blame] | 219 | if (video_receive_stream_) { |
| 220 | video_receive_stream_->Stop(); |
| 221 | } |
pbos@webrtc.org | 5ab7567 | 2013-12-16 12:24:44 +0000 | [diff] [blame] | 222 | is_sending_receiving_ = false; |
| 223 | } |
| 224 | } |
| 225 | |
| 226 | private: |
| 227 | BitrateEstimatorTest* test_; |
| 228 | bool is_sending_receiving_; |
| 229 | VideoSendStream* send_stream_; |
Fredrik Solenberg | 23fba1f | 2015-04-29 15:24:01 +0200 | [diff] [blame] | 230 | VideoReceiveStream* video_receive_stream_; |
kwiberg | b25345e | 2016-03-12 06:10:44 -0800 | [diff] [blame] | 231 | std::unique_ptr<test::FrameGeneratorCapturer> frame_generator_capturer_; |
Niels Möller | cbcbc22 | 2018-09-28 09:07:24 +0200 | [diff] [blame] | 232 | |
| 233 | test::FunctionVideoDecoderFactory decoder_factory_; |
pbos@webrtc.org | 5ab7567 | 2013-12-16 12:24:44 +0000 | [diff] [blame] | 234 | }; |
| 235 | |
Peter Boström | 7c704b8 | 2015-12-04 16:13:05 +0100 | [diff] [blame] | 236 | LogObserver receiver_log_; |
kwiberg | b25345e | 2016-03-12 06:10:44 -0800 | [diff] [blame] | 237 | std::unique_ptr<test::DirectTransport> send_transport_; |
| 238 | std::unique_ptr<test::DirectTransport> receive_transport_; |
pbos@webrtc.org | 5ab7567 | 2013-12-16 12:24:44 +0000 | [diff] [blame] | 239 | VideoReceiveStream::Config receive_config_; |
| 240 | std::vector<Stream*> streams_; |
| 241 | }; |
| 242 | |
Erik Språng | 468e62a | 2015-07-06 10:50:47 +0200 | [diff] [blame] | 243 | static const char* kAbsSendTimeLog = |
| 244 | "RemoteBitrateEstimatorAbsSendTime: Instantiating."; |
| 245 | static const char* kSingleStreamLog = |
| 246 | "RemoteBitrateEstimatorSingleStream: Instantiating."; |
| 247 | |
Fredrik Solenberg | 23fba1f | 2015-04-29 15:24:01 +0200 | [diff] [blame] | 248 | TEST_F(BitrateEstimatorTest, InstantiatesTOFPerDefaultForVideo) { |
eladalon | 413ee9a | 2017-08-22 04:02:52 -0700 | [diff] [blame] | 249 | task_queue_.SendTask([this]() { |
Sebastian Jansson | f33905d | 2018-07-13 09:49:00 +0200 | [diff] [blame] | 250 | GetVideoSendConfig()->rtp.extensions.push_back( |
eladalon | 413ee9a | 2017-08-22 04:02:52 -0700 | [diff] [blame] | 251 | RtpExtension(RtpExtension::kTimestampOffsetUri, kTOFExtensionId)); |
| 252 | receiver_log_.PushExpectedLogLine(kSingleStreamLog); |
| 253 | receiver_log_.PushExpectedLogLine(kSingleStreamLog); |
| 254 | streams_.push_back(new Stream(this)); |
| 255 | }); |
Peter Boström | 5811a39 | 2015-12-10 13:02:50 +0100 | [diff] [blame] | 256 | EXPECT_TRUE(receiver_log_.Wait()); |
pbos@webrtc.org | 5ab7567 | 2013-12-16 12:24:44 +0000 | [diff] [blame] | 257 | } |
| 258 | |
Fredrik Solenberg | 23fba1f | 2015-04-29 15:24:01 +0200 | [diff] [blame] | 259 | TEST_F(BitrateEstimatorTest, ImmediatelySwitchToASTForVideo) { |
eladalon | 413ee9a | 2017-08-22 04:02:52 -0700 | [diff] [blame] | 260 | task_queue_.SendTask([this]() { |
Sebastian Jansson | f33905d | 2018-07-13 09:49:00 +0200 | [diff] [blame] | 261 | GetVideoSendConfig()->rtp.extensions.push_back( |
eladalon | 413ee9a | 2017-08-22 04:02:52 -0700 | [diff] [blame] | 262 | RtpExtension(RtpExtension::kAbsSendTimeUri, kASTExtensionId)); |
| 263 | receiver_log_.PushExpectedLogLine(kSingleStreamLog); |
| 264 | receiver_log_.PushExpectedLogLine(kSingleStreamLog); |
| 265 | receiver_log_.PushExpectedLogLine("Switching to absolute send time RBE."); |
| 266 | receiver_log_.PushExpectedLogLine(kAbsSendTimeLog); |
| 267 | streams_.push_back(new Stream(this)); |
| 268 | }); |
Peter Boström | 5811a39 | 2015-12-10 13:02:50 +0100 | [diff] [blame] | 269 | EXPECT_TRUE(receiver_log_.Wait()); |
Fredrik Solenberg | 23fba1f | 2015-04-29 15:24:01 +0200 | [diff] [blame] | 270 | } |
| 271 | |
Fredrik Solenberg | 23fba1f | 2015-04-29 15:24:01 +0200 | [diff] [blame] | 272 | TEST_F(BitrateEstimatorTest, SwitchesToASTForVideo) { |
eladalon | 413ee9a | 2017-08-22 04:02:52 -0700 | [diff] [blame] | 273 | task_queue_.SendTask([this]() { |
Sebastian Jansson | f33905d | 2018-07-13 09:49:00 +0200 | [diff] [blame] | 274 | GetVideoSendConfig()->rtp.extensions.push_back( |
eladalon | 413ee9a | 2017-08-22 04:02:52 -0700 | [diff] [blame] | 275 | RtpExtension(RtpExtension::kTimestampOffsetUri, kTOFExtensionId)); |
| 276 | receiver_log_.PushExpectedLogLine(kSingleStreamLog); |
| 277 | receiver_log_.PushExpectedLogLine(kSingleStreamLog); |
| 278 | streams_.push_back(new Stream(this)); |
| 279 | }); |
Peter Boström | 5811a39 | 2015-12-10 13:02:50 +0100 | [diff] [blame] | 280 | EXPECT_TRUE(receiver_log_.Wait()); |
pbos@webrtc.org | 5ab7567 | 2013-12-16 12:24:44 +0000 | [diff] [blame] | 281 | |
eladalon | 413ee9a | 2017-08-22 04:02:52 -0700 | [diff] [blame] | 282 | task_queue_.SendTask([this]() { |
Sebastian Jansson | f33905d | 2018-07-13 09:49:00 +0200 | [diff] [blame] | 283 | GetVideoSendConfig()->rtp.extensions[0] = |
eladalon | 413ee9a | 2017-08-22 04:02:52 -0700 | [diff] [blame] | 284 | RtpExtension(RtpExtension::kAbsSendTimeUri, kASTExtensionId); |
| 285 | receiver_log_.PushExpectedLogLine("Switching to absolute send time RBE."); |
| 286 | receiver_log_.PushExpectedLogLine(kAbsSendTimeLog); |
| 287 | streams_.push_back(new Stream(this)); |
| 288 | }); |
Peter Boström | 5811a39 | 2015-12-10 13:02:50 +0100 | [diff] [blame] | 289 | EXPECT_TRUE(receiver_log_.Wait()); |
pbos@webrtc.org | 5ab7567 | 2013-12-16 12:24:44 +0000 | [diff] [blame] | 290 | } |
| 291 | |
deadbeef | 1086ed6 | 2016-04-22 10:52:40 -0700 | [diff] [blame] | 292 | // This test is flaky. See webrtc:5790. |
| 293 | TEST_F(BitrateEstimatorTest, DISABLED_SwitchesToASTThenBackToTOFForVideo) { |
eladalon | 413ee9a | 2017-08-22 04:02:52 -0700 | [diff] [blame] | 294 | task_queue_.SendTask([this]() { |
Sebastian Jansson | f33905d | 2018-07-13 09:49:00 +0200 | [diff] [blame] | 295 | GetVideoSendConfig()->rtp.extensions.push_back( |
eladalon | 413ee9a | 2017-08-22 04:02:52 -0700 | [diff] [blame] | 296 | RtpExtension(RtpExtension::kTimestampOffsetUri, kTOFExtensionId)); |
| 297 | receiver_log_.PushExpectedLogLine(kSingleStreamLog); |
| 298 | receiver_log_.PushExpectedLogLine(kAbsSendTimeLog); |
| 299 | receiver_log_.PushExpectedLogLine(kSingleStreamLog); |
| 300 | streams_.push_back(new Stream(this)); |
| 301 | }); |
Peter Boström | 5811a39 | 2015-12-10 13:02:50 +0100 | [diff] [blame] | 302 | EXPECT_TRUE(receiver_log_.Wait()); |
pbos@webrtc.org | 5ab7567 | 2013-12-16 12:24:44 +0000 | [diff] [blame] | 303 | |
eladalon | 413ee9a | 2017-08-22 04:02:52 -0700 | [diff] [blame] | 304 | task_queue_.SendTask([this]() { |
Sebastian Jansson | f33905d | 2018-07-13 09:49:00 +0200 | [diff] [blame] | 305 | GetVideoSendConfig()->rtp.extensions[0] = |
eladalon | 413ee9a | 2017-08-22 04:02:52 -0700 | [diff] [blame] | 306 | RtpExtension(RtpExtension::kAbsSendTimeUri, kASTExtensionId); |
| 307 | receiver_log_.PushExpectedLogLine(kAbsSendTimeLog); |
| 308 | receiver_log_.PushExpectedLogLine("Switching to absolute send time RBE."); |
| 309 | streams_.push_back(new Stream(this)); |
| 310 | }); |
Peter Boström | 5811a39 | 2015-12-10 13:02:50 +0100 | [diff] [blame] | 311 | EXPECT_TRUE(receiver_log_.Wait()); |
pbos@webrtc.org | 5ab7567 | 2013-12-16 12:24:44 +0000 | [diff] [blame] | 312 | |
eladalon | 413ee9a | 2017-08-22 04:02:52 -0700 | [diff] [blame] | 313 | task_queue_.SendTask([this]() { |
Sebastian Jansson | f33905d | 2018-07-13 09:49:00 +0200 | [diff] [blame] | 314 | GetVideoSendConfig()->rtp.extensions[0] = |
eladalon | 413ee9a | 2017-08-22 04:02:52 -0700 | [diff] [blame] | 315 | RtpExtension(RtpExtension::kTimestampOffsetUri, kTOFExtensionId); |
| 316 | receiver_log_.PushExpectedLogLine(kAbsSendTimeLog); |
| 317 | receiver_log_.PushExpectedLogLine( |
| 318 | "WrappingBitrateEstimator: Switching to transmission time offset RBE."); |
| 319 | streams_.push_back(new Stream(this)); |
| 320 | streams_[0]->StopSending(); |
| 321 | streams_[1]->StopSending(); |
| 322 | }); |
Peter Boström | 5811a39 | 2015-12-10 13:02:50 +0100 | [diff] [blame] | 323 | EXPECT_TRUE(receiver_log_.Wait()); |
pbos@webrtc.org | 5ab7567 | 2013-12-16 12:24:44 +0000 | [diff] [blame] | 324 | } |
| 325 | } // namespace webrtc |