Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(233)

Side by Side Diff: webrtc/test/fuzzers/producer_fec_fuzzer.cc

Issue 2110763002: Style updates to ProducerFec/FecReceiver. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Rebase + 'git cl format'. Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/modules/rtp_rtcp/source/rtp_sender_video.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 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 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 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #include <memory> 11 #include <memory>
12 12
13 #include "webrtc/base/checks.h" 13 #include "webrtc/base/checks.h"
14 #include "webrtc/modules/rtp_rtcp/source/byte_io.h" 14 #include "webrtc/modules/rtp_rtcp/source/byte_io.h"
15 #include "webrtc/modules/rtp_rtcp/source/fec_test_helper.h"
15 #include "webrtc/modules/rtp_rtcp/source/producer_fec.h" 16 #include "webrtc/modules/rtp_rtcp/source/producer_fec.h"
16 17
17 namespace webrtc { 18 namespace webrtc {
18 19
19 void FuzzOneInput(const uint8_t* data, size_t size) { 20 void FuzzOneInput(const uint8_t* data, size_t size) {
20 ForwardErrorCorrection fec; 21 ForwardErrorCorrection fec;
21 ProducerFec producer(&fec); 22 ProducerFec producer(&fec);
22 size_t i = 0; 23 size_t i = 0;
23 if (size < 4) 24 if (size < 4)
24 return; 25 return;
25 FecProtectionParams params = { 26 FecProtectionParams params = {
26 data[i++] % 128, static_cast<int>(data[i++] % 10), kFecMaskBursty}; 27 data[i++] % 128, static_cast<int>(data[i++] % 10), kFecMaskBursty};
27 producer.SetFecParameters(&params, 0); 28 producer.SetFecParameters(&params, 0);
28 uint16_t seq_num = data[i++]; 29 uint16_t seq_num = data[i++];
29 30
30 while (i + 3 < size) { 31 while (i + 3 < size) {
31 size_t rtp_header_length = data[i++] % 10 + 12; 32 size_t rtp_header_length = data[i++] % 10 + 12;
32 size_t payload_size = data[i++] % 10; 33 size_t payload_size = data[i++] % 10;
33 if (i + payload_size + rtp_header_length + 2 > size) 34 if (i + payload_size + rtp_header_length + 2 > size)
34 break; 35 break;
35 std::unique_ptr<uint8_t[]> packet( 36 std::unique_ptr<uint8_t[]> packet(
36 new uint8_t[payload_size + rtp_header_length]); 37 new uint8_t[payload_size + rtp_header_length]);
37 memcpy(packet.get(), &data[i], payload_size + rtp_header_length); 38 memcpy(packet.get(), &data[i], payload_size + rtp_header_length);
38 ByteWriter<uint16_t>::WriteBigEndian(&packet[2], seq_num++); 39 ByteWriter<uint16_t>::WriteBigEndian(&packet[2], seq_num++);
39 i += payload_size + rtp_header_length; 40 i += payload_size + rtp_header_length;
40 // Make sure sequence numbers are increasing. 41 // Make sure sequence numbers are increasing.
41 const int kRedPayloadType = 98; 42 std::unique_ptr<RedPacket> red_packet = ProducerFec::BuildRedPacket(
42 std::unique_ptr<RedPacket> red_packet(producer.BuildRedPacket( 43 packet.get(), payload_size, rtp_header_length, kRedPayloadType);
43 packet.get(), payload_size, rtp_header_length, kRedPayloadType));
44 const bool protect = data[i++] % 2 == 1; 44 const bool protect = data[i++] % 2 == 1;
45 if (protect) { 45 if (protect) {
46 producer.AddRtpPacketAndGenerateFec(packet.get(), payload_size, 46 producer.AddRtpPacketAndGenerateFec(packet.get(), payload_size,
47 rtp_header_length); 47 rtp_header_length);
48 } 48 }
49 const size_t num_fec_packets = producer.NumAvailableFecPackets(); 49 const size_t num_fec_packets = producer.NumAvailableFecPackets();
50 if (num_fec_packets > 0) { 50 if (num_fec_packets > 0) {
51 std::vector<RedPacket*> fec_packets = 51 std::vector<std::unique_ptr<RedPacket>> fec_packets =
52 producer.GetFecPackets(kRedPayloadType, 99, 100, rtp_header_length); 52 producer.GetFecPacketsAsRed(kRedPayloadType, kFecPayloadType, 100,
53 rtp_header_length);
53 RTC_CHECK_EQ(num_fec_packets, fec_packets.size()); 54 RTC_CHECK_EQ(num_fec_packets, fec_packets.size());
54 for (RedPacket* fec_packet : fec_packets)
55 delete fec_packet;
56 } 55 }
57 } 56 }
58 } 57 }
59 } // namespace webrtc 58 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/rtp_rtcp/source/rtp_sender_video.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698