| OLD | NEW |
| (Empty) |
| 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. | |
| 4 | |
| 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_ | |
| 9 | |
| 10 #include "base/big_endian.h" | |
| 11 #include "media/cast/cast_config.h" | |
| 12 #include "media/cast/rtcp/rtcp_defines.h" | |
| 13 | |
| 14 namespace media { | |
| 15 namespace cast { | |
| 16 | |
| 17 // These values are arbitrary only for the purpose of testing. | |
| 18 | |
| 19 namespace { | |
| 20 // Sender report. | |
| 21 static const int kNtpHigh = 0x01020304; | |
| 22 static const int kNtpLow = 0x05060708; | |
| 23 static const int kRtpTimestamp = 0x10203040; | |
| 24 static const int kSendPacketCount = 987; | |
| 25 static const int kSendOctetCount = 87654; | |
| 26 | |
| 27 // Report block. | |
| 28 static const int kLoss = 0x01000123; | |
| 29 static const int kExtendedMax = 0x15678; | |
| 30 static const int kTestJitter = 0x10203; | |
| 31 static const int kLastSr = 0x34561234; | |
| 32 static const int kDelayLastSr = 1000; | |
| 33 | |
| 34 // DLRR block. | |
| 35 static const int kLastRr = 0x34561234; | |
| 36 static const int kDelayLastRr = 1000; | |
| 37 | |
| 38 // REMB. | |
| 39 static const int kTestRembBitrate = 52428; | |
| 40 | |
| 41 // RPSI. | |
| 42 static const int kPayloadtype = 126; | |
| 43 static const uint64 kPictureId = 0x1234567890; | |
| 44 | |
| 45 // NACK. | |
| 46 static const int kMissingPacket = 34567; | |
| 47 | |
| 48 // CAST. | |
| 49 static const uint32 kAckFrameId = 17; | |
| 50 static const uint32 kLostFrameId = 18; | |
| 51 static const uint32 kFrameIdWithLostPackets = 19; | |
| 52 static const int kLostPacketId1 = 3; | |
| 53 static const int kLostPacketId2 = 5; | |
| 54 static const int kLostPacketId3 = 12; | |
| 55 } // namespace | |
| 56 | |
| 57 class TestRtcpPacketBuilder { | |
| 58 public: | |
| 59 TestRtcpPacketBuilder(); | |
| 60 | |
| 61 void AddSr(uint32 sender_ssrc, int number_of_report_blocks); | |
| 62 void AddSrWithNtp(uint32 sender_ssrc, | |
| 63 uint32 ntp_high, | |
| 64 uint32 ntp_low, | |
| 65 uint32 rtp_timestamp); | |
| 66 void AddRr(uint32 sender_ssrc, int number_of_report_blocks); | |
| 67 void AddRb(uint32 rtp_ssrc); | |
| 68 void AddSdesCname(uint32 sender_ssrc, const std::string& c_name); | |
| 69 | |
| 70 void AddXrHeader(uint32 sender_ssrc); | |
| 71 void AddXrDlrrBlock(uint32 sender_ssrc); | |
| 72 void AddXrExtendedDlrrBlock(uint32 sender_ssrc); | |
| 73 void AddXrRrtrBlock(); | |
| 74 void AddXrUnknownBlock(); | |
| 75 | |
| 76 void AddNack(uint32 sender_ssrc, uint32 media_ssrc); | |
| 77 void AddSendReportRequest(uint32 sender_ssrc, uint32 media_ssrc); | |
| 78 | |
| 79 void AddPli(uint32 sender_ssrc, uint32 media_ssrc); | |
| 80 void AddRpsi(uint32 sender_ssrc, uint32 media_ssrc); | |
| 81 void AddRemb(uint32 sender_ssrc, uint32 media_ssrc); | |
| 82 void AddCast(uint32 sender_ssrc, | |
| 83 uint32 media_ssrc, | |
| 84 base::TimeDelta target_delay); | |
| 85 void AddReceiverLog(uint32 sender_ssrc); | |
| 86 void AddReceiverFrameLog(uint32 rtp_timestamp, | |
| 87 int num_events, | |
| 88 uint32 event_timesamp_base); | |
| 89 void AddReceiverEventLog(uint16 event_data, | |
| 90 CastLoggingEvent event, | |
| 91 uint16 event_timesamp_delta); | |
| 92 | |
| 93 scoped_ptr<Packet> GetPacket(); | |
| 94 const uint8* Data(); | |
| 95 int Length() { return kMaxIpPacketSize - big_endian_writer_.remaining(); } | |
| 96 | |
| 97 private: | |
| 98 void AddRtcpHeader(int payload, int format_or_count); | |
| 99 void PatchLengthField(); | |
| 100 | |
| 101 // Where the length field of the current packet is. | |
| 102 // Note: 0 is not a legal value, it is used for "uninitialized". | |
| 103 uint8 buffer_[kMaxIpPacketSize]; | |
| 104 char* ptr_of_length_; | |
| 105 base::BigEndianWriter big_endian_writer_; | |
| 106 | |
| 107 DISALLOW_COPY_AND_ASSIGN(TestRtcpPacketBuilder); | |
| 108 }; | |
| 109 | |
| 110 } // namespace cast | |
| 111 } // namespace media | |
| 112 | |
| 113 #endif // MEDIA_CAST_RTCP_TEST_RTCP_PACKET_BUILDER_H_ | |
| OLD | NEW |