stefan | bded44b | 2016-07-18 09:26:06 -0700 | [diff] [blame] | 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 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 11 | #include "modules/congestion_controller/include/receive_side_congestion_controller.h" |
| 12 | #include "modules/pacing/packet_router.h" |
| 13 | #include "modules/remote_bitrate_estimator/include/remote_bitrate_estimator.h" |
| 14 | #include "modules/rtp_rtcp/source/byte_io.h" |
stefan | bded44b | 2016-07-18 09:26:06 -0700 | [diff] [blame] | 15 | |
| 16 | namespace webrtc { |
| 17 | |
stefan | bded44b | 2016-07-18 09:26:06 -0700 | [diff] [blame] | 18 | void FuzzOneInput(const uint8_t* data, size_t size) { |
| 19 | size_t i = 0; |
| 20 | if (size < sizeof(int64_t) + sizeof(uint8_t) + sizeof(uint32_t)) |
| 21 | return; |
| 22 | SimulatedClock clock(data[i++]); |
nisse | 0245da0 | 2016-11-30 03:35:20 -0800 | [diff] [blame] | 23 | PacketRouter packet_router; |
Niels Möller | 245f17e | 2017-08-21 10:45:07 +0200 | [diff] [blame] | 24 | ReceiveSideCongestionController cc(&clock, &packet_router); |
stefan | bded44b | 2016-07-18 09:26:06 -0700 | [diff] [blame] | 25 | RemoteBitrateEstimator* rbe = cc.GetRemoteBitrateEstimator(true); |
| 26 | RTPHeader header; |
| 27 | header.ssrc = ByteReader<uint32_t>::ReadBigEndian(&data[i]); |
| 28 | i += sizeof(uint32_t); |
| 29 | header.extension.hasTransportSequenceNumber = true; |
Stefan Holmer | d7e2513 | 2017-11-23 10:36:11 +0100 | [diff] [blame] | 30 | int64_t arrival_time_ms = std::min<int64_t>( |
| 31 | std::max<int64_t>(ByteReader<int64_t>::ReadBigEndian(&data[i]), 0), |
| 32 | std::numeric_limits<int64_t>::max() / 2); |
stefan | bded44b | 2016-07-18 09:26:06 -0700 | [diff] [blame] | 33 | i += sizeof(int64_t); |
| 34 | const size_t kMinPacketSize = |
| 35 | sizeof(size_t) + sizeof(uint16_t) + sizeof(uint8_t); |
| 36 | while (i + kMinPacketSize < size) { |
| 37 | size_t payload_size = ByteReader<size_t>::ReadBigEndian(&data[i]) % 1500; |
| 38 | i += sizeof(size_t); |
| 39 | header.extension.transportSequenceNumber = |
| 40 | ByteReader<uint16_t>::ReadBigEndian(&data[i]); |
| 41 | i += sizeof(uint16_t); |
| 42 | rbe->IncomingPacket(arrival_time_ms, payload_size, header); |
| 43 | clock.AdvanceTimeMilliseconds(5); |
| 44 | arrival_time_ms += ByteReader<uint8_t>::ReadBigEndian(&data[i]); |
Stefan Holmer | d7e2513 | 2017-11-23 10:36:11 +0100 | [diff] [blame] | 45 | i += sizeof(uint8_t); |
stefan | bded44b | 2016-07-18 09:26:06 -0700 | [diff] [blame] | 46 | } |
| 47 | rbe->Process(); |
| 48 | } |
| 49 | } // namespace webrtc |