| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // A very simple packet builder class for building RTCP packets. | 5 // A very simple packet builder class for building RTCP packets. |
| 6 // Used for testing only. | 6 // Used for testing only. |
| 7 #ifndef MEDIA_CAST_RTCP_TEST_RTCP_PACKET_BUILDER_H_ | 7 #ifndef MEDIA_CAST_RTCP_TEST_RTCP_PACKET_BUILDER_H_ |
| 8 #define MEDIA_CAST_RTCP_TEST_RTCP_PACKET_BUILDER_H_ | 8 #define MEDIA_CAST_RTCP_TEST_RTCP_PACKET_BUILDER_H_ |
| 9 | 9 |
| 10 #include "base/big_endian.h" | 10 #include "base/big_endian.h" |
| 11 #include "media/cast/net/cast_transport_defines.h" | 11 #include "media/cast/net/cast_transport_defines.h" |
| 12 #include "media/cast/net/rtcp/rtcp_defines.h" | 12 #include "media/cast/net/rtcp/rtcp_defines.h" |
| 13 | 13 |
| 14 namespace media { | 14 namespace media { |
| 15 namespace cast { | 15 namespace cast { |
| 16 | 16 |
| 17 // These values are arbitrary only for the purpose of testing. | 17 // These values are arbitrary only for the purpose of testing. |
| 18 | 18 |
| 19 namespace { | 19 namespace { |
| 20 // Sender report. | 20 // Sender report. |
| 21 static const uint32 kNtpHigh = 0x01020304; | 21 static const uint32_t kNtpHigh = 0x01020304; |
| 22 static const uint32 kNtpLow = 0x05060708; | 22 static const uint32_t kNtpLow = 0x05060708; |
| 23 static const uint32 kRtpTimestamp = 0x10203040; | 23 static const uint32_t kRtpTimestamp = 0x10203040; |
| 24 static const uint32 kSendPacketCount = 987; | 24 static const uint32_t kSendPacketCount = 987; |
| 25 static const uint32 kSendOctetCount = 87654; | 25 static const uint32_t kSendOctetCount = 87654; |
| 26 | 26 |
| 27 // Report block. | 27 // Report block. |
| 28 static const int kLoss = 0x01000123; | 28 static const int kLoss = 0x01000123; |
| 29 static const int kExtendedMax = 0x15678; | 29 static const int kExtendedMax = 0x15678; |
| 30 static const int kTestJitter = 0x10203; | 30 static const int kTestJitter = 0x10203; |
| 31 static const uint32 kLastSr = 0x34561234; | 31 static const uint32_t kLastSr = 0x34561234; |
| 32 static const uint32 kDelayLastSr = 1000; | 32 static const uint32_t kDelayLastSr = 1000; |
| 33 | 33 |
| 34 // DLRR block. | 34 // DLRR block. |
| 35 static const int kLastRr = 0x34561234; | 35 static const int kLastRr = 0x34561234; |
| 36 static const int kDelayLastRr = 1000; | 36 static const int kDelayLastRr = 1000; |
| 37 | 37 |
| 38 // NACK. | 38 // NACK. |
| 39 static const int kMissingPacket = 34567; | 39 static const int kMissingPacket = 34567; |
| 40 | 40 |
| 41 // CAST. | 41 // CAST. |
| 42 static const uint32 kAckFrameId = 17; | 42 static const uint32_t kAckFrameId = 17; |
| 43 static const uint32 kLostFrameId = 18; | 43 static const uint32_t kLostFrameId = 18; |
| 44 static const uint32 kFrameIdWithLostPackets = 19; | 44 static const uint32_t kFrameIdWithLostPackets = 19; |
| 45 static const int kLostPacketId1 = 3; | 45 static const int kLostPacketId1 = 3; |
| 46 static const int kLostPacketId2 = 5; | 46 static const int kLostPacketId2 = 5; |
| 47 static const int kLostPacketId3 = 12; | 47 static const int kLostPacketId3 = 12; |
| 48 } // namespace | 48 } // namespace |
| 49 | 49 |
| 50 class TestRtcpPacketBuilder { | 50 class TestRtcpPacketBuilder { |
| 51 public: | 51 public: |
| 52 TestRtcpPacketBuilder(); | 52 TestRtcpPacketBuilder(); |
| 53 | 53 |
| 54 void AddSr(uint32 sender_ssrc, int number_of_report_blocks); | 54 void AddSr(uint32_t sender_ssrc, int number_of_report_blocks); |
| 55 void AddSrWithNtp(uint32 sender_ssrc, | 55 void AddSrWithNtp(uint32_t sender_ssrc, |
| 56 uint32 ntp_high, | 56 uint32_t ntp_high, |
| 57 uint32 ntp_low, | 57 uint32_t ntp_low, |
| 58 uint32 rtp_timestamp); | 58 uint32_t rtp_timestamp); |
| 59 void AddRr(uint32 sender_ssrc, int number_of_report_blocks); | 59 void AddRr(uint32_t sender_ssrc, int number_of_report_blocks); |
| 60 void AddRb(uint32 rtp_ssrc); | 60 void AddRb(uint32_t rtp_ssrc); |
| 61 | 61 |
| 62 void AddXrHeader(uint32 sender_ssrc); | 62 void AddXrHeader(uint32_t sender_ssrc); |
| 63 void AddXrDlrrBlock(uint32 sender_ssrc); | 63 void AddXrDlrrBlock(uint32_t sender_ssrc); |
| 64 void AddXrExtendedDlrrBlock(uint32 sender_ssrc); | 64 void AddXrExtendedDlrrBlock(uint32_t sender_ssrc); |
| 65 void AddXrRrtrBlock(); | 65 void AddXrRrtrBlock(); |
| 66 void AddXrUnknownBlock(); | 66 void AddXrUnknownBlock(); |
| 67 void AddUnknownBlock(); | 67 void AddUnknownBlock(); |
| 68 | 68 |
| 69 void AddNack(uint32 sender_ssrc, uint32 media_ssrc); | 69 void AddNack(uint32_t sender_ssrc, uint32_t media_ssrc); |
| 70 void AddSendReportRequest(uint32 sender_ssrc, uint32 media_ssrc); | 70 void AddSendReportRequest(uint32_t sender_ssrc, uint32_t media_ssrc); |
| 71 | 71 |
| 72 void AddCast(uint32 sender_ssrc, | 72 void AddCast(uint32_t sender_ssrc, |
| 73 uint32 media_ssrc, | 73 uint32_t media_ssrc, |
| 74 base::TimeDelta target_delay); | 74 base::TimeDelta target_delay); |
| 75 void AddReceiverLog(uint32 sender_ssrc); | 75 void AddReceiverLog(uint32_t sender_ssrc); |
| 76 void AddReceiverFrameLog(uint32 rtp_timestamp, | 76 void AddReceiverFrameLog(uint32_t rtp_timestamp, |
| 77 int num_events, | 77 int num_events, |
| 78 uint32 event_timesamp_base); | 78 uint32_t event_timesamp_base); |
| 79 void AddReceiverEventLog(uint16 event_data, | 79 void AddReceiverEventLog(uint16_t event_data, |
| 80 CastLoggingEvent event, | 80 CastLoggingEvent event, |
| 81 uint16 event_timesamp_delta); | 81 uint16_t event_timesamp_delta); |
| 82 | 82 |
| 83 scoped_ptr<Packet> GetPacket(); | 83 scoped_ptr<Packet> GetPacket(); |
| 84 const uint8* Data(); | 84 const uint8_t* Data(); |
| 85 int Length() { return kMaxIpPacketSize - big_endian_writer_.remaining(); } | 85 int Length() { return kMaxIpPacketSize - big_endian_writer_.remaining(); } |
| 86 base::BigEndianReader* Reader(); | 86 base::BigEndianReader* Reader(); |
| 87 | 87 |
| 88 private: | 88 private: |
| 89 void AddRtcpHeader(int payload, int format_or_count); | 89 void AddRtcpHeader(int payload, int format_or_count); |
| 90 void PatchLengthField(); | 90 void PatchLengthField(); |
| 91 | 91 |
| 92 // Where the length field of the current packet is. | 92 // Where the length field of the current packet is. |
| 93 // Note: 0 is not a legal value, it is used for "uninitialized". | 93 // Note: 0 is not a legal value, it is used for "uninitialized". |
| 94 uint8 buffer_[kMaxIpPacketSize]; | 94 uint8_t buffer_[kMaxIpPacketSize]; |
| 95 char* ptr_of_length_; | 95 char* ptr_of_length_; |
| 96 base::BigEndianWriter big_endian_writer_; | 96 base::BigEndianWriter big_endian_writer_; |
| 97 base::BigEndianReader big_endian_reader_; | 97 base::BigEndianReader big_endian_reader_; |
| 98 | 98 |
| 99 DISALLOW_COPY_AND_ASSIGN(TestRtcpPacketBuilder); | 99 DISALLOW_COPY_AND_ASSIGN(TestRtcpPacketBuilder); |
| 100 }; | 100 }; |
| 101 | 101 |
| 102 } // namespace cast | 102 } // namespace cast |
| 103 } // namespace media | 103 } // namespace media |
| 104 | 104 |
| 105 #endif // MEDIA_CAST_RTCP_TEST_RTCP_PACKET_BUILDER_H_ | 105 #endif // MEDIA_CAST_RTCP_TEST_RTCP_PACKET_BUILDER_H_ |
| OLD | NEW |