OLD | NEW |
---|---|
(Empty) | |
1 /* | |
2 * Copyright (c) 2017 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/modules/video_coding/packet_buffer.h" | |
12 #include "webrtc/system_wrappers/include/clock.h" | |
13 | |
14 namespace webrtc { | |
15 | |
16 namespace { | |
17 class DummyCallback : public video_coding::OnReceivedFrameCallback { | |
stefan-webrtc
2017/01/10 11:50:00
NullCallback is usually the naming convention
philipel
2017/01/10 12:03:36
Done.
| |
18 void OnReceivedFrame(std::unique_ptr<video_coding::RtpFrameObject> frame) {} | |
19 }; | |
20 } // namespace | |
21 | |
22 void FuzzOneInput(const uint8_t* data, size_t size) { | |
23 // Two bytes for the sequence number, | |
24 // one byte for isFirstPacket and markerBit. | |
25 constexpr size_t kMinDataNeeded = 3; | |
26 if (size < 200) { | |
stefan-webrtc
2017/01/10 11:50:00
No need for this check, right?
philipel
2017/01/10 12:03:36
We need at least kMinDataNeeded bytes, but we want
stefan-webrtc
2017/01/10 12:11:08
The fuzzer will fairly quickly check with long seq
| |
27 return; | |
28 } | |
29 | |
30 VCMPacket packet; | |
31 DummyCallback callback; | |
32 SimulatedClock clock(0); | |
33 rtc::scoped_refptr<video_coding::PacketBuffer> packet_buffer( | |
34 video_coding::PacketBuffer::Create(&clock, 8, 1024, &callback)); | |
35 | |
36 size_t i = kMinDataNeeded; | |
37 while (i < size) { | |
38 memcpy(&packet.seqNum, &data[i - kMinDataNeeded], 2); | |
39 packet.isFirstPacket = data[i] & 1; | |
40 packet.markerBit = data[i] & 2; | |
41 packet_buffer->InsertPacket(&packet); | |
42 i += kMinDataNeeded; | |
43 } | |
44 } | |
45 | |
46 } // namespace webrtc | |
OLD | NEW |