Change some pointers to std::unique_ptr in rtp_rtcp tests.
Bug: none Change-Id: Ia4e69e44bbda7b5b633b8be1779d105649f44930 Reviewed-on: https://webrtc-review.googlesource.com/94844 Commit-Queue: Åsa Persson <asapersson@webrtc.org> Reviewed-by: Rasmus Brandt <brandtr@webrtc.org> Cr-Commit-Position: refs/heads/master@{#24419}
This commit is contained in:
parent
e89dda7cb9
commit
a765c8208a
@ -13,7 +13,6 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
#include "rtc_base/checks.h"
|
#include "rtc_base/checks.h"
|
||||||
#include "rtc_base/rate_limiter.h"
|
#include "rtc_base/rate_limiter.h"
|
||||||
@ -96,10 +95,10 @@ class RtpRtcpAPITest : public ::testing::Test {
|
|||||||
module_->SetSSRC(kInitialSsrc);
|
module_->SetSSRC(kInitialSsrc);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<RtpRtcp> module_;
|
|
||||||
SimulatedClock fake_clock_;
|
SimulatedClock fake_clock_;
|
||||||
test::NullTransport null_transport_;
|
test::NullTransport null_transport_;
|
||||||
RateLimiter retransmission_rate_limiter_;
|
RateLimiter retransmission_rate_limiter_;
|
||||||
|
std::unique_ptr<RtpRtcp> module_;
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_F(RtpRtcpAPITest, Basic) {
|
TEST_F(RtpRtcpAPITest, Basic) {
|
||||||
|
|||||||
@ -88,78 +88,79 @@ class VerifyingAudioReceiver : public RtpData {
|
|||||||
class RtpRtcpAudioTest : public ::testing::Test {
|
class RtpRtcpAudioTest : public ::testing::Test {
|
||||||
protected:
|
protected:
|
||||||
RtpRtcpAudioTest()
|
RtpRtcpAudioTest()
|
||||||
: fake_clock_(123456), retransmission_rate_limiter_(&fake_clock_, 1000) {}
|
: fake_clock_(123456),
|
||||||
~RtpRtcpAudioTest() override = default;
|
retransmission_rate_limiter_(&fake_clock_, 1000),
|
||||||
|
receive_statistics1_(ReceiveStatistics::Create(&fake_clock_)),
|
||||||
void SetUp() override {
|
receive_statistics2_(ReceiveStatistics::Create(&fake_clock_)),
|
||||||
receive_statistics1_.reset(ReceiveStatistics::Create(&fake_clock_));
|
rtp_receiver1_(
|
||||||
receive_statistics2_.reset(ReceiveStatistics::Create(&fake_clock_));
|
RtpReceiver::CreateAudioReceiver(&fake_clock_,
|
||||||
|
&data_receiver1_,
|
||||||
|
&rtp_payload_registry1_)),
|
||||||
|
rtp_receiver2_(
|
||||||
|
RtpReceiver::CreateAudioReceiver(&fake_clock_,
|
||||||
|
&data_receiver2_,
|
||||||
|
&rtp_payload_registry2_)) {
|
||||||
RtpRtcp::Configuration configuration;
|
RtpRtcp::Configuration configuration;
|
||||||
configuration.audio = true;
|
configuration.audio = true;
|
||||||
configuration.clock = &fake_clock_;
|
configuration.clock = &fake_clock_;
|
||||||
configuration.receive_statistics = receive_statistics1_.get();
|
configuration.receive_statistics = receive_statistics1_.get();
|
||||||
configuration.outgoing_transport = &transport1;
|
configuration.outgoing_transport = &transport1_;
|
||||||
configuration.retransmission_rate_limiter = &retransmission_rate_limiter_;
|
configuration.retransmission_rate_limiter = &retransmission_rate_limiter_;
|
||||||
|
module1_.reset(RtpRtcp::CreateRtpRtcp(configuration));
|
||||||
module1.reset(RtpRtcp::CreateRtpRtcp(configuration));
|
|
||||||
rtp_receiver1_.reset(RtpReceiver::CreateAudioReceiver(
|
|
||||||
&fake_clock_, &data_receiver1, &rtp_payload_registry1_));
|
|
||||||
|
|
||||||
configuration.receive_statistics = receive_statistics2_.get();
|
configuration.receive_statistics = receive_statistics2_.get();
|
||||||
configuration.outgoing_transport = &transport2;
|
configuration.outgoing_transport = &transport2_;
|
||||||
|
module2_.reset(RtpRtcp::CreateRtpRtcp(configuration));
|
||||||
|
|
||||||
module2.reset(RtpRtcp::CreateRtpRtcp(configuration));
|
transport1_.SetSendModule(module2_.get(), &rtp_payload_registry2_,
|
||||||
rtp_receiver2_.reset(RtpReceiver::CreateAudioReceiver(
|
rtp_receiver2_.get(), receive_statistics2_.get());
|
||||||
&fake_clock_, &data_receiver2, &rtp_payload_registry2_));
|
transport2_.SetSendModule(module1_.get(), &rtp_payload_registry1_,
|
||||||
|
rtp_receiver1_.get(), receive_statistics1_.get());
|
||||||
transport1.SetSendModule(module2.get(), &rtp_payload_registry2_,
|
|
||||||
rtp_receiver2_.get(), receive_statistics2_.get());
|
|
||||||
transport2.SetSendModule(module1.get(), &rtp_payload_registry1_,
|
|
||||||
rtp_receiver1_.get(), receive_statistics1_.get());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
~RtpRtcpAudioTest() override = default;
|
||||||
|
|
||||||
void RegisterPayload(const CodecInst& codec) {
|
void RegisterPayload(const CodecInst& codec) {
|
||||||
EXPECT_EQ(0, module1->RegisterSendPayload(codec));
|
EXPECT_EQ(0, module1_->RegisterSendPayload(codec));
|
||||||
EXPECT_EQ(0, rtp_receiver1_->RegisterReceivePayload(codec.pltype,
|
EXPECT_EQ(0, rtp_receiver1_->RegisterReceivePayload(codec.pltype,
|
||||||
CodecInstToSdp(codec)));
|
CodecInstToSdp(codec)));
|
||||||
EXPECT_EQ(0, module2->RegisterSendPayload(codec));
|
EXPECT_EQ(0, module2_->RegisterSendPayload(codec));
|
||||||
EXPECT_EQ(0, rtp_receiver2_->RegisterReceivePayload(codec.pltype,
|
EXPECT_EQ(0, rtp_receiver2_->RegisterReceivePayload(codec.pltype,
|
||||||
CodecInstToSdp(codec)));
|
CodecInstToSdp(codec)));
|
||||||
}
|
}
|
||||||
|
|
||||||
VerifyingAudioReceiver data_receiver1;
|
SimulatedClock fake_clock_;
|
||||||
VerifyingAudioReceiver data_receiver2;
|
RateLimiter retransmission_rate_limiter_;
|
||||||
|
VerifyingAudioReceiver data_receiver1_;
|
||||||
|
VerifyingAudioReceiver data_receiver2_;
|
||||||
std::unique_ptr<ReceiveStatistics> receive_statistics1_;
|
std::unique_ptr<ReceiveStatistics> receive_statistics1_;
|
||||||
std::unique_ptr<ReceiveStatistics> receive_statistics2_;
|
std::unique_ptr<ReceiveStatistics> receive_statistics2_;
|
||||||
RTPPayloadRegistry rtp_payload_registry1_;
|
RTPPayloadRegistry rtp_payload_registry1_;
|
||||||
RTPPayloadRegistry rtp_payload_registry2_;
|
RTPPayloadRegistry rtp_payload_registry2_;
|
||||||
std::unique_ptr<RtpReceiver> rtp_receiver1_;
|
std::unique_ptr<RtpReceiver> rtp_receiver1_;
|
||||||
std::unique_ptr<RtpReceiver> rtp_receiver2_;
|
std::unique_ptr<RtpReceiver> rtp_receiver2_;
|
||||||
std::unique_ptr<RtpRtcp> module1;
|
std::unique_ptr<RtpRtcp> module1_;
|
||||||
std::unique_ptr<RtpRtcp> module2;
|
std::unique_ptr<RtpRtcp> module2_;
|
||||||
LoopBackTransport transport1;
|
LoopBackTransport transport1_;
|
||||||
LoopBackTransport transport2;
|
LoopBackTransport transport2_;
|
||||||
SimulatedClock fake_clock_;
|
|
||||||
RateLimiter retransmission_rate_limiter_;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_F(RtpRtcpAudioTest, Basic) {
|
TEST_F(RtpRtcpAudioTest, Basic) {
|
||||||
module1->SetSSRC(kSsrc);
|
module1_->SetSSRC(kSsrc);
|
||||||
module1->SetStartTimestamp(kTimestamp);
|
module1_->SetStartTimestamp(kTimestamp);
|
||||||
|
|
||||||
// Test detection at the end of a DTMF tone.
|
// Test detection at the end of a DTMF tone.
|
||||||
// EXPECT_EQ(0, module2->SetTelephoneEventForwardToDecoder(true));
|
// EXPECT_EQ(0, module2_->SetTelephoneEventForwardToDecoder(true));
|
||||||
|
|
||||||
EXPECT_EQ(0, module1->SetSendingStatus(true));
|
EXPECT_EQ(0, module1_->SetSendingStatus(true));
|
||||||
|
|
||||||
// Start basic RTP test.
|
// Start basic RTP test.
|
||||||
|
|
||||||
// Send an empty RTP packet.
|
// Send an empty RTP packet.
|
||||||
// Should fail since we have not registered the payload type.
|
// Should fail since we have not registered the payload type.
|
||||||
EXPECT_FALSE(module1->SendOutgoingData(webrtc::kAudioFrameSpeech,
|
EXPECT_FALSE(module1_->SendOutgoingData(webrtc::kAudioFrameSpeech,
|
||||||
kPcmuPayloadType, 0, -1, nullptr, 0,
|
kPcmuPayloadType, 0, -1, nullptr, 0,
|
||||||
nullptr, nullptr, nullptr));
|
nullptr, nullptr, nullptr));
|
||||||
|
|
||||||
CodecInst voice_codec = {};
|
CodecInst voice_codec = {};
|
||||||
voice_codec.pltype = kPcmuPayloadType;
|
voice_codec.pltype = kPcmuPayloadType;
|
||||||
@ -168,9 +169,9 @@ TEST_F(RtpRtcpAudioTest, Basic) {
|
|||||||
memcpy(voice_codec.plname, "PCMU", 5);
|
memcpy(voice_codec.plname, "PCMU", 5);
|
||||||
RegisterPayload(voice_codec);
|
RegisterPayload(voice_codec);
|
||||||
|
|
||||||
EXPECT_TRUE(module1->SendOutgoingData(webrtc::kAudioFrameSpeech,
|
EXPECT_TRUE(module1_->SendOutgoingData(webrtc::kAudioFrameSpeech,
|
||||||
kPcmuPayloadType, 0, -1, kTestPayload,
|
kPcmuPayloadType, 0, -1, kTestPayload,
|
||||||
4, nullptr, nullptr, nullptr));
|
4, nullptr, nullptr, nullptr));
|
||||||
|
|
||||||
EXPECT_EQ(kSsrc, rtp_receiver2_->SSRC());
|
EXPECT_EQ(kSsrc, rtp_receiver2_->SSRC());
|
||||||
uint32_t timestamp;
|
uint32_t timestamp;
|
||||||
@ -189,16 +190,16 @@ TEST_F(RtpRtcpAudioTest, DTMF) {
|
|||||||
memcpy(voice_codec.plname, "PCMU", 5);
|
memcpy(voice_codec.plname, "PCMU", 5);
|
||||||
RegisterPayload(voice_codec);
|
RegisterPayload(voice_codec);
|
||||||
|
|
||||||
module1->SetSSRC(kSsrc);
|
module1_->SetSSRC(kSsrc);
|
||||||
module1->SetStartTimestamp(kTimestamp);
|
module1_->SetStartTimestamp(kTimestamp);
|
||||||
EXPECT_EQ(0, module1->SetSendingStatus(true));
|
EXPECT_EQ(0, module1_->SetSendingStatus(true));
|
||||||
|
|
||||||
// Prepare for DTMF.
|
// Prepare for DTMF.
|
||||||
voice_codec.pltype = kDtmfPayloadType;
|
voice_codec.pltype = kDtmfPayloadType;
|
||||||
voice_codec.plfreq = 8000;
|
voice_codec.plfreq = 8000;
|
||||||
memcpy(voice_codec.plname, "telephone-event", 16);
|
memcpy(voice_codec.plname, "telephone-event", 16);
|
||||||
|
|
||||||
EXPECT_EQ(0, module1->RegisterSendPayload(voice_codec));
|
EXPECT_EQ(0, module1_->RegisterSendPayload(voice_codec));
|
||||||
EXPECT_EQ(0, rtp_receiver2_->RegisterReceivePayload(
|
EXPECT_EQ(0, rtp_receiver2_->RegisterReceivePayload(
|
||||||
voice_codec.pltype, CodecInstToSdp(voice_codec)));
|
voice_codec.pltype, CodecInstToSdp(voice_codec)));
|
||||||
|
|
||||||
@ -207,37 +208,37 @@ TEST_F(RtpRtcpAudioTest, DTMF) {
|
|||||||
|
|
||||||
// Send a DTMF tone using RFC 2833 (4733).
|
// Send a DTMF tone using RFC 2833 (4733).
|
||||||
for (int i = 0; i < 16; i++) {
|
for (int i = 0; i < 16; i++) {
|
||||||
EXPECT_EQ(0, module1->SendTelephoneEventOutband(i, timeStamp, 10));
|
EXPECT_EQ(0, module1_->SendTelephoneEventOutband(i, timeStamp, 10));
|
||||||
}
|
}
|
||||||
timeStamp += 160; // Prepare for next packet.
|
timeStamp += 160; // Prepare for next packet.
|
||||||
|
|
||||||
// Send RTP packets for 16 tones a 160 ms 100ms
|
// Send RTP packets for 16 tones a 160 ms 100ms
|
||||||
// pause between = 2560ms + 1600ms = 4160ms
|
// pause between = 2560ms + 1600ms = 4160ms
|
||||||
for (; timeStamp <= 250 * 160; timeStamp += 160) {
|
for (; timeStamp <= 250 * 160; timeStamp += 160) {
|
||||||
EXPECT_TRUE(module1->SendOutgoingData(
|
EXPECT_TRUE(module1_->SendOutgoingData(
|
||||||
webrtc::kAudioFrameSpeech, kPcmuPayloadType, timeStamp, -1,
|
webrtc::kAudioFrameSpeech, kPcmuPayloadType, timeStamp, -1,
|
||||||
kTestPayload, 4, nullptr, nullptr, nullptr));
|
kTestPayload, 4, nullptr, nullptr, nullptr));
|
||||||
fake_clock_.AdvanceTimeMilliseconds(20);
|
fake_clock_.AdvanceTimeMilliseconds(20);
|
||||||
module1->Process();
|
module1_->Process();
|
||||||
}
|
}
|
||||||
EXPECT_EQ(0, module1->SendTelephoneEventOutband(32, 9000, 10));
|
EXPECT_EQ(0, module1_->SendTelephoneEventOutband(32, 9000, 10));
|
||||||
|
|
||||||
for (; timeStamp <= 740 * 160; timeStamp += 160) {
|
for (; timeStamp <= 740 * 160; timeStamp += 160) {
|
||||||
EXPECT_TRUE(module1->SendOutgoingData(
|
EXPECT_TRUE(module1_->SendOutgoingData(
|
||||||
webrtc::kAudioFrameSpeech, kPcmuPayloadType, timeStamp, -1,
|
webrtc::kAudioFrameSpeech, kPcmuPayloadType, timeStamp, -1,
|
||||||
kTestPayload, 4, nullptr, nullptr, nullptr));
|
kTestPayload, 4, nullptr, nullptr, nullptr));
|
||||||
fake_clock_.AdvanceTimeMilliseconds(20);
|
fake_clock_.AdvanceTimeMilliseconds(20);
|
||||||
module1->Process();
|
module1_->Process();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(RtpRtcpAudioTest, ComfortNoise) {
|
TEST_F(RtpRtcpAudioTest, ComfortNoise) {
|
||||||
module1->SetSSRC(kSsrc);
|
module1_->SetSSRC(kSsrc);
|
||||||
module1->SetStartTimestamp(kTimestamp);
|
module1_->SetStartTimestamp(kTimestamp);
|
||||||
|
|
||||||
EXPECT_EQ(0, module1->SetSendingStatus(true));
|
EXPECT_EQ(0, module1_->SetSendingStatus(true));
|
||||||
|
|
||||||
// Register PCMU and all four comfort noise codecs
|
// Register PCMU and all four comfort noise codecs.
|
||||||
CodecInst voice_codec = {};
|
CodecInst voice_codec = {};
|
||||||
voice_codec.pltype = kPcmuPayloadType;
|
voice_codec.pltype = kPcmuPayloadType;
|
||||||
voice_codec.plfreq = 8000;
|
voice_codec.plfreq = 8000;
|
||||||
@ -258,7 +259,7 @@ TEST_F(RtpRtcpAudioTest, ComfortNoise) {
|
|||||||
for (const auto& c : kCngCodecs) {
|
for (const auto& c : kCngCodecs) {
|
||||||
uint32_t timestamp;
|
uint32_t timestamp;
|
||||||
int64_t receive_time_ms;
|
int64_t receive_time_ms;
|
||||||
EXPECT_TRUE(module1->SendOutgoingData(
|
EXPECT_TRUE(module1_->SendOutgoingData(
|
||||||
webrtc::kAudioFrameSpeech, kPcmuPayloadType, in_timestamp, -1,
|
webrtc::kAudioFrameSpeech, kPcmuPayloadType, in_timestamp, -1,
|
||||||
kTestPayload, 4, nullptr, nullptr, nullptr));
|
kTestPayload, 4, nullptr, nullptr, nullptr));
|
||||||
|
|
||||||
@ -270,9 +271,9 @@ TEST_F(RtpRtcpAudioTest, ComfortNoise) {
|
|||||||
in_timestamp += 10;
|
in_timestamp += 10;
|
||||||
fake_clock_.AdvanceTimeMilliseconds(20);
|
fake_clock_.AdvanceTimeMilliseconds(20);
|
||||||
|
|
||||||
EXPECT_TRUE(module1->SendOutgoingData(webrtc::kAudioFrameCN, c.payload_type,
|
EXPECT_TRUE(module1_->SendOutgoingData(
|
||||||
in_timestamp, -1, kTestPayload, 1,
|
webrtc::kAudioFrameCN, c.payload_type, in_timestamp, -1, kTestPayload,
|
||||||
nullptr, nullptr, nullptr));
|
1, nullptr, nullptr, nullptr));
|
||||||
|
|
||||||
EXPECT_EQ(kSsrc, rtp_receiver2_->SSRC());
|
EXPECT_EQ(kSsrc, rtp_receiver2_->SSRC());
|
||||||
EXPECT_TRUE(
|
EXPECT_TRUE(
|
||||||
|
|||||||
@ -20,7 +20,6 @@
|
|||||||
#include "modules/rtp_rtcp/source/rtp_receiver_audio.h"
|
#include "modules/rtp_rtcp/source/rtp_receiver_audio.h"
|
||||||
#include "modules/rtp_rtcp/test/testAPI/test_api.h"
|
#include "modules/rtp_rtcp/test/testAPI/test_api.h"
|
||||||
#include "rtc_base/rate_limiter.h"
|
#include "rtc_base/rate_limiter.h"
|
||||||
#include "test/gmock.h"
|
|
||||||
#include "test/gtest.h"
|
#include "test/gtest.h"
|
||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
@ -37,57 +36,53 @@ class RtcpCallback : public RtcpIntraFrameObserver {
|
|||||||
class RtpRtcpRtcpTest : public ::testing::Test {
|
class RtpRtcpRtcpTest : public ::testing::Test {
|
||||||
protected:
|
protected:
|
||||||
RtpRtcpRtcpTest()
|
RtpRtcpRtcpTest()
|
||||||
: fake_clock_(123456), retransmission_rate_limiter_(&fake_clock_, 1000) {}
|
: fake_clock_(123456),
|
||||||
|
retransmission_rate_limiter_(&fake_clock_, 1000),
|
||||||
|
receive_statistics1_(ReceiveStatistics::Create(&fake_clock_)),
|
||||||
|
receive_statistics2_(ReceiveStatistics::Create(&fake_clock_)),
|
||||||
|
rtp_receiver1_(
|
||||||
|
RtpReceiver::CreateAudioReceiver(&fake_clock_,
|
||||||
|
&receiver_,
|
||||||
|
&rtp_payload_registry1_)),
|
||||||
|
rtp_receiver2_(
|
||||||
|
RtpReceiver::CreateAudioReceiver(&fake_clock_,
|
||||||
|
&receiver_,
|
||||||
|
&rtp_payload_registry2_)) {}
|
||||||
~RtpRtcpRtcpTest() override = default;
|
~RtpRtcpRtcpTest() override = default;
|
||||||
|
|
||||||
void SetUp() override {
|
void SetUp() override {
|
||||||
receiver = new TestRtpReceiver();
|
|
||||||
transport1 = new LoopBackTransport();
|
|
||||||
transport2 = new LoopBackTransport();
|
|
||||||
|
|
||||||
receive_statistics1_.reset(ReceiveStatistics::Create(&fake_clock_));
|
|
||||||
receive_statistics2_.reset(ReceiveStatistics::Create(&fake_clock_));
|
|
||||||
|
|
||||||
RtpRtcp::Configuration configuration;
|
RtpRtcp::Configuration configuration;
|
||||||
configuration.audio = true;
|
configuration.audio = true;
|
||||||
configuration.clock = &fake_clock_;
|
configuration.clock = &fake_clock_;
|
||||||
configuration.receive_statistics = receive_statistics1_.get();
|
configuration.receive_statistics = receive_statistics1_.get();
|
||||||
configuration.outgoing_transport = transport1;
|
configuration.outgoing_transport = &transport1_;
|
||||||
configuration.intra_frame_callback = &rtcp_callback1_;
|
configuration.intra_frame_callback = &rtcp_callback1_;
|
||||||
configuration.retransmission_rate_limiter = &retransmission_rate_limiter_;
|
configuration.retransmission_rate_limiter = &retransmission_rate_limiter_;
|
||||||
|
module1_.reset(RtpRtcp::CreateRtpRtcp(configuration));
|
||||||
module1 = RtpRtcp::CreateRtpRtcp(configuration);
|
|
||||||
|
|
||||||
rtp_receiver1_.reset(RtpReceiver::CreateAudioReceiver(
|
|
||||||
&fake_clock_, receiver, &rtp_payload_registry1_));
|
|
||||||
|
|
||||||
configuration.receive_statistics = receive_statistics2_.get();
|
configuration.receive_statistics = receive_statistics2_.get();
|
||||||
configuration.outgoing_transport = transport2;
|
configuration.outgoing_transport = &transport2_;
|
||||||
configuration.intra_frame_callback = &rtcp_callback2_;
|
configuration.intra_frame_callback = &rtcp_callback2_;
|
||||||
|
module2_.reset(RtpRtcp::CreateRtpRtcp(configuration));
|
||||||
|
|
||||||
module2 = RtpRtcp::CreateRtpRtcp(configuration);
|
transport1_.SetSendModule(module2_.get(), &rtp_payload_registry2_,
|
||||||
|
|
||||||
rtp_receiver2_.reset(RtpReceiver::CreateAudioReceiver(
|
|
||||||
&fake_clock_, receiver, &rtp_payload_registry2_));
|
|
||||||
|
|
||||||
transport1->SetSendModule(module2, &rtp_payload_registry2_,
|
|
||||||
rtp_receiver2_.get(), receive_statistics2_.get());
|
rtp_receiver2_.get(), receive_statistics2_.get());
|
||||||
transport2->SetSendModule(module1, &rtp_payload_registry1_,
|
transport2_.SetSendModule(module1_.get(), &rtp_payload_registry1_,
|
||||||
rtp_receiver1_.get(), receive_statistics1_.get());
|
rtp_receiver1_.get(), receive_statistics1_.get());
|
||||||
|
|
||||||
module1->SetRTCPStatus(RtcpMode::kCompound);
|
module1_->SetRTCPStatus(RtcpMode::kCompound);
|
||||||
module2->SetRTCPStatus(RtcpMode::kCompound);
|
module2_->SetRTCPStatus(RtcpMode::kCompound);
|
||||||
|
|
||||||
module2->SetSSRC(kSsrc + 1);
|
module2_->SetSSRC(kSsrc + 1);
|
||||||
module2->SetRemoteSSRC(kSsrc);
|
module2_->SetRemoteSSRC(kSsrc);
|
||||||
module1->SetSSRC(kSsrc);
|
module1_->SetSSRC(kSsrc);
|
||||||
module1->SetSequenceNumber(kSequenceNumber);
|
module1_->SetSequenceNumber(kSequenceNumber);
|
||||||
module1->SetStartTimestamp(kTimestamp);
|
module1_->SetStartTimestamp(kTimestamp);
|
||||||
|
|
||||||
module1->SetCsrcs(kCsrcs);
|
module1_->SetCsrcs(kCsrcs);
|
||||||
EXPECT_EQ(0, module1->SetCNAME("john.doe@test.test"));
|
EXPECT_EQ(0, module1_->SetCNAME("john.doe@test.test"));
|
||||||
|
|
||||||
EXPECT_EQ(0, module1->SetSendingStatus(true));
|
EXPECT_EQ(0, module1_->SetSendingStatus(true));
|
||||||
|
|
||||||
CodecInst voice_codec;
|
CodecInst voice_codec;
|
||||||
voice_codec.pltype = 96;
|
voice_codec.pltype = 96;
|
||||||
@ -95,10 +90,10 @@ class RtpRtcpRtcpTest : public ::testing::Test {
|
|||||||
voice_codec.rate = 64000;
|
voice_codec.rate = 64000;
|
||||||
memcpy(voice_codec.plname, "PCMU", 5);
|
memcpy(voice_codec.plname, "PCMU", 5);
|
||||||
|
|
||||||
EXPECT_EQ(0, module1->RegisterSendPayload(voice_codec));
|
EXPECT_EQ(0, module1_->RegisterSendPayload(voice_codec));
|
||||||
EXPECT_EQ(0, rtp_receiver1_->RegisterReceivePayload(
|
EXPECT_EQ(0, rtp_receiver1_->RegisterReceivePayload(
|
||||||
voice_codec.pltype, CodecInstToSdp(voice_codec)));
|
voice_codec.pltype, CodecInstToSdp(voice_codec)));
|
||||||
EXPECT_EQ(0, module2->RegisterSendPayload(voice_codec));
|
EXPECT_EQ(0, module2_->RegisterSendPayload(voice_codec));
|
||||||
EXPECT_EQ(0, rtp_receiver2_->RegisterReceivePayload(
|
EXPECT_EQ(0, rtp_receiver2_->RegisterReceivePayload(
|
||||||
voice_codec.pltype, CodecInstToSdp(voice_codec)));
|
voice_codec.pltype, CodecInstToSdp(voice_codec)));
|
||||||
|
|
||||||
@ -107,84 +102,74 @@ class RtpRtcpRtcpTest : public ::testing::Test {
|
|||||||
// Send RTP packet with the data "testtest".
|
// Send RTP packet with the data "testtest".
|
||||||
const uint8_t test[9] = "testtest";
|
const uint8_t test[9] = "testtest";
|
||||||
EXPECT_EQ(true,
|
EXPECT_EQ(true,
|
||||||
module1->SendOutgoingData(webrtc::kAudioFrameSpeech, 96, 0, -1,
|
module1_->SendOutgoingData(webrtc::kAudioFrameSpeech, 96, 0, -1,
|
||||||
test, 8, nullptr, nullptr, nullptr));
|
test, 8, nullptr, nullptr, nullptr));
|
||||||
}
|
}
|
||||||
|
|
||||||
void TearDown() override {
|
|
||||||
delete module1;
|
|
||||||
delete module2;
|
|
||||||
delete transport1;
|
|
||||||
delete transport2;
|
|
||||||
delete receiver;
|
|
||||||
}
|
|
||||||
|
|
||||||
RtcpCallback rtcp_callback1_;
|
|
||||||
RtcpCallback rtcp_callback2_;
|
|
||||||
RTPPayloadRegistry rtp_payload_registry1_;
|
|
||||||
RTPPayloadRegistry rtp_payload_registry2_;
|
|
||||||
std::unique_ptr<ReceiveStatistics> receive_statistics1_;
|
|
||||||
std::unique_ptr<ReceiveStatistics> receive_statistics2_;
|
|
||||||
std::unique_ptr<RtpReceiver> rtp_receiver1_;
|
|
||||||
std::unique_ptr<RtpReceiver> rtp_receiver2_;
|
|
||||||
RtpRtcp* module1;
|
|
||||||
RtpRtcp* module2;
|
|
||||||
TestRtpReceiver* receiver;
|
|
||||||
LoopBackTransport* transport1;
|
|
||||||
LoopBackTransport* transport2;
|
|
||||||
|
|
||||||
const std::vector<uint32_t> kCsrcs = {1234, 2345};
|
const std::vector<uint32_t> kCsrcs = {1234, 2345};
|
||||||
SimulatedClock fake_clock_;
|
SimulatedClock fake_clock_;
|
||||||
RateLimiter retransmission_rate_limiter_;
|
RateLimiter retransmission_rate_limiter_;
|
||||||
|
RtcpCallback rtcp_callback1_;
|
||||||
|
RtcpCallback rtcp_callback2_;
|
||||||
|
RTPPayloadRegistry rtp_payload_registry1_;
|
||||||
|
RTPPayloadRegistry rtp_payload_registry2_;
|
||||||
|
TestRtpReceiver receiver_;
|
||||||
|
std::unique_ptr<ReceiveStatistics> receive_statistics1_;
|
||||||
|
std::unique_ptr<ReceiveStatistics> receive_statistics2_;
|
||||||
|
std::unique_ptr<RtpReceiver> rtp_receiver1_;
|
||||||
|
std::unique_ptr<RtpReceiver> rtp_receiver2_;
|
||||||
|
std::unique_ptr<RtpRtcp> module1_;
|
||||||
|
std::unique_ptr<RtpRtcp> module2_;
|
||||||
|
LoopBackTransport transport1_;
|
||||||
|
LoopBackTransport transport2_;
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_F(RtpRtcpRtcpTest, RTCP_CNAME) {
|
TEST_F(RtpRtcpRtcpTest, RTCP_CNAME) {
|
||||||
// Set cname of mixed.
|
// Set cname of mixed.
|
||||||
EXPECT_EQ(0, module1->AddMixedCNAME(kCsrcs[0], "john@192.168.0.1"));
|
EXPECT_EQ(0, module1_->AddMixedCNAME(kCsrcs[0], "john@192.168.0.1"));
|
||||||
EXPECT_EQ(0, module1->AddMixedCNAME(kCsrcs[1], "jane@192.168.0.2"));
|
EXPECT_EQ(0, module1_->AddMixedCNAME(kCsrcs[1], "jane@192.168.0.2"));
|
||||||
|
|
||||||
EXPECT_EQ(-1, module1->RemoveMixedCNAME(kCsrcs[0] + 1));
|
EXPECT_EQ(-1, module1_->RemoveMixedCNAME(kCsrcs[0] + 1));
|
||||||
EXPECT_EQ(0, module1->RemoveMixedCNAME(kCsrcs[1]));
|
EXPECT_EQ(0, module1_->RemoveMixedCNAME(kCsrcs[1]));
|
||||||
EXPECT_EQ(0, module1->AddMixedCNAME(kCsrcs[1], "jane@192.168.0.2"));
|
EXPECT_EQ(0, module1_->AddMixedCNAME(kCsrcs[1], "jane@192.168.0.2"));
|
||||||
|
|
||||||
// Send RTCP packet, triggered by timer.
|
// Send RTCP packet, triggered by timer.
|
||||||
fake_clock_.AdvanceTimeMilliseconds(7500);
|
fake_clock_.AdvanceTimeMilliseconds(7500);
|
||||||
module1->Process();
|
module1_->Process();
|
||||||
fake_clock_.AdvanceTimeMilliseconds(100);
|
fake_clock_.AdvanceTimeMilliseconds(100);
|
||||||
module2->Process();
|
module2_->Process();
|
||||||
|
|
||||||
char cName[RTCP_CNAME_SIZE];
|
char cName[RTCP_CNAME_SIZE];
|
||||||
EXPECT_EQ(-1, module2->RemoteCNAME(rtp_receiver2_->SSRC() + 1, cName));
|
EXPECT_EQ(-1, module2_->RemoteCNAME(rtp_receiver2_->SSRC() + 1, cName));
|
||||||
|
|
||||||
// Check multiple CNAME.
|
// Check multiple CNAME.
|
||||||
EXPECT_EQ(0, module2->RemoteCNAME(rtp_receiver2_->SSRC(), cName));
|
EXPECT_EQ(0, module2_->RemoteCNAME(rtp_receiver2_->SSRC(), cName));
|
||||||
EXPECT_EQ(0, strncmp(cName, "john.doe@test.test", RTCP_CNAME_SIZE));
|
EXPECT_EQ(0, strncmp(cName, "john.doe@test.test", RTCP_CNAME_SIZE));
|
||||||
|
|
||||||
EXPECT_EQ(0, module2->RemoteCNAME(kCsrcs[0], cName));
|
EXPECT_EQ(0, module2_->RemoteCNAME(kCsrcs[0], cName));
|
||||||
EXPECT_EQ(0, strncmp(cName, "john@192.168.0.1", RTCP_CNAME_SIZE));
|
EXPECT_EQ(0, strncmp(cName, "john@192.168.0.1", RTCP_CNAME_SIZE));
|
||||||
|
|
||||||
EXPECT_EQ(0, module2->RemoteCNAME(kCsrcs[1], cName));
|
EXPECT_EQ(0, module2_->RemoteCNAME(kCsrcs[1], cName));
|
||||||
EXPECT_EQ(0, strncmp(cName, "jane@192.168.0.2", RTCP_CNAME_SIZE));
|
EXPECT_EQ(0, strncmp(cName, "jane@192.168.0.2", RTCP_CNAME_SIZE));
|
||||||
|
|
||||||
EXPECT_EQ(0, module1->SetSendingStatus(false));
|
EXPECT_EQ(0, module1_->SetSendingStatus(false));
|
||||||
|
|
||||||
// Test that BYE clears the CNAME.
|
// Test that BYE clears the CNAME.
|
||||||
EXPECT_EQ(-1, module2->RemoteCNAME(rtp_receiver2_->SSRC(), cName));
|
EXPECT_EQ(-1, module2_->RemoteCNAME(rtp_receiver2_->SSRC(), cName));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(RtpRtcpRtcpTest, RemoteRTCPStatRemote) {
|
TEST_F(RtpRtcpRtcpTest, RemoteRTCPStatRemote) {
|
||||||
std::vector<RTCPReportBlock> report_blocks;
|
std::vector<RTCPReportBlock> report_blocks;
|
||||||
|
EXPECT_EQ(0, module1_->RemoteRTCPStat(&report_blocks));
|
||||||
EXPECT_EQ(0, module1->RemoteRTCPStat(&report_blocks));
|
|
||||||
EXPECT_EQ(0u, report_blocks.size());
|
EXPECT_EQ(0u, report_blocks.size());
|
||||||
|
|
||||||
// Send RTCP packet, triggered by timer.
|
// Send RTCP packet, triggered by timer.
|
||||||
fake_clock_.AdvanceTimeMilliseconds(7500);
|
fake_clock_.AdvanceTimeMilliseconds(7500);
|
||||||
module1->Process();
|
module1_->Process();
|
||||||
fake_clock_.AdvanceTimeMilliseconds(100);
|
fake_clock_.AdvanceTimeMilliseconds(100);
|
||||||
module2->Process();
|
module2_->Process();
|
||||||
|
|
||||||
EXPECT_EQ(0, module1->RemoteRTCPStat(&report_blocks));
|
EXPECT_EQ(0, module1_->RemoteRTCPStat(&report_blocks));
|
||||||
ASSERT_EQ(1u, report_blocks.size());
|
ASSERT_EQ(1u, report_blocks.size());
|
||||||
|
|
||||||
// |kSsrc+1| is the SSRC of module2 that send the report.
|
// |kSsrc+1| is the SSRC of module2 that send the report.
|
||||||
|
|||||||
@ -33,30 +33,30 @@ namespace webrtc {
|
|||||||
class RtpRtcpVideoTest : public ::testing::Test {
|
class RtpRtcpVideoTest : public ::testing::Test {
|
||||||
protected:
|
protected:
|
||||||
RtpRtcpVideoTest()
|
RtpRtcpVideoTest()
|
||||||
: fake_clock_(123456), retransmission_rate_limiter_(&fake_clock_, 1000) {}
|
: fake_clock_(123456),
|
||||||
|
retransmission_rate_limiter_(&fake_clock_, 1000),
|
||||||
|
receive_statistics_(ReceiveStatistics::Create(&fake_clock_)),
|
||||||
|
rtp_receiver_(
|
||||||
|
RtpReceiver::CreateVideoReceiver(&fake_clock_,
|
||||||
|
&receiver_,
|
||||||
|
&rtp_payload_registry_)) {}
|
||||||
~RtpRtcpVideoTest() override = default;
|
~RtpRtcpVideoTest() override = default;
|
||||||
|
|
||||||
void SetUp() override {
|
void SetUp() override {
|
||||||
transport_ = new LoopBackTransport();
|
|
||||||
receiver_ = new TestRtpReceiver();
|
|
||||||
receive_statistics_.reset(ReceiveStatistics::Create(&fake_clock_));
|
|
||||||
RtpRtcp::Configuration configuration;
|
RtpRtcp::Configuration configuration;
|
||||||
configuration.audio = false;
|
configuration.audio = false;
|
||||||
configuration.clock = &fake_clock_;
|
configuration.clock = &fake_clock_;
|
||||||
configuration.outgoing_transport = transport_;
|
configuration.outgoing_transport = &transport_;
|
||||||
configuration.retransmission_rate_limiter = &retransmission_rate_limiter_;
|
configuration.retransmission_rate_limiter = &retransmission_rate_limiter_;
|
||||||
|
video_module_.reset(RtpRtcp::CreateRtpRtcp(configuration));
|
||||||
video_module_ = RtpRtcp::CreateRtpRtcp(configuration);
|
|
||||||
rtp_receiver_.reset(RtpReceiver::CreateVideoReceiver(
|
|
||||||
&fake_clock_, receiver_, &rtp_payload_registry_));
|
|
||||||
|
|
||||||
video_module_->SetRTCPStatus(RtcpMode::kCompound);
|
video_module_->SetRTCPStatus(RtcpMode::kCompound);
|
||||||
video_module_->SetSSRC(kSsrc);
|
video_module_->SetSSRC(kSsrc);
|
||||||
video_module_->SetStorePacketsStatus(true, 600);
|
video_module_->SetStorePacketsStatus(true, 600);
|
||||||
EXPECT_EQ(0, video_module_->SetSendingStatus(true));
|
EXPECT_EQ(0, video_module_->SetSendingStatus(true));
|
||||||
|
|
||||||
transport_->SetSendModule(video_module_, &rtp_payload_registry_,
|
transport_.SetSendModule(video_module_.get(), &rtp_payload_registry_,
|
||||||
rtp_receiver_.get(), receive_statistics_.get());
|
rtp_receiver_.get(), receive_statistics_.get());
|
||||||
|
|
||||||
VideoCodec video_codec;
|
VideoCodec video_codec;
|
||||||
memset(&video_codec, 0, sizeof(video_codec));
|
memset(&video_codec, 0, sizeof(video_codec));
|
||||||
@ -111,22 +111,16 @@ class RtpRtcpVideoTest : public ::testing::Test {
|
|||||||
return padding_bytes_in_packet + header_length;
|
return padding_bytes_in_packet + header_length;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TearDown() override {
|
|
||||||
delete video_module_;
|
|
||||||
delete transport_;
|
|
||||||
delete receiver_;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::unique_ptr<ReceiveStatistics> receive_statistics_;
|
|
||||||
RTPPayloadRegistry rtp_payload_registry_;
|
|
||||||
std::unique_ptr<RtpReceiver> rtp_receiver_;
|
|
||||||
RtpRtcp* video_module_;
|
|
||||||
LoopBackTransport* transport_;
|
|
||||||
TestRtpReceiver* receiver_;
|
|
||||||
uint8_t video_frame_[65000];
|
uint8_t video_frame_[65000];
|
||||||
size_t payload_data_length_;
|
size_t payload_data_length_;
|
||||||
SimulatedClock fake_clock_;
|
SimulatedClock fake_clock_;
|
||||||
RateLimiter retransmission_rate_limiter_;
|
RateLimiter retransmission_rate_limiter_;
|
||||||
|
std::unique_ptr<ReceiveStatistics> receive_statistics_;
|
||||||
|
RTPPayloadRegistry rtp_payload_registry_;
|
||||||
|
TestRtpReceiver receiver_;
|
||||||
|
std::unique_ptr<RtpReceiver> rtp_receiver_;
|
||||||
|
std::unique_ptr<RtpRtcp> video_module_;
|
||||||
|
LoopBackTransport transport_;
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_F(RtpRtcpVideoTest, BasicVideo) {
|
TEST_F(RtpRtcpVideoTest, BasicVideo) {
|
||||||
@ -161,8 +155,8 @@ TEST_F(RtpRtcpVideoTest, PaddingOnlyFrames) {
|
|||||||
const size_t payload_length = packet_size - header.headerLength;
|
const size_t payload_length = packet_size - header.headerLength;
|
||||||
EXPECT_TRUE(rtp_receiver_->IncomingRtpPacket(
|
EXPECT_TRUE(rtp_receiver_->IncomingRtpPacket(
|
||||||
header, payload, payload_length, pl->typeSpecific));
|
header, payload, payload_length, pl->typeSpecific));
|
||||||
EXPECT_EQ(0u, receiver_->payload_size());
|
EXPECT_EQ(0u, receiver_.payload_size());
|
||||||
EXPECT_EQ(payload_length, receiver_->rtp_header().header.paddingLength);
|
EXPECT_EQ(payload_length, receiver_.rtp_header().header.paddingLength);
|
||||||
}
|
}
|
||||||
timestamp += 3000;
|
timestamp += 3000;
|
||||||
fake_clock_.AdvanceTimeMilliseconds(33);
|
fake_clock_.AdvanceTimeMilliseconds(33);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user