Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 /* | |
| 2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. | |
| 3 * | |
| 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 | |
| 6 * tree. An additional intellectual property rights grant can be found | |
| 7 * in the file PATENTS. All contributing project authors may | |
| 8 * be found in the AUTHORS file in the root of the source tree. | |
| 9 */ | |
| 10 | |
| 11 #include "webrtc/call/mock/mock_rtc_event_log.h" | |
| 12 #include "webrtc/modules/congestion_controller/include/congestion_controller.h" | |
| 13 #include "webrtc/modules/congestion_controller/include/mock/mock_congestion_cont roller.h" | |
| 14 #include "webrtc/modules/remote_bitrate_estimator/include/mock/mock_remote_bitra te_estimator.h" | |
| 15 #include "webrtc/modules/rtp_rtcp/source/byte_io.h" | |
| 16 | |
| 17 namespace webrtc { | |
| 18 | |
| 19 void FuzzOneInput(const uint8_t* data, size_t size) { | |
| 20 size_t i = 0; | |
| 21 const size_t kMinSize = sizeof(size_t) + sizeof(uint16_t) + sizeof(uint8_t); | |
|
pbos-webrtc
2016/07/18 08:02:52
Something like kMinPacketSize?
stefan-webrtc
2016/07/18 15:46:56
Roughly, it also includes the size of the packet.
| |
| 22 if (size < sizeof(int64_t) + sizeof(uint8_t) + sizeof(uint32_t) + kMinSize) | |
|
pbos-webrtc
2016/07/18 08:02:52
You can permit this to run with 0 packets as well,
stefan-webrtc
2016/07/18 15:46:56
Good suggestion, fixing.
| |
| 23 return; | |
| 24 SimulatedClock clock(data[i++]); | |
| 25 testing::NiceMock<test::MockCongestionObserver> observer; | |
| 26 testing::NiceMock<MockRemoteBitrateObserver> rbe_observer; | |
| 27 testing::NiceMock<MockRtcEventLog> event_log; | |
| 28 CongestionController cc(&clock, &observer, &rbe_observer, &event_log); | |
| 29 RemoteBitrateEstimator* rbe = cc.GetRemoteBitrateEstimator(true); | |
| 30 RTPHeader header; | |
| 31 header.ssrc = ByteReader<uint32_t>::ReadBigEndian(&data[i]); | |
| 32 i += sizeof(uint32_t); | |
| 33 header.extension.hasTransportSequenceNumber = true; | |
| 34 int64_t arrival_time_ms = | |
| 35 std::max<int64_t>(ByteReader<int64_t>::ReadBigEndian(&data[i]), 0); | |
| 36 i += sizeof(int64_t); | |
| 37 while (i + kMinSize < size) { | |
| 38 size_t payload_size = ByteReader<size_t>::ReadBigEndian(&data[i]) % 1500; | |
| 39 i += sizeof(size_t); | |
| 40 header.extension.transportSequenceNumber = | |
| 41 ByteReader<uint16_t>::ReadBigEndian(&data[i]); | |
| 42 i += sizeof(uint16_t); | |
| 43 rbe->IncomingPacket(arrival_time_ms, payload_size, header); | |
| 44 clock.AdvanceTimeMilliseconds(5); | |
| 45 arrival_time_ms += ByteReader<uint8_t>::ReadBigEndian(&data[i]); | |
| 46 arrival_time_ms += sizeof(uint8_t); | |
| 47 } | |
| 48 rbe->Process(); | |
| 49 } | |
| 50 } // namespace webrtc | |
| OLD | NEW |