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 | 10 |
11 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
12 #include "webrtc/base/checks.h" | 12 #include "webrtc/base/checks.h" |
13 #include "webrtc/base/common.h" | 13 #include "webrtc/base/common.h" |
| 14 #include "webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_abs_s
end_time.h" |
| 15 #include "webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_singl
e_stream.h" |
14 #include "webrtc/modules/rtp_rtcp/interface/receive_statistics.h" | 16 #include "webrtc/modules/rtp_rtcp/interface/receive_statistics.h" |
15 #include "webrtc/modules/rtp_rtcp/interface/rtp_header_parser.h" | 17 #include "webrtc/modules/rtp_rtcp/interface/rtp_header_parser.h" |
16 #include "webrtc/modules/rtp_rtcp/interface/rtp_payload_registry.h" | 18 #include "webrtc/modules/rtp_rtcp/interface/rtp_payload_registry.h" |
17 #include "webrtc/modules/rtp_rtcp/interface/rtp_rtcp.h" | 19 #include "webrtc/modules/rtp_rtcp/interface/rtp_rtcp.h" |
18 #include "webrtc/modules/rtp_rtcp/source/rtcp_utility.h" | 20 #include "webrtc/modules/rtp_rtcp/source/rtcp_utility.h" |
19 #include "webrtc/system_wrappers/interface/critical_section_wrapper.h" | 21 #include "webrtc/system_wrappers/interface/critical_section_wrapper.h" |
20 #include "webrtc/test/testsupport/perf_test.h" | 22 #include "webrtc/test/testsupport/perf_test.h" |
21 #include "webrtc/video/rampup_tests.h" | 23 #include "webrtc/video/rampup_tests.h" |
22 | 24 |
23 namespace webrtc { | 25 namespace webrtc { |
24 namespace { | 26 namespace { |
25 | 27 |
26 static const int kMaxPacketSize = 1500; | 28 static const int kMaxPacketSize = 1500; |
| 29 const uint32_t kRemoteBitrateEstimatorMinBitrateBps = 30000; |
27 | 30 |
28 std::vector<uint32_t> GenerateSsrcs(size_t num_streams, | 31 std::vector<uint32_t> GenerateSsrcs(size_t num_streams, |
29 uint32_t ssrc_offset) { | 32 uint32_t ssrc_offset) { |
30 std::vector<uint32_t> ssrcs; | 33 std::vector<uint32_t> ssrcs; |
31 for (size_t i = 0; i != num_streams; ++i) | 34 for (size_t i = 0; i != num_streams; ++i) |
32 ssrcs.push_back(static_cast<uint32_t>(ssrc_offset + i)); | 35 ssrcs.push_back(static_cast<uint32_t>(ssrc_offset + i)); |
33 return ssrcs; | 36 return ssrcs; |
34 } | 37 } |
35 } // namespace | 38 } // namespace |
36 | 39 |
37 StreamObserver::StreamObserver(const SsrcMap& rtx_media_ssrcs, | 40 StreamObserver::StreamObserver(const SsrcMap& rtx_media_ssrcs, |
38 newapi::Transport* feedback_transport, | 41 newapi::Transport* feedback_transport, |
39 Clock* clock, | 42 Clock* clock) |
40 RemoteBitrateEstimatorFactory* rbe_factory, | |
41 RateControlType control_type) | |
42 : clock_(clock), | 43 : clock_(clock), |
43 test_done_(EventWrapper::Create()), | 44 test_done_(EventWrapper::Create()), |
44 rtp_parser_(RtpHeaderParser::Create()), | 45 rtp_parser_(RtpHeaderParser::Create()), |
45 feedback_transport_(feedback_transport), | 46 feedback_transport_(feedback_transport), |
46 receive_stats_(ReceiveStatistics::Create(clock)), | 47 receive_stats_(ReceiveStatistics::Create(clock)), |
47 payload_registry_( | 48 payload_registry_( |
48 new RTPPayloadRegistry(RTPPayloadStrategy::CreateStrategy(false))), | 49 new RTPPayloadRegistry(RTPPayloadStrategy::CreateStrategy(false))), |
| 50 remote_bitrate_estimator_(nullptr), |
49 expected_bitrate_bps_(0), | 51 expected_bitrate_bps_(0), |
50 start_bitrate_bps_(0), | 52 start_bitrate_bps_(0), |
51 rtx_media_ssrcs_(rtx_media_ssrcs), | 53 rtx_media_ssrcs_(rtx_media_ssrcs), |
52 total_sent_(0), | 54 total_sent_(0), |
53 padding_sent_(0), | 55 padding_sent_(0), |
54 rtx_media_sent_(0), | 56 rtx_media_sent_(0), |
55 total_packets_sent_(0), | 57 total_packets_sent_(0), |
56 padding_packets_sent_(0), | 58 padding_packets_sent_(0), |
57 rtx_media_packets_sent_(0), | 59 rtx_media_packets_sent_(0), |
58 test_start_ms_(clock_->TimeInMilliseconds()), | 60 test_start_ms_(clock_->TimeInMilliseconds()), |
59 ramp_up_finished_ms_(0) { | 61 ramp_up_finished_ms_(0) { |
60 // Ideally we would only have to instantiate an RtcpSender, an | 62 // Ideally we would only have to instantiate an RtcpSender, an |
61 // RtpHeaderParser and a RemoteBitrateEstimator here, but due to the current | 63 // RtpHeaderParser and a RemoteBitrateEstimator here, but due to the current |
62 // state of the RTP module we need a full module and receive statistics to | 64 // state of the RTP module we need a full module and receive statistics to |
63 // be able to produce an RTCP with REMB. | 65 // be able to produce an RTCP with REMB. |
64 RtpRtcp::Configuration config; | 66 RtpRtcp::Configuration config; |
65 config.receive_statistics = receive_stats_.get(); | 67 config.receive_statistics = receive_stats_.get(); |
66 feedback_transport_.Enable(); | 68 feedback_transport_.Enable(); |
67 config.outgoing_transport = &feedback_transport_; | 69 config.outgoing_transport = &feedback_transport_; |
68 rtp_rtcp_.reset(RtpRtcp::CreateRtpRtcp(config)); | 70 rtp_rtcp_.reset(RtpRtcp::CreateRtpRtcp(config)); |
69 rtp_rtcp_->SetREMBStatus(true); | 71 rtp_rtcp_->SetREMBStatus(true); |
70 rtp_rtcp_->SetRTCPStatus(kRtcpNonCompound); | 72 rtp_rtcp_->SetRTCPStatus(kRtcpNonCompound); |
71 rtp_parser_->RegisterRtpHeaderExtension(kRtpExtensionAbsoluteSendTime, | 73 rtp_parser_->RegisterRtpHeaderExtension(kRtpExtensionAbsoluteSendTime, |
72 kAbsSendTimeExtensionId); | 74 kAbsSendTimeExtensionId); |
73 rtp_parser_->RegisterRtpHeaderExtension(kRtpExtensionTransmissionTimeOffset, | 75 rtp_parser_->RegisterRtpHeaderExtension(kRtpExtensionTransmissionTimeOffset, |
74 kTransmissionTimeOffsetExtensionId); | 76 kTransmissionTimeOffsetExtensionId); |
75 const uint32_t kRemoteBitrateEstimatorMinBitrateBps = 30000; | |
76 remote_bitrate_estimator_.reset( | |
77 rbe_factory->Create(this, clock, control_type, | |
78 kRemoteBitrateEstimatorMinBitrateBps)); | |
79 payload_registry_->SetRtxPayloadType(RampUpTest::kSendRtxPayloadType, | 77 payload_registry_->SetRtxPayloadType(RampUpTest::kSendRtxPayloadType, |
80 RampUpTest::kFakeSendPayloadType); | 78 RampUpTest::kFakeSendPayloadType); |
81 } | 79 } |
82 | 80 |
83 void StreamObserver::set_expected_bitrate_bps( | 81 void StreamObserver::set_expected_bitrate_bps( |
84 unsigned int expected_bitrate_bps) { | 82 unsigned int expected_bitrate_bps) { |
85 rtc::CritScope lock(&crit_); | 83 rtc::CritScope lock(&crit_); |
86 expected_bitrate_bps_ = expected_bitrate_bps; | 84 expected_bitrate_bps_ = expected_bitrate_bps; |
87 } | 85 } |
88 | 86 |
(...skipping 25 matching lines...) Expand all Loading... |
114 rtp_rtcp_->SetREMBData(bitrate, ssrcs); | 112 rtp_rtcp_->SetREMBData(bitrate, ssrcs); |
115 rtp_rtcp_->Process(); | 113 rtp_rtcp_->Process(); |
116 } | 114 } |
117 | 115 |
118 bool StreamObserver::SendRtp(const uint8_t* packet, size_t length) { | 116 bool StreamObserver::SendRtp(const uint8_t* packet, size_t length) { |
119 rtc::CritScope lock(&crit_); | 117 rtc::CritScope lock(&crit_); |
120 RTPHeader header; | 118 RTPHeader header; |
121 EXPECT_TRUE(rtp_parser_->Parse(packet, length, &header)); | 119 EXPECT_TRUE(rtp_parser_->Parse(packet, length, &header)); |
122 receive_stats_->IncomingPacket(header, length, false); | 120 receive_stats_->IncomingPacket(header, length, false); |
123 payload_registry_->SetIncomingPayloadType(header); | 121 payload_registry_->SetIncomingPayloadType(header); |
| 122 DCHECK(remote_bitrate_estimator_ != nullptr); |
124 remote_bitrate_estimator_->IncomingPacket(clock_->TimeInMilliseconds(), | 123 remote_bitrate_estimator_->IncomingPacket(clock_->TimeInMilliseconds(), |
125 length - 12, header, true); | 124 length - 12, header, true); |
126 if (remote_bitrate_estimator_->TimeUntilNextProcess() <= 0) { | 125 if (remote_bitrate_estimator_->TimeUntilNextProcess() <= 0) { |
127 remote_bitrate_estimator_->Process(); | 126 remote_bitrate_estimator_->Process(); |
128 } | 127 } |
129 total_sent_ += length; | 128 total_sent_ += length; |
130 padding_sent_ += header.paddingLength; | 129 padding_sent_ += header.paddingLength; |
131 ++total_packets_sent_; | 130 ++total_packets_sent_; |
132 if (header.paddingLength > 0) | 131 if (header.paddingLength > 0) |
133 ++padding_packets_sent_; | 132 ++padding_packets_sent_; |
(...skipping 17 matching lines...) Expand all Loading... |
151 } | 150 } |
152 | 151 |
153 bool StreamObserver::SendRtcp(const uint8_t* packet, size_t length) { | 152 bool StreamObserver::SendRtcp(const uint8_t* packet, size_t length) { |
154 return true; | 153 return true; |
155 } | 154 } |
156 | 155 |
157 EventTypeWrapper StreamObserver::Wait() { | 156 EventTypeWrapper StreamObserver::Wait() { |
158 return test_done_->Wait(test::CallTest::kLongTimeoutMs); | 157 return test_done_->Wait(test::CallTest::kLongTimeoutMs); |
159 } | 158 } |
160 | 159 |
| 160 void StreamObserver::SetRemoteBitrateEstimator(RemoteBitrateEstimator* rbe) { |
| 161 remote_bitrate_estimator_.reset(rbe); |
| 162 } |
| 163 |
161 void StreamObserver::ReportResult(const std::string& measurement, | 164 void StreamObserver::ReportResult(const std::string& measurement, |
162 size_t value, | 165 size_t value, |
163 const std::string& units) { | 166 const std::string& units) { |
164 webrtc::test::PrintResult( | 167 webrtc::test::PrintResult( |
165 measurement, "", | 168 measurement, "", |
166 ::testing::UnitTest::GetInstance()->current_test_info()->name(), | 169 ::testing::UnitTest::GetInstance()->current_test_info()->name(), |
167 value, units, false); | 170 value, units, false); |
168 } | 171 } |
169 | 172 |
170 void StreamObserver::TriggerTestDone() EXCLUSIVE_LOCKS_REQUIRED(crit_) { | 173 void StreamObserver::TriggerTestDone() EXCLUSIVE_LOCKS_REQUIRED(crit_) { |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 suspended_in_stats_(false) { | 209 suspended_in_stats_(false) { |
207 RtpRtcp::Configuration config; | 210 RtpRtcp::Configuration config; |
208 config.receive_statistics = receive_stats_.get(); | 211 config.receive_statistics = receive_stats_.get(); |
209 feedback_transport_.Enable(); | 212 feedback_transport_.Enable(); |
210 config.outgoing_transport = &feedback_transport_; | 213 config.outgoing_transport = &feedback_transport_; |
211 rtp_rtcp_.reset(RtpRtcp::CreateRtpRtcp(config)); | 214 rtp_rtcp_.reset(RtpRtcp::CreateRtpRtcp(config)); |
212 rtp_rtcp_->SetREMBStatus(true); | 215 rtp_rtcp_->SetREMBStatus(true); |
213 rtp_rtcp_->SetRTCPStatus(kRtcpNonCompound); | 216 rtp_rtcp_->SetRTCPStatus(kRtcpNonCompound); |
214 rtp_parser_->RegisterRtpHeaderExtension(kRtpExtensionAbsoluteSendTime, | 217 rtp_parser_->RegisterRtpHeaderExtension(kRtpExtensionAbsoluteSendTime, |
215 kAbsSendTimeExtensionId); | 218 kAbsSendTimeExtensionId); |
216 AbsoluteSendTimeRemoteBitrateEstimatorFactory rbe_factory; | |
217 const uint32_t kRemoteBitrateEstimatorMinBitrateBps = 10000; | 219 const uint32_t kRemoteBitrateEstimatorMinBitrateBps = 10000; |
218 remote_bitrate_estimator_.reset( | 220 remote_bitrate_estimator_.reset(new RemoteBitrateEstimatorAbsSendTime( |
219 rbe_factory.Create(this, clock, kAimdControl, | 221 this, clock, kRemoteBitrateEstimatorMinBitrateBps)); |
220 kRemoteBitrateEstimatorMinBitrateBps)); | |
221 forward_transport_config_.link_capacity_kbps = | 222 forward_transport_config_.link_capacity_kbps = |
222 kHighBandwidthLimitBps / 1000; | 223 kHighBandwidthLimitBps / 1000; |
223 forward_transport_config_.queue_length_packets = 100; // Something large. | 224 forward_transport_config_.queue_length_packets = 100; // Something large. |
224 test::DirectTransport::SetConfig(forward_transport_config_); | 225 test::DirectTransport::SetConfig(forward_transport_config_); |
225 test::DirectTransport::SetReceiver(this); | 226 test::DirectTransport::SetReceiver(this); |
226 } | 227 } |
227 | 228 |
228 void LowRateStreamObserver::SetSendStream(VideoSendStream* send_stream) { | 229 void LowRateStreamObserver::SetSendStream(VideoSendStream* send_stream) { |
229 rtc::CritScope lock(&crit_); | 230 rtc::CritScope lock(&crit_); |
230 send_stream_ = send_stream; | 231 send_stream_ = send_stream; |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
374 std::vector<uint32_t> rtx_ssrcs(GenerateSsrcs(num_streams, 200)); | 375 std::vector<uint32_t> rtx_ssrcs(GenerateSsrcs(num_streams, 200)); |
375 StreamObserver::SsrcMap rtx_ssrc_map; | 376 StreamObserver::SsrcMap rtx_ssrc_map; |
376 if (rtx) { | 377 if (rtx) { |
377 for (size_t i = 0; i < ssrcs.size(); ++i) | 378 for (size_t i = 0; i < ssrcs.size(); ++i) |
378 rtx_ssrc_map[rtx_ssrcs[i]] = ssrcs[i]; | 379 rtx_ssrc_map[rtx_ssrcs[i]] = ssrcs[i]; |
379 } | 380 } |
380 | 381 |
381 CreateSendConfig(num_streams); | 382 CreateSendConfig(num_streams); |
382 send_config_.rtp.extensions.clear(); | 383 send_config_.rtp.extensions.clear(); |
383 | 384 |
384 rtc::scoped_ptr<RemoteBitrateEstimatorFactory> rbe_factory; | 385 test::DirectTransport receiver_transport; |
385 RateControlType control_type; | 386 StreamObserver stream_observer(rtx_ssrc_map, &receiver_transport, |
| 387 Clock::GetRealTimeClock()); |
| 388 |
386 if (extension_type == RtpExtension::kAbsSendTime) { | 389 if (extension_type == RtpExtension::kAbsSendTime) { |
387 control_type = kAimdControl; | 390 stream_observer.SetRemoteBitrateEstimator( |
388 rbe_factory.reset(new AbsoluteSendTimeRemoteBitrateEstimatorFactory); | 391 new RemoteBitrateEstimatorAbsSendTime( |
| 392 &stream_observer, Clock::GetRealTimeClock(), |
| 393 kRemoteBitrateEstimatorMinBitrateBps)); |
389 send_config_.rtp.extensions.push_back(RtpExtension( | 394 send_config_.rtp.extensions.push_back(RtpExtension( |
390 extension_type.c_str(), kAbsSendTimeExtensionId)); | 395 extension_type.c_str(), kAbsSendTimeExtensionId)); |
391 } else { | 396 } else { |
392 control_type = kMimdControl; | 397 stream_observer.SetRemoteBitrateEstimator( |
393 rbe_factory.reset(new RemoteBitrateEstimatorFactory); | 398 new RemoteBitrateEstimatorSingleStream( |
| 399 &stream_observer, Clock::GetRealTimeClock(), |
| 400 kRemoteBitrateEstimatorMinBitrateBps)); |
394 send_config_.rtp.extensions.push_back(RtpExtension( | 401 send_config_.rtp.extensions.push_back(RtpExtension( |
395 extension_type.c_str(), kTransmissionTimeOffsetExtensionId)); | 402 extension_type.c_str(), kTransmissionTimeOffsetExtensionId)); |
396 } | 403 } |
397 | 404 |
398 test::DirectTransport receiver_transport; | |
399 StreamObserver stream_observer(rtx_ssrc_map, | |
400 &receiver_transport, | |
401 Clock::GetRealTimeClock(), | |
402 rbe_factory.get(), | |
403 control_type); | |
404 | |
405 Call::Config call_config(&stream_observer); | 405 Call::Config call_config(&stream_observer); |
406 if (start_bitrate_bps != 0) { | 406 if (start_bitrate_bps != 0) { |
407 call_config.bitrate_config.start_bitrate_bps = start_bitrate_bps; | 407 call_config.bitrate_config.start_bitrate_bps = start_bitrate_bps; |
408 stream_observer.set_start_bitrate_bps(start_bitrate_bps); | 408 stream_observer.set_start_bitrate_bps(start_bitrate_bps); |
409 } | 409 } |
410 | 410 |
411 CreateSenderCall(call_config); | 411 CreateSenderCall(call_config); |
412 | 412 |
413 receiver_transport.SetReceiver(sender_call_->Receiver()); | 413 receiver_transport.SetReceiver(sender_call_->Receiver()); |
414 | 414 |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
551 | 551 |
552 TEST_F(RampUpTest, AbsSendTimeSimulcastByRedWithRtx) { | 552 TEST_F(RampUpTest, AbsSendTimeSimulcastByRedWithRtx) { |
553 RunRampUpTest(3, 0, RtpExtension::kAbsSendTime, true, true); | 553 RunRampUpTest(3, 0, RtpExtension::kAbsSendTime, true, true); |
554 } | 554 } |
555 | 555 |
556 TEST_F(RampUpTest, AbsSendTimeSingleStreamWithHighStartBitrate) { | 556 TEST_F(RampUpTest, AbsSendTimeSingleStreamWithHighStartBitrate) { |
557 RunRampUpTest(1, 0.9 * kSingleStreamTargetBps, RtpExtension::kAbsSendTime, | 557 RunRampUpTest(1, 0.9 * kSingleStreamTargetBps, RtpExtension::kAbsSendTime, |
558 false, false); | 558 false, false); |
559 } | 559 } |
560 } // namespace webrtc | 560 } // namespace webrtc |
OLD | NEW |