Add a test that shows when channel_receive fires RR
This seems to happen 2.5 seconds after initialization. Written as part of debugging a different issue. Bug: webrtc:13931 Change-Id: I3686cdbc39284505a437ebc0bfd8c74c483624c9 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/291704 Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> Commit-Queue: Harald Alvestrand <hta@webrtc.org> Cr-Commit-Position: refs/heads/main@{#39245}
This commit is contained in:
parent
84f75699c6
commit
ba846ccf24
@ -228,13 +228,17 @@ if (rtc_include_tests) {
|
||||
":audio",
|
||||
"../api/crypto:frame_decryptor_interface",
|
||||
"../api/task_queue:default_task_queue_factory",
|
||||
"../logging:mocks",
|
||||
"../modules/audio_device:audio_device_api",
|
||||
"../modules/audio_device:mock_audio_device",
|
||||
"../modules/rtp_rtcp:rtp_rtcp_format",
|
||||
"../rtc_base:logging",
|
||||
"../rtc_base:threading",
|
||||
"../test:mock_transport",
|
||||
"../test:test_support",
|
||||
"../test/time_controller",
|
||||
]
|
||||
absl_deps = [ "//third_party/abseil-cpp/absl/strings" ]
|
||||
}
|
||||
|
||||
if (rtc_enable_protobuf && !build_with_chromium) {
|
||||
|
||||
@ -12,8 +12,12 @@
|
||||
|
||||
#include "api/crypto/frame_decryptor_interface.h"
|
||||
#include "api/task_queue/default_task_queue_factory.h"
|
||||
#include "logging/rtc_event_log/mock/mock_rtc_event_log.h"
|
||||
#include "modules/audio_device/include/audio_device.h"
|
||||
#include "modules/audio_device/include/mock_audio_device.h"
|
||||
#include "modules/rtp_rtcp/source/byte_io.h"
|
||||
#include "modules/rtp_rtcp/source/rtcp_packet/receiver_report.h"
|
||||
#include "rtc_base/logging.h"
|
||||
#include "rtc_base/thread.h"
|
||||
#include "test/gmock.h"
|
||||
#include "test/gtest.h"
|
||||
@ -22,19 +26,27 @@
|
||||
|
||||
namespace webrtc {
|
||||
namespace voe {
|
||||
namespace {
|
||||
|
||||
TEST(ChannelReceiveTest, CreateAndDestroy) {
|
||||
GlobalSimulatedTimeController time_controller(Timestamp::Seconds(5555));
|
||||
uint32_t local_ssrc = 1111;
|
||||
uint32_t remote_ssrc = 2222;
|
||||
webrtc::CryptoOptions crypto_options;
|
||||
rtc::scoped_refptr<test::MockAudioDeviceModule> audio_device_module =
|
||||
test::MockAudioDeviceModule::CreateNice();
|
||||
MockTransport transport;
|
||||
auto channel = CreateChannelReceive(
|
||||
time_controller.GetClock(),
|
||||
/* neteq_factory= */ nullptr, audio_device_module.get(), &transport,
|
||||
/* rtc_event_log= */ nullptr, local_ssrc, remote_ssrc,
|
||||
using ::testing::NiceMock;
|
||||
using ::testing::NotNull;
|
||||
using ::testing::Test;
|
||||
|
||||
constexpr uint32_t kLocalSsrc = 1111;
|
||||
constexpr uint32_t kRemoteSsrc = 2222;
|
||||
|
||||
class ChannelReceiveTest : public Test {
|
||||
public:
|
||||
ChannelReceiveTest()
|
||||
: time_controller_(Timestamp::Seconds(5555)),
|
||||
audio_device_module_(test::MockAudioDeviceModule::CreateStrict()) {}
|
||||
|
||||
std::unique_ptr<ChannelReceiveInterface> CreateTestChannelReceive() {
|
||||
CryptoOptions crypto_options;
|
||||
return CreateChannelReceive(
|
||||
time_controller_.GetClock(),
|
||||
/* neteq_factory= */ nullptr, audio_device_module_.get(), &transport_,
|
||||
&event_log_, kLocalSsrc, kRemoteSsrc,
|
||||
/* jitter_buffer_max_packets= */ 0,
|
||||
/* jitter_buffer_fast_playout= */ false,
|
||||
/* jitter_buffer_min_delay_ms= */ 0,
|
||||
@ -43,8 +55,41 @@ TEST(ChannelReceiveTest, CreateAndDestroy) {
|
||||
/* codec_pair_id= */ absl::nullopt,
|
||||
/* frame_decryptor_interface= */ nullptr, crypto_options,
|
||||
/* frame_transformer= */ nullptr);
|
||||
EXPECT_TRUE(!!channel);
|
||||
}
|
||||
|
||||
NtpTime NtpNow() { return time_controller_.GetClock()->CurrentNtpTime(); }
|
||||
|
||||
protected:
|
||||
GlobalSimulatedTimeController time_controller_;
|
||||
rtc::scoped_refptr<test::MockAudioDeviceModule> audio_device_module_;
|
||||
MockTransport transport_;
|
||||
NiceMock<MockRtcEventLog> event_log_;
|
||||
};
|
||||
|
||||
TEST_F(ChannelReceiveTest, CreateAndDestroy) {
|
||||
auto channel = CreateTestChannelReceive();
|
||||
EXPECT_THAT(channel, NotNull());
|
||||
}
|
||||
|
||||
TEST_F(ChannelReceiveTest, ReceiveReportGeneratedOnTime) {
|
||||
auto channel = CreateTestChannelReceive();
|
||||
channel->SetReceiveCodecs({{10, {"L16", 44100, 1}}});
|
||||
|
||||
bool receiver_report_sent = false;
|
||||
EXPECT_CALL(transport_, SendRtcp)
|
||||
.WillRepeatedly([&](const uint8_t* packet, size_t length) {
|
||||
if (length >= 2 && packet[1] == rtcp::ReceiverReport::kPacketType) {
|
||||
receiver_report_sent = true;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
// RFC 3550 section 6.2 mentions 5 seconds as a reasonable expectation
|
||||
// for the interval between RTCP packets.
|
||||
time_controller_.AdvanceTime(TimeDelta::Seconds(5));
|
||||
|
||||
EXPECT_TRUE(receiver_report_sent);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace voe
|
||||
} // namespace webrtc
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user