Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 "webrtc/call/rtc_event_log.h" | 11 #include "webrtc/call/rtc_event_log.h" |
| 12 #include "webrtc/modules/congestion_controller/include/congestion_controller.h" | 12 #include "webrtc/modules/congestion_controller/include/congestion_controller.h" |
| 13 #include "webrtc/modules/remote_bitrate_estimator/include/remote_bitrate_estimat or.h" | 13 #include "webrtc/modules/remote_bitrate_estimator/include/remote_bitrate_estimat or.h" |
| 14 #include "webrtc/modules/rtp_rtcp/source/byte_io.h" | 14 #include "webrtc/modules/rtp_rtcp/source/byte_io.h" |
| 15 | 15 |
| 16 namespace webrtc { | 16 namespace webrtc { |
| 17 | 17 |
| 18 class NullBitrateObserver : public CongestionController::Observer, | 18 class NullBitrateObserver : public CongestionController::Observer, |
| 19 public RemoteBitrateObserver { | 19 public RemoteBitrateObserver { |
| 20 public: | 20 public: |
| 21 ~NullBitrateObserver() override {} | 21 ~NullBitrateObserver() override {} |
| 22 void OnNetworkChanged(uint32_t bitrate_bps, | 22 void OnNetworkChanged(uint32_t bitrate_bps, |
| 23 uint8_t fraction_loss, | 23 uint8_t fraction_loss, |
| 24 int64_t rtt_ms) override {} | 24 int64_t rtt_ms) override {} |
| 25 void OnReceiveBitrateChanged(const std::vector<uint32_t>& ssrcs, | 25 void OnReceiveBitrateChanged(const std::vector<uint32_t>& ssrcs, |
| 26 uint32_t bitrate) override {} | 26 uint32_t bitrate) override {} |
| 27 }; | 27 }; |
| 28 | 28 |
| 29 class NullEventLog : public RtcEventLog { | |
| 30 public: | |
| 31 ~NullEventLog() override {} | |
| 32 bool StartLogging(const std::string& file_name, | |
| 33 int64_t max_size_bytes) override { | |
| 34 return true; | |
| 35 } | |
| 36 bool StartLogging(rtc::PlatformFile platform_file, int64_t max_size_bytes) { | |
| 37 return true; | |
| 38 } | |
| 39 void StopLogging() override{}; | |
| 40 void LogVideoReceiveStreamConfig( | |
| 41 const webrtc::VideoReceiveStream::Config& config) override {} | |
| 42 void LogVideoSendStreamConfig( | |
| 43 const webrtc::VideoSendStream::Config& config) override {} | |
| 44 void LogRtpHeader(PacketDirection direction, | |
| 45 MediaType media_type, | |
| 46 const uint8_t* header, | |
| 47 size_t packet_length) override {} | |
| 48 void LogRtcpPacket(PacketDirection direction, | |
| 49 MediaType media_type, | |
| 50 const uint8_t* packet, | |
| 51 size_t length) override {} | |
| 52 void LogAudioPlayout(uint32_t ssrc) override {} | |
| 53 void LogBwePacketLossEvent(int32_t bitrate, | |
| 54 uint8_t fraction_loss, | |
| 55 int32_t total_packets) override {} | |
| 56 }; | |
| 57 | |
| 58 void FuzzOneInput(const uint8_t* data, size_t size) { | 29 void FuzzOneInput(const uint8_t* data, size_t size) { |
| 59 size_t i = 0; | 30 size_t i = 0; |
| 60 if (size < sizeof(int64_t) + sizeof(uint8_t) + sizeof(uint32_t)) | 31 if (size < sizeof(int64_t) + sizeof(uint8_t) + sizeof(uint32_t)) |
| 61 return; | 32 return; |
| 62 SimulatedClock clock(data[i++]); | 33 SimulatedClock clock(data[i++]); |
| 63 NullBitrateObserver observer; | 34 NullBitrateObserver observer; |
| 64 NullEventLog event_log; | 35 NullRtcEventLog event_log; |
|
terelius
2016/07/28 13:22:35
Would the MockRtcEventLog be useful here?
stefan-webrtc
2016/07/28 13:47:23
Fuzzers can't depend on gmock/gtest, that's why I'
| |
| 65 CongestionController cc(&clock, &observer, &observer, &event_log); | 36 CongestionController cc(&clock, &observer, &observer, &event_log); |
| 66 RemoteBitrateEstimator* rbe = cc.GetRemoteBitrateEstimator(true); | 37 RemoteBitrateEstimator* rbe = cc.GetRemoteBitrateEstimator(true); |
| 67 RTPHeader header; | 38 RTPHeader header; |
| 68 header.ssrc = ByteReader<uint32_t>::ReadBigEndian(&data[i]); | 39 header.ssrc = ByteReader<uint32_t>::ReadBigEndian(&data[i]); |
| 69 i += sizeof(uint32_t); | 40 i += sizeof(uint32_t); |
| 70 header.extension.hasTransportSequenceNumber = true; | 41 header.extension.hasTransportSequenceNumber = true; |
| 71 int64_t arrival_time_ms = | 42 int64_t arrival_time_ms = |
| 72 std::max<int64_t>(ByteReader<int64_t>::ReadBigEndian(&data[i]), 0); | 43 std::max<int64_t>(ByteReader<int64_t>::ReadBigEndian(&data[i]), 0); |
| 73 i += sizeof(int64_t); | 44 i += sizeof(int64_t); |
| 74 const size_t kMinPacketSize = | 45 const size_t kMinPacketSize = |
| 75 sizeof(size_t) + sizeof(uint16_t) + sizeof(uint8_t); | 46 sizeof(size_t) + sizeof(uint16_t) + sizeof(uint8_t); |
| 76 while (i + kMinPacketSize < size) { | 47 while (i + kMinPacketSize < size) { |
| 77 size_t payload_size = ByteReader<size_t>::ReadBigEndian(&data[i]) % 1500; | 48 size_t payload_size = ByteReader<size_t>::ReadBigEndian(&data[i]) % 1500; |
| 78 i += sizeof(size_t); | 49 i += sizeof(size_t); |
| 79 header.extension.transportSequenceNumber = | 50 header.extension.transportSequenceNumber = |
| 80 ByteReader<uint16_t>::ReadBigEndian(&data[i]); | 51 ByteReader<uint16_t>::ReadBigEndian(&data[i]); |
| 81 i += sizeof(uint16_t); | 52 i += sizeof(uint16_t); |
| 82 rbe->IncomingPacket(arrival_time_ms, payload_size, header); | 53 rbe->IncomingPacket(arrival_time_ms, payload_size, header); |
| 83 clock.AdvanceTimeMilliseconds(5); | 54 clock.AdvanceTimeMilliseconds(5); |
| 84 arrival_time_ms += ByteReader<uint8_t>::ReadBigEndian(&data[i]); | 55 arrival_time_ms += ByteReader<uint8_t>::ReadBigEndian(&data[i]); |
| 85 arrival_time_ms += sizeof(uint8_t); | 56 arrival_time_ms += sizeof(uint8_t); |
| 86 } | 57 } |
| 87 rbe->Process(); | 58 rbe->Process(); |
| 88 } | 59 } |
| 89 } // namespace webrtc | 60 } // namespace webrtc |
| OLD | NEW |