logged_events.h 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673
  1. /*
  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 LOGGING_RTC_EVENT_LOG_LOGGED_EVENTS_H_
  11. #define LOGGING_RTC_EVENT_LOG_LOGGED_EVENTS_H_
  12. #include <string>
  13. #include <vector>
  14. #include "absl/types/optional.h"
  15. #include "api/rtp_headers.h"
  16. #include "api/units/data_rate.h"
  17. #include "api/units/time_delta.h"
  18. #include "api/units/timestamp.h"
  19. #include "api/video/video_codec_type.h"
  20. #include "logging/rtc_event_log/events/rtc_event_dtls_transport_state.h"
  21. #include "logging/rtc_event_log/events/rtc_event_ice_candidate_pair.h"
  22. #include "logging/rtc_event_log/events/rtc_event_ice_candidate_pair_config.h"
  23. #include "logging/rtc_event_log/events/rtc_event_probe_result_failure.h"
  24. #include "logging/rtc_event_log/rtc_stream_config.h"
  25. #include "modules/audio_coding/audio_network_adaptor/include/audio_network_adaptor_config.h"
  26. #include "modules/remote_bitrate_estimator/include/bwe_defines.h"
  27. #include "modules/rtp_rtcp/source/rtcp_packet/extended_reports.h"
  28. #include "modules/rtp_rtcp/source/rtcp_packet/fir.h"
  29. #include "modules/rtp_rtcp/source/rtcp_packet/loss_notification.h"
  30. #include "modules/rtp_rtcp/source/rtcp_packet/nack.h"
  31. #include "modules/rtp_rtcp/source/rtcp_packet/pli.h"
  32. #include "modules/rtp_rtcp/source/rtcp_packet/receiver_report.h"
  33. #include "modules/rtp_rtcp/source/rtcp_packet/remb.h"
  34. #include "modules/rtp_rtcp/source/rtcp_packet/sender_report.h"
  35. #include "modules/rtp_rtcp/source/rtcp_packet/transport_feedback.h"
  36. namespace webrtc {
  37. // The different event types are deliberately POD. Analysis of large logs is
  38. // already resource intensive. The code simplifications that would be possible
  39. // possible by having a base class (containing e.g. the log time) are not
  40. // considered to outweigh the added memory and runtime overhead incurred by
  41. // adding a vptr.
  42. struct LoggedAlrStateEvent {
  43. LoggedAlrStateEvent() = default;
  44. LoggedAlrStateEvent(int64_t timestamp_us, bool in_alr)
  45. : timestamp_us(timestamp_us), in_alr(in_alr) {}
  46. int64_t log_time_us() const { return timestamp_us; }
  47. int64_t log_time_ms() const { return timestamp_us / 1000; }
  48. int64_t timestamp_us;
  49. bool in_alr;
  50. };
  51. struct LoggedAudioPlayoutEvent {
  52. LoggedAudioPlayoutEvent() = default;
  53. LoggedAudioPlayoutEvent(int64_t timestamp_us, uint32_t ssrc)
  54. : timestamp_us(timestamp_us), ssrc(ssrc) {}
  55. int64_t log_time_us() const { return timestamp_us; }
  56. int64_t log_time_ms() const { return timestamp_us / 1000; }
  57. int64_t timestamp_us;
  58. uint32_t ssrc;
  59. };
  60. struct LoggedAudioNetworkAdaptationEvent {
  61. LoggedAudioNetworkAdaptationEvent() = default;
  62. LoggedAudioNetworkAdaptationEvent(int64_t timestamp_us,
  63. const AudioEncoderRuntimeConfig& config)
  64. : timestamp_us(timestamp_us), config(config) {}
  65. int64_t log_time_us() const { return timestamp_us; }
  66. int64_t log_time_ms() const { return timestamp_us / 1000; }
  67. int64_t timestamp_us;
  68. AudioEncoderRuntimeConfig config;
  69. };
  70. struct LoggedBweDelayBasedUpdate {
  71. LoggedBweDelayBasedUpdate() = default;
  72. LoggedBweDelayBasedUpdate(int64_t timestamp_us,
  73. int32_t bitrate_bps,
  74. BandwidthUsage detector_state)
  75. : timestamp_us(timestamp_us),
  76. bitrate_bps(bitrate_bps),
  77. detector_state(detector_state) {}
  78. int64_t log_time_us() const { return timestamp_us; }
  79. int64_t log_time_ms() const { return timestamp_us / 1000; }
  80. int64_t timestamp_us;
  81. int32_t bitrate_bps;
  82. BandwidthUsage detector_state;
  83. };
  84. struct LoggedBweLossBasedUpdate {
  85. LoggedBweLossBasedUpdate() = default;
  86. LoggedBweLossBasedUpdate(int64_t timestamp_us,
  87. int32_t bitrate_bps,
  88. uint8_t fraction_lost,
  89. int32_t expected_packets)
  90. : timestamp_us(timestamp_us),
  91. bitrate_bps(bitrate_bps),
  92. fraction_lost(fraction_lost),
  93. expected_packets(expected_packets) {}
  94. int64_t log_time_us() const { return timestamp_us; }
  95. int64_t log_time_ms() const { return timestamp_us / 1000; }
  96. int64_t timestamp_us;
  97. int32_t bitrate_bps;
  98. uint8_t fraction_lost;
  99. int32_t expected_packets;
  100. };
  101. struct LoggedDtlsTransportState {
  102. int64_t log_time_us() const { return timestamp_us; }
  103. int64_t log_time_ms() const { return timestamp_us / 1000; }
  104. int64_t timestamp_us;
  105. DtlsTransportState dtls_transport_state;
  106. };
  107. struct LoggedDtlsWritableState {
  108. LoggedDtlsWritableState() = default;
  109. explicit LoggedDtlsWritableState(bool writable) : writable(writable) {}
  110. int64_t log_time_us() const { return timestamp_us; }
  111. int64_t log_time_ms() const { return timestamp_us / 1000; }
  112. int64_t timestamp_us;
  113. bool writable;
  114. };
  115. struct LoggedBweProbeClusterCreatedEvent {
  116. LoggedBweProbeClusterCreatedEvent() = default;
  117. LoggedBweProbeClusterCreatedEvent(int64_t timestamp_us,
  118. int32_t id,
  119. int32_t bitrate_bps,
  120. uint32_t min_packets,
  121. uint32_t min_bytes)
  122. : timestamp_us(timestamp_us),
  123. id(id),
  124. bitrate_bps(bitrate_bps),
  125. min_packets(min_packets),
  126. min_bytes(min_bytes) {}
  127. int64_t log_time_us() const { return timestamp_us; }
  128. int64_t log_time_ms() const { return timestamp_us / 1000; }
  129. int64_t timestamp_us;
  130. int32_t id;
  131. int32_t bitrate_bps;
  132. uint32_t min_packets;
  133. uint32_t min_bytes;
  134. };
  135. struct LoggedBweProbeSuccessEvent {
  136. LoggedBweProbeSuccessEvent() = default;
  137. LoggedBweProbeSuccessEvent(int64_t timestamp_us,
  138. int32_t id,
  139. int32_t bitrate_bps)
  140. : timestamp_us(timestamp_us), id(id), bitrate_bps(bitrate_bps) {}
  141. int64_t log_time_us() const { return timestamp_us; }
  142. int64_t log_time_ms() const { return timestamp_us / 1000; }
  143. int64_t timestamp_us;
  144. int32_t id;
  145. int32_t bitrate_bps;
  146. };
  147. struct LoggedBweProbeFailureEvent {
  148. LoggedBweProbeFailureEvent() = default;
  149. LoggedBweProbeFailureEvent(int64_t timestamp_us,
  150. int32_t id,
  151. ProbeFailureReason failure_reason)
  152. : timestamp_us(timestamp_us), id(id), failure_reason(failure_reason) {}
  153. int64_t log_time_us() const { return timestamp_us; }
  154. int64_t log_time_ms() const { return timestamp_us / 1000; }
  155. int64_t timestamp_us;
  156. int32_t id;
  157. ProbeFailureReason failure_reason;
  158. };
  159. struct LoggedFrameDecoded {
  160. int64_t log_time_us() const { return timestamp_us; }
  161. int64_t log_time_ms() const { return timestamp_us / 1000; }
  162. int64_t timestamp_us;
  163. int64_t render_time_ms;
  164. uint32_t ssrc;
  165. int width;
  166. int height;
  167. VideoCodecType codec;
  168. uint8_t qp;
  169. };
  170. struct LoggedIceCandidatePairConfig {
  171. int64_t log_time_us() const { return timestamp_us; }
  172. int64_t log_time_ms() const { return timestamp_us / 1000; }
  173. int64_t timestamp_us;
  174. IceCandidatePairConfigType type;
  175. uint32_t candidate_pair_id;
  176. IceCandidateType local_candidate_type;
  177. IceCandidatePairProtocol local_relay_protocol;
  178. IceCandidateNetworkType local_network_type;
  179. IceCandidatePairAddressFamily local_address_family;
  180. IceCandidateType remote_candidate_type;
  181. IceCandidatePairAddressFamily remote_address_family;
  182. IceCandidatePairProtocol candidate_pair_protocol;
  183. };
  184. struct LoggedIceCandidatePairEvent {
  185. LoggedIceCandidatePairEvent() = default;
  186. LoggedIceCandidatePairEvent(int64_t timestamp_us,
  187. IceCandidatePairEventType type,
  188. uint32_t candidate_pair_id,
  189. uint32_t transaction_id)
  190. : timestamp_us(timestamp_us),
  191. type(type),
  192. candidate_pair_id(candidate_pair_id),
  193. transaction_id(transaction_id) {}
  194. int64_t log_time_us() const { return timestamp_us; }
  195. int64_t log_time_ms() const { return timestamp_us / 1000; }
  196. int64_t timestamp_us;
  197. IceCandidatePairEventType type;
  198. uint32_t candidate_pair_id;
  199. uint32_t transaction_id;
  200. };
  201. struct LoggedRouteChangeEvent {
  202. LoggedRouteChangeEvent() = default;
  203. LoggedRouteChangeEvent(int64_t timestamp_ms,
  204. bool connected,
  205. uint32_t overhead)
  206. : timestamp_ms(timestamp_ms), connected(connected), overhead(overhead) {}
  207. int64_t log_time_us() const { return timestamp_ms * 1000; }
  208. int64_t log_time_ms() const { return timestamp_ms; }
  209. int64_t timestamp_ms;
  210. bool connected;
  211. uint32_t overhead;
  212. };
  213. struct LoggedRemoteEstimateEvent {
  214. LoggedRemoteEstimateEvent() = default;
  215. int64_t log_time_us() const { return timestamp_ms * 1000; }
  216. int64_t log_time_ms() const { return timestamp_ms; }
  217. int64_t timestamp_ms;
  218. absl::optional<DataRate> link_capacity_lower;
  219. absl::optional<DataRate> link_capacity_upper;
  220. };
  221. struct LoggedRtpPacket {
  222. LoggedRtpPacket(int64_t timestamp_us,
  223. RTPHeader header,
  224. size_t header_length,
  225. size_t total_length)
  226. : timestamp_us(timestamp_us),
  227. header(header),
  228. header_length(header_length),
  229. total_length(total_length) {}
  230. int64_t log_time_us() const { return timestamp_us; }
  231. int64_t log_time_ms() const { return timestamp_us / 1000; }
  232. int64_t timestamp_us;
  233. // TODO(terelius): This allocates space for 15 CSRCs even if none are used.
  234. RTPHeader header;
  235. size_t header_length;
  236. size_t total_length;
  237. };
  238. struct LoggedRtpPacketIncoming {
  239. LoggedRtpPacketIncoming(int64_t timestamp_us,
  240. RTPHeader header,
  241. size_t header_length,
  242. size_t total_length)
  243. : rtp(timestamp_us, header, header_length, total_length) {}
  244. int64_t log_time_us() const { return rtp.timestamp_us; }
  245. int64_t log_time_ms() const { return rtp.timestamp_us / 1000; }
  246. LoggedRtpPacket rtp;
  247. };
  248. struct LoggedRtpPacketOutgoing {
  249. LoggedRtpPacketOutgoing(int64_t timestamp_us,
  250. RTPHeader header,
  251. size_t header_length,
  252. size_t total_length)
  253. : rtp(timestamp_us, header, header_length, total_length) {}
  254. int64_t log_time_us() const { return rtp.timestamp_us; }
  255. int64_t log_time_ms() const { return rtp.timestamp_us / 1000; }
  256. LoggedRtpPacket rtp;
  257. };
  258. struct LoggedRtcpPacket {
  259. LoggedRtcpPacket(int64_t timestamp_us,
  260. const uint8_t* packet,
  261. size_t total_length);
  262. LoggedRtcpPacket(int64_t timestamp_us, const std::string& packet);
  263. LoggedRtcpPacket(const LoggedRtcpPacket&);
  264. ~LoggedRtcpPacket();
  265. int64_t log_time_us() const { return timestamp_us; }
  266. int64_t log_time_ms() const { return timestamp_us / 1000; }
  267. int64_t timestamp_us;
  268. std::vector<uint8_t> raw_data;
  269. };
  270. struct LoggedRtcpPacketIncoming {
  271. LoggedRtcpPacketIncoming(int64_t timestamp_us,
  272. const uint8_t* packet,
  273. size_t total_length)
  274. : rtcp(timestamp_us, packet, total_length) {}
  275. LoggedRtcpPacketIncoming(uint64_t timestamp_us, const std::string& packet)
  276. : rtcp(timestamp_us, packet) {}
  277. int64_t log_time_us() const { return rtcp.timestamp_us; }
  278. int64_t log_time_ms() const { return rtcp.timestamp_us / 1000; }
  279. LoggedRtcpPacket rtcp;
  280. };
  281. struct LoggedRtcpPacketOutgoing {
  282. LoggedRtcpPacketOutgoing(int64_t timestamp_us,
  283. const uint8_t* packet,
  284. size_t total_length)
  285. : rtcp(timestamp_us, packet, total_length) {}
  286. LoggedRtcpPacketOutgoing(uint64_t timestamp_us, const std::string& packet)
  287. : rtcp(timestamp_us, packet) {}
  288. int64_t log_time_us() const { return rtcp.timestamp_us; }
  289. int64_t log_time_ms() const { return rtcp.timestamp_us / 1000; }
  290. LoggedRtcpPacket rtcp;
  291. };
  292. struct LoggedRtcpPacketReceiverReport {
  293. LoggedRtcpPacketReceiverReport() = default;
  294. LoggedRtcpPacketReceiverReport(int64_t timestamp_us,
  295. const rtcp::ReceiverReport& rr)
  296. : timestamp_us(timestamp_us), rr(rr) {}
  297. int64_t log_time_us() const { return timestamp_us; }
  298. int64_t log_time_ms() const { return timestamp_us / 1000; }
  299. int64_t timestamp_us;
  300. rtcp::ReceiverReport rr;
  301. };
  302. struct LoggedRtcpPacketSenderReport {
  303. LoggedRtcpPacketSenderReport() = default;
  304. LoggedRtcpPacketSenderReport(int64_t timestamp_us,
  305. const rtcp::SenderReport& sr)
  306. : timestamp_us(timestamp_us), sr(sr) {}
  307. int64_t log_time_us() const { return timestamp_us; }
  308. int64_t log_time_ms() const { return timestamp_us / 1000; }
  309. int64_t timestamp_us;
  310. rtcp::SenderReport sr;
  311. };
  312. struct LoggedRtcpPacketExtendedReports {
  313. LoggedRtcpPacketExtendedReports() = default;
  314. int64_t log_time_us() const { return timestamp_us; }
  315. int64_t log_time_ms() const { return timestamp_us / 1000; }
  316. int64_t timestamp_us;
  317. rtcp::ExtendedReports xr;
  318. };
  319. struct LoggedRtcpPacketRemb {
  320. LoggedRtcpPacketRemb() = default;
  321. LoggedRtcpPacketRemb(int64_t timestamp_us, const rtcp::Remb& remb)
  322. : timestamp_us(timestamp_us), remb(remb) {}
  323. int64_t log_time_us() const { return timestamp_us; }
  324. int64_t log_time_ms() const { return timestamp_us / 1000; }
  325. int64_t timestamp_us;
  326. rtcp::Remb remb;
  327. };
  328. struct LoggedRtcpPacketNack {
  329. LoggedRtcpPacketNack() = default;
  330. LoggedRtcpPacketNack(int64_t timestamp_us, const rtcp::Nack& nack)
  331. : timestamp_us(timestamp_us), nack(nack) {}
  332. int64_t log_time_us() const { return timestamp_us; }
  333. int64_t log_time_ms() const { return timestamp_us / 1000; }
  334. int64_t timestamp_us;
  335. rtcp::Nack nack;
  336. };
  337. struct LoggedRtcpPacketFir {
  338. LoggedRtcpPacketFir() = default;
  339. int64_t log_time_us() const { return timestamp_us; }
  340. int64_t log_time_ms() const { return timestamp_us / 1000; }
  341. int64_t timestamp_us;
  342. rtcp::Fir fir;
  343. };
  344. struct LoggedRtcpPacketPli {
  345. LoggedRtcpPacketPli() = default;
  346. int64_t log_time_us() const { return timestamp_us; }
  347. int64_t log_time_ms() const { return timestamp_us / 1000; }
  348. int64_t timestamp_us;
  349. rtcp::Pli pli;
  350. };
  351. struct LoggedRtcpPacketTransportFeedback {
  352. LoggedRtcpPacketTransportFeedback()
  353. : transport_feedback(/*include_timestamps=*/true, /*include_lost*/ true) {
  354. }
  355. LoggedRtcpPacketTransportFeedback(
  356. int64_t timestamp_us,
  357. const rtcp::TransportFeedback& transport_feedback)
  358. : timestamp_us(timestamp_us), transport_feedback(transport_feedback) {}
  359. int64_t log_time_us() const { return timestamp_us; }
  360. int64_t log_time_ms() const { return timestamp_us / 1000; }
  361. int64_t timestamp_us;
  362. rtcp::TransportFeedback transport_feedback;
  363. };
  364. struct LoggedRtcpPacketLossNotification {
  365. LoggedRtcpPacketLossNotification() = default;
  366. LoggedRtcpPacketLossNotification(
  367. int64_t timestamp_us,
  368. const rtcp::LossNotification& loss_notification)
  369. : timestamp_us(timestamp_us), loss_notification(loss_notification) {}
  370. int64_t log_time_us() const { return timestamp_us; }
  371. int64_t log_time_ms() const { return timestamp_us / 1000; }
  372. int64_t timestamp_us;
  373. rtcp::LossNotification loss_notification;
  374. };
  375. struct LoggedStartEvent {
  376. explicit LoggedStartEvent(int64_t timestamp_us)
  377. : LoggedStartEvent(timestamp_us, timestamp_us / 1000) {}
  378. LoggedStartEvent(int64_t timestamp_us, int64_t utc_start_time_ms)
  379. : timestamp_us(timestamp_us), utc_start_time_ms(utc_start_time_ms) {}
  380. int64_t log_time_us() const { return timestamp_us; }
  381. int64_t log_time_ms() const { return timestamp_us / 1000; }
  382. int64_t timestamp_us;
  383. int64_t utc_start_time_ms;
  384. };
  385. struct LoggedStopEvent {
  386. explicit LoggedStopEvent(int64_t timestamp_us) : timestamp_us(timestamp_us) {}
  387. int64_t log_time_us() const { return timestamp_us; }
  388. int64_t log_time_ms() const { return timestamp_us / 1000; }
  389. int64_t timestamp_us;
  390. };
  391. struct LoggedAudioRecvConfig {
  392. LoggedAudioRecvConfig() = default;
  393. LoggedAudioRecvConfig(int64_t timestamp_us, const rtclog::StreamConfig config)
  394. : timestamp_us(timestamp_us), config(config) {}
  395. int64_t log_time_us() const { return timestamp_us; }
  396. int64_t log_time_ms() const { return timestamp_us / 1000; }
  397. int64_t timestamp_us;
  398. rtclog::StreamConfig config;
  399. };
  400. struct LoggedAudioSendConfig {
  401. LoggedAudioSendConfig() = default;
  402. LoggedAudioSendConfig(int64_t timestamp_us, const rtclog::StreamConfig config)
  403. : timestamp_us(timestamp_us), config(config) {}
  404. int64_t log_time_us() const { return timestamp_us; }
  405. int64_t log_time_ms() const { return timestamp_us / 1000; }
  406. int64_t timestamp_us;
  407. rtclog::StreamConfig config;
  408. };
  409. struct LoggedVideoRecvConfig {
  410. LoggedVideoRecvConfig() = default;
  411. LoggedVideoRecvConfig(int64_t timestamp_us, const rtclog::StreamConfig config)
  412. : timestamp_us(timestamp_us), config(config) {}
  413. int64_t log_time_us() const { return timestamp_us; }
  414. int64_t log_time_ms() const { return timestamp_us / 1000; }
  415. int64_t timestamp_us;
  416. rtclog::StreamConfig config;
  417. };
  418. struct LoggedVideoSendConfig {
  419. LoggedVideoSendConfig() = default;
  420. LoggedVideoSendConfig(int64_t timestamp_us, const rtclog::StreamConfig config)
  421. : timestamp_us(timestamp_us), config(config) {}
  422. int64_t log_time_us() const { return timestamp_us; }
  423. int64_t log_time_ms() const { return timestamp_us / 1000; }
  424. int64_t timestamp_us;
  425. rtclog::StreamConfig config;
  426. };
  427. struct InferredRouteChangeEvent {
  428. int64_t log_time_ms() const { return log_time.ms(); }
  429. int64_t log_time_us() const { return log_time.us(); }
  430. uint32_t route_id;
  431. Timestamp log_time = Timestamp::MinusInfinity();
  432. uint16_t send_overhead;
  433. uint16_t return_overhead;
  434. };
  435. enum class LoggedMediaType : uint8_t { kUnknown, kAudio, kVideo };
  436. struct LoggedPacketInfo {
  437. LoggedPacketInfo(const LoggedRtpPacket& rtp,
  438. LoggedMediaType media_type,
  439. bool rtx,
  440. Timestamp capture_time);
  441. LoggedPacketInfo(const LoggedPacketInfo&);
  442. ~LoggedPacketInfo();
  443. int64_t log_time_ms() const { return log_packet_time.ms(); }
  444. int64_t log_time_us() const { return log_packet_time.us(); }
  445. uint32_t ssrc;
  446. uint16_t stream_seq_no;
  447. uint16_t size;
  448. uint16_t payload_size;
  449. uint16_t padding_size;
  450. uint16_t overhead = 0;
  451. uint8_t payload_type;
  452. LoggedMediaType media_type = LoggedMediaType::kUnknown;
  453. bool rtx = false;
  454. bool marker_bit = false;
  455. bool has_transport_seq_no = false;
  456. bool last_in_feedback = false;
  457. uint16_t transport_seq_no = 0;
  458. // The RTP header timestamp unwrapped and converted from tick count to seconds
  459. // based timestamp.
  460. Timestamp capture_time;
  461. // The time the packet was logged. This is the receive time for incoming
  462. // packets and send time for outgoing.
  463. Timestamp log_packet_time;
  464. // Send time as reported by abs-send-time extension, For outgoing packets this
  465. // corresponds to log_packet_time, but might be measured using another clock.
  466. Timestamp reported_send_time;
  467. // The receive time that was reported in feedback. For incoming packets this
  468. // corresponds to log_packet_time, but might be measured using another clock.
  469. // PlusInfinity indicates that the packet was lost.
  470. Timestamp reported_recv_time = Timestamp::MinusInfinity();
  471. // The time feedback message was logged. This is the feedback send time for
  472. // incoming packets and feedback receive time for outgoing.
  473. // PlusInfinity indicates that feedback was expected but not received.
  474. Timestamp log_feedback_time = Timestamp::MinusInfinity();
  475. // The delay betweeen receiving an RTP packet and sending feedback for
  476. // incoming packets. For outgoing packets we don't know the feedback send
  477. // time, and this is instead calculated as the difference in reported receive
  478. // time between this packet and the last packet in the same feedback message.
  479. TimeDelta feedback_hold_duration = TimeDelta::MinusInfinity();
  480. };
  481. enum class LoggedIceEventType {
  482. kAdded,
  483. kUpdated,
  484. kDestroyed,
  485. kSelected,
  486. kCheckSent,
  487. kCheckReceived,
  488. kCheckResponseSent,
  489. kCheckResponseReceived,
  490. };
  491. struct LoggedIceEvent {
  492. uint32_t candidate_pair_id;
  493. Timestamp log_time;
  494. LoggedIceEventType event_type;
  495. };
  496. struct LoggedGenericPacketSent {
  497. LoggedGenericPacketSent() = default;
  498. LoggedGenericPacketSent(int64_t timestamp_us,
  499. int64_t packet_number,
  500. size_t overhead_length,
  501. size_t payload_length,
  502. size_t padding_length)
  503. : timestamp_us(timestamp_us),
  504. packet_number(packet_number),
  505. overhead_length(overhead_length),
  506. payload_length(payload_length),
  507. padding_length(padding_length) {}
  508. int64_t log_time_us() const { return timestamp_us; }
  509. int64_t log_time_ms() const { return timestamp_us / 1000; }
  510. size_t packet_length() const {
  511. return payload_length + padding_length + overhead_length;
  512. }
  513. int64_t timestamp_us;
  514. int64_t packet_number;
  515. size_t overhead_length;
  516. size_t payload_length;
  517. size_t padding_length;
  518. };
  519. struct LoggedGenericPacketReceived {
  520. LoggedGenericPacketReceived() = default;
  521. LoggedGenericPacketReceived(int64_t timestamp_us,
  522. int64_t packet_number,
  523. int packet_length)
  524. : timestamp_us(timestamp_us),
  525. packet_number(packet_number),
  526. packet_length(packet_length) {}
  527. int64_t log_time_us() const { return timestamp_us; }
  528. int64_t log_time_ms() const { return timestamp_us / 1000; }
  529. int64_t timestamp_us;
  530. int64_t packet_number;
  531. int packet_length;
  532. };
  533. struct LoggedGenericAckReceived {
  534. LoggedGenericAckReceived() = default;
  535. LoggedGenericAckReceived(int64_t timestamp_us,
  536. int64_t packet_number,
  537. int64_t acked_packet_number,
  538. absl::optional<int64_t> receive_acked_packet_time_ms)
  539. : timestamp_us(timestamp_us),
  540. packet_number(packet_number),
  541. acked_packet_number(acked_packet_number),
  542. receive_acked_packet_time_ms(receive_acked_packet_time_ms) {}
  543. int64_t log_time_us() const { return timestamp_us; }
  544. int64_t log_time_ms() const { return timestamp_us / 1000; }
  545. int64_t timestamp_us;
  546. int64_t packet_number;
  547. int64_t acked_packet_number;
  548. absl::optional<int64_t> receive_acked_packet_time_ms;
  549. };
  550. } // namespace webrtc
  551. #endif // LOGGING_RTC_EVENT_LOG_LOGGED_EVENTS_H_