OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 FuzzHeader(); | 80 FuzzHeader(); |
81 return packet_to_return; | 81 return packet_to_return; |
82 } | 82 } |
83 | 83 |
84 void AdvanceOutputEvent() override { return input_->AdvanceOutputEvent(); } | 84 void AdvanceOutputEvent() override { return input_->AdvanceOutputEvent(); } |
85 | 85 |
86 bool ended() const override { return ended_; } | 86 bool ended() const override { return ended_; } |
87 | 87 |
88 rtc::Optional<RTPHeader> NextHeader() const override { | 88 rtc::Optional<RTPHeader> NextHeader() const override { |
89 RTC_DCHECK(packet_); | 89 RTC_DCHECK(packet_); |
90 return rtc::Optional<RTPHeader>(packet_->header.header); | 90 return rtc::Optional<RTPHeader>(packet_->header); |
91 } | 91 } |
92 | 92 |
93 private: | 93 private: |
94 void FuzzHeader() { | 94 void FuzzHeader() { |
95 constexpr size_t kNumBytesToFuzz = 11; | 95 constexpr size_t kNumBytesToFuzz = 11; |
96 if (data_ix_ + kNumBytesToFuzz > data_.size()) { | 96 if (data_ix_ + kNumBytesToFuzz > data_.size()) { |
97 ended_ = true; | 97 ended_ = true; |
98 return; | 98 return; |
99 } | 99 } |
100 RTC_DCHECK(packet_); | 100 RTC_DCHECK(packet_); |
101 const size_t start_ix = data_ix_; | 101 const size_t start_ix = data_ix_; |
102 packet_->header.header.payloadType = | 102 packet_->header.payloadType = |
103 ByteReader<uint8_t>::ReadLittleEndian(&data_[data_ix_]); | 103 ByteReader<uint8_t>::ReadLittleEndian(&data_[data_ix_]); |
104 packet_->header.header.payloadType &= 0x7F; | 104 packet_->header.payloadType &= 0x7F; |
105 data_ix_ += sizeof(uint8_t); | 105 data_ix_ += sizeof(uint8_t); |
106 packet_->header.header.sequenceNumber = | 106 packet_->header.sequenceNumber = |
107 ByteReader<uint16_t>::ReadLittleEndian(&data_[data_ix_]); | 107 ByteReader<uint16_t>::ReadLittleEndian(&data_[data_ix_]); |
108 data_ix_ += sizeof(uint16_t); | 108 data_ix_ += sizeof(uint16_t); |
109 packet_->header.header.timestamp = | 109 packet_->header.timestamp = |
110 ByteReader<uint32_t>::ReadLittleEndian(&data_[data_ix_]); | 110 ByteReader<uint32_t>::ReadLittleEndian(&data_[data_ix_]); |
111 data_ix_ += sizeof(uint32_t); | 111 data_ix_ += sizeof(uint32_t); |
112 packet_->header.header.ssrc = | 112 packet_->header.ssrc = |
113 ByteReader<uint32_t>::ReadLittleEndian(&data_[data_ix_]); | 113 ByteReader<uint32_t>::ReadLittleEndian(&data_[data_ix_]); |
114 data_ix_ += sizeof(uint32_t); | 114 data_ix_ += sizeof(uint32_t); |
115 RTC_CHECK_EQ(data_ix_ - start_ix, kNumBytesToFuzz); | 115 RTC_CHECK_EQ(data_ix_ - start_ix, kNumBytesToFuzz); |
116 } | 116 } |
117 | 117 |
118 bool ended_ = false; | 118 bool ended_ = false; |
119 rtc::ArrayView<const uint8_t> data_; | 119 rtc::ArrayView<const uint8_t> data_; |
120 size_t data_ix_ = 0; | 120 size_t data_ix_ = 0; |
121 std::unique_ptr<EncodeNetEqInput> input_; | 121 std::unique_ptr<EncodeNetEqInput> input_; |
122 std::unique_ptr<PacketData> packet_; | 122 std::unique_ptr<PacketData> packet_; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 test.Run(); | 159 test.Run(); |
160 } | 160 } |
161 | 161 |
162 } // namespace test | 162 } // namespace test |
163 | 163 |
164 void FuzzOneInput(const uint8_t* data, size_t size) { | 164 void FuzzOneInput(const uint8_t* data, size_t size) { |
165 test::FuzzOneInputTest(data, size); | 165 test::FuzzOneInputTest(data, size); |
166 } | 166 } |
167 | 167 |
168 } // namespace webrtc | 168 } // namespace webrtc |
OLD | NEW |