Index: webrtc/modules/rtp_rtcp/source/rtcp_packet_unittest.cc |
diff --git a/webrtc/modules/rtp_rtcp/source/rtcp_packet_unittest.cc b/webrtc/modules/rtp_rtcp/source/rtcp_packet_unittest.cc |
index 6b4ef902a167d1260c075563c4b3a7739fb604b5..1b5d4f32a62f41793da137647b0736270798b997 100644 |
--- a/webrtc/modules/rtp_rtcp/source/rtcp_packet_unittest.cc |
+++ b/webrtc/modules/rtp_rtcp/source/rtcp_packet_unittest.cc |
@@ -14,142 +14,14 @@ |
#include "testing/gtest/include/gtest/gtest.h" |
#include "webrtc/modules/rtp_rtcp/source/rtcp_packet.h" |
-#include "webrtc/modules/rtp_rtcp/source/rtcp_packet/app.h" |
-#include "webrtc/modules/rtp_rtcp/source/rtcp_packet/bye.h" |
#include "webrtc/modules/rtp_rtcp/source/rtcp_packet/receiver_report.h" |
-#include "webrtc/test/rtcp_packet_parser.h" |
-using ::testing::ElementsAre; |
- |
-using webrtc::rtcp::App; |
-using webrtc::rtcp::Bye; |
-using webrtc::rtcp::RawPacket; |
using webrtc::rtcp::ReceiverReport; |
using webrtc::rtcp::ReportBlock; |
-using webrtc::rtcp::SenderReport; |
-using webrtc::test::RtcpPacketParser; |
namespace webrtc { |
const uint32_t kSenderSsrc = 0x12345678; |
-const uint32_t kRemoteSsrc = 0x23456789; |
- |
-TEST(RtcpPacketTest, Sr) { |
- SenderReport sr; |
- sr.From(kSenderSsrc); |
- sr.WithNtpSec(0x11111111); |
- sr.WithNtpFrac(0x22222222); |
- sr.WithRtpTimestamp(0x33333333); |
- sr.WithPacketCount(0x44444444); |
- sr.WithOctetCount(0x55555555); |
- |
- rtc::scoped_ptr<RawPacket> packet(sr.Build()); |
- RtcpPacketParser parser; |
- parser.Parse(packet->Buffer(), packet->Length()); |
- |
- EXPECT_EQ(1, parser.sender_report()->num_packets()); |
- EXPECT_EQ(kSenderSsrc, parser.sender_report()->Ssrc()); |
- EXPECT_EQ(0x11111111U, parser.sender_report()->NtpSec()); |
- EXPECT_EQ(0x22222222U, parser.sender_report()->NtpFrac()); |
- EXPECT_EQ(0x33333333U, parser.sender_report()->RtpTimestamp()); |
- EXPECT_EQ(0x44444444U, parser.sender_report()->PacketCount()); |
- EXPECT_EQ(0x55555555U, parser.sender_report()->OctetCount()); |
- EXPECT_EQ(0, parser.report_block()->num_packets()); |
-} |
- |
-TEST(RtcpPacketTest, SrWithOneReportBlock) { |
- ReportBlock rb; |
- rb.To(kRemoteSsrc); |
- |
- SenderReport sr; |
- sr.From(kSenderSsrc); |
- EXPECT_TRUE(sr.WithReportBlock(rb)); |
- |
- rtc::scoped_ptr<RawPacket> packet(sr.Build()); |
- RtcpPacketParser parser; |
- parser.Parse(packet->Buffer(), packet->Length()); |
- EXPECT_EQ(1, parser.sender_report()->num_packets()); |
- EXPECT_EQ(kSenderSsrc, parser.sender_report()->Ssrc()); |
- EXPECT_EQ(1, parser.report_block()->num_packets()); |
- EXPECT_EQ(kRemoteSsrc, parser.report_block()->Ssrc()); |
-} |
- |
-TEST(RtcpPacketTest, SrWithTwoReportBlocks) { |
- ReportBlock rb1; |
- rb1.To(kRemoteSsrc); |
- ReportBlock rb2; |
- rb2.To(kRemoteSsrc + 1); |
- |
- SenderReport sr; |
- sr.From(kSenderSsrc); |
- EXPECT_TRUE(sr.WithReportBlock(rb1)); |
- EXPECT_TRUE(sr.WithReportBlock(rb2)); |
- |
- rtc::scoped_ptr<RawPacket> packet(sr.Build()); |
- RtcpPacketParser parser; |
- parser.Parse(packet->Buffer(), packet->Length()); |
- EXPECT_EQ(1, parser.sender_report()->num_packets()); |
- EXPECT_EQ(kSenderSsrc, parser.sender_report()->Ssrc()); |
- EXPECT_EQ(2, parser.report_block()->num_packets()); |
- EXPECT_EQ(1, parser.report_blocks_per_ssrc(kRemoteSsrc)); |
- EXPECT_EQ(1, parser.report_blocks_per_ssrc(kRemoteSsrc + 1)); |
-} |
- |
-TEST(RtcpPacketTest, SrWithTooManyReportBlocks) { |
- SenderReport sr; |
- sr.From(kSenderSsrc); |
- const int kMaxReportBlocks = (1 << 5) - 1; |
- ReportBlock rb; |
- for (int i = 0; i < kMaxReportBlocks; ++i) { |
- rb.To(kRemoteSsrc + i); |
- EXPECT_TRUE(sr.WithReportBlock(rb)); |
- } |
- rb.To(kRemoteSsrc + kMaxReportBlocks); |
- EXPECT_FALSE(sr.WithReportBlock(rb)); |
-} |
- |
-TEST(RtcpPacketTest, AppWithNoData) { |
- App app; |
- app.WithSubType(30); |
- uint32_t name = 'n' << 24; |
- name += 'a' << 16; |
- name += 'm' << 8; |
- name += 'e'; |
- app.WithName(name); |
- |
- rtc::scoped_ptr<RawPacket> packet(app.Build()); |
- RtcpPacketParser parser; |
- parser.Parse(packet->Buffer(), packet->Length()); |
- EXPECT_EQ(1, parser.app()->num_packets()); |
- EXPECT_EQ(30U, parser.app()->SubType()); |
- EXPECT_EQ(name, parser.app()->Name()); |
- EXPECT_EQ(0, parser.app_item()->num_packets()); |
-} |
- |
-TEST(RtcpPacketTest, App) { |
- App app; |
- app.From(kSenderSsrc); |
- app.WithSubType(30); |
- uint32_t name = 'n' << 24; |
- name += 'a' << 16; |
- name += 'm' << 8; |
- name += 'e'; |
- app.WithName(name); |
- const char kData[] = {'t', 'e', 's', 't', 'd', 'a', 't', 'a'}; |
- const size_t kDataLength = sizeof(kData) / sizeof(kData[0]); |
- app.WithData((const uint8_t*)kData, kDataLength); |
- |
- rtc::scoped_ptr<RawPacket> packet(app.Build()); |
- RtcpPacketParser parser; |
- parser.Parse(packet->Buffer(), packet->Length()); |
- EXPECT_EQ(1, parser.app()->num_packets()); |
- EXPECT_EQ(30U, parser.app()->SubType()); |
- EXPECT_EQ(name, parser.app()->Name()); |
- EXPECT_EQ(1, parser.app_item()->num_packets()); |
- EXPECT_EQ(kDataLength, parser.app_item()->DataLength()); |
- EXPECT_EQ(0, strncmp(kData, (const char*)parser.app_item()->Data(), |
- parser.app_item()->DataLength())); |
-} |
TEST(RtcpPacketTest, BuildWithTooSmallBuffer) { |
ReportBlock rb; |