blob: 38213c3a6e27f19a2622645df3029333c2e736fd [file] [log] [blame]
Peter Boströmba3e25e2016-02-23 11:35:30 +01001/*
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 */
Mirko Bonadei3b676722019-07-12 17:35:05 +000010#include "modules/rtp_rtcp/include/rtp_rtcp.h"
Jonathan Metzman9f80b972018-10-05 10:38:13 -070011#include "modules/rtp_rtcp/source/rtcp_packet/tmmb_item.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020012#include "modules/rtp_rtcp/source/rtcp_receiver.h"
13#include "rtc_base/checks.h"
14#include "system_wrappers/include/clock.h"
Peter Boströmba3e25e2016-02-23 11:35:30 +010015
16namespace webrtc {
Danil Chapovalov97088842016-09-13 12:41:41 +020017namespace {
18
Jiawei Ou8b5d9d82018-11-15 16:44:37 -080019constexpr int kRtcpIntervalMs = 1000;
20
Elad Alon800a1032019-04-07 23:50:08 +020021// RTCP is typically sent over UDP, which has a maximum payload length
22// of 65535 bytes. We err on the side of caution and check a bit above that.
23constexpr size_t kMaxInputLenBytes = 66000;
24
Danil Chapovalov97088842016-09-13 12:41:41 +020025class NullModuleRtpRtcp : public RTCPReceiver::ModuleRtpRtcp {
26 public:
27 void SetTmmbn(std::vector<rtcp::TmmbItem>) override {}
28 void OnRequestSendReport() override {}
Nico Weber7572bb42019-02-25 11:39:52 -050029 void OnReceivedNack(const std::vector<uint16_t>&) override {}
30 void OnReceivedRtcpReportBlocks(const ReportBlockList&) override {}
Danil Chapovalov97088842016-09-13 12:41:41 +020031};
32
Yves Gerey665174f2018-06-19 15:03:05 +020033} // namespace
Peter Boströmba3e25e2016-02-23 11:35:30 +010034
35void FuzzOneInput(const uint8_t* data, size_t size) {
Elad Alon800a1032019-04-07 23:50:08 +020036 if (size > kMaxInputLenBytes) {
37 return;
38 }
39
Danil Chapovalov97088842016-09-13 12:41:41 +020040 NullModuleRtpRtcp rtp_rtcp_module;
41 SimulatedClock clock(1234);
Peter Boströmba3e25e2016-02-23 11:35:30 +010042
Mirko Bonadei3b676722019-07-12 17:35:05 +000043 RtpRtcp::Configuration config;
44 config.clock = &clock;
45 config.rtcp_report_interval_ms = kRtcpIntervalMs;
Erik Språngdbbf4132019-10-18 10:34:25 +020046 config.local_media_ssrc = 1;
Mirko Bonadei3b676722019-07-12 17:35:05 +000047
48 RTCPReceiver receiver(config, &rtp_rtcp_module);
Peter Boströmba3e25e2016-02-23 11:35:30 +010049
Danil Chapovalov97088842016-09-13 12:41:41 +020050 receiver.IncomingPacket(data, size);
Peter Boströmba3e25e2016-02-23 11:35:30 +010051}
52} // namespace webrtc