blob: f891db62c0546085936d794a8e49cea5cd3ed263 [file] [log] [blame]
Sebastian Jansson1175ae02019-03-13 08:56:58 +01001/*
2 * Copyright 2019 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 RTC_TOOLS_EVENT_LOG_VISUALIZER_LOG_SIMULATION_H_
11#define RTC_TOOLS_EVENT_LOG_VISUALIZER_LOG_SIMULATION_H_
12
13#include <deque>
14#include <functional>
15#include <map>
16#include <memory>
17#include <vector>
18
19#include "api/transport/network_control.h"
20#include "logging/rtc_event_log/rtc_event_log_parser.h"
21#include "modules/congestion_controller/rtp/transport_feedback_adapter.h"
22
23namespace webrtc {
24
25class LogBasedNetworkControllerSimulation {
26 public:
27 explicit LogBasedNetworkControllerSimulation(
28 std::unique_ptr<NetworkControllerFactoryInterface> factory,
29 std::function<void(const NetworkControlUpdate&, Timestamp)>
30 update_handler);
31 ~LogBasedNetworkControllerSimulation();
32 void ProcessEventsInLog(const ParsedRtcEventLog& parsed_log_);
33
34 private:
35 struct ProbingStatus {
36 const LoggedBweProbeClusterCreatedEvent event;
37 size_t bytes_sent;
38 size_t packets_sent;
39 };
40 void HandleStateUpdate(const NetworkControlUpdate& update);
41 void ProcessUntil(Timestamp to_time);
42
43 void OnProbeCreated(const LoggedBweProbeClusterCreatedEvent& probe_cluster);
44 void OnPacketSent(const LoggedPacketInfo& packet);
45 void OnFeedback(const LoggedRtcpPacketTransportFeedback& feedback);
46 void OnReceiverReport(const LoggedRtcpPacketReceiverReport& report);
47 void OnIceConfig(const LoggedIceCandidatePairConfig& candidate);
48
49 const std::function<void(const NetworkControlUpdate&, Timestamp)>
50 update_handler_;
51 std::unique_ptr<NetworkControllerFactoryInterface> factory_;
52 std::unique_ptr<NetworkControllerInterface> controller_;
53
54 Timestamp current_time_ = Timestamp::MinusInfinity();
55 Timestamp last_process_ = Timestamp::MinusInfinity();
56 TransportFeedbackAdapter transport_feedback_;
57 std::deque<ProbingStatus> pending_probes_;
58 std::map<uint32_t, rtcp::ReportBlock> last_report_blocks_;
59 Timestamp last_report_block_time_ = Timestamp::MinusInfinity();
60};
61} // namespace webrtc
62
63#endif // RTC_TOOLS_EVENT_LOG_VISUALIZER_LOG_SIMULATION_H_