Introduce ModuleRtpRtcpImpl2 constructor that accepts Environment
And checks similar fields in Configuration struct are not set. Migrate rtp_rtcp to use new constructor. Bug: webrtc:362762208 Change-Id: I2385439c169a7432d174c72ca57ecb0ca639d864 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/361100 Commit-Queue: Danil Chapovalov <danilchap@webrtc.org> Reviewed-by: Åsa Persson <asapersson@webrtc.org> Cr-Commit-Position: refs/heads/main@{#42896}
This commit is contained in:
parent
058972f84e
commit
d385af56c3
@ -15,6 +15,8 @@
|
||||
|
||||
#include "absl/algorithm/container.h"
|
||||
#include "api/call/transport.h"
|
||||
#include "api/environment/environment.h"
|
||||
#include "api/environment/environment_factory.h"
|
||||
#include "call/rtp_stream_receiver_controller.h"
|
||||
#include "call/rtx_receive_stream.h"
|
||||
#include "modules/rtp_rtcp/include/receive_statistics.h"
|
||||
@ -24,7 +26,6 @@
|
||||
#include "modules/rtp_rtcp/source/rtp_sender_video.h"
|
||||
#include "rtc_base/rate_limiter.h"
|
||||
#include "rtc_base/thread.h"
|
||||
#include "test/explicit_key_value_config.h"
|
||||
#include "test/gtest.h"
|
||||
|
||||
namespace webrtc {
|
||||
@ -119,29 +120,28 @@ class RtxLoopBackTransport : public webrtc::Transport {
|
||||
class RtpRtcpRtxNackTest : public ::testing::Test {
|
||||
protected:
|
||||
RtpRtcpRtxNackTest()
|
||||
: rtp_rtcp_module_(nullptr),
|
||||
: fake_clock_(123456),
|
||||
env_(CreateEnvironment(&fake_clock_)),
|
||||
transport_(kTestRtxSsrc),
|
||||
rtx_stream_(&media_stream_, rtx_associated_payload_types_, kTestSsrc),
|
||||
fake_clock(123456),
|
||||
retransmission_rate_limiter_(&fake_clock, kMaxRttMs) {}
|
||||
retransmission_rate_limiter_(&fake_clock_, kMaxRttMs) {}
|
||||
~RtpRtcpRtxNackTest() override {}
|
||||
|
||||
void SetUp() override {
|
||||
RtpRtcpInterface::Configuration configuration;
|
||||
configuration.audio = false;
|
||||
configuration.clock = &fake_clock;
|
||||
receive_statistics_ = ReceiveStatistics::Create(&fake_clock);
|
||||
receive_statistics_ = ReceiveStatistics::Create(&fake_clock_);
|
||||
configuration.receive_statistics = receive_statistics_.get();
|
||||
configuration.outgoing_transport = &transport_;
|
||||
configuration.retransmission_rate_limiter = &retransmission_rate_limiter_;
|
||||
configuration.local_media_ssrc = kTestSsrc;
|
||||
configuration.rtx_send_ssrc = kTestRtxSsrc;
|
||||
rtp_rtcp_module_ = ModuleRtpRtcpImpl2::Create(configuration);
|
||||
test::ExplicitKeyValueConfig field_trials("");
|
||||
rtp_rtcp_module_ =
|
||||
std::make_unique<ModuleRtpRtcpImpl2>(env_, configuration);
|
||||
RTPSenderVideo::Config video_config;
|
||||
video_config.clock = &fake_clock;
|
||||
video_config.clock = &fake_clock_;
|
||||
video_config.rtp_sender = rtp_rtcp_module_->RtpSender();
|
||||
video_config.field_trials = &field_trials;
|
||||
video_config.field_trials = &env_.field_trials();
|
||||
rtp_sender_video_ = std::make_unique<RTPSenderVideo>(video_config);
|
||||
rtp_rtcp_module_->SetRTCPStatus(RtcpMode::kCompound);
|
||||
rtp_rtcp_module_->SetStorePacketsStatus(true, 600);
|
||||
@ -212,11 +212,11 @@ class RtpRtcpRtxNackTest : public ::testing::Test {
|
||||
/*capture_time=*/Timestamp::Millis(timestamp / 90), payload_data,
|
||||
sizeof(payload_data), video_header, TimeDelta::Zero(), {}));
|
||||
// Min required delay until retransmit = 5 + RTT ms (RTT = 0).
|
||||
fake_clock.AdvanceTimeMilliseconds(5);
|
||||
fake_clock_.AdvanceTimeMilliseconds(5);
|
||||
int length = BuildNackList(nack_list);
|
||||
if (length > 0)
|
||||
rtp_rtcp_module_->SendNACK(nack_list, length);
|
||||
fake_clock.AdvanceTimeMilliseconds(28); // 33ms - 5ms delay.
|
||||
fake_clock_.AdvanceTimeMilliseconds(28); // 33ms - 5ms delay.
|
||||
// Prepare next frame.
|
||||
timestamp += 3000;
|
||||
}
|
||||
@ -224,6 +224,8 @@ class RtpRtcpRtxNackTest : public ::testing::Test {
|
||||
}
|
||||
|
||||
rtc::AutoThread main_thread_;
|
||||
SimulatedClock fake_clock_;
|
||||
const Environment env_;
|
||||
std::unique_ptr<ReceiveStatistics> receive_statistics_;
|
||||
std::unique_ptr<ModuleRtpRtcpImpl2> rtp_rtcp_module_;
|
||||
std::unique_ptr<RTPSenderVideo> rtp_sender_video_;
|
||||
@ -233,7 +235,6 @@ class RtpRtcpRtxNackTest : public ::testing::Test {
|
||||
VerifyingMediaStream media_stream_;
|
||||
RtxReceiveStream rtx_stream_;
|
||||
uint8_t payload_data[65000];
|
||||
SimulatedClock fake_clock;
|
||||
RateLimiter retransmission_rate_limiter_;
|
||||
std::unique_ptr<RtpStreamReceiverInterface> media_receiver_;
|
||||
std::unique_ptr<RtpStreamReceiverInterface> rtx_receiver_;
|
||||
@ -264,7 +265,7 @@ TEST_F(RtpRtcpRtxNackTest, LongNackList) {
|
||||
video_header, TimeDelta::Zero(), {}));
|
||||
// Prepare next frame.
|
||||
timestamp += 3000;
|
||||
fake_clock.AdvanceTimeMilliseconds(33);
|
||||
fake_clock_.AdvanceTimeMilliseconds(33);
|
||||
}
|
||||
EXPECT_FALSE(transport_.expected_sequence_numbers_.empty());
|
||||
EXPECT_FALSE(media_stream_.sequence_numbers_.empty());
|
||||
|
||||
@ -14,6 +14,8 @@
|
||||
#include <utility>
|
||||
|
||||
#include "absl/base/macros.h"
|
||||
#include "api/environment/environment.h"
|
||||
#include "api/environment/environment_factory.h"
|
||||
#include "api/units/time_delta.h"
|
||||
#include "modules/rtp_rtcp/include/rtp_rtcp_defines.h"
|
||||
#include "modules/rtp_rtcp/source/rtcp_packet/bye.h"
|
||||
@ -89,9 +91,9 @@ class RtcpSenderTest : public ::testing::Test {
|
||||
protected:
|
||||
RtcpSenderTest()
|
||||
: clock_(1335900000),
|
||||
receive_statistics_(ReceiveStatistics::Create(&clock_)) {
|
||||
rtp_rtcp_impl_.reset(new ModuleRtpRtcpImpl2(GetDefaultRtpRtcpConfig()));
|
||||
}
|
||||
env_(CreateEnvironment(&clock_)),
|
||||
receive_statistics_(ReceiveStatistics::Create(&clock_)),
|
||||
rtp_rtcp_impl_(env_, GetDefaultRtpRtcpConfig()) {}
|
||||
|
||||
RTCPSender::Configuration GetDefaultConfig() {
|
||||
RTCPSender::Configuration configuration;
|
||||
@ -108,7 +110,6 @@ class RtcpSenderTest : public ::testing::Test {
|
||||
RTCPSender::Configuration config = GetDefaultConfig();
|
||||
RtpRtcpInterface::Configuration result;
|
||||
result.audio = config.audio;
|
||||
result.clock = config.clock;
|
||||
result.outgoing_transport = config.outgoing_transport;
|
||||
result.rtcp_report_interval_ms = config.rtcp_report_interval->ms();
|
||||
result.receive_statistics = config.receive_statistics;
|
||||
@ -128,14 +129,15 @@ class RtcpSenderTest : public ::testing::Test {
|
||||
test::RtcpPacketParser* parser() { return &test_transport_.parser_; }
|
||||
|
||||
RTCPSender::FeedbackState feedback_state() {
|
||||
return rtp_rtcp_impl_->GetFeedbackState();
|
||||
return rtp_rtcp_impl_.GetFeedbackState();
|
||||
}
|
||||
|
||||
rtc::AutoThread main_thread_;
|
||||
SimulatedClock clock_;
|
||||
const Environment env_;
|
||||
TestTransport test_transport_;
|
||||
std::unique_ptr<ReceiveStatistics> receive_statistics_;
|
||||
std::unique_ptr<ModuleRtpRtcpImpl2> rtp_rtcp_impl_;
|
||||
ModuleRtpRtcpImpl2 rtp_rtcp_impl_;
|
||||
};
|
||||
|
||||
TEST_F(RtcpSenderTest, SetRtcpStatus) {
|
||||
@ -163,7 +165,7 @@ TEST_F(RtcpSenderTest, SendSr) {
|
||||
const uint32_t kOctetCount = 0x23456;
|
||||
auto rtcp_sender = CreateRtcpSender(GetDefaultConfig());
|
||||
rtcp_sender->SetRTCPStatus(RtcpMode::kReducedSize);
|
||||
RTCPSender::FeedbackState feedback_state = rtp_rtcp_impl_->GetFeedbackState();
|
||||
RTCPSender::FeedbackState feedback_state = rtp_rtcp_impl_.GetFeedbackState();
|
||||
rtcp_sender->SetSendingStatus(feedback_state, true);
|
||||
feedback_state.packets_sent = kPacketCount;
|
||||
feedback_state.media_bytes_sent = kOctetCount;
|
||||
@ -188,7 +190,7 @@ TEST_F(RtcpSenderTest, SendConsecutiveSrWithExactSlope) {
|
||||
// Make sure clock is not exactly at some milliseconds point.
|
||||
clock_.AdvanceTimeMicroseconds(kTimeBetweenSRsUs);
|
||||
rtcp_sender->SetRTCPStatus(RtcpMode::kReducedSize);
|
||||
RTCPSender::FeedbackState feedback_state = rtp_rtcp_impl_->GetFeedbackState();
|
||||
RTCPSender::FeedbackState feedback_state = rtp_rtcp_impl_.GetFeedbackState();
|
||||
rtcp_sender->SetSendingStatus(feedback_state, true);
|
||||
feedback_state.packets_sent = kPacketCount;
|
||||
feedback_state.media_bytes_sent = kOctetCount;
|
||||
@ -480,7 +482,7 @@ TEST_F(RtcpSenderTest, RembIncludedInEachCompoundPacketAfterSet) {
|
||||
TEST_F(RtcpSenderTest, SendXrWithDlrr) {
|
||||
auto rtcp_sender = CreateRtcpSender(GetDefaultConfig());
|
||||
rtcp_sender->SetRTCPStatus(RtcpMode::kCompound);
|
||||
RTCPSender::FeedbackState feedback_state = rtp_rtcp_impl_->GetFeedbackState();
|
||||
RTCPSender::FeedbackState feedback_state = rtp_rtcp_impl_.GetFeedbackState();
|
||||
rtcp::ReceiveTimeInfo last_xr_rr;
|
||||
last_xr_rr.ssrc = 0x11111111;
|
||||
last_xr_rr.last_rr = 0x22222222;
|
||||
@ -500,7 +502,7 @@ TEST_F(RtcpSenderTest, SendXrWithMultipleDlrrSubBlocks) {
|
||||
const size_t kNumReceivers = 2;
|
||||
auto rtcp_sender = CreateRtcpSender(GetDefaultConfig());
|
||||
rtcp_sender->SetRTCPStatus(RtcpMode::kCompound);
|
||||
RTCPSender::FeedbackState feedback_state = rtp_rtcp_impl_->GetFeedbackState();
|
||||
RTCPSender::FeedbackState feedback_state = rtp_rtcp_impl_.GetFeedbackState();
|
||||
for (size_t i = 0; i < kNumReceivers; ++i) {
|
||||
rtcp::ReceiveTimeInfo last_xr_rr;
|
||||
last_xr_rr.ssrc = i;
|
||||
|
||||
@ -19,6 +19,7 @@
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
#include "absl/memory/memory.h"
|
||||
#include "absl/strings/string_view.h"
|
||||
#include "absl/types/optional.h"
|
||||
#include "api/sequence_checker.h"
|
||||
@ -69,6 +70,25 @@ ModuleRtpRtcpImpl2::RtpSenderContext::RtpSenderContext(
|
||||
&packet_history,
|
||||
config.paced_sender ? config.paced_sender : &non_paced_sender) {}
|
||||
|
||||
// TODO: b/362762208 - Update ModuleRtpRtcpImpl2 including its members to query
|
||||
// Environment directly, and remove similar fields from the Configuration.
|
||||
// Merge two constructors into single one after that.
|
||||
ModuleRtpRtcpImpl2::ModuleRtpRtcpImpl2(const Environment& env,
|
||||
const Configuration& configuration)
|
||||
: ModuleRtpRtcpImpl2([&] {
|
||||
// Check users of this constructor switch to not duplicate
|
||||
// utilities passed with environment.
|
||||
RTC_DCHECK(configuration.field_trials == nullptr);
|
||||
RTC_DCHECK(configuration.clock == nullptr);
|
||||
RTC_DCHECK(configuration.event_log == nullptr);
|
||||
|
||||
Configuration config = configuration;
|
||||
config.field_trials = &env.field_trials();
|
||||
config.clock = &env.clock();
|
||||
config.event_log = &env.event_log();
|
||||
return config;
|
||||
}()) {}
|
||||
|
||||
ModuleRtpRtcpImpl2::ModuleRtpRtcpImpl2(const Configuration& configuration)
|
||||
: worker_queue_(TaskQueueBase::Current()),
|
||||
rtcp_sender_(AddRtcpSendEvaluationCallback(
|
||||
@ -118,7 +138,8 @@ std::unique_ptr<ModuleRtpRtcpImpl2> ModuleRtpRtcpImpl2::Create(
|
||||
const Configuration& configuration) {
|
||||
RTC_DCHECK(configuration.clock);
|
||||
RTC_DCHECK(TaskQueueBase::Current());
|
||||
return std::make_unique<ModuleRtpRtcpImpl2>(configuration);
|
||||
// Use WrapUnique to access private constructor.
|
||||
return absl::WrapUnique(new ModuleRtpRtcpImpl2(configuration));
|
||||
}
|
||||
|
||||
void ModuleRtpRtcpImpl2::SetRtxSendStatus(int mode) {
|
||||
|
||||
@ -21,6 +21,7 @@
|
||||
|
||||
#include "absl/strings/string_view.h"
|
||||
#include "absl/types/optional.h"
|
||||
#include "api/environment/environment.h"
|
||||
#include "api/rtp_headers.h"
|
||||
#include "api/sequence_checker.h"
|
||||
#include "api/task_queue/pending_task_safety_flag.h"
|
||||
@ -52,8 +53,8 @@ struct RTPVideoHeader;
|
||||
class ModuleRtpRtcpImpl2 final : public RtpRtcpInterface,
|
||||
public RTCPReceiver::ModuleRtpRtcp {
|
||||
public:
|
||||
explicit ModuleRtpRtcpImpl2(
|
||||
const RtpRtcpInterface::Configuration& configuration);
|
||||
ModuleRtpRtcpImpl2(const Environment& env,
|
||||
const RtpRtcpInterface::Configuration& configuration);
|
||||
~ModuleRtpRtcpImpl2() override;
|
||||
|
||||
// This method is provided to easy with migrating away from the
|
||||
@ -275,6 +276,8 @@ class ModuleRtpRtcpImpl2 final : public RtpRtcpInterface,
|
||||
RTPSender packet_generator;
|
||||
};
|
||||
|
||||
explicit ModuleRtpRtcpImpl2(const Configuration& configuration);
|
||||
|
||||
void set_rtt_ms(int64_t rtt_ms);
|
||||
int64_t rtt_ms() const;
|
||||
|
||||
|
||||
@ -238,7 +238,6 @@ class RtpRtcpModule : public RtcpPacketTypeCounterObserver,
|
||||
void CreateModuleImpl() {
|
||||
RtpRtcpInterface::Configuration config;
|
||||
config.audio = false;
|
||||
config.clock = &env_.clock();
|
||||
config.outgoing_transport = &transport_;
|
||||
config.receive_statistics = receive_statistics_.get();
|
||||
config.rtcp_packet_type_counter_observer = this;
|
||||
@ -249,10 +248,9 @@ class RtpRtcpModule : public RtcpPacketTypeCounterObserver,
|
||||
is_sender_ ? absl::make_optional(kRtxSenderSsrc) : absl::nullopt;
|
||||
config.need_rtp_packet_infos = true;
|
||||
config.non_sender_rtt_measurement = true;
|
||||
config.field_trials = &env_.field_trials();
|
||||
config.send_packet_observer = this;
|
||||
config.fec_generator = fec_generator_;
|
||||
impl_.reset(new ModuleRtpRtcpImpl2(config));
|
||||
impl_ = std::make_unique<ModuleRtpRtcpImpl2>(env_, config);
|
||||
impl_->SetRemoteSSRC(is_sender_ ? kReceiverSsrc : kSenderSsrc);
|
||||
impl_->SetRTCPStatus(RtcpMode::kCompound);
|
||||
}
|
||||
|
||||
@ -44,12 +44,6 @@ class VideoBitrateAllocationObserver;
|
||||
class RtpRtcpInterface : public RtcpFeedbackSenderInterface {
|
||||
public:
|
||||
struct Configuration {
|
||||
Configuration() = default;
|
||||
Configuration(Configuration&& rhs) = default;
|
||||
|
||||
Configuration(const Configuration&) = delete;
|
||||
Configuration& operator=(const Configuration&) = delete;
|
||||
|
||||
// True for a audio version of the RTP/RTCP module object false will create
|
||||
// a video version.
|
||||
bool audio = false;
|
||||
|
||||
@ -13,6 +13,8 @@
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "api/environment/environment.h"
|
||||
#include "api/environment/environment_factory.h"
|
||||
#include "modules/rtp_rtcp/include/rtp_header_extension_map.h"
|
||||
#include "modules/rtp_rtcp/include/rtp_rtcp_defines.h"
|
||||
#include "modules/rtp_rtcp/source/rtp_header_extensions.h"
|
||||
@ -65,24 +67,22 @@ class RtpSenderAudioTest : public ::testing::Test {
|
||||
public:
|
||||
RtpSenderAudioTest()
|
||||
: fake_clock_(kStartTime),
|
||||
rtp_module_(ModuleRtpRtcpImpl2::Create([&] {
|
||||
RtpRtcpInterface::Configuration config;
|
||||
config.audio = true;
|
||||
config.clock = &fake_clock_;
|
||||
config.outgoing_transport = &transport_;
|
||||
config.local_media_ssrc = kSsrc;
|
||||
return config;
|
||||
}())),
|
||||
env_(CreateEnvironment(&fake_clock_)),
|
||||
rtp_module_(env_,
|
||||
{.audio = true,
|
||||
.outgoing_transport = &transport_,
|
||||
.local_media_ssrc = kSsrc}),
|
||||
rtp_sender_audio_(
|
||||
std::make_unique<RTPSenderAudio>(&fake_clock_,
|
||||
rtp_module_->RtpSender())) {
|
||||
rtp_module_->SetSequenceNumber(kSeqNum);
|
||||
rtp_module_.RtpSender())) {
|
||||
rtp_module_.SetSequenceNumber(kSeqNum);
|
||||
}
|
||||
|
||||
rtc::AutoThread main_thread_;
|
||||
SimulatedClock fake_clock_;
|
||||
const Environment env_;
|
||||
LoopbackTransportTest transport_;
|
||||
std::unique_ptr<ModuleRtpRtcpImpl2> rtp_module_;
|
||||
ModuleRtpRtcpImpl2 rtp_module_;
|
||||
std::unique_ptr<RTPSenderAudio> rtp_sender_audio_;
|
||||
};
|
||||
|
||||
@ -102,8 +102,8 @@ TEST_F(RtpSenderAudioTest, SendAudio) {
|
||||
|
||||
TEST_F(RtpSenderAudioTest, SendAudioWithAudioLevelExtension) {
|
||||
const uint8_t kAudioLevel = 0x5a;
|
||||
rtp_module_->RegisterRtpHeaderExtension(AudioLevelExtension::Uri(),
|
||||
kAudioLevelExtensionId);
|
||||
rtp_module_.RegisterRtpHeaderExtension(AudioLevelExtension::Uri(),
|
||||
kAudioLevelExtensionId);
|
||||
|
||||
const char payload_name[] = "PAYLOAD_NAME";
|
||||
const uint8_t payload_type = 127;
|
||||
@ -148,8 +148,8 @@ TEST_F(RtpSenderAudioTest, SendAudioWithoutAbsoluteCaptureTime) {
|
||||
|
||||
TEST_F(RtpSenderAudioTest,
|
||||
SendAudioWithAbsoluteCaptureTimeWithCaptureClockOffset) {
|
||||
rtp_module_->RegisterRtpHeaderExtension(AbsoluteCaptureTimeExtension::Uri(),
|
||||
kAbsoluteCaptureTimeExtensionId);
|
||||
rtp_module_.RegisterRtpHeaderExtension(AbsoluteCaptureTimeExtension::Uri(),
|
||||
kAbsoluteCaptureTimeExtensionId);
|
||||
constexpr Timestamp kAbsoluteCaptureTimestamp = Timestamp::Millis(521);
|
||||
const char payload_name[] = "audio";
|
||||
const uint8_t payload_type = 127;
|
||||
|
||||
@ -16,6 +16,8 @@
|
||||
#include <vector>
|
||||
|
||||
#include "absl/memory/memory.h"
|
||||
#include "api/environment/environment.h"
|
||||
#include "api/environment/environment_factory.h"
|
||||
#include "api/frame_transformer_factory.h"
|
||||
#include "api/rtp_headers.h"
|
||||
#include "api/task_queue/task_queue_base.h"
|
||||
@ -44,7 +46,6 @@
|
||||
#include "rtc_base/logging.h"
|
||||
#include "rtc_base/rate_limiter.h"
|
||||
#include "rtc_base/thread.h"
|
||||
#include "test/explicit_key_value_config.h"
|
||||
#include "test/gmock.h"
|
||||
#include "test/gtest.h"
|
||||
#include "test/time_controller/simulated_time_controller.h"
|
||||
@ -158,24 +159,21 @@ class RtpSenderVideoTest : public ::testing::Test {
|
||||
public:
|
||||
RtpSenderVideoTest()
|
||||
: fake_clock_(kStartTime),
|
||||
env_(CreateEnvironment(&fake_clock_)),
|
||||
retransmission_rate_limiter_(&fake_clock_, 1000),
|
||||
rtp_module_(ModuleRtpRtcpImpl2::Create([&] {
|
||||
RtpRtcpInterface::Configuration config;
|
||||
config.clock = &fake_clock_;
|
||||
config.outgoing_transport = &transport_;
|
||||
config.retransmission_rate_limiter = &retransmission_rate_limiter_;
|
||||
config.field_trials = &field_trials_;
|
||||
config.local_media_ssrc = kSsrc;
|
||||
config.rtx_send_ssrc = kRtxSsrc;
|
||||
config.rid = "rid";
|
||||
return config;
|
||||
}())),
|
||||
rtp_module_(
|
||||
env_,
|
||||
{.outgoing_transport = &transport_,
|
||||
.retransmission_rate_limiter = &retransmission_rate_limiter_,
|
||||
.local_media_ssrc = kSsrc,
|
||||
.rtx_send_ssrc = kRtxSsrc,
|
||||
.rid = "rid"}),
|
||||
rtp_sender_video_(
|
||||
std::make_unique<TestRtpSenderVideo>(&fake_clock_,
|
||||
rtp_module_->RtpSender(),
|
||||
field_trials_)) {
|
||||
rtp_module_->SetSequenceNumber(kSeqNum);
|
||||
rtp_module_->SetStartTimestamp(0);
|
||||
rtp_module_.RtpSender(),
|
||||
env_.field_trials())) {
|
||||
rtp_module_.SetSequenceNumber(kSeqNum);
|
||||
rtp_module_.SetStartTimestamp(0);
|
||||
}
|
||||
|
||||
void UsesMinimalVp8DescriptorWhenGenericFrameDescriptorExtensionIsUsed(
|
||||
@ -183,19 +181,18 @@ class RtpSenderVideoTest : public ::testing::Test {
|
||||
|
||||
protected:
|
||||
rtc::AutoThread main_thread_;
|
||||
const RtpRtcpInterface::Configuration config_;
|
||||
test::ExplicitKeyValueConfig field_trials_{""};
|
||||
SimulatedClock fake_clock_;
|
||||
const Environment env_;
|
||||
LoopbackTransportTest transport_;
|
||||
RateLimiter retransmission_rate_limiter_;
|
||||
std::unique_ptr<ModuleRtpRtcpImpl2> rtp_module_;
|
||||
ModuleRtpRtcpImpl2 rtp_module_;
|
||||
std::unique_ptr<TestRtpSenderVideo> rtp_sender_video_;
|
||||
};
|
||||
|
||||
TEST_F(RtpSenderVideoTest, KeyFrameHasCVO) {
|
||||
uint8_t kFrame[kMaxPacketLength];
|
||||
rtp_module_->RegisterRtpHeaderExtension(VideoOrientation::Uri(),
|
||||
kVideoRotationExtensionId);
|
||||
rtp_module_.RegisterRtpHeaderExtension(VideoOrientation::Uri(),
|
||||
kVideoRotationExtensionId);
|
||||
|
||||
RTPVideoHeader hdr;
|
||||
hdr.rotation = kVideoRotation_0;
|
||||
@ -215,8 +212,8 @@ TEST_F(RtpSenderVideoTest, TimingFrameHasPacketizationTimstampSet) {
|
||||
const int64_t kPacketizationTimeMs = 100;
|
||||
const int64_t kEncodeStartDeltaMs = 10;
|
||||
const int64_t kEncodeFinishDeltaMs = 50;
|
||||
rtp_module_->RegisterRtpHeaderExtension(VideoTimingExtension::Uri(),
|
||||
kVideoTimingExtensionId);
|
||||
rtp_module_.RegisterRtpHeaderExtension(VideoTimingExtension::Uri(),
|
||||
kVideoTimingExtensionId);
|
||||
|
||||
const Timestamp kCaptureTimestamp = fake_clock_.CurrentTime();
|
||||
|
||||
@ -240,8 +237,8 @@ TEST_F(RtpSenderVideoTest, TimingFrameHasPacketizationTimstampSet) {
|
||||
|
||||
TEST_F(RtpSenderVideoTest, DeltaFrameHasCVOWhenChanged) {
|
||||
uint8_t kFrame[kMaxPacketLength];
|
||||
rtp_module_->RegisterRtpHeaderExtension(VideoOrientation::Uri(),
|
||||
kVideoRotationExtensionId);
|
||||
rtp_module_.RegisterRtpHeaderExtension(VideoOrientation::Uri(),
|
||||
kVideoRotationExtensionId);
|
||||
|
||||
RTPVideoHeader hdr;
|
||||
hdr.rotation = kVideoRotation_90;
|
||||
@ -264,8 +261,8 @@ TEST_F(RtpSenderVideoTest, DeltaFrameHasCVOWhenChanged) {
|
||||
|
||||
TEST_F(RtpSenderVideoTest, DeltaFrameHasCVOWhenNonZero) {
|
||||
uint8_t kFrame[kMaxPacketLength];
|
||||
rtp_module_->RegisterRtpHeaderExtension(VideoOrientation::Uri(),
|
||||
kVideoRotationExtensionId);
|
||||
rtp_module_.RegisterRtpHeaderExtension(VideoOrientation::Uri(),
|
||||
kVideoRotationExtensionId);
|
||||
|
||||
RTPVideoHeader hdr;
|
||||
hdr.rotation = kVideoRotation_90;
|
||||
@ -489,15 +486,15 @@ TEST_F(RtpSenderVideoTest,
|
||||
constexpr int kRtxPayloadId = 101;
|
||||
constexpr size_t kMaxPacketSize = 1'000;
|
||||
|
||||
rtp_module_->SetMaxRtpPacketSize(kMaxPacketSize);
|
||||
rtp_module_->RegisterRtpHeaderExtension(RtpMid::Uri(), 1);
|
||||
rtp_module_->RegisterRtpHeaderExtension(RtpStreamId::Uri(), 2);
|
||||
rtp_module_->RegisterRtpHeaderExtension(RepairedRtpStreamId::Uri(), 3);
|
||||
rtp_module_->RegisterRtpHeaderExtension(AbsoluteSendTime::Uri(), 4);
|
||||
rtp_module_->SetMid("long_mid");
|
||||
rtp_module_->SetRtxSendPayloadType(kRtxPayloadId, kMediaPayloadId);
|
||||
rtp_module_->SetStorePacketsStatus(/*enable=*/true, 10);
|
||||
rtp_module_->SetRtxSendStatus(kRtxRetransmitted);
|
||||
rtp_module_.SetMaxRtpPacketSize(kMaxPacketSize);
|
||||
rtp_module_.RegisterRtpHeaderExtension(RtpMid::Uri(), 1);
|
||||
rtp_module_.RegisterRtpHeaderExtension(RtpStreamId::Uri(), 2);
|
||||
rtp_module_.RegisterRtpHeaderExtension(RepairedRtpStreamId::Uri(), 3);
|
||||
rtp_module_.RegisterRtpHeaderExtension(AbsoluteSendTime::Uri(), 4);
|
||||
rtp_module_.SetMid("long_mid");
|
||||
rtp_module_.SetRtxSendPayloadType(kRtxPayloadId, kMediaPayloadId);
|
||||
rtp_module_.SetStorePacketsStatus(/*enable=*/true, 10);
|
||||
rtp_module_.SetRtxSendStatus(kRtxRetransmitted);
|
||||
|
||||
RTPVideoHeader header;
|
||||
header.codec = kVideoCodecVP8;
|
||||
@ -519,7 +516,7 @@ TEST_F(RtpSenderVideoTest,
|
||||
rb.SetMediaSsrc(kSsrc);
|
||||
rb.SetExtHighestSeqNum(transport_.last_sent_packet().SequenceNumber());
|
||||
rr.AddReportBlock(rb);
|
||||
rtp_module_->IncomingRtcpPacket(rr.Build());
|
||||
rtp_module_.IncomingRtcpPacket(rr.Build());
|
||||
|
||||
// Test for various frame size close to `kMaxPacketSize` to catch edge cases
|
||||
// when rtx packet barely fit.
|
||||
@ -537,7 +534,7 @@ TEST_F(RtpSenderVideoTest,
|
||||
rtcp::Nack nack;
|
||||
nack.SetMediaSsrc(kSsrc);
|
||||
nack.SetPacketIds({media_packet.SequenceNumber()});
|
||||
rtp_module_->IncomingRtcpPacket(nack.Build());
|
||||
rtp_module_.IncomingRtcpPacket(nack.Build());
|
||||
|
||||
const RtpPacketReceived& rtx_packet = transport_.last_sent_packet();
|
||||
EXPECT_EQ(rtx_packet.Ssrc(), kRtxSsrc);
|
||||
@ -548,7 +545,7 @@ TEST_F(RtpSenderVideoTest,
|
||||
TEST_F(RtpSenderVideoTest, SendsDependencyDescriptorWhenVideoStructureIsSet) {
|
||||
const int64_t kFrameId = 100000;
|
||||
uint8_t kFrame[100];
|
||||
rtp_module_->RegisterRtpHeaderExtension(
|
||||
rtp_module_.RegisterRtpHeaderExtension(
|
||||
RtpDependencyDescriptorExtension::Uri(), kDependencyDescriptorId);
|
||||
FrameDependencyStructure video_structure;
|
||||
video_structure.num_decode_targets = 2;
|
||||
@ -619,9 +616,9 @@ TEST_F(RtpSenderVideoTest,
|
||||
SkipsDependencyDescriptorOnDeltaFrameWhenFailedToAttachToKeyFrame) {
|
||||
const int64_t kFrameId = 100000;
|
||||
uint8_t kFrame[100];
|
||||
rtp_module_->RegisterRtpHeaderExtension(
|
||||
rtp_module_.RegisterRtpHeaderExtension(
|
||||
RtpDependencyDescriptorExtension::Uri(), kDependencyDescriptorId);
|
||||
rtp_module_->SetExtmapAllowMixed(false);
|
||||
rtp_module_.SetExtmapAllowMixed(false);
|
||||
FrameDependencyStructure video_structure;
|
||||
video_structure.num_decode_targets = 2;
|
||||
// Use many templates so that key dependency descriptor would be too large
|
||||
@ -674,7 +671,7 @@ TEST_F(RtpSenderVideoTest,
|
||||
TEST_F(RtpSenderVideoTest, PropagatesChainDiffsIntoDependencyDescriptor) {
|
||||
const int64_t kFrameId = 100000;
|
||||
uint8_t kFrame[100];
|
||||
rtp_module_->RegisterRtpHeaderExtension(
|
||||
rtp_module_.RegisterRtpHeaderExtension(
|
||||
RtpDependencyDescriptorExtension::Uri(), kDependencyDescriptorId);
|
||||
FrameDependencyStructure video_structure;
|
||||
video_structure.num_decode_targets = 2;
|
||||
@ -709,7 +706,7 @@ TEST_F(RtpSenderVideoTest,
|
||||
PropagatesActiveDecodeTargetsIntoDependencyDescriptor) {
|
||||
const int64_t kFrameId = 100000;
|
||||
uint8_t kFrame[100];
|
||||
rtp_module_->RegisterRtpHeaderExtension(
|
||||
rtp_module_.RegisterRtpHeaderExtension(
|
||||
RtpDependencyDescriptorExtension::Uri(), kDependencyDescriptorId);
|
||||
FrameDependencyStructure video_structure;
|
||||
video_structure.num_decode_targets = 2;
|
||||
@ -744,7 +741,7 @@ TEST_F(RtpSenderVideoTest,
|
||||
SetDiffentVideoStructureAvoidsCollisionWithThePreviousStructure) {
|
||||
const int64_t kFrameId = 100000;
|
||||
uint8_t kFrame[100];
|
||||
rtp_module_->RegisterRtpHeaderExtension(
|
||||
rtp_module_.RegisterRtpHeaderExtension(
|
||||
RtpDependencyDescriptorExtension::Uri(), kDependencyDescriptorId);
|
||||
FrameDependencyStructure video_structure1;
|
||||
video_structure1.num_decode_targets = 2;
|
||||
@ -822,7 +819,7 @@ TEST_F(RtpSenderVideoTest,
|
||||
static constexpr size_t kFrameSize = 100;
|
||||
uint8_t kFrame[kFrameSize] = {1, 2, 3, 4};
|
||||
|
||||
rtp_module_->RegisterRtpHeaderExtension(
|
||||
rtp_module_.RegisterRtpHeaderExtension(
|
||||
RtpDependencyDescriptorExtension::Uri(), kDependencyDescriptorId);
|
||||
auto encryptor = rtc::make_ref_counted<NiceMock<MockFrameEncryptor>>();
|
||||
ON_CALL(*encryptor, GetMaxCiphertextByteSize).WillByDefault(ReturnArg<1>());
|
||||
@ -834,8 +831,8 @@ TEST_F(RtpSenderVideoTest,
|
||||
}));
|
||||
RTPSenderVideo::Config config;
|
||||
config.clock = &fake_clock_;
|
||||
config.rtp_sender = rtp_module_->RtpSender();
|
||||
config.field_trials = &field_trials_;
|
||||
config.rtp_sender = rtp_module_.RtpSender();
|
||||
config.field_trials = &env_.field_trials();
|
||||
config.frame_encryptor = encryptor.get();
|
||||
RTPSenderVideo rtp_sender_video(config);
|
||||
|
||||
@ -864,7 +861,7 @@ TEST_F(RtpSenderVideoTest,
|
||||
TEST_F(RtpSenderVideoTest, PopulateGenericFrameDescriptor) {
|
||||
const int64_t kFrameId = 100000;
|
||||
uint8_t kFrame[100];
|
||||
rtp_module_->RegisterRtpHeaderExtension(
|
||||
rtp_module_.RegisterRtpHeaderExtension(
|
||||
RtpGenericFrameDescriptorExtension00::Uri(), kGenericDescriptorId);
|
||||
|
||||
RTPVideoHeader hdr;
|
||||
@ -897,7 +894,7 @@ void RtpSenderVideoTest::
|
||||
const size_t kFrameSize = 100;
|
||||
uint8_t kFrame[kFrameSize];
|
||||
|
||||
rtp_module_->RegisterRtpHeaderExtension(
|
||||
rtp_module_.RegisterRtpHeaderExtension(
|
||||
RtpGenericFrameDescriptorExtension00::Uri(), kGenericDescriptorId);
|
||||
|
||||
RTPVideoHeader hdr;
|
||||
@ -933,7 +930,7 @@ TEST_F(RtpSenderVideoTest,
|
||||
TEST_F(RtpSenderVideoTest, VideoLayersAllocationWithResolutionSentOnKeyFrames) {
|
||||
const size_t kFrameSize = 100;
|
||||
uint8_t kFrame[kFrameSize];
|
||||
rtp_module_->RegisterRtpHeaderExtension(
|
||||
rtp_module_.RegisterRtpHeaderExtension(
|
||||
RtpVideoLayersAllocationExtension::Uri(),
|
||||
kVideoLayersAllocationExtensionId);
|
||||
|
||||
@ -972,7 +969,7 @@ TEST_F(RtpSenderVideoTest,
|
||||
VideoLayersAllocationWithoutResolutionSentOnDeltaWhenUpdated) {
|
||||
const size_t kFrameSize = 100;
|
||||
uint8_t kFrame[kFrameSize];
|
||||
rtp_module_->RegisterRtpHeaderExtension(
|
||||
rtp_module_.RegisterRtpHeaderExtension(
|
||||
RtpVideoLayersAllocationExtension::Uri(),
|
||||
kVideoLayersAllocationExtensionId);
|
||||
|
||||
@ -1023,7 +1020,7 @@ TEST_F(RtpSenderVideoTest,
|
||||
VideoLayersAllocationWithResolutionSentOnDeltaWhenSpatialLayerAdded) {
|
||||
const size_t kFrameSize = 100;
|
||||
uint8_t kFrame[kFrameSize];
|
||||
rtp_module_->RegisterRtpHeaderExtension(
|
||||
rtp_module_.RegisterRtpHeaderExtension(
|
||||
RtpVideoLayersAllocationExtension::Uri(),
|
||||
kVideoLayersAllocationExtensionId);
|
||||
|
||||
@ -1071,7 +1068,7 @@ TEST_F(RtpSenderVideoTest,
|
||||
VideoLayersAllocationWithResolutionSentOnLargeFrameRateChange) {
|
||||
const size_t kFrameSize = 100;
|
||||
uint8_t kFrame[kFrameSize];
|
||||
rtp_module_->RegisterRtpHeaderExtension(
|
||||
rtp_module_.RegisterRtpHeaderExtension(
|
||||
RtpVideoLayersAllocationExtension::Uri(),
|
||||
kVideoLayersAllocationExtensionId);
|
||||
|
||||
@ -1115,7 +1112,7 @@ TEST_F(RtpSenderVideoTest,
|
||||
VideoLayersAllocationWithoutResolutionSentOnSmallFrameRateChange) {
|
||||
const size_t kFrameSize = 100;
|
||||
uint8_t kFrame[kFrameSize];
|
||||
rtp_module_->RegisterRtpHeaderExtension(
|
||||
rtp_module_.RegisterRtpHeaderExtension(
|
||||
RtpVideoLayersAllocationExtension::Uri(),
|
||||
kVideoLayersAllocationExtensionId);
|
||||
|
||||
@ -1157,7 +1154,7 @@ TEST_F(RtpSenderVideoTest,
|
||||
TEST_F(RtpSenderVideoTest, VideoLayersAllocationSentOnDeltaFramesOnlyOnUpdate) {
|
||||
const size_t kFrameSize = 100;
|
||||
uint8_t kFrame[kFrameSize];
|
||||
rtp_module_->RegisterRtpHeaderExtension(
|
||||
rtp_module_.RegisterRtpHeaderExtension(
|
||||
RtpVideoLayersAllocationExtension::Uri(),
|
||||
kVideoLayersAllocationExtensionId);
|
||||
|
||||
@ -1202,7 +1199,7 @@ TEST_F(RtpSenderVideoTest, VideoLayersAllocationSentOnDeltaFramesOnlyOnUpdate) {
|
||||
TEST_F(RtpSenderVideoTest, VideoLayersAllocationNotSentOnHigherTemporalLayers) {
|
||||
const size_t kFrameSize = 100;
|
||||
uint8_t kFrame[kFrameSize];
|
||||
rtp_module_->RegisterRtpHeaderExtension(
|
||||
rtp_module_.RegisterRtpHeaderExtension(
|
||||
RtpVideoLayersAllocationExtension::Uri(),
|
||||
kVideoLayersAllocationExtensionId);
|
||||
|
||||
@ -1240,8 +1237,8 @@ TEST_F(RtpSenderVideoTest, VideoLayersAllocationNotSentOnHigherTemporalLayers) {
|
||||
TEST_F(RtpSenderVideoTest,
|
||||
AbsoluteCaptureTimeNotForwardedWhenImageHasNoCaptureTime) {
|
||||
uint8_t kFrame[kMaxPacketLength];
|
||||
rtp_module_->RegisterRtpHeaderExtension(AbsoluteCaptureTimeExtension::Uri(),
|
||||
kAbsoluteCaptureTimeExtensionId);
|
||||
rtp_module_.RegisterRtpHeaderExtension(AbsoluteCaptureTimeExtension::Uri(),
|
||||
kAbsoluteCaptureTimeExtensionId);
|
||||
|
||||
RTPVideoHeader hdr;
|
||||
hdr.frame_type = VideoFrameType::kVideoFrameKey;
|
||||
@ -1258,12 +1255,12 @@ TEST_F(RtpSenderVideoTest,
|
||||
|
||||
TEST_F(RtpSenderVideoTest, AbsoluteCaptureTime) {
|
||||
rtp_sender_video_ = std::make_unique<TestRtpSenderVideo>(
|
||||
&fake_clock_, rtp_module_->RtpSender(), field_trials_);
|
||||
&fake_clock_, rtp_module_.RtpSender(), env_.field_trials());
|
||||
|
||||
constexpr Timestamp kAbsoluteCaptureTimestamp = Timestamp::Millis(12345678);
|
||||
uint8_t kFrame[kMaxPacketLength];
|
||||
rtp_module_->RegisterRtpHeaderExtension(AbsoluteCaptureTimeExtension::Uri(),
|
||||
kAbsoluteCaptureTimeExtensionId);
|
||||
rtp_module_.RegisterRtpHeaderExtension(AbsoluteCaptureTimeExtension::Uri(),
|
||||
kAbsoluteCaptureTimeExtensionId);
|
||||
|
||||
RTPVideoHeader hdr;
|
||||
hdr.frame_type = VideoFrameType::kVideoFrameKey;
|
||||
@ -1299,8 +1296,8 @@ TEST_F(RtpSenderVideoTest, AbsoluteCaptureTimeWithExtensionProvided) {
|
||||
absl::optional<int64_t>(456),
|
||||
};
|
||||
uint8_t kFrame[kMaxPacketLength];
|
||||
rtp_module_->RegisterRtpHeaderExtension(AbsoluteCaptureTimeExtension::Uri(),
|
||||
kAbsoluteCaptureTimeExtensionId);
|
||||
rtp_module_.RegisterRtpHeaderExtension(AbsoluteCaptureTimeExtension::Uri(),
|
||||
kAbsoluteCaptureTimeExtensionId);
|
||||
|
||||
RTPVideoHeader hdr;
|
||||
hdr.frame_type = VideoFrameType::kVideoFrameKey;
|
||||
@ -1331,8 +1328,8 @@ TEST_F(RtpSenderVideoTest, PopulatesPlayoutDelay) {
|
||||
// Single packet frames.
|
||||
constexpr size_t kPacketSize = 123;
|
||||
uint8_t kFrame[kPacketSize];
|
||||
rtp_module_->RegisterRtpHeaderExtension(PlayoutDelayLimits::Uri(),
|
||||
kPlayoutDelayExtensionId);
|
||||
rtp_module_.RegisterRtpHeaderExtension(PlayoutDelayLimits::Uri(),
|
||||
kPlayoutDelayExtensionId);
|
||||
const VideoPlayoutDelay kExpectedDelay(TimeDelta::Millis(10),
|
||||
TimeDelta::Millis(20));
|
||||
|
||||
@ -1443,26 +1440,24 @@ class RtpSenderVideoWithFrameTransformerTest : public ::testing::Test {
|
||||
public:
|
||||
RtpSenderVideoWithFrameTransformerTest()
|
||||
: time_controller_(kStartTime),
|
||||
env_(CreateEnvironment(time_controller_.GetClock(),
|
||||
time_controller_.GetTaskQueueFactory())),
|
||||
retransmission_rate_limiter_(time_controller_.GetClock(), 1000),
|
||||
rtp_module_(ModuleRtpRtcpImpl2::Create([&] {
|
||||
RtpRtcpInterface::Configuration config;
|
||||
config.clock = time_controller_.GetClock();
|
||||
config.outgoing_transport = &transport_;
|
||||
config.retransmission_rate_limiter = &retransmission_rate_limiter_;
|
||||
config.field_trials = &field_trials_;
|
||||
config.local_media_ssrc = kSsrc;
|
||||
return config;
|
||||
}())) {
|
||||
rtp_module_->SetSequenceNumber(kSeqNum);
|
||||
rtp_module_->SetStartTimestamp(0);
|
||||
rtp_module_(
|
||||
env_,
|
||||
{.outgoing_transport = &transport_,
|
||||
.retransmission_rate_limiter = &retransmission_rate_limiter_,
|
||||
.local_media_ssrc = kSsrc}) {
|
||||
rtp_module_.SetSequenceNumber(kSeqNum);
|
||||
rtp_module_.SetStartTimestamp(0);
|
||||
}
|
||||
|
||||
std::unique_ptr<RTPSenderVideo> CreateSenderWithFrameTransformer(
|
||||
rtc::scoped_refptr<FrameTransformerInterface> transformer) {
|
||||
RTPSenderVideo::Config config;
|
||||
config.clock = time_controller_.GetClock();
|
||||
config.rtp_sender = rtp_module_->RtpSender();
|
||||
config.field_trials = &field_trials_;
|
||||
config.rtp_sender = rtp_module_.RtpSender();
|
||||
config.field_trials = &env_.field_trials();
|
||||
config.frame_transformer = transformer;
|
||||
config.task_queue_factory = time_controller_.GetTaskQueueFactory();
|
||||
return std::make_unique<RTPSenderVideo>(config);
|
||||
@ -1470,10 +1465,10 @@ class RtpSenderVideoWithFrameTransformerTest : public ::testing::Test {
|
||||
|
||||
protected:
|
||||
GlobalSimulatedTimeController time_controller_;
|
||||
test::ExplicitKeyValueConfig field_trials_{""};
|
||||
const Environment env_;
|
||||
LoopbackTransportTest transport_;
|
||||
RateLimiter retransmission_rate_limiter_;
|
||||
std::unique_ptr<ModuleRtpRtcpImpl2> rtp_module_;
|
||||
ModuleRtpRtcpImpl2 rtp_module_;
|
||||
};
|
||||
|
||||
std::unique_ptr<EncodedImage> CreateDefaultEncodedImage() {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user