Update talk to 50918584.

Together with Stefan's http://review.webrtc.org/1960004/.

R=mallinath@webrtc.org

Review URL: https://webrtc-codereview.appspot.com/2048004

git-svn-id: http://webrtc.googlecode.com/svn/trunk@4556 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
wu@webrtc.org
2013-08-15 23:38:54 +00:00
parent dde7d4c6ed
commit 822fbd8b68
108 changed files with 2926 additions and 4301 deletions

View File

@ -33,6 +33,10 @@ class RtpRtcpAPITest : public ::testing::Test {
configuration.audio = true;
configuration.clock = &fake_clock;
module = RtpRtcp::CreateRtpRtcp(configuration);
rtp_payload_registry_.reset(new RTPPayloadRegistry(
test_id, RTPPayloadStrategy::CreateStrategy(true)));
rtp_receiver_.reset(RtpReceiver::CreateAudioReceiver(
test_id, &fake_clock, NULL, NULL, NULL, rtp_payload_registry_.get()));
}
virtual void TearDown() {
@ -40,6 +44,8 @@ class RtpRtcpAPITest : public ::testing::Test {
}
int test_id;
scoped_ptr<RTPPayloadRegistry> rtp_payload_registry_;
scoped_ptr<RtpReceiver> rtp_receiver_;
RtpRtcp* module;
uint32_t test_ssrc;
uint32_t test_timestamp;
@ -103,9 +109,9 @@ TEST_F(RtpRtcpAPITest, RTCP) {
EXPECT_EQ(0, module->SetTMMBRStatus(false));
EXPECT_FALSE(module->TMMBR());
EXPECT_EQ(kNackOff, module->NACK());
EXPECT_EQ(0, module->SetNACKStatus(kNackRtcp, 450));
EXPECT_EQ(kNackRtcp, module->NACK());
EXPECT_EQ(kNackOff, rtp_receiver_->NACK());
EXPECT_EQ(0, rtp_receiver_->SetNACKStatus(kNackRtcp, 450));
EXPECT_EQ(kNackRtcp, rtp_receiver_->NACK());
}
TEST_F(RtpRtcpAPITest, RTXSender) {
@ -129,7 +135,7 @@ TEST_F(RtpRtcpAPITest, RTXSender) {
EXPECT_EQ(0, module->SetRTXSendStatus(kRtxRetransmitted, false, 1));
EXPECT_EQ(0, module->RTXSendStatus(&rtx_mode, &ssrc, &payload_type));
EXPECT_EQ(kRtxRetransmitted, rtx_mode);
EXPECT_EQ(kRtxPayloadType ,payload_type);
EXPECT_EQ(kRtxPayloadType, payload_type);
}
TEST_F(RtpRtcpAPITest, RTXReceiver) {
@ -137,14 +143,14 @@ TEST_F(RtpRtcpAPITest, RTXReceiver) {
unsigned int ssrc = 0;
const int kRtxPayloadType = 119;
int payload_type = -1;
EXPECT_EQ(0, module->SetRTXReceiveStatus(true, 1));
module->SetRtxReceivePayloadType(kRtxPayloadType);
EXPECT_EQ(0, module->RTXReceiveStatus(&enable, &ssrc, &payload_type));
rtp_receiver_->SetRTXStatus(true, 1);
rtp_receiver_->SetRtxPayloadType(kRtxPayloadType);
rtp_receiver_->RTXStatus(&enable, &ssrc, &payload_type);
EXPECT_TRUE(enable);
EXPECT_EQ(1u, ssrc);
EXPECT_EQ(kRtxPayloadType ,payload_type);
EXPECT_EQ(0, module->SetRTXReceiveStatus(false, 0));
EXPECT_EQ(0, module->RTXReceiveStatus(&enable, &ssrc, &payload_type));
rtp_receiver_->SetRTXStatus(false, 0);
rtp_receiver_->RTXStatus(&enable, &ssrc, &payload_type);
EXPECT_FALSE(enable);
EXPECT_EQ(kRtxPayloadType ,payload_type);
}

View File

@ -10,7 +10,10 @@
#include "testing/gtest/include/gtest/gtest.h"
#include "webrtc/common_types.h"
#include "webrtc/modules/rtp_rtcp/interface/receive_statistics.h"
#include "webrtc/modules/rtp_rtcp/interface/rtp_header_parser.h"
#include "webrtc/modules/rtp_rtcp/interface/rtp_payload_registry.h"
#include "webrtc/modules/rtp_rtcp/interface/rtp_receiver.h"
#include "webrtc/modules/rtp_rtcp/interface/rtp_rtcp.h"
#include "webrtc/modules/rtp_rtcp/interface/rtp_rtcp_defines.h"
#include "webrtc/system_wrappers/interface/scoped_ptr.h"
@ -24,10 +27,18 @@ class LoopBackTransport : public webrtc::Transport {
LoopBackTransport()
: _count(0),
_packetLoss(0),
rtp_payload_registry_(NULL),
rtp_receiver_(NULL),
_rtpRtcpModule(NULL) {
}
void SetSendModule(RtpRtcp* rtpRtcpModule) {
void SetSendModule(RtpRtcp* rtpRtcpModule,
RTPPayloadRegistry* payload_registry,
RtpReceiver* receiver,
ReceiveStatistics* receive_statistics) {
_rtpRtcpModule = rtpRtcpModule;
rtp_payload_registry_ = payload_registry;
rtp_receiver_ = receiver;
receive_statistics_ = receive_statistics;
}
void DropEveryNthPacket(int n) {
_packetLoss = n;
@ -44,8 +55,15 @@ class LoopBackTransport : public webrtc::Transport {
if (!parser->Parse(static_cast<const uint8_t*>(data), len, &header)) {
return -1;
}
if (_rtpRtcpModule->IncomingRtpPacket(static_cast<const uint8_t*>(data),
len, header) < 0) {
PayloadUnion payload_specific;
if (!rtp_payload_registry_->GetPayloadSpecifics(
header.payloadType, &payload_specific)) {
return -1;
}
receive_statistics_->IncomingPacket(header, len, false, true);
if (!rtp_receiver_->IncomingRtpPacket(&header,
static_cast<const uint8_t*>(data),
len, payload_specific, true)) {
return -1;
}
return len;
@ -59,10 +77,13 @@ class LoopBackTransport : public webrtc::Transport {
private:
int _count;
int _packetLoss;
ReceiveStatistics* receive_statistics_;
RTPPayloadRegistry* rtp_payload_registry_;
RtpReceiver* rtp_receiver_;
RtpRtcp* _rtpRtcpModule;
};
class RtpReceiver : public RtpData {
class TestRtpReceiver : public NullRtpData {
public:
virtual int32_t OnReceivedPayloadData(

View File

@ -17,12 +17,13 @@
#include "webrtc/common_types.h"
#include "webrtc/modules/rtp_rtcp/interface/rtp_rtcp.h"
#include "webrtc/modules/rtp_rtcp/interface/rtp_rtcp_defines.h"
#include "webrtc/modules/rtp_rtcp/source/rtp_receiver_audio.h"
using namespace webrtc;
#define test_rate 64000u
class VerifyingAudioReceiver : public RtpData {
class VerifyingAudioReceiver : public NullRtpData {
public:
virtual int32_t OnReceivedPayloadData(
const uint8_t* payloadData,
@ -58,7 +59,7 @@ class VerifyingAudioReceiver : public RtpData {
}
};
class RTPCallback : public RtpFeedback {
class RTPCallback : public NullRtpFeedback {
public:
virtual int32_t OnInitializeDecoder(
const int32_t id,
@ -73,24 +74,9 @@ class RTPCallback : public RtpFeedback {
}
return 0;
}
virtual void OnPacketTimeout(const int32_t id) {
}
virtual void OnReceivedPacket(const int32_t id,
const RtpRtcpPacketType packetType) {
}
virtual void OnPeriodicDeadOrAlive(const int32_t id,
const RTPAliveType alive) {
}
virtual void OnIncomingSSRCChanged(const int32_t id,
const uint32_t SSRC) {
}
virtual void OnIncomingCSRCChanged(const int32_t id,
const uint32_t CSRC,
const bool added) {
}
};
class AudioFeedback : public RtpAudioFeedback {
class AudioFeedback : public NullRtpAudioFeedback {
virtual void OnReceivedTelephoneEvent(const int32_t id,
const uint8_t event,
const bool end) {
@ -110,11 +96,6 @@ class AudioFeedback : public RtpAudioFeedback {
expectedEvent = 32;
}
}
virtual void OnPlayTelephoneEvent(const int32_t id,
const uint8_t event,
const uint16_t lengthMs,
const uint8_t volume) {
};
};
class RtpRtcpAudioTest : public ::testing::Test {
@ -137,26 +118,41 @@ class RtpRtcpAudioTest : public ::testing::Test {
transport1 = new LoopBackTransport();
transport2 = new LoopBackTransport();
receive_statistics1_.reset(ReceiveStatistics::Create(&fake_clock));
receive_statistics2_.reset(ReceiveStatistics::Create(&fake_clock));
rtp_payload_registry1_.reset(new RTPPayloadRegistry(
test_id, RTPPayloadStrategy::CreateStrategy(true)));
rtp_payload_registry2_.reset(new RTPPayloadRegistry(
test_id, RTPPayloadStrategy::CreateStrategy(true)));
RtpRtcp::Configuration configuration;
configuration.id = test_id;
configuration.audio = true;
configuration.clock = &fake_clock;
configuration.incoming_data = data_receiver1;
configuration.receive_statistics = receive_statistics1_.get();
configuration.outgoing_transport = transport1;
configuration.audio_messages = audioFeedback;
module1 = RtpRtcp::CreateRtpRtcp(configuration);
rtp_receiver1_.reset(RtpReceiver::CreateAudioReceiver(
test_id, &fake_clock, audioFeedback, data_receiver1, NULL,
rtp_payload_registry1_.get()));
configuration.id = test_id + 1;
configuration.incoming_data = data_receiver2;
configuration.incoming_messages = rtp_callback;
configuration.receive_statistics = receive_statistics2_.get();
configuration.outgoing_transport = transport2;
configuration.audio_messages = audioFeedback;
module2 = RtpRtcp::CreateRtpRtcp(configuration);
rtp_receiver2_.reset(RtpReceiver::CreateAudioReceiver(
test_id + 1, &fake_clock, audioFeedback, data_receiver2, NULL,
rtp_payload_registry2_.get()));
transport1->SetSendModule(module2);
transport2->SetSendModule(module1);
transport1->SetSendModule(module2, rtp_payload_registry2_.get(),
rtp_receiver2_.get(), receive_statistics2_.get());
transport2->SetSendModule(module1, rtp_payload_registry1_.get(),
rtp_receiver1_.get(), receive_statistics1_.get());
}
virtual void TearDown() {
@ -173,6 +169,12 @@ class RtpRtcpAudioTest : public ::testing::Test {
int test_id;
RtpRtcp* module1;
RtpRtcp* module2;
scoped_ptr<ReceiveStatistics> receive_statistics1_;
scoped_ptr<ReceiveStatistics> receive_statistics2_;
scoped_ptr<RtpReceiver> rtp_receiver1_;
scoped_ptr<RtpReceiver> rtp_receiver2_;
scoped_ptr<RTPPayloadRegistry> rtp_payload_registry1_;
scoped_ptr<RTPPayloadRegistry> rtp_payload_registry2_;
VerifyingAudioReceiver* data_receiver1;
VerifyingAudioReceiver* data_receiver2;
LoopBackTransport* transport1;
@ -191,63 +193,93 @@ TEST_F(RtpRtcpAudioTest, Basic) {
EXPECT_EQ(0, module1->SetStartTimestamp(test_timestamp));
// 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));
// Start basic RTP test.
// Send an empty RTP packet.
// Should fail since we have not registerd the payload type.
// Should fail since we have not registered the payload type.
EXPECT_EQ(-1, module1->SendOutgoingData(webrtc::kAudioFrameSpeech,
96, 0, -1, NULL, 0));
CodecInst voiceCodec;
voiceCodec.pltype = 96;
voiceCodec.plfreq = 8000;
memcpy(voiceCodec.plname, "PCMU", 5);
CodecInst voice_codec;
voice_codec.pltype = 96;
voice_codec.plfreq = 8000;
memcpy(voice_codec.plname, "PCMU", 5);
EXPECT_EQ(0, module1->RegisterSendPayload(voiceCodec));
EXPECT_EQ(0, module1->RegisterReceivePayload(voiceCodec));
EXPECT_EQ(0, module2->RegisterSendPayload(voiceCodec));
voiceCodec.rate = test_rate;
EXPECT_EQ(0, module2->RegisterReceivePayload(voiceCodec));
EXPECT_EQ(0, module1->RegisterSendPayload(voice_codec));
EXPECT_EQ(0, rtp_receiver1_->RegisterReceivePayload(
voice_codec.plname,
voice_codec.pltype,
voice_codec.plfreq,
voice_codec.channels,
(voice_codec.rate < 0) ? 0 : voice_codec.rate));
EXPECT_EQ(0, module2->RegisterSendPayload(voice_codec));
voice_codec.rate = test_rate;
EXPECT_EQ(0, rtp_receiver2_->RegisterReceivePayload(
voice_codec.plname,
voice_codec.pltype,
voice_codec.plfreq,
voice_codec.channels,
(voice_codec.rate < 0) ? 0 : voice_codec.rate));
printf("4\n");
const uint8_t test[5] = "test";
EXPECT_EQ(0, module1->SendOutgoingData(webrtc::kAudioFrameSpeech, 96,
0, -1, test, 4));
EXPECT_EQ(test_ssrc, module2->RemoteSSRC());
EXPECT_EQ(test_timestamp, module2->RemoteTimestamp());
EXPECT_EQ(test_ssrc, rtp_receiver2_->SSRC());
EXPECT_EQ(test_timestamp, rtp_receiver2_->Timestamp());
}
TEST_F(RtpRtcpAudioTest, RED) {
CodecInst voiceCodec;
voiceCodec.pltype = 96;
voiceCodec.plfreq = 8000;
memcpy(voiceCodec.plname, "PCMU", 5);
CodecInst voice_codec;
voice_codec.pltype = 96;
voice_codec.plfreq = 8000;
memcpy(voice_codec.plname, "PCMU", 5);
EXPECT_EQ(0, module1->RegisterSendPayload(voiceCodec));
EXPECT_EQ(0, module1->RegisterReceivePayload(voiceCodec));
EXPECT_EQ(0, module2->RegisterSendPayload(voiceCodec));
voiceCodec.rate = test_rate;
EXPECT_EQ(0, module2->RegisterReceivePayload(voiceCodec));
EXPECT_EQ(0, module1->RegisterSendPayload(voice_codec));
EXPECT_EQ(0, rtp_receiver1_->RegisterReceivePayload(
voice_codec.plname,
voice_codec.pltype,
voice_codec.plfreq,
voice_codec.channels,
(voice_codec.rate < 0) ? 0 : voice_codec.rate));
EXPECT_EQ(0, module2->RegisterSendPayload(voice_codec));
voice_codec.rate = test_rate;
EXPECT_EQ(0, rtp_receiver2_->RegisterReceivePayload(
voice_codec.plname,
voice_codec.pltype,
voice_codec.plfreq,
voice_codec.channels,
(voice_codec.rate < 0) ? 0 : voice_codec.rate));
EXPECT_EQ(0, module1->SetSSRC(test_ssrc));
EXPECT_EQ(0, module1->SetStartTimestamp(test_timestamp));
EXPECT_EQ(0, module1->SetSendingStatus(true));
voiceCodec.pltype = 127;
voiceCodec.plfreq = 8000;
memcpy(voiceCodec.plname, "RED", 4);
voice_codec.pltype = 127;
voice_codec.plfreq = 8000;
memcpy(voice_codec.plname, "RED", 4);
EXPECT_EQ(0, module1->SetSendREDPayloadType(voiceCodec.pltype));
EXPECT_EQ(0, module1->SetSendREDPayloadType(voice_codec.pltype));
int8_t red = 0;
EXPECT_EQ(0, module1->SendREDPayloadType(red));
EXPECT_EQ(voiceCodec.pltype, red);
EXPECT_EQ(0, module1->RegisterReceivePayload(voiceCodec));
EXPECT_EQ(0, module2->RegisterReceivePayload(voiceCodec));
EXPECT_EQ(voice_codec.pltype, red);
EXPECT_EQ(0, rtp_receiver1_->RegisterReceivePayload(
voice_codec.plname,
voice_codec.pltype,
voice_codec.plfreq,
voice_codec.channels,
(voice_codec.rate < 0) ? 0 : voice_codec.rate));
EXPECT_EQ(0, rtp_receiver2_->RegisterReceivePayload(
voice_codec.plname,
voice_codec.pltype,
voice_codec.plfreq,
voice_codec.channels,
(voice_codec.rate < 0) ? 0 : voice_codec.rate));
RTPFragmentationHeader fragmentation;
fragmentation.fragmentationVectorSize = 2;
@ -275,28 +307,43 @@ TEST_F(RtpRtcpAudioTest, RED) {
}
TEST_F(RtpRtcpAudioTest, DTMF) {
CodecInst voiceCodec;
voiceCodec.pltype = 96;
voiceCodec.plfreq = 8000;
memcpy(voiceCodec.plname, "PCMU", 5);
CodecInst voice_codec;
voice_codec.pltype = 96;
voice_codec.plfreq = 8000;
memcpy(voice_codec.plname, "PCMU", 5);
EXPECT_EQ(0, module1->RegisterSendPayload(voiceCodec));
EXPECT_EQ(0, module1->RegisterReceivePayload(voiceCodec));
EXPECT_EQ(0, module2->RegisterSendPayload(voiceCodec));
voiceCodec.rate = test_rate;
EXPECT_EQ(0, module2->RegisterReceivePayload(voiceCodec));
EXPECT_EQ(0, module1->RegisterSendPayload(voice_codec));
EXPECT_EQ(0, rtp_receiver1_->RegisterReceivePayload(
voice_codec.plname,
voice_codec.pltype,
voice_codec.plfreq,
voice_codec.channels,
(voice_codec.rate < 0) ? 0 : voice_codec.rate));
EXPECT_EQ(0, module2->RegisterSendPayload(voice_codec));
voice_codec.rate = test_rate;
EXPECT_EQ(0, rtp_receiver2_->RegisterReceivePayload(
voice_codec.plname,
voice_codec.pltype,
voice_codec.plfreq,
voice_codec.channels,
(voice_codec.rate < 0) ? 0 : voice_codec.rate));
EXPECT_EQ(0, module1->SetSSRC(test_ssrc));
EXPECT_EQ(0, module1->SetStartTimestamp(test_timestamp));
EXPECT_EQ(0, module1->SetSendingStatus(true));
// Prepare for DTMF.
voiceCodec.pltype = 97;
voiceCodec.plfreq = 8000;
memcpy(voiceCodec.plname, "telephone-event", 16);
voice_codec.pltype = 97;
voice_codec.plfreq = 8000;
memcpy(voice_codec.plname, "telephone-event", 16);
EXPECT_EQ(0, module1->RegisterSendPayload(voiceCodec));
EXPECT_EQ(0, module2->RegisterReceivePayload(voiceCodec));
EXPECT_EQ(0, module1->RegisterSendPayload(voice_codec));
EXPECT_EQ(0, rtp_receiver2_->RegisterReceivePayload(
voice_codec.plname,
voice_codec.pltype,
voice_codec.plfreq,
voice_codec.channels,
(voice_codec.rate < 0) ? 0 : voice_codec.rate));
// Start DTMF test.
uint32_t timeStamp = 160;

View File

@ -14,8 +14,10 @@
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "webrtc/common_types.h"
#include "webrtc/modules/rtp_rtcp/interface/receive_statistics.h"
#include "webrtc/modules/rtp_rtcp/interface/rtp_rtcp.h"
#include "webrtc/modules/rtp_rtcp/interface/rtp_rtcp_defines.h"
#include "webrtc/modules/rtp_rtcp/source/rtp_receiver_audio.h"
#include "webrtc/modules/rtp_rtcp/test/testAPI/test_api.h"
using namespace webrtc;
@ -68,6 +70,20 @@ class RtcpCallback : public RtcpFeedback, public RtcpIntraFrameObserver {
RtpRtcp* _rtpRtcpModule;
};
class TestRtpFeedback : public NullRtpFeedback {
public:
TestRtpFeedback(RtpRtcp* rtp_rtcp) : rtp_rtcp_(rtp_rtcp) {}
virtual ~TestRtpFeedback() {}
virtual void OnIncomingSSRCChanged(const int32_t id,
const uint32_t SSRC) {
rtp_rtcp_->SetRemoteSSRC(SSRC);
}
private:
RtpRtcp* rtp_rtcp_;
};
class RtpRtcpRtcpTest : public ::testing::Test {
protected:
RtpRtcpRtcpTest() : fake_clock(123456) {
@ -81,31 +97,55 @@ class RtpRtcpRtcpTest : public ::testing::Test {
~RtpRtcpRtcpTest() {}
virtual void SetUp() {
receiver = new RtpReceiver();
receiver = new TestRtpReceiver();
transport1 = new LoopBackTransport();
transport2 = new LoopBackTransport();
myRTCPFeedback1 = new RtcpCallback();
myRTCPFeedback2 = new RtcpCallback();
receive_statistics1_.reset(ReceiveStatistics::Create(&fake_clock));
receive_statistics2_.reset(ReceiveStatistics::Create(&fake_clock));
RtpRtcp::Configuration configuration;
configuration.id = test_id;
configuration.audio = true;
configuration.clock = &fake_clock;
configuration.receive_statistics = receive_statistics1_.get();
configuration.outgoing_transport = transport1;
configuration.rtcp_feedback = myRTCPFeedback1;
configuration.intra_frame_callback = myRTCPFeedback1;
configuration.incoming_data = receiver;
rtp_payload_registry1_.reset(new RTPPayloadRegistry(
test_id, RTPPayloadStrategy::CreateStrategy(true)));
rtp_payload_registry2_.reset(new RTPPayloadRegistry(
test_id, RTPPayloadStrategy::CreateStrategy(true)));
module1 = RtpRtcp::CreateRtpRtcp(configuration);
rtp_feedback1_.reset(new TestRtpFeedback(module1));
rtp_receiver1_.reset(RtpReceiver::CreateAudioReceiver(
test_id, &fake_clock, NULL, receiver, rtp_feedback1_.get(),
rtp_payload_registry1_.get()));
configuration.receive_statistics = receive_statistics2_.get();
configuration.id = test_id + 1;
configuration.outgoing_transport = transport2;
configuration.rtcp_feedback = myRTCPFeedback2;
configuration.intra_frame_callback = myRTCPFeedback2;
module2 = RtpRtcp::CreateRtpRtcp(configuration);
transport1->SetSendModule(module2);
transport2->SetSendModule(module1);
rtp_feedback2_.reset(new TestRtpFeedback(module2));
rtp_receiver2_.reset(RtpReceiver::CreateAudioReceiver(
test_id + 1, &fake_clock, NULL, receiver, rtp_feedback2_.get(),
rtp_payload_registry2_.get()));
transport1->SetSendModule(module2, rtp_payload_registry2_.get(),
rtp_receiver2_.get(), receive_statistics2_.get());
transport2->SetSendModule(module1, rtp_payload_registry1_.get(),
rtp_receiver1_.get(), receive_statistics1_.get());
myRTCPFeedback1->SetModule(module1);
myRTCPFeedback2->SetModule(module2);
@ -121,16 +161,26 @@ class RtpRtcpRtcpTest : public ::testing::Test {
EXPECT_EQ(0, module1->SetSendingStatus(true));
CodecInst voiceCodec;
voiceCodec.pltype = 96;
voiceCodec.plfreq = 8000;
voiceCodec.rate = 64000;
memcpy(voiceCodec.plname, "PCMU", 5);
CodecInst voice_codec;
voice_codec.pltype = 96;
voice_codec.plfreq = 8000;
voice_codec.rate = 64000;
memcpy(voice_codec.plname, "PCMU", 5);
EXPECT_EQ(0, module1->RegisterSendPayload(voiceCodec));
EXPECT_EQ(0, module1->RegisterReceivePayload(voiceCodec));
EXPECT_EQ(0, module2->RegisterSendPayload(voiceCodec));
EXPECT_EQ(0, module2->RegisterReceivePayload(voiceCodec));
EXPECT_EQ(0, module1->RegisterSendPayload(voice_codec));
EXPECT_EQ(0, rtp_receiver1_->RegisterReceivePayload(
voice_codec.plname,
voice_codec.pltype,
voice_codec.plfreq,
voice_codec.channels,
(voice_codec.rate < 0) ? 0 : voice_codec.rate));
EXPECT_EQ(0, module2->RegisterSendPayload(voice_codec));
EXPECT_EQ(0, rtp_receiver2_->RegisterReceivePayload(
voice_codec.plname,
voice_codec.pltype,
voice_codec.plfreq,
voice_codec.channels,
(voice_codec.rate < 0) ? 0 : voice_codec.rate));
// We need to send one RTP packet to get the RTCP packet to be accepted by
// the receiving module.
@ -151,9 +201,17 @@ class RtpRtcpRtcpTest : public ::testing::Test {
}
int test_id;
scoped_ptr<TestRtpFeedback> rtp_feedback1_;
scoped_ptr<TestRtpFeedback> rtp_feedback2_;
scoped_ptr<ReceiveStatistics> receive_statistics1_;
scoped_ptr<ReceiveStatistics> receive_statistics2_;
scoped_ptr<RTPPayloadRegistry> rtp_payload_registry1_;
scoped_ptr<RTPPayloadRegistry> rtp_payload_registry2_;
scoped_ptr<RtpReceiver> rtp_receiver1_;
scoped_ptr<RtpReceiver> rtp_receiver2_;
RtpRtcp* module1;
RtpRtcp* module2;
RtpReceiver* receiver;
TestRtpReceiver* receiver;
LoopBackTransport* transport1;
LoopBackTransport* transport2;
RtcpCallback* myRTCPFeedback1;
@ -173,7 +231,7 @@ TEST_F(RtpRtcpRtcpTest, RTCP_PLI_RPSI) {
TEST_F(RtpRtcpRtcpTest, RTCP_CNAME) {
uint32_t testOfCSRC[webrtc::kRtpCsrcSize];
EXPECT_EQ(2, module2->RemoteCSRCs(testOfCSRC));
EXPECT_EQ(2, rtp_receiver2_->CSRCs(testOfCSRC));
EXPECT_EQ(test_CSRC[0], testOfCSRC[0]);
EXPECT_EQ(test_CSRC[1], testOfCSRC[1]);
@ -192,10 +250,10 @@ TEST_F(RtpRtcpRtcpTest, RTCP_CNAME) {
module2->Process();
char cName[RTCP_CNAME_SIZE];
EXPECT_EQ(-1, module2->RemoteCNAME(module2->RemoteSSRC() + 1, cName));
EXPECT_EQ(-1, module2->RemoteCNAME(rtp_receiver2_->SSRC() + 1, cName));
// Check multiple CNAME.
EXPECT_EQ(0, module2->RemoteCNAME(module2->RemoteSSRC(), 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, module2->RemoteCNAME(test_CSRC[0], cName));
@ -207,7 +265,7 @@ TEST_F(RtpRtcpRtcpTest, RTCP_CNAME) {
EXPECT_EQ(0, module1->SetSendingStatus(false));
// Test that BYE clears the CNAME
EXPECT_EQ(-1, module2->RemoteCNAME(module2->RemoteSSRC(), cName));
EXPECT_EQ(-1, module2->RemoteCNAME(rtp_receiver2_->SSRC(), cName));
}
TEST_F(RtpRtcpRtcpTest, RTCP) {
@ -276,20 +334,12 @@ TEST_F(RtpRtcpRtcpTest, RTCP) {
EXPECT_EQ(static_cast<uint32_t>(0),
reportBlockReceived.cumulativeLost);
uint8_t fraction_lost = 0; // scale 0 to 255
uint32_t cum_lost = 0; // number of lost packets
uint32_t ext_max = 0; // highest sequence number received
uint32_t jitter = 0;
uint32_t max_jitter = 0;
EXPECT_EQ(0, module2->StatisticsRTP(&fraction_lost,
&cum_lost,
&ext_max,
&jitter,
&max_jitter));
EXPECT_EQ(0, fraction_lost);
EXPECT_EQ((uint32_t)0, cum_lost);
EXPECT_EQ(test_sequence_number, ext_max);
EXPECT_EQ(reportBlockReceived.jitter, jitter);
ReceiveStatistics::RtpReceiveStatistics stats;
EXPECT_TRUE(receive_statistics2_->Statistics(&stats, true));
EXPECT_EQ(0, stats.fraction_lost);
EXPECT_EQ((uint32_t)0, stats.cumulative_lost);
EXPECT_EQ(test_sequence_number, stats.extended_max_sequence_number);
EXPECT_EQ(reportBlockReceived.jitter, stats.jitter);
uint16_t RTT;
uint16_t avgRTT;

View File

@ -15,6 +15,7 @@
#include "testing/gtest/include/gtest/gtest.h"
#include "webrtc/common_types.h"
#include "webrtc/modules/rtp_rtcp/interface/rtp_payload_registry.h"
#include "webrtc/modules/rtp_rtcp/interface/rtp_rtcp.h"
#include "webrtc/modules/rtp_rtcp/interface/rtp_rtcp_defines.h"
#include "webrtc/modules/rtp_rtcp/source/rtp_receiver_video.h"
@ -27,6 +28,7 @@ class RtpRtcpVideoTest : public ::testing::Test {
protected:
RtpRtcpVideoTest()
: test_id_(123),
rtp_payload_registry_(0, RTPPayloadStrategy::CreateStrategy(false)),
test_ssrc_(3456),
test_timestamp_(4567),
test_sequence_number_(2345),
@ -36,23 +38,26 @@ class RtpRtcpVideoTest : public ::testing::Test {
virtual void SetUp() {
transport_ = new LoopBackTransport();
receiver_ = new RtpReceiver();
receiver_ = new TestRtpReceiver();
receive_statistics_.reset(ReceiveStatistics::Create(&fake_clock));
RtpRtcp::Configuration configuration;
configuration.id = test_id_;
configuration.audio = false;
configuration.clock = &fake_clock;
configuration.incoming_data = receiver_;
configuration.outgoing_transport = transport_;
video_module_ = RtpRtcp::CreateRtpRtcp(configuration);
rtp_receiver_.reset(RtpReceiver::CreateVideoReceiver(
test_id_, &fake_clock, receiver_, NULL, &rtp_payload_registry_));
EXPECT_EQ(0, video_module_->SetRTCPStatus(kRtcpCompound));
EXPECT_EQ(0, video_module_->SetSSRC(test_ssrc_));
EXPECT_EQ(0, video_module_->SetNACKStatus(kNackRtcp, 450));
EXPECT_EQ(0, rtp_receiver_->SetNACKStatus(kNackRtcp, 450));
EXPECT_EQ(0, video_module_->SetStorePacketsStatus(true, 600));
EXPECT_EQ(0, video_module_->SetSendingStatus(true));
transport_->SetSendModule(video_module_);
transport_->SetSendModule(video_module_, &rtp_payload_registry_,
rtp_receiver_.get(), receive_statistics_.get());
VideoCodec video_codec;
memset(&video_codec, 0, sizeof(video_codec));
@ -60,7 +65,11 @@ class RtpRtcpVideoTest : public ::testing::Test {
memcpy(video_codec.plName, "I420", 5);
EXPECT_EQ(0, video_module_->RegisterSendPayload(video_codec));
EXPECT_EQ(0, video_module_->RegisterReceivePayload(video_codec));
EXPECT_EQ(0, rtp_receiver_->RegisterReceivePayload(video_codec.plName,
video_codec.plType,
90000,
0,
video_codec.maxBitrate));
payload_data_length_ = sizeof(video_frame_);
@ -118,9 +127,12 @@ class RtpRtcpVideoTest : public ::testing::Test {
}
int test_id_;
scoped_ptr<ReceiveStatistics> receive_statistics_;
RTPPayloadRegistry rtp_payload_registry_;
scoped_ptr<RtpReceiver> rtp_receiver_;
RtpRtcp* video_module_;
LoopBackTransport* transport_;
RtpReceiver* receiver_;
TestRtpReceiver* receiver_;
uint32_t test_ssrc_;
uint32_t test_timestamp_;
uint16_t test_sequence_number_;
@ -148,7 +160,11 @@ TEST_F(RtpRtcpVideoTest, PaddingOnlyFrames) {
codec.codecType = kVideoCodecVP8;
codec.plType = kPayloadType;
strncpy(codec.plName, "VP8", 4);
EXPECT_EQ(0, video_module_->RegisterReceivePayload(codec));
EXPECT_EQ(0, rtp_receiver_->RegisterReceivePayload(codec.plName,
codec.plType,
90000,
0,
codec.maxBitrate));
for (int frame_idx = 0; frame_idx < 10; ++frame_idx) {
for (int packet_idx = 0; packet_idx < 5; ++packet_idx) {
int packet_size = PaddingPacket(padding_packet, timestamp, seq_num,
@ -157,8 +173,12 @@ TEST_F(RtpRtcpVideoTest, PaddingOnlyFrames) {
RTPHeader header;
scoped_ptr<RtpHeaderParser> parser(RtpHeaderParser::Create());
EXPECT_TRUE(parser->Parse(padding_packet, packet_size, &header));
EXPECT_EQ(0, video_module_->IncomingRtpPacket(padding_packet,
packet_size, header));
PayloadUnion payload_specific;
EXPECT_TRUE(rtp_payload_registry_.GetPayloadSpecifics(header.payloadType,
&payload_specific));
EXPECT_TRUE(rtp_receiver_->IncomingRtpPacket(&header, padding_packet,
packet_size,
payload_specific, true));
EXPECT_EQ(0, receiver_->payload_size());
EXPECT_EQ(packet_size - 12, receiver_->rtp_header().header.paddingLength);
}