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 13 #include <string> 14 #include <vector> 15 16 #include "absl/types/optional.h" 17 #include "api/rtp_headers.h" 18 #include "api/units/data_rate.h" 19 #include "api/units/time_delta.h" 20 #include "api/units/timestamp.h" 21 #include "logging/rtc_event_log/events/rtc_event_dtls_transport_state.h" 22 #include "logging/rtc_event_log/events/rtc_event_ice_candidate_pair.h" 23 #include "logging/rtc_event_log/events/rtc_event_ice_candidate_pair_config.h" 24 #include "logging/rtc_event_log/events/rtc_event_probe_result_failure.h" 25 #include "logging/rtc_event_log/rtc_stream_config.h" 26 #include "modules/audio_coding/audio_network_adaptor/include/audio_network_adaptor_config.h" 27 #include "modules/remote_bitrate_estimator/include/bwe_defines.h" 28 #include "modules/rtp_rtcp/source/rtcp_packet/extended_reports.h" 29 #include "modules/rtp_rtcp/source/rtcp_packet/fir.h" 30 #include "modules/rtp_rtcp/source/rtcp_packet/loss_notification.h" 31 #include "modules/rtp_rtcp/source/rtcp_packet/nack.h" 32 #include "modules/rtp_rtcp/source/rtcp_packet/pli.h" 33 #include "modules/rtp_rtcp/source/rtcp_packet/receiver_report.h" 34 #include "modules/rtp_rtcp/source/rtcp_packet/remb.h" 35 #include "modules/rtp_rtcp/source/rtcp_packet/sender_report.h" 36 #include "modules/rtp_rtcp/source/rtcp_packet/transport_feedback.h" 37 38 namespace webrtc { 39 40 // The different event types are deliberately POD. Analysis of large logs is 41 // already resource intensive. The code simplifications that would be possible 42 // possible by having a base class (containing e.g. the log time) are not 43 // considered to outweigh the added memory and runtime overhead incurred by 44 // adding a vptr. 45 struct LoggedAlrStateEvent { 46 LoggedAlrStateEvent() = default; LoggedAlrStateEventLoggedAlrStateEvent47 LoggedAlrStateEvent(int64_t timestamp_us, bool in_alr) 48 : timestamp_us(timestamp_us), in_alr(in_alr) {} 49 log_time_usLoggedAlrStateEvent50 int64_t log_time_us() const { return timestamp_us; } log_time_msLoggedAlrStateEvent51 int64_t log_time_ms() const { return timestamp_us / 1000; } 52 53 int64_t timestamp_us; 54 bool in_alr; 55 }; 56 57 struct LoggedAudioPlayoutEvent { 58 LoggedAudioPlayoutEvent() = default; LoggedAudioPlayoutEventLoggedAudioPlayoutEvent59 LoggedAudioPlayoutEvent(int64_t timestamp_us, uint32_t ssrc) 60 : timestamp_us(timestamp_us), ssrc(ssrc) {} 61 log_time_usLoggedAudioPlayoutEvent62 int64_t log_time_us() const { return timestamp_us; } log_time_msLoggedAudioPlayoutEvent63 int64_t log_time_ms() const { return timestamp_us / 1000; } 64 65 int64_t timestamp_us; 66 uint32_t ssrc; 67 }; 68 69 struct LoggedAudioNetworkAdaptationEvent { 70 LoggedAudioNetworkAdaptationEvent() = default; LoggedAudioNetworkAdaptationEventLoggedAudioNetworkAdaptationEvent71 LoggedAudioNetworkAdaptationEvent(int64_t timestamp_us, 72 const AudioEncoderRuntimeConfig& config) 73 : timestamp_us(timestamp_us), config(config) {} 74 log_time_usLoggedAudioNetworkAdaptationEvent75 int64_t log_time_us() const { return timestamp_us; } log_time_msLoggedAudioNetworkAdaptationEvent76 int64_t log_time_ms() const { return timestamp_us / 1000; } 77 78 int64_t timestamp_us; 79 AudioEncoderRuntimeConfig config; 80 }; 81 82 struct LoggedBweDelayBasedUpdate { 83 LoggedBweDelayBasedUpdate() = default; LoggedBweDelayBasedUpdateLoggedBweDelayBasedUpdate84 LoggedBweDelayBasedUpdate(int64_t timestamp_us, 85 int32_t bitrate_bps, 86 BandwidthUsage detector_state) 87 : timestamp_us(timestamp_us), 88 bitrate_bps(bitrate_bps), 89 detector_state(detector_state) {} 90 log_time_usLoggedBweDelayBasedUpdate91 int64_t log_time_us() const { return timestamp_us; } log_time_msLoggedBweDelayBasedUpdate92 int64_t log_time_ms() const { return timestamp_us / 1000; } 93 94 int64_t timestamp_us; 95 int32_t bitrate_bps; 96 BandwidthUsage detector_state; 97 }; 98 99 struct LoggedBweLossBasedUpdate { 100 LoggedBweLossBasedUpdate() = default; LoggedBweLossBasedUpdateLoggedBweLossBasedUpdate101 LoggedBweLossBasedUpdate(int64_t timestamp_us, 102 int32_t bitrate_bps, 103 uint8_t fraction_lost, 104 int32_t expected_packets) 105 : timestamp_us(timestamp_us), 106 bitrate_bps(bitrate_bps), 107 fraction_lost(fraction_lost), 108 expected_packets(expected_packets) {} 109 log_time_usLoggedBweLossBasedUpdate110 int64_t log_time_us() const { return timestamp_us; } log_time_msLoggedBweLossBasedUpdate111 int64_t log_time_ms() const { return timestamp_us / 1000; } 112 113 int64_t timestamp_us; 114 int32_t bitrate_bps; 115 uint8_t fraction_lost; 116 int32_t expected_packets; 117 }; 118 119 struct LoggedDtlsTransportState { log_time_usLoggedDtlsTransportState120 int64_t log_time_us() const { return timestamp_us; } log_time_msLoggedDtlsTransportState121 int64_t log_time_ms() const { return timestamp_us / 1000; } 122 123 int64_t timestamp_us; 124 DtlsTransportState dtls_transport_state; 125 }; 126 127 struct LoggedDtlsWritableState { 128 LoggedDtlsWritableState() = default; LoggedDtlsWritableStateLoggedDtlsWritableState129 explicit LoggedDtlsWritableState(bool writable) : writable(writable) {} 130 log_time_usLoggedDtlsWritableState131 int64_t log_time_us() const { return timestamp_us; } log_time_msLoggedDtlsWritableState132 int64_t log_time_ms() const { return timestamp_us / 1000; } 133 134 int64_t timestamp_us; 135 bool writable; 136 }; 137 138 struct LoggedBweProbeClusterCreatedEvent { 139 LoggedBweProbeClusterCreatedEvent() = default; LoggedBweProbeClusterCreatedEventLoggedBweProbeClusterCreatedEvent140 LoggedBweProbeClusterCreatedEvent(int64_t timestamp_us, 141 int32_t id, 142 int32_t bitrate_bps, 143 uint32_t min_packets, 144 uint32_t min_bytes) 145 : timestamp_us(timestamp_us), 146 id(id), 147 bitrate_bps(bitrate_bps), 148 min_packets(min_packets), 149 min_bytes(min_bytes) {} 150 log_time_usLoggedBweProbeClusterCreatedEvent151 int64_t log_time_us() const { return timestamp_us; } log_time_msLoggedBweProbeClusterCreatedEvent152 int64_t log_time_ms() const { return timestamp_us / 1000; } 153 154 int64_t timestamp_us; 155 int32_t id; 156 int32_t bitrate_bps; 157 uint32_t min_packets; 158 uint32_t min_bytes; 159 }; 160 161 struct LoggedBweProbeSuccessEvent { 162 LoggedBweProbeSuccessEvent() = default; LoggedBweProbeSuccessEventLoggedBweProbeSuccessEvent163 LoggedBweProbeSuccessEvent(int64_t timestamp_us, 164 int32_t id, 165 int32_t bitrate_bps) 166 : timestamp_us(timestamp_us), id(id), bitrate_bps(bitrate_bps) {} 167 log_time_usLoggedBweProbeSuccessEvent168 int64_t log_time_us() const { return timestamp_us; } log_time_msLoggedBweProbeSuccessEvent169 int64_t log_time_ms() const { return timestamp_us / 1000; } 170 171 int64_t timestamp_us; 172 int32_t id; 173 int32_t bitrate_bps; 174 }; 175 176 struct LoggedBweProbeFailureEvent { 177 LoggedBweProbeFailureEvent() = default; LoggedBweProbeFailureEventLoggedBweProbeFailureEvent178 LoggedBweProbeFailureEvent(int64_t timestamp_us, 179 int32_t id, 180 ProbeFailureReason failure_reason) 181 : timestamp_us(timestamp_us), id(id), failure_reason(failure_reason) {} 182 log_time_usLoggedBweProbeFailureEvent183 int64_t log_time_us() const { return timestamp_us; } log_time_msLoggedBweProbeFailureEvent184 int64_t log_time_ms() const { return timestamp_us / 1000; } 185 186 int64_t timestamp_us; 187 int32_t id; 188 ProbeFailureReason failure_reason; 189 }; 190 191 struct LoggedIceCandidatePairConfig { log_time_usLoggedIceCandidatePairConfig192 int64_t log_time_us() const { return timestamp_us; } log_time_msLoggedIceCandidatePairConfig193 int64_t log_time_ms() const { return timestamp_us / 1000; } 194 195 int64_t timestamp_us; 196 IceCandidatePairConfigType type; 197 uint32_t candidate_pair_id; 198 IceCandidateType local_candidate_type; 199 IceCandidatePairProtocol local_relay_protocol; 200 IceCandidateNetworkType local_network_type; 201 IceCandidatePairAddressFamily local_address_family; 202 IceCandidateType remote_candidate_type; 203 IceCandidatePairAddressFamily remote_address_family; 204 IceCandidatePairProtocol candidate_pair_protocol; 205 }; 206 207 struct LoggedIceCandidatePairEvent { 208 LoggedIceCandidatePairEvent() = default; LoggedIceCandidatePairEventLoggedIceCandidatePairEvent209 LoggedIceCandidatePairEvent(int64_t timestamp_us, 210 IceCandidatePairEventType type, 211 uint32_t candidate_pair_id, 212 uint32_t transaction_id) 213 : timestamp_us(timestamp_us), 214 type(type), 215 candidate_pair_id(candidate_pair_id), 216 transaction_id(transaction_id) {} 217 log_time_usLoggedIceCandidatePairEvent218 int64_t log_time_us() const { return timestamp_us; } log_time_msLoggedIceCandidatePairEvent219 int64_t log_time_ms() const { return timestamp_us / 1000; } 220 221 int64_t timestamp_us; 222 IceCandidatePairEventType type; 223 uint32_t candidate_pair_id; 224 uint32_t transaction_id; 225 }; 226 227 struct LoggedRouteChangeEvent { 228 LoggedRouteChangeEvent() = default; LoggedRouteChangeEventLoggedRouteChangeEvent229 LoggedRouteChangeEvent(int64_t timestamp_ms, 230 bool connected, 231 uint32_t overhead) 232 : timestamp_ms(timestamp_ms), connected(connected), overhead(overhead) {} 233 log_time_usLoggedRouteChangeEvent234 int64_t log_time_us() const { return timestamp_ms * 1000; } log_time_msLoggedRouteChangeEvent235 int64_t log_time_ms() const { return timestamp_ms; } 236 237 int64_t timestamp_ms; 238 bool connected; 239 uint32_t overhead; 240 }; 241 242 struct LoggedRemoteEstimateEvent { 243 LoggedRemoteEstimateEvent() = default; 244 log_time_usLoggedRemoteEstimateEvent245 int64_t log_time_us() const { return timestamp_ms * 1000; } log_time_msLoggedRemoteEstimateEvent246 int64_t log_time_ms() const { return timestamp_ms; } 247 248 int64_t timestamp_ms; 249 absl::optional<DataRate> link_capacity_lower; 250 absl::optional<DataRate> link_capacity_upper; 251 }; 252 253 struct LoggedRtpPacket { LoggedRtpPacketLoggedRtpPacket254 LoggedRtpPacket(int64_t timestamp_us, 255 RTPHeader header, 256 size_t header_length, 257 size_t total_length) 258 : timestamp_us(timestamp_us), 259 header(header), 260 header_length(header_length), 261 total_length(total_length) {} 262 log_time_usLoggedRtpPacket263 int64_t log_time_us() const { return timestamp_us; } log_time_msLoggedRtpPacket264 int64_t log_time_ms() const { return timestamp_us / 1000; } 265 266 int64_t timestamp_us; 267 // TODO(terelius): This allocates space for 15 CSRCs even if none are used. 268 RTPHeader header; 269 size_t header_length; 270 size_t total_length; 271 }; 272 273 struct LoggedRtpPacketIncoming { LoggedRtpPacketIncomingLoggedRtpPacketIncoming274 LoggedRtpPacketIncoming(int64_t timestamp_us, 275 RTPHeader header, 276 size_t header_length, 277 size_t total_length) 278 : rtp(timestamp_us, header, header_length, total_length) {} log_time_usLoggedRtpPacketIncoming279 int64_t log_time_us() const { return rtp.timestamp_us; } log_time_msLoggedRtpPacketIncoming280 int64_t log_time_ms() const { return rtp.timestamp_us / 1000; } 281 282 LoggedRtpPacket rtp; 283 }; 284 285 struct LoggedRtpPacketOutgoing { LoggedRtpPacketOutgoingLoggedRtpPacketOutgoing286 LoggedRtpPacketOutgoing(int64_t timestamp_us, 287 RTPHeader header, 288 size_t header_length, 289 size_t total_length) 290 : rtp(timestamp_us, header, header_length, total_length) {} log_time_usLoggedRtpPacketOutgoing291 int64_t log_time_us() const { return rtp.timestamp_us; } log_time_msLoggedRtpPacketOutgoing292 int64_t log_time_ms() const { return rtp.timestamp_us / 1000; } 293 294 LoggedRtpPacket rtp; 295 }; 296 297 struct LoggedRtcpPacket { 298 LoggedRtcpPacket(int64_t timestamp_us, 299 const uint8_t* packet, 300 size_t total_length); 301 LoggedRtcpPacket(int64_t timestamp_us, const std::string& packet); 302 LoggedRtcpPacket(const LoggedRtcpPacket&); 303 ~LoggedRtcpPacket(); 304 log_time_usLoggedRtcpPacket305 int64_t log_time_us() const { return timestamp_us; } log_time_msLoggedRtcpPacket306 int64_t log_time_ms() const { return timestamp_us / 1000; } 307 308 int64_t timestamp_us; 309 std::vector<uint8_t> raw_data; 310 }; 311 312 struct LoggedRtcpPacketIncoming { LoggedRtcpPacketIncomingLoggedRtcpPacketIncoming313 LoggedRtcpPacketIncoming(int64_t timestamp_us, 314 const uint8_t* packet, 315 size_t total_length) 316 : rtcp(timestamp_us, packet, total_length) {} LoggedRtcpPacketIncomingLoggedRtcpPacketIncoming317 LoggedRtcpPacketIncoming(uint64_t timestamp_us, const std::string& packet) 318 : rtcp(timestamp_us, packet) {} 319 log_time_usLoggedRtcpPacketIncoming320 int64_t log_time_us() const { return rtcp.timestamp_us; } log_time_msLoggedRtcpPacketIncoming321 int64_t log_time_ms() const { return rtcp.timestamp_us / 1000; } 322 323 LoggedRtcpPacket rtcp; 324 }; 325 326 struct LoggedRtcpPacketOutgoing { LoggedRtcpPacketOutgoingLoggedRtcpPacketOutgoing327 LoggedRtcpPacketOutgoing(int64_t timestamp_us, 328 const uint8_t* packet, 329 size_t total_length) 330 : rtcp(timestamp_us, packet, total_length) {} LoggedRtcpPacketOutgoingLoggedRtcpPacketOutgoing331 LoggedRtcpPacketOutgoing(uint64_t timestamp_us, const std::string& packet) 332 : rtcp(timestamp_us, packet) {} 333 log_time_usLoggedRtcpPacketOutgoing334 int64_t log_time_us() const { return rtcp.timestamp_us; } log_time_msLoggedRtcpPacketOutgoing335 int64_t log_time_ms() const { return rtcp.timestamp_us / 1000; } 336 337 LoggedRtcpPacket rtcp; 338 }; 339 340 struct LoggedRtcpPacketReceiverReport { 341 LoggedRtcpPacketReceiverReport() = default; LoggedRtcpPacketReceiverReportLoggedRtcpPacketReceiverReport342 LoggedRtcpPacketReceiverReport(int64_t timestamp_us, 343 const rtcp::ReceiverReport& rr) 344 : timestamp_us(timestamp_us), rr(rr) {} 345 log_time_usLoggedRtcpPacketReceiverReport346 int64_t log_time_us() const { return timestamp_us; } log_time_msLoggedRtcpPacketReceiverReport347 int64_t log_time_ms() const { return timestamp_us / 1000; } 348 349 int64_t timestamp_us; 350 rtcp::ReceiverReport rr; 351 }; 352 353 struct LoggedRtcpPacketSenderReport { 354 LoggedRtcpPacketSenderReport() = default; LoggedRtcpPacketSenderReportLoggedRtcpPacketSenderReport355 LoggedRtcpPacketSenderReport(int64_t timestamp_us, 356 const rtcp::SenderReport& sr) 357 : timestamp_us(timestamp_us), sr(sr) {} 358 log_time_usLoggedRtcpPacketSenderReport359 int64_t log_time_us() const { return timestamp_us; } log_time_msLoggedRtcpPacketSenderReport360 int64_t log_time_ms() const { return timestamp_us / 1000; } 361 362 int64_t timestamp_us; 363 rtcp::SenderReport sr; 364 }; 365 366 struct LoggedRtcpPacketExtendedReports { 367 LoggedRtcpPacketExtendedReports() = default; 368 log_time_usLoggedRtcpPacketExtendedReports369 int64_t log_time_us() const { return timestamp_us; } log_time_msLoggedRtcpPacketExtendedReports370 int64_t log_time_ms() const { return timestamp_us / 1000; } 371 372 int64_t timestamp_us; 373 rtcp::ExtendedReports xr; 374 }; 375 376 struct LoggedRtcpPacketRemb { 377 LoggedRtcpPacketRemb() = default; LoggedRtcpPacketRembLoggedRtcpPacketRemb378 LoggedRtcpPacketRemb(int64_t timestamp_us, const rtcp::Remb& remb) 379 : timestamp_us(timestamp_us), remb(remb) {} 380 log_time_usLoggedRtcpPacketRemb381 int64_t log_time_us() const { return timestamp_us; } log_time_msLoggedRtcpPacketRemb382 int64_t log_time_ms() const { return timestamp_us / 1000; } 383 384 int64_t timestamp_us; 385 rtcp::Remb remb; 386 }; 387 388 struct LoggedRtcpPacketNack { 389 LoggedRtcpPacketNack() = default; LoggedRtcpPacketNackLoggedRtcpPacketNack390 LoggedRtcpPacketNack(int64_t timestamp_us, const rtcp::Nack& nack) 391 : timestamp_us(timestamp_us), nack(nack) {} 392 log_time_usLoggedRtcpPacketNack393 int64_t log_time_us() const { return timestamp_us; } log_time_msLoggedRtcpPacketNack394 int64_t log_time_ms() const { return timestamp_us / 1000; } 395 396 int64_t timestamp_us; 397 rtcp::Nack nack; 398 }; 399 400 struct LoggedRtcpPacketFir { 401 LoggedRtcpPacketFir() = default; 402 log_time_usLoggedRtcpPacketFir403 int64_t log_time_us() const { return timestamp_us; } log_time_msLoggedRtcpPacketFir404 int64_t log_time_ms() const { return timestamp_us / 1000; } 405 406 int64_t timestamp_us; 407 rtcp::Fir fir; 408 }; 409 410 struct LoggedRtcpPacketPli { 411 LoggedRtcpPacketPli() = default; 412 log_time_usLoggedRtcpPacketPli413 int64_t log_time_us() const { return timestamp_us; } log_time_msLoggedRtcpPacketPli414 int64_t log_time_ms() const { return timestamp_us / 1000; } 415 416 int64_t timestamp_us; 417 rtcp::Pli pli; 418 }; 419 420 struct LoggedRtcpPacketTransportFeedback { LoggedRtcpPacketTransportFeedbackLoggedRtcpPacketTransportFeedback421 LoggedRtcpPacketTransportFeedback() 422 : transport_feedback(/*include_timestamps=*/true, /*include_lost*/ true) { 423 } LoggedRtcpPacketTransportFeedbackLoggedRtcpPacketTransportFeedback424 LoggedRtcpPacketTransportFeedback( 425 int64_t timestamp_us, 426 const rtcp::TransportFeedback& transport_feedback) 427 : timestamp_us(timestamp_us), transport_feedback(transport_feedback) {} 428 log_time_usLoggedRtcpPacketTransportFeedback429 int64_t log_time_us() const { return timestamp_us; } log_time_msLoggedRtcpPacketTransportFeedback430 int64_t log_time_ms() const { return timestamp_us / 1000; } 431 432 int64_t timestamp_us; 433 rtcp::TransportFeedback transport_feedback; 434 }; 435 436 struct LoggedRtcpPacketLossNotification { 437 LoggedRtcpPacketLossNotification() = default; LoggedRtcpPacketLossNotificationLoggedRtcpPacketLossNotification438 LoggedRtcpPacketLossNotification( 439 int64_t timestamp_us, 440 const rtcp::LossNotification& loss_notification) 441 : timestamp_us(timestamp_us), loss_notification(loss_notification) {} 442 log_time_usLoggedRtcpPacketLossNotification443 int64_t log_time_us() const { return timestamp_us; } log_time_msLoggedRtcpPacketLossNotification444 int64_t log_time_ms() const { return timestamp_us / 1000; } 445 446 int64_t timestamp_us; 447 rtcp::LossNotification loss_notification; 448 }; 449 450 struct LoggedStartEvent { LoggedStartEventLoggedStartEvent451 explicit LoggedStartEvent(int64_t timestamp_us) 452 : LoggedStartEvent(timestamp_us, timestamp_us / 1000) {} 453 LoggedStartEventLoggedStartEvent454 LoggedStartEvent(int64_t timestamp_us, int64_t utc_start_time_ms) 455 : timestamp_us(timestamp_us), utc_start_time_ms(utc_start_time_ms) {} 456 log_time_usLoggedStartEvent457 int64_t log_time_us() const { return timestamp_us; } log_time_msLoggedStartEvent458 int64_t log_time_ms() const { return timestamp_us / 1000; } 459 460 int64_t timestamp_us; 461 int64_t utc_start_time_ms; 462 }; 463 464 struct LoggedStopEvent { LoggedStopEventLoggedStopEvent465 explicit LoggedStopEvent(int64_t timestamp_us) : timestamp_us(timestamp_us) {} 466 log_time_usLoggedStopEvent467 int64_t log_time_us() const { return timestamp_us; } log_time_msLoggedStopEvent468 int64_t log_time_ms() const { return timestamp_us / 1000; } 469 470 int64_t timestamp_us; 471 }; 472 473 struct LoggedAudioRecvConfig { 474 LoggedAudioRecvConfig() = default; LoggedAudioRecvConfigLoggedAudioRecvConfig475 LoggedAudioRecvConfig(int64_t timestamp_us, const rtclog::StreamConfig config) 476 : timestamp_us(timestamp_us), config(config) {} 477 log_time_usLoggedAudioRecvConfig478 int64_t log_time_us() const { return timestamp_us; } log_time_msLoggedAudioRecvConfig479 int64_t log_time_ms() const { return timestamp_us / 1000; } 480 481 int64_t timestamp_us; 482 rtclog::StreamConfig config; 483 }; 484 485 struct LoggedAudioSendConfig { 486 LoggedAudioSendConfig() = default; LoggedAudioSendConfigLoggedAudioSendConfig487 LoggedAudioSendConfig(int64_t timestamp_us, const rtclog::StreamConfig config) 488 : timestamp_us(timestamp_us), config(config) {} 489 log_time_usLoggedAudioSendConfig490 int64_t log_time_us() const { return timestamp_us; } log_time_msLoggedAudioSendConfig491 int64_t log_time_ms() const { return timestamp_us / 1000; } 492 493 int64_t timestamp_us; 494 rtclog::StreamConfig config; 495 }; 496 497 struct LoggedVideoRecvConfig { 498 LoggedVideoRecvConfig() = default; LoggedVideoRecvConfigLoggedVideoRecvConfig499 LoggedVideoRecvConfig(int64_t timestamp_us, const rtclog::StreamConfig config) 500 : timestamp_us(timestamp_us), config(config) {} 501 log_time_usLoggedVideoRecvConfig502 int64_t log_time_us() const { return timestamp_us; } log_time_msLoggedVideoRecvConfig503 int64_t log_time_ms() const { return timestamp_us / 1000; } 504 505 int64_t timestamp_us; 506 rtclog::StreamConfig config; 507 }; 508 509 struct LoggedVideoSendConfig { 510 LoggedVideoSendConfig() = default; LoggedVideoSendConfigLoggedVideoSendConfig511 LoggedVideoSendConfig(int64_t timestamp_us, const rtclog::StreamConfig config) 512 : timestamp_us(timestamp_us), config(config) {} 513 log_time_usLoggedVideoSendConfig514 int64_t log_time_us() const { return timestamp_us; } log_time_msLoggedVideoSendConfig515 int64_t log_time_ms() const { return timestamp_us / 1000; } 516 517 int64_t timestamp_us; 518 rtclog::StreamConfig config; 519 }; 520 521 struct InferredRouteChangeEvent { log_time_msInferredRouteChangeEvent522 int64_t log_time_ms() const { return log_time.ms(); } log_time_usInferredRouteChangeEvent523 int64_t log_time_us() const { return log_time.us(); } 524 uint32_t route_id; 525 Timestamp log_time = Timestamp::MinusInfinity(); 526 uint16_t send_overhead; 527 uint16_t return_overhead; 528 }; 529 530 enum class LoggedMediaType : uint8_t { kUnknown, kAudio, kVideo }; 531 532 struct LoggedPacketInfo { 533 LoggedPacketInfo(const LoggedRtpPacket& rtp, 534 LoggedMediaType media_type, 535 bool rtx, 536 Timestamp capture_time); 537 LoggedPacketInfo(const LoggedPacketInfo&); 538 ~LoggedPacketInfo(); log_time_msLoggedPacketInfo539 int64_t log_time_ms() const { return log_packet_time.ms(); } log_time_usLoggedPacketInfo540 int64_t log_time_us() const { return log_packet_time.us(); } 541 uint32_t ssrc; 542 uint16_t stream_seq_no; 543 uint16_t size; 544 uint16_t payload_size; 545 uint16_t padding_size; 546 uint16_t overhead = 0; 547 uint8_t payload_type; 548 LoggedMediaType media_type = LoggedMediaType::kUnknown; 549 bool rtx = false; 550 bool marker_bit = false; 551 bool has_transport_seq_no = false; 552 bool last_in_feedback = false; 553 uint16_t transport_seq_no = 0; 554 // The RTP header timestamp unwrapped and converted from tick count to seconds 555 // based timestamp. 556 Timestamp capture_time; 557 // The time the packet was logged. This is the receive time for incoming 558 // packets and send time for outgoing. 559 Timestamp log_packet_time; 560 // Send time as reported by abs-send-time extension, For outgoing packets this 561 // corresponds to log_packet_time, but might be measured using another clock. 562 Timestamp reported_send_time; 563 // The receive time that was reported in feedback. For incoming packets this 564 // corresponds to log_packet_time, but might be measured using another clock. 565 // PlusInfinity indicates that the packet was lost. 566 Timestamp reported_recv_time = Timestamp::MinusInfinity(); 567 // The time feedback message was logged. This is the feedback send time for 568 // incoming packets and feedback receive time for outgoing. 569 // PlusInfinity indicates that feedback was expected but not received. 570 Timestamp log_feedback_time = Timestamp::MinusInfinity(); 571 // The delay betweeen receiving an RTP packet and sending feedback for 572 // incoming packets. For outgoing packets we don't know the feedback send 573 // time, and this is instead calculated as the difference in reported receive 574 // time between this packet and the last packet in the same feedback message. 575 TimeDelta feedback_hold_duration = TimeDelta::MinusInfinity(); 576 }; 577 578 enum class LoggedIceEventType { 579 kAdded, 580 kUpdated, 581 kDestroyed, 582 kSelected, 583 kCheckSent, 584 kCheckReceived, 585 kCheckResponseSent, 586 kCheckResponseReceived, 587 }; 588 589 struct LoggedIceEvent { 590 uint32_t candidate_pair_id; 591 Timestamp log_time; 592 LoggedIceEventType event_type; 593 }; 594 595 struct LoggedGenericPacketSent { 596 LoggedGenericPacketSent() = default; LoggedGenericPacketSentLoggedGenericPacketSent597 LoggedGenericPacketSent(int64_t timestamp_us, 598 int64_t packet_number, 599 size_t overhead_length, 600 size_t payload_length, 601 size_t padding_length) 602 : timestamp_us(timestamp_us), 603 packet_number(packet_number), 604 overhead_length(overhead_length), 605 payload_length(payload_length), 606 padding_length(padding_length) {} 607 log_time_usLoggedGenericPacketSent608 int64_t log_time_us() const { return timestamp_us; } log_time_msLoggedGenericPacketSent609 int64_t log_time_ms() const { return timestamp_us / 1000; } 610 packet_lengthLoggedGenericPacketSent611 size_t packet_length() const { 612 return payload_length + padding_length + overhead_length; 613 } 614 int64_t timestamp_us; 615 int64_t packet_number; 616 size_t overhead_length; 617 size_t payload_length; 618 size_t padding_length; 619 }; 620 621 struct LoggedGenericPacketReceived { 622 LoggedGenericPacketReceived() = default; LoggedGenericPacketReceivedLoggedGenericPacketReceived623 LoggedGenericPacketReceived(int64_t timestamp_us, 624 int64_t packet_number, 625 int packet_length) 626 : timestamp_us(timestamp_us), 627 packet_number(packet_number), 628 packet_length(packet_length) {} 629 log_time_usLoggedGenericPacketReceived630 int64_t log_time_us() const { return timestamp_us; } log_time_msLoggedGenericPacketReceived631 int64_t log_time_ms() const { return timestamp_us / 1000; } 632 633 int64_t timestamp_us; 634 int64_t packet_number; 635 int packet_length; 636 }; 637 638 struct LoggedGenericAckReceived { 639 LoggedGenericAckReceived() = default; LoggedGenericAckReceivedLoggedGenericAckReceived640 LoggedGenericAckReceived(int64_t timestamp_us, 641 int64_t packet_number, 642 int64_t acked_packet_number, 643 absl::optional<int64_t> receive_acked_packet_time_ms) 644 : timestamp_us(timestamp_us), 645 packet_number(packet_number), 646 acked_packet_number(acked_packet_number), 647 receive_acked_packet_time_ms(receive_acked_packet_time_ms) {} 648 log_time_usLoggedGenericAckReceived649 int64_t log_time_us() const { return timestamp_us; } log_time_msLoggedGenericAckReceived650 int64_t log_time_ms() const { return timestamp_us / 1000; } 651 652 int64_t timestamp_us; 653 int64_t packet_number; 654 int64_t acked_packet_number; 655 absl::optional<int64_t> receive_acked_packet_time_ms; 656 }; 657 658 } // namespace webrtc 659 #endif // LOGGING_RTC_EVENT_LOG_LOGGED_EVENTS_H_ 660