1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 // A very simple packet builder class for building RTCP packets.
6 // Used for testing only.
7 #ifndef MEDIA_CAST_RTCP_TEST_RTCP_PACKET_BUILDER_H_
8 #define MEDIA_CAST_RTCP_TEST_RTCP_PACKET_BUILDER_H_
10 #include "media/cast/rtcp/rtcp_defines.h"
11 #include "net/base/big_endian.h"
16 // These values are arbitrary only for the purpose of testing.
19 static const int kNtpHigh = 0x01020304;
20 static const int kNtpLow = 0x05060708;
21 static const int kRtpTimestamp = 0x10203;
22 static const int kSendPacketCount = 987;
23 static const int kSendOctetCount = 87654;
26 static const int kLoss = 0x01000123;
27 static const int kExtendedMax = 0x15678;
28 static const int kJitter = 0x10203;
29 static const int kLastSr = 0x34561234;
30 static const int kDelayLastSr = 1000;
33 static const int kLastRr = 0x34561234;
34 static const int kDelayLastRr = 1000;
37 static const int kRembBitrate = 52428;
40 static const int kPayloadtype = 126;
41 static const uint64 kPictureId = 0x1234567890;
44 static const int kMissingPacket = 34567;
47 static const int kAckFrameId = 17;
48 static const int kLostFrameId = 18;
49 static const int kFrameIdWithLostPackets = 19;
50 static const int kLostPacketId1 = 3;
51 static const int kLostPacketId2 = 5;
52 static const int kLostPacketId3 = 12;
54 class TestRtcpPacketBuilder {
56 TestRtcpPacketBuilder();
58 void AddSr(uint32 sender_ssrc, int number_of_report_blocks);
59 void AddSrWithNtp(uint32 sender_ssrc, uint32 ntp_high, uint32 ntp_low,
60 uint32 rtp_timestamp);
61 void AddRr(uint32 sender_ssrc, int number_of_report_blocks);
62 void AddRb(uint32 rtp_ssrc);
63 void AddSdesCname(uint32 sender_ssrc, const std::string& c_name);
65 void AddXrHeader(uint32 sender_ssrc);
66 void AddXrDlrrBlock(uint32 sender_ssrc);
67 void AddXrExtendedDlrrBlock(uint32 sender_ssrc);
68 void AddXrRrtrBlock();
69 void AddXrUnknownBlock();
71 void AddNack(uint32 sender_ssrc, uint32 media_ssrc);
72 void AddSendReportRequest(uint32 sender_ssrc, uint32 media_ssrc);
74 void AddPli(uint32 sender_ssrc, uint32 media_ssrc);
75 void AddRpsi(uint32 sender_ssrc, uint32 media_ssrc);
76 void AddRemb(uint32 sender_ssrc, uint32 media_ssrc);
77 void AddCast(uint32 sender_ssrc, uint32 media_ssrc);
79 const uint8* Packet();
80 int Length() { return kIpPacketSize - big_endian_writer_.remaining(); }
83 void AddRtcpHeader(int payload, int format_or_count);
84 void PatchLengthField();
86 // Where the length field of the current packet is.
87 // Note: 0 is not a legal value, it is used for "uninitialized".
88 uint8 buffer_[kIpPacketSize];
90 net::BigEndianWriter big_endian_writer_;
96 #endif // MEDIA_CAST_RTCP_TEST_RTCP_PACKET_BUILDER_H_