blob: 480368dc99c75a77b34d4fae1580aa3c8c1b9298 [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 */
Mirko Bonadei575998c2019-07-25 13:57:41 +020010#ifndef RTC_TOOLS_RTC_EVENT_LOG_VISUALIZER_LOG_SIMULATION_H_
11#define RTC_TOOLS_RTC_EVENT_LOG_VISUALIZER_LOG_SIMULATION_H_
Sebastian Jansson1175ae02019-03-13 08:56:58 +010012
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);
Sebastian Jansson2db5fc02019-04-30 14:17:45 +020048 RtcEventLogNullImpl null_event_log_;
Sebastian Jansson1175ae02019-03-13 08:56:58 +010049
50 const std::function<void(const NetworkControlUpdate&, Timestamp)>
51 update_handler_;
52 std::unique_ptr<NetworkControllerFactoryInterface> factory_;
53 std::unique_ptr<NetworkControllerInterface> controller_;
54
55 Timestamp current_time_ = Timestamp::MinusInfinity();
56 Timestamp last_process_ = Timestamp::MinusInfinity();
57 TransportFeedbackAdapter transport_feedback_;
58 std::deque<ProbingStatus> pending_probes_;
59 std::map<uint32_t, rtcp::ReportBlock> last_report_blocks_;
60 Timestamp last_report_block_time_ = Timestamp::MinusInfinity();
61};
62} // namespace webrtc
63
Mirko Bonadei575998c2019-07-25 13:57:41 +020064#endif // RTC_TOOLS_RTC_EVENT_LOG_VISUALIZER_LOG_SIMULATION_H_