-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Expand file tree
/
Copy pathFuzzerRtpStreamSend.cpp
More file actions
65 lines (50 loc) · 1.57 KB
/
FuzzerRtpStreamSend.cpp
File metadata and controls
65 lines (50 loc) · 1.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#include "RTC/FuzzerRtpStreamSend.hpp"
#include "Utils.hpp"
#include "RTC/RtpStreamSend.hpp"
class TestRtpStreamListener : public RTC::RtpStreamSend::Listener
{
public:
void OnRtpStreamScore(RTC::RtpStream* /*rtpStream*/, uint8_t /*score*/, uint8_t /*previousScore*/) override
{
}
void OnRtpStreamRetransmitRtpPacket(RTC::RtpStreamSend* /*rtpStream*/, RTC::RtpPacket* packet) override
{
}
};
void Fuzzer::RTC::RtpStreamSend::Fuzz(const uint8_t* data, size_t len)
{
// clang-format off
uint8_t buffer[] =
{
0b10000000, 0b01111011, 0b01010010, 0b00001110,
0b01011011, 0b01101011, 0b11001010, 0b10110101,
0, 0, 0, 2
};
// clang-format on
// Create base RtpPacket instance.
auto* packet = ::RTC::RtpPacket::Parse(buffer, 12);
size_t offset{ 0u };
// Create a RtpStreamSend instance.
TestRtpStreamListener testRtpStreamListener;
// Create RtpStreamSend instance.
::RTC::RtpStream::Params params;
params.ssrc = 1111;
params.clockRate = 90000;
params.useNack = true;
params.mimeType.type = ::RTC::RtpCodecMimeType::Type::VIDEO;
packet->SetSsrc(params.ssrc);
std::string mid;
::RTC::RtpStreamSend* stream = new ::RTC::RtpStreamSend(&testRtpStreamListener, params, mid);
while (len >= 4u)
{
std::shared_ptr<::RTC::RtpPacket> sharedPacket;
// Set 'random' sequence number and timestamp.
packet->SetSequenceNumber(Utils::Byte::Get2Bytes(data, offset));
packet->SetTimestamp(Utils::Byte::Get4Bytes(data, offset));
stream->ReceivePacket(packet, sharedPacket);
len -= 4u;
offset += 4;
}
delete stream;
::RTC::RtpPacket::Deallocate(packet);
}