1 /* 2 * Copyright (c) 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 11 #ifndef LOGGING_RTC_EVENT_LOG_EVENTS_RTC_EVENT_GENERIC_ACK_RECEIVED_H_ 12 #define LOGGING_RTC_EVENT_LOG_EVENTS_RTC_EVENT_GENERIC_ACK_RECEIVED_H_ 13 14 #include <memory> 15 #include <vector> 16 17 #include "absl/types/optional.h" 18 #include "api/rtc_event_log/rtc_event.h" 19 20 namespace webrtc { 21 22 struct AckedPacket { 23 // The packet number that was acked. 24 int64_t packet_number; 25 26 // The time where the packet was received. Not every ACK will 27 // include the receive timestamp. 28 absl::optional<int64_t> receive_acked_packet_time_ms; 29 }; 30 31 class RtcEventGenericAckReceived final : public RtcEvent { 32 public: 33 // For a collection of acked packets, it creates a vector of logs to log with 34 // the same timestamp. 35 static std::vector<std::unique_ptr<RtcEventGenericAckReceived>> CreateLogs( 36 int64_t packet_number, 37 const std::vector<AckedPacket>& acked_packets); 38 39 ~RtcEventGenericAckReceived() override; 40 41 std::unique_ptr<RtcEventGenericAckReceived> Copy() const; 42 43 Type GetType() const override; 44 45 bool IsConfigEvent() const override; 46 47 // An identifier of the packet which contained an ack. packet_number()48 int64_t packet_number() const { return packet_number_; } 49 50 // An identifier of the acked packet. acked_packet_number()51 int64_t acked_packet_number() const { return acked_packet_number_; } 52 53 // Timestamp when the |acked_packet_number| was received by the remote side. receive_acked_packet_time_ms()54 absl::optional<int64_t> receive_acked_packet_time_ms() const { 55 return receive_acked_packet_time_ms_; 56 } 57 58 private: 59 RtcEventGenericAckReceived(const RtcEventGenericAckReceived& packet); 60 61 // When the ack is received, |packet_number| identifies the packet which 62 // contained an ack for |acked_packet_number|, and contains the 63 // |receive_acked_packet_time_ms| on which the |acked_packet_number| was 64 // received on the remote side. The |receive_acked_packet_time_ms| may be 65 // null. 66 RtcEventGenericAckReceived( 67 int64_t timestamp_us, 68 int64_t packet_number, 69 int64_t acked_packet_number, 70 absl::optional<int64_t> receive_acked_packet_time_ms); 71 72 const int64_t packet_number_; 73 const int64_t acked_packet_number_; 74 const absl::optional<int64_t> receive_acked_packet_time_ms_; 75 }; 76 77 } // namespace webrtc 78 79 #endif // LOGGING_RTC_EVENT_LOG_EVENTS_RTC_EVENT_GENERIC_ACK_RECEIVED_H_ 80