1 /* 2 * Copyright 2018 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 #ifndef MODULES_CONGESTION_CONTROLLER_GOOG_CC_TEST_GOOG_CC_PRINTER_H_ 11 #define MODULES_CONGESTION_CONTROLLER_GOOG_CC_TEST_GOOG_CC_PRINTER_H_ 12 13 #include <deque> 14 #include <memory> 15 #include <string> 16 17 #include "api/rtc_event_log/rtc_event_log.h" 18 #include "api/transport/goog_cc_factory.h" 19 #include "api/transport/network_control.h" 20 #include "api/transport/network_types.h" 21 #include "api/units/timestamp.h" 22 #include "modules/congestion_controller/goog_cc/goog_cc_network_control.h" 23 #include "test/logging/log_writer.h" 24 25 namespace webrtc { 26 27 class FieldLogger { 28 public: 29 virtual ~FieldLogger() = default; 30 virtual const std::string& name() const = 0; 31 virtual void WriteValue(RtcEventLogOutput* out) = 0; 32 }; 33 34 class GoogCcStatePrinter { 35 public: 36 GoogCcStatePrinter(); 37 GoogCcStatePrinter(const GoogCcStatePrinter&) = delete; 38 GoogCcStatePrinter& operator=(const GoogCcStatePrinter&) = delete; 39 ~GoogCcStatePrinter(); 40 41 void PrintHeaders(RtcEventLogOutput* log); 42 void PrintState(RtcEventLogOutput* log, 43 GoogCcNetworkController* controller, 44 Timestamp at_time); 45 46 private: 47 std::deque<FieldLogger*> CreateLoggers(); 48 std::deque<std::unique_ptr<FieldLogger>> loggers_; 49 50 GoogCcNetworkController* controller_ = nullptr; 51 TargetTransferRate target_; 52 PacerConfig pacing_; 53 DataSize congestion_window_ = DataSize::PlusInfinity(); 54 NetworkStateEstimate est_; 55 }; 56 57 class GoogCcDebugFactory : public GoogCcNetworkControllerFactory { 58 public: 59 GoogCcDebugFactory(); 60 explicit GoogCcDebugFactory(GoogCcFactoryConfig config); 61 std::unique_ptr<NetworkControllerInterface> Create( 62 NetworkControllerConfig config) override; 63 64 void PrintState(Timestamp at_time); 65 66 void AttachWriter(std::unique_ptr<RtcEventLogOutput> log_writer); 67 68 private: 69 GoogCcStatePrinter printer_; 70 GoogCcNetworkController* controller_ = nullptr; 71 std::unique_ptr<RtcEventLogOutput> log_writer_; 72 }; 73 } // namespace webrtc 74 75 #endif // MODULES_CONGESTION_CONTROLLER_GOOG_CC_TEST_GOOG_CC_PRINTER_H_ 76