2012-01-10 14:09:18 +00:00
|
|
|
/*
|
2012-02-29 16:09:51 +00:00
|
|
|
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
|
2012-01-10 14:09:18 +00:00
|
|
|
*
|
|
|
|
|
* Use of this source code is governed by a BSD-style license
|
|
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
|
|
|
|
* in the file PATENTS. All contributing project authors may
|
|
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
|
|
|
*/
|
|
|
|
|
|
2013-03-15 23:21:52 +00:00
|
|
|
#include "webrtc/modules/rtp_rtcp/test/testAPI/test_api.h"
|
|
|
|
|
|
2012-01-10 14:09:18 +00:00
|
|
|
#include <algorithm>
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
|
|
using namespace webrtc;
|
|
|
|
|
|
|
|
|
|
class RtpRtcpAPITest : public ::testing::Test {
|
|
|
|
|
protected:
|
2013-01-21 07:42:11 +00:00
|
|
|
RtpRtcpAPITest() : module(NULL), fake_clock(123456) {
|
2014-11-24 08:25:50 +00:00
|
|
|
test_csrcs.push_back(1234);
|
|
|
|
|
test_csrcs.push_back(2345);
|
2012-01-10 14:09:18 +00:00
|
|
|
test_id = 123;
|
|
|
|
|
test_ssrc = 3456;
|
|
|
|
|
test_timestamp = 4567;
|
|
|
|
|
test_sequence_number = 2345;
|
|
|
|
|
}
|
|
|
|
|
~RtpRtcpAPITest() {}
|
|
|
|
|
|
|
|
|
|
virtual void SetUp() {
|
2012-05-11 11:08:54 +00:00
|
|
|
RtpRtcp::Configuration configuration;
|
|
|
|
|
configuration.id = test_id;
|
|
|
|
|
configuration.audio = true;
|
|
|
|
|
configuration.clock = &fake_clock;
|
|
|
|
|
module = RtpRtcp::CreateRtpRtcp(configuration);
|
2013-08-15 23:38:54 +00:00
|
|
|
rtp_payload_registry_.reset(new RTPPayloadRegistry(
|
2014-04-08 11:06:12 +00:00
|
|
|
RTPPayloadStrategy::CreateStrategy(true)));
|
2013-08-15 23:38:54 +00:00
|
|
|
rtp_receiver_.reset(RtpReceiver::CreateAudioReceiver(
|
|
|
|
|
test_id, &fake_clock, NULL, NULL, NULL, rtp_payload_registry_.get()));
|
2012-01-10 14:09:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
virtual void TearDown() {
|
2012-05-11 11:08:54 +00:00
|
|
|
delete module;
|
2012-01-10 14:09:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int test_id;
|
2013-08-15 23:38:54 +00:00
|
|
|
scoped_ptr<RTPPayloadRegistry> rtp_payload_registry_;
|
|
|
|
|
scoped_ptr<RtpReceiver> rtp_receiver_;
|
2012-01-10 14:09:18 +00:00
|
|
|
RtpRtcp* module;
|
2013-04-08 11:08:41 +00:00
|
|
|
uint32_t test_ssrc;
|
|
|
|
|
uint32_t test_timestamp;
|
|
|
|
|
uint16_t test_sequence_number;
|
2014-11-24 08:25:50 +00:00
|
|
|
std::vector<uint32_t> test_csrcs;
|
2013-01-21 07:42:11 +00:00
|
|
|
SimulatedClock fake_clock;
|
2012-01-10 14:09:18 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
TEST_F(RtpRtcpAPITest, Basic) {
|
2014-12-19 13:49:55 +00:00
|
|
|
module->SetSequenceNumber(test_sequence_number);
|
2012-01-10 14:09:18 +00:00
|
|
|
EXPECT_EQ(test_sequence_number, module->SequenceNumber());
|
|
|
|
|
|
2014-12-19 13:49:55 +00:00
|
|
|
module->SetStartTimestamp(test_timestamp);
|
2012-01-10 14:09:18 +00:00
|
|
|
EXPECT_EQ(test_timestamp, module->StartTimestamp());
|
|
|
|
|
|
2012-01-26 14:49:28 +00:00
|
|
|
EXPECT_FALSE(module->Sending());
|
2012-01-10 14:09:18 +00:00
|
|
|
EXPECT_EQ(0, module->SetSendingStatus(true));
|
2012-01-26 14:49:28 +00:00
|
|
|
EXPECT_TRUE(module->Sending());
|
2012-01-10 14:09:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(RtpRtcpAPITest, MTU) {
|
|
|
|
|
EXPECT_EQ(-1, module->SetMaxTransferUnit(10));
|
|
|
|
|
EXPECT_EQ(-1, module->SetMaxTransferUnit(IP_PACKET_SIZE + 1));
|
|
|
|
|
EXPECT_EQ(0, module->SetMaxTransferUnit(1234));
|
|
|
|
|
EXPECT_EQ(1234-20-8, module->MaxPayloadLength());
|
|
|
|
|
|
|
|
|
|
EXPECT_EQ(0, module->SetTransportOverhead(true, true, 12));
|
|
|
|
|
EXPECT_EQ(1234 - 20- 20 -20 - 12, module->MaxPayloadLength());
|
|
|
|
|
|
|
|
|
|
EXPECT_EQ(0, module->SetTransportOverhead(false, false, 0));
|
|
|
|
|
EXPECT_EQ(1234 - 20 - 8, module->MaxPayloadLength());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(RtpRtcpAPITest, SSRC) {
|
2014-06-05 08:25:29 +00:00
|
|
|
module->SetSSRC(test_ssrc);
|
2012-01-10 14:09:18 +00:00
|
|
|
EXPECT_EQ(test_ssrc, module->SSRC());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(RtpRtcpAPITest, RTCP) {
|
|
|
|
|
EXPECT_EQ(kRtcpOff, module->RTCP());
|
2014-12-19 13:49:55 +00:00
|
|
|
module->SetRTCPStatus(kRtcpCompound);
|
2012-01-10 14:09:18 +00:00
|
|
|
EXPECT_EQ(kRtcpCompound, module->RTCP());
|
|
|
|
|
|
|
|
|
|
EXPECT_EQ(0, module->SetCNAME("john.doe@test.test"));
|
|
|
|
|
|
2012-01-26 14:49:28 +00:00
|
|
|
EXPECT_FALSE(module->TMMBR());
|
2014-12-19 13:49:55 +00:00
|
|
|
module->SetTMMBRStatus(true);
|
2012-01-26 14:49:28 +00:00
|
|
|
EXPECT_TRUE(module->TMMBR());
|
2014-12-19 13:49:55 +00:00
|
|
|
module->SetTMMBRStatus(false);
|
2012-01-26 14:49:28 +00:00
|
|
|
EXPECT_FALSE(module->TMMBR());
|
2012-01-10 14:09:18 +00:00
|
|
|
|
2013-08-15 23:38:54 +00:00
|
|
|
EXPECT_EQ(kNackOff, rtp_receiver_->NACK());
|
2013-09-06 13:40:11 +00:00
|
|
|
rtp_receiver_->SetNACKStatus(kNackRtcp);
|
2013-08-15 23:38:54 +00:00
|
|
|
EXPECT_EQ(kNackRtcp, rtp_receiver_->NACK());
|
2012-01-10 14:09:18 +00:00
|
|
|
}
|
2013-03-15 23:21:52 +00:00
|
|
|
|
2013-09-06 13:40:11 +00:00
|
|
|
TEST_F(RtpRtcpAPITest, RtxSender) {
|
2015-01-13 14:15:15 +00:00
|
|
|
module->SetRtxSendStatus(kRtxRetransmitted);
|
|
|
|
|
int rtx_mode = module->RtxSendStatus();
|
2013-03-15 23:21:52 +00:00
|
|
|
EXPECT_EQ(kRtxRetransmitted, rtx_mode);
|
2015-01-13 14:15:15 +00:00
|
|
|
|
|
|
|
|
module->SetRtxSendStatus(kRtxOff);
|
|
|
|
|
rtx_mode = module->RtxSendStatus();
|
2013-03-15 23:21:52 +00:00
|
|
|
EXPECT_EQ(kRtxOff, rtx_mode);
|
2015-01-13 14:15:15 +00:00
|
|
|
|
|
|
|
|
module->SetRtxSendStatus(kRtxRetransmitted);
|
|
|
|
|
rtx_mode = module->RtxSendStatus();
|
2013-04-12 14:55:46 +00:00
|
|
|
EXPECT_EQ(kRtxRetransmitted, rtx_mode);
|
2013-03-15 23:21:52 +00:00
|
|
|
}
|
|
|
|
|
|
2013-09-06 13:40:11 +00:00
|
|
|
TEST_F(RtpRtcpAPITest, RtxReceiver) {
|
|
|
|
|
const uint32_t kRtxSsrc = 1;
|
2013-04-12 14:55:46 +00:00
|
|
|
const int kRtxPayloadType = 119;
|
2014-06-05 08:25:29 +00:00
|
|
|
EXPECT_FALSE(rtp_payload_registry_->RtxEnabled());
|
|
|
|
|
rtp_payload_registry_->SetRtxSsrc(kRtxSsrc);
|
2015-01-09 20:22:46 +00:00
|
|
|
rtp_payload_registry_->SetRtxPayloadType(kRtxPayloadType);
|
2013-09-06 13:40:11 +00:00
|
|
|
EXPECT_TRUE(rtp_payload_registry_->RtxEnabled());
|
|
|
|
|
RTPHeader rtx_header;
|
|
|
|
|
rtx_header.ssrc = kRtxSsrc;
|
|
|
|
|
rtx_header.payloadType = kRtxPayloadType;
|
|
|
|
|
EXPECT_TRUE(rtp_payload_registry_->IsRtx(rtx_header));
|
|
|
|
|
rtx_header.ssrc = 0;
|
|
|
|
|
EXPECT_FALSE(rtp_payload_registry_->IsRtx(rtx_header));
|
|
|
|
|
rtx_header.ssrc = kRtxSsrc;
|
2014-06-05 08:25:29 +00:00
|
|
|
rtx_header.payloadType = 0;
|
|
|
|
|
EXPECT_TRUE(rtp_payload_registry_->IsRtx(rtx_header));
|
2013-03-15 23:21:52 +00:00
|
|
|
}
|