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.
20 static const int kNtpHigh = 0x01020304;
21 static const int kNtpLow = 0x05060708;
22 static const int kRtpTimestamp = 0x10203040;
23 static const int kSendPacketCount = 987;
24 static const int kSendOctetCount = 87654;
27 static const int kLoss = 0x01000123;
28 static const int kExtendedMax = 0x15678;
29 static const int kTestJitter = 0x10203;
30 static const int kLastSr = 0x34561234;
31 static const int kDelayLastSr = 1000;
34 static const int kLastRr = 0x34561234;
35 static const int kDelayLastRr = 1000;
38 static const int kTestRembBitrate = 52428;
41 static const int kPayloadtype = 126;
42 static const uint64 kPictureId = 0x1234567890;
45 static const int kMissingPacket = 34567;
48 static const uint32 kAckFrameId = 17;
49 static const uint32 kLostFrameId = 18;
50 static const uint32 kFrameIdWithLostPackets = 19;
51 static const int kLostPacketId1 = 3;
52 static const int kLostPacketId2 = 5;
53 static const int kLostPacketId3 = 12;
56 class TestRtcpPacketBuilder {
58 TestRtcpPacketBuilder();
60 void AddSr(uint32 sender_ssrc, int number_of_report_blocks);
61 void AddSrWithNtp(uint32 sender_ssrc, uint32 ntp_high, uint32 ntp_low,
62 uint32 rtp_timestamp);
63 void AddRr(uint32 sender_ssrc, int number_of_report_blocks);
64 void AddRb(uint32 rtp_ssrc);
65 void AddSdesCname(uint32 sender_ssrc, const std::string& c_name);
67 void AddXrHeader(uint32 sender_ssrc);
68 void AddXrDlrrBlock(uint32 sender_ssrc);
69 void AddXrExtendedDlrrBlock(uint32 sender_ssrc);
70 void AddXrRrtrBlock();
71 void AddXrUnknownBlock();
73 void AddNack(uint32 sender_ssrc, uint32 media_ssrc);
74 void AddSendReportRequest(uint32 sender_ssrc, uint32 media_ssrc);
76 void AddPli(uint32 sender_ssrc, uint32 media_ssrc);
77 void AddRpsi(uint32 sender_ssrc, uint32 media_ssrc);
78 void AddRemb(uint32 sender_ssrc, uint32 media_ssrc);
79 void AddCast(uint32 sender_ssrc, uint32 media_ssrc);
80 void AddSenderLog(uint32 sender_ssrc);
81 void AddSenderFrameLog(uint8 event_id, uint32 rtp_timestamp);
82 void AddReceiverLog(uint32 sender_ssrc);
83 void AddReceiverFrameLog(uint32 rtp_timestamp, int num_events,
84 uint32 event_timesamp_base);
85 void AddReceiverEventLog(uint16 event_data, uint8 event_id,
86 uint16 event_timesamp_delta);
88 const uint8* Packet();
89 int Length() { return kMaxIpPacketSize - big_endian_writer_.remaining(); }
92 void AddRtcpHeader(int payload, int format_or_count);
93 void PatchLengthField();
95 // Where the length field of the current packet is.
96 // Note: 0 is not a legal value, it is used for "uninitialized".
97 uint8 buffer_[kMaxIpPacketSize];
99 net::BigEndianWriter big_endian_writer_;
105 #endif // MEDIA_CAST_RTCP_TEST_RTCP_PACKET_BUILDER_H_