blob: d6af5ca3ceaeadde77bcadc66f2add0dc18e9940 [file] [log] [blame]
Benjamin Wright1295b0d2019-03-13 15:01:22 -07001/*
2 * Copyright (c) 2019 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 <stddef.h>
12#include <stdint.h>
Jonas Olssona4d87372019-07-05 19:08:33 +020013
Benjamin Wright1295b0d2019-03-13 15:01:22 -070014#include <algorithm>
15#include <memory>
16#include <string>
17
Tommi25eb47c2019-08-29 16:39:05 +020018#include "test/rtp_header_parser.h"
Benjamin Wright1295b0d2019-03-13 15:01:22 -070019
20namespace webrtc {
21
22void FuzzOneInput(const uint8_t* data, size_t size) {
23 RtpHeaderParser::IsRtcp(data, size);
24 RtpHeaderParser::GetSsrc(data, size);
25 RTPHeader rtp_header;
26
Tommi25eb47c2019-08-29 16:39:05 +020027 std::unique_ptr<RtpHeaderParser> rtp_header_parser(
28 RtpHeaderParser::CreateForTest());
Benjamin Wright1295b0d2019-03-13 15:01:22 -070029
30 rtp_header_parser->Parse(data, size, &rtp_header);
31 for (int i = 1; i < kRtpExtensionNumberOfExtensions; ++i) {
32 if (size > 0 && i >= data[size - 1]) {
33 RTPExtensionType add_extension = static_cast<RTPExtensionType>(i);
34 rtp_header_parser->RegisterRtpHeaderExtension(add_extension, i);
35 }
36 }
37 rtp_header_parser->Parse(data, size, &rtp_header);
38
39 for (int i = 1; i < kRtpExtensionNumberOfExtensions; ++i) {
40 if (size > 1 && i >= data[size - 2]) {
41 RTPExtensionType remove_extension = static_cast<RTPExtensionType>(i);
42 rtp_header_parser->DeregisterRtpHeaderExtension(remove_extension);
43 }
44 }
45 rtp_header_parser->Parse(data, size, &rtp_header);
46}
47
48} // namespace webrtc