1 /* 2 * Copyright 2016 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 API_STATS_RTCSTATS_OBJECTS_H_ 12 #define API_STATS_RTCSTATS_OBJECTS_H_ 13 14 #include <stdint.h> 15 16 #include <map> 17 #include <memory> 18 #include <string> 19 #include <vector> 20 21 #include "api/stats/rtc_stats.h" 22 #include "rtc_base/system/rtc_export.h" 23 24 namespace webrtc { 25 26 // https://w3c.github.io/webrtc-pc/#idl-def-rtcdatachannelstate 27 struct RTCDataChannelState { 28 static const char* const kConnecting; 29 static const char* const kOpen; 30 static const char* const kClosing; 31 static const char* const kClosed; 32 }; 33 34 // https://w3c.github.io/webrtc-stats/#dom-rtcstatsicecandidatepairstate 35 struct RTCStatsIceCandidatePairState { 36 static const char* const kFrozen; 37 static const char* const kWaiting; 38 static const char* const kInProgress; 39 static const char* const kFailed; 40 static const char* const kSucceeded; 41 }; 42 43 // https://w3c.github.io/webrtc-pc/#rtcicecandidatetype-enum 44 struct RTCIceCandidateType { 45 static const char* const kHost; 46 static const char* const kSrflx; 47 static const char* const kPrflx; 48 static const char* const kRelay; 49 }; 50 51 // https://w3c.github.io/webrtc-pc/#idl-def-rtcdtlstransportstate 52 struct RTCDtlsTransportState { 53 static const char* const kNew; 54 static const char* const kConnecting; 55 static const char* const kConnected; 56 static const char* const kClosed; 57 static const char* const kFailed; 58 }; 59 60 // `RTCMediaStreamTrackStats::kind` is not an enum in the spec but the only 61 // valid values are "audio" and "video". 62 // https://w3c.github.io/webrtc-stats/#dom-rtcmediastreamtrackstats-kind 63 struct RTCMediaStreamTrackKind { 64 static const char* const kAudio; 65 static const char* const kVideo; 66 }; 67 68 // https://w3c.github.io/webrtc-stats/#dom-rtcnetworktype 69 struct RTCNetworkType { 70 static const char* const kBluetooth; 71 static const char* const kCellular; 72 static const char* const kEthernet; 73 static const char* const kWifi; 74 static const char* const kWimax; 75 static const char* const kVpn; 76 static const char* const kUnknown; 77 }; 78 79 // https://w3c.github.io/webrtc-stats/#dom-rtcqualitylimitationreason 80 struct RTCQualityLimitationReason { 81 static const char* const kNone; 82 static const char* const kCpu; 83 static const char* const kBandwidth; 84 static const char* const kOther; 85 }; 86 87 // https://webrtc.org/experiments/rtp-hdrext/video-content-type/ 88 struct RTCContentType { 89 static const char* const kUnspecified; 90 static const char* const kScreenshare; 91 }; 92 93 // https://w3c.github.io/webrtc-stats/#dom-rtcdtlsrole 94 struct RTCDtlsRole { 95 static const char* const kUnknown; 96 static const char* const kClient; 97 static const char* const kServer; 98 }; 99 100 // https://www.w3.org/TR/webrtc/#rtcicerole 101 struct RTCIceRole { 102 static const char* const kUnknown; 103 static const char* const kControlled; 104 static const char* const kControlling; 105 }; 106 107 // https://www.w3.org/TR/webrtc/#dom-rtcicetransportstate 108 struct RTCIceTransportState { 109 static const char* const kNew; 110 static const char* const kChecking; 111 static const char* const kConnected; 112 static const char* const kCompleted; 113 static const char* const kDisconnected; 114 static const char* const kFailed; 115 static const char* const kClosed; 116 }; 117 118 // https://w3c.github.io/webrtc-stats/#certificatestats-dict* 119 class RTC_EXPORT RTCCertificateStats final : public RTCStats { 120 public: 121 WEBRTC_RTCSTATS_DECL(); 122 123 RTCCertificateStats(const std::string& id, int64_t timestamp_us); 124 RTCCertificateStats(std::string&& id, int64_t timestamp_us); 125 RTCCertificateStats(const RTCCertificateStats& other); 126 ~RTCCertificateStats() override; 127 128 RTCStatsMember<std::string> fingerprint; 129 RTCStatsMember<std::string> fingerprint_algorithm; 130 RTCStatsMember<std::string> base64_certificate; 131 RTCStatsMember<std::string> issuer_certificate_id; 132 }; 133 134 // Non standard extension mapping to rtc::AdapterType 135 struct RTCNetworkAdapterType { 136 static constexpr char kUnknown[] = "unknown"; 137 static constexpr char kEthernet[] = "ethernet"; 138 static constexpr char kWifi[] = "wifi"; 139 static constexpr char kCellular[] = "cellular"; 140 static constexpr char kLoopback[] = "loopback"; 141 static constexpr char kAny[] = "any"; 142 static constexpr char kCellular2g[] = "cellular2g"; 143 static constexpr char kCellular3g[] = "cellular3g"; 144 static constexpr char kCellular4g[] = "cellular4g"; 145 static constexpr char kCellular5g[] = "cellular5g"; 146 }; 147 148 // https://w3c.github.io/webrtc-stats/#codec-dict* 149 class RTC_EXPORT RTCCodecStats final : public RTCStats { 150 public: 151 WEBRTC_RTCSTATS_DECL(); 152 153 RTCCodecStats(const std::string& id, int64_t timestamp_us); 154 RTCCodecStats(std::string&& id, int64_t timestamp_us); 155 RTCCodecStats(const RTCCodecStats& other); 156 ~RTCCodecStats() override; 157 158 RTCStatsMember<std::string> transport_id; 159 RTCStatsMember<uint32_t> payload_type; 160 RTCStatsMember<std::string> mime_type; 161 RTCStatsMember<uint32_t> clock_rate; 162 RTCStatsMember<uint32_t> channels; 163 RTCStatsMember<std::string> sdp_fmtp_line; 164 }; 165 166 // https://w3c.github.io/webrtc-stats/#dcstats-dict* 167 class RTC_EXPORT RTCDataChannelStats final : public RTCStats { 168 public: 169 WEBRTC_RTCSTATS_DECL(); 170 171 RTCDataChannelStats(const std::string& id, int64_t timestamp_us); 172 RTCDataChannelStats(std::string&& id, int64_t timestamp_us); 173 RTCDataChannelStats(const RTCDataChannelStats& other); 174 ~RTCDataChannelStats() override; 175 176 RTCStatsMember<std::string> label; 177 RTCStatsMember<std::string> protocol; 178 RTCStatsMember<int32_t> data_channel_identifier; 179 // Enum type RTCDataChannelState. 180 RTCStatsMember<std::string> state; 181 RTCStatsMember<uint32_t> messages_sent; 182 RTCStatsMember<uint64_t> bytes_sent; 183 RTCStatsMember<uint32_t> messages_received; 184 RTCStatsMember<uint64_t> bytes_received; 185 }; 186 187 // https://w3c.github.io/webrtc-stats/#candidatepair-dict* 188 class RTC_EXPORT RTCIceCandidatePairStats final : public RTCStats { 189 public: 190 WEBRTC_RTCSTATS_DECL(); 191 192 RTCIceCandidatePairStats(const std::string& id, int64_t timestamp_us); 193 RTCIceCandidatePairStats(std::string&& id, int64_t timestamp_us); 194 RTCIceCandidatePairStats(const RTCIceCandidatePairStats& other); 195 ~RTCIceCandidatePairStats() override; 196 197 RTCStatsMember<std::string> transport_id; 198 RTCStatsMember<std::string> local_candidate_id; 199 RTCStatsMember<std::string> remote_candidate_id; 200 // Enum type RTCStatsIceCandidatePairState. 201 RTCStatsMember<std::string> state; 202 // Obsolete: priority 203 RTCStatsMember<uint64_t> priority; 204 RTCStatsMember<bool> nominated; 205 // `writable` does not exist in the spec and old comments suggest it used to 206 // exist but was incorrectly implemented. 207 // TODO(https://crbug.com/webrtc/14171): Standardize and/or modify 208 // implementation. 209 RTCStatsMember<bool> writable; 210 RTCStatsMember<uint64_t> packets_sent; 211 RTCStatsMember<uint64_t> packets_received; 212 RTCStatsMember<uint64_t> bytes_sent; 213 RTCStatsMember<uint64_t> bytes_received; 214 RTCStatsMember<double> total_round_trip_time; 215 RTCStatsMember<double> current_round_trip_time; 216 RTCStatsMember<double> available_outgoing_bitrate; 217 RTCStatsMember<double> available_incoming_bitrate; 218 RTCStatsMember<uint64_t> requests_received; 219 RTCStatsMember<uint64_t> requests_sent; 220 RTCStatsMember<uint64_t> responses_received; 221 RTCStatsMember<uint64_t> responses_sent; 222 RTCStatsMember<uint64_t> consent_requests_sent; 223 RTCStatsMember<uint64_t> packets_discarded_on_send; 224 RTCStatsMember<uint64_t> bytes_discarded_on_send; 225 RTCStatsMember<double> last_packet_received_timestamp; 226 RTCStatsMember<double> last_packet_sent_timestamp; 227 }; 228 229 // https://w3c.github.io/webrtc-stats/#icecandidate-dict* 230 class RTC_EXPORT RTCIceCandidateStats : public RTCStats { 231 public: 232 WEBRTC_RTCSTATS_DECL(); 233 234 RTCIceCandidateStats(const RTCIceCandidateStats& other); 235 ~RTCIceCandidateStats() override; 236 237 RTCStatsMember<std::string> transport_id; 238 // Obsolete: is_remote 239 RTCStatsMember<bool> is_remote; 240 RTCStatsMember<std::string> network_type; 241 RTCStatsMember<std::string> ip; 242 RTCStatsMember<std::string> address; 243 RTCStatsMember<int32_t> port; 244 RTCStatsMember<std::string> protocol; 245 RTCStatsMember<std::string> relay_protocol; 246 // Enum type RTCIceCandidateType. 247 RTCStatsMember<std::string> candidate_type; 248 RTCStatsMember<int32_t> priority; 249 RTCStatsMember<std::string> url; 250 RTCStatsMember<std::string> foundation; 251 RTCStatsMember<std::string> related_address; 252 RTCStatsMember<int32_t> related_port; 253 RTCStatsMember<std::string> username_fragment; 254 // Enum type RTCIceTcpCandidateType. 255 RTCStatsMember<std::string> tcp_type; 256 257 RTCNonStandardStatsMember<bool> vpn; 258 RTCNonStandardStatsMember<std::string> network_adapter_type; 259 260 protected: 261 RTCIceCandidateStats(const std::string& id, 262 int64_t timestamp_us, 263 bool is_remote); 264 RTCIceCandidateStats(std::string&& id, int64_t timestamp_us, bool is_remote); 265 }; 266 267 // In the spec both local and remote varieties are of type RTCIceCandidateStats. 268 // But here we define them as subclasses of `RTCIceCandidateStats` because the 269 // `kType` need to be different ("RTCStatsType type") in the local/remote case. 270 // https://w3c.github.io/webrtc-stats/#rtcstatstype-str* 271 // This forces us to have to override copy() and type(). 272 class RTC_EXPORT RTCLocalIceCandidateStats final : public RTCIceCandidateStats { 273 public: 274 static const char kType[]; 275 RTCLocalIceCandidateStats(const std::string& id, int64_t timestamp_us); 276 RTCLocalIceCandidateStats(std::string&& id, int64_t timestamp_us); 277 std::unique_ptr<RTCStats> copy() const override; 278 const char* type() const override; 279 }; 280 281 class RTC_EXPORT RTCRemoteIceCandidateStats final 282 : public RTCIceCandidateStats { 283 public: 284 static const char kType[]; 285 RTCRemoteIceCandidateStats(const std::string& id, int64_t timestamp_us); 286 RTCRemoteIceCandidateStats(std::string&& id, int64_t timestamp_us); 287 std::unique_ptr<RTCStats> copy() const override; 288 const char* type() const override; 289 }; 290 291 // TODO(https://crbug.com/webrtc/14419): Delete this class, it's deprecated. 292 class RTC_EXPORT DEPRECATED_RTCMediaStreamStats final : public RTCStats { 293 public: 294 WEBRTC_RTCSTATS_DECL(); 295 296 DEPRECATED_RTCMediaStreamStats(const std::string& id, int64_t timestamp_us); 297 DEPRECATED_RTCMediaStreamStats(std::string&& id, int64_t timestamp_us); 298 DEPRECATED_RTCMediaStreamStats(const DEPRECATED_RTCMediaStreamStats& other); 299 ~DEPRECATED_RTCMediaStreamStats() override; 300 301 RTCStatsMember<std::string> stream_identifier; 302 RTCStatsMember<std::vector<std::string>> track_ids; 303 }; 304 using RTCMediaStreamStats [[deprecated("bugs.webrtc.org/14419")]] = 305 DEPRECATED_RTCMediaStreamStats; 306 307 // TODO(https://crbug.com/webrtc/14175): Delete this class, it's deprecated. 308 class RTC_EXPORT DEPRECATED_RTCMediaStreamTrackStats final : public RTCStats { 309 public: 310 WEBRTC_RTCSTATS_DECL(); 311 312 DEPRECATED_RTCMediaStreamTrackStats(const std::string& id, 313 int64_t timestamp_us, 314 const char* kind); 315 DEPRECATED_RTCMediaStreamTrackStats(std::string&& id, 316 int64_t timestamp_us, 317 const char* kind); 318 DEPRECATED_RTCMediaStreamTrackStats( 319 const DEPRECATED_RTCMediaStreamTrackStats& other); 320 ~DEPRECATED_RTCMediaStreamTrackStats() override; 321 322 RTCStatsMember<std::string> track_identifier; 323 RTCStatsMember<std::string> media_source_id; 324 RTCStatsMember<bool> remote_source; 325 RTCStatsMember<bool> ended; 326 // TODO(https://crbug.com/webrtc/14173): Remove this obsolete metric. 327 RTCStatsMember<bool> detached; 328 // Enum type RTCMediaStreamTrackKind. 329 RTCStatsMember<std::string> kind; 330 RTCStatsMember<double> jitter_buffer_delay; 331 RTCStatsMember<uint64_t> jitter_buffer_emitted_count; 332 // Video-only members 333 RTCStatsMember<uint32_t> frame_width; 334 RTCStatsMember<uint32_t> frame_height; 335 RTCStatsMember<uint32_t> frames_sent; 336 RTCStatsMember<uint32_t> huge_frames_sent; 337 RTCStatsMember<uint32_t> frames_received; 338 RTCStatsMember<uint32_t> frames_decoded; 339 RTCStatsMember<uint32_t> frames_dropped; 340 // Audio-only members 341 RTCStatsMember<double> audio_level; // Receive-only 342 RTCStatsMember<double> total_audio_energy; // Receive-only 343 RTCStatsMember<double> echo_return_loss; 344 RTCStatsMember<double> echo_return_loss_enhancement; 345 RTCStatsMember<uint64_t> total_samples_received; 346 RTCStatsMember<double> total_samples_duration; // Receive-only 347 RTCStatsMember<uint64_t> concealed_samples; 348 RTCStatsMember<uint64_t> silent_concealed_samples; 349 RTCStatsMember<uint64_t> concealment_events; 350 RTCStatsMember<uint64_t> inserted_samples_for_deceleration; 351 RTCStatsMember<uint64_t> removed_samples_for_acceleration; 352 }; 353 using RTCMediaStreamTrackStats [[deprecated("bugs.webrtc.org/14175")]] = 354 DEPRECATED_RTCMediaStreamTrackStats; 355 356 // https://w3c.github.io/webrtc-stats/#pcstats-dict* 357 class RTC_EXPORT RTCPeerConnectionStats final : public RTCStats { 358 public: 359 WEBRTC_RTCSTATS_DECL(); 360 361 RTCPeerConnectionStats(const std::string& id, int64_t timestamp_us); 362 RTCPeerConnectionStats(std::string&& id, int64_t timestamp_us); 363 RTCPeerConnectionStats(const RTCPeerConnectionStats& other); 364 ~RTCPeerConnectionStats() override; 365 366 RTCStatsMember<uint32_t> data_channels_opened; 367 RTCStatsMember<uint32_t> data_channels_closed; 368 }; 369 370 // https://w3c.github.io/webrtc-stats/#streamstats-dict* 371 class RTC_EXPORT RTCRTPStreamStats : public RTCStats { 372 public: 373 WEBRTC_RTCSTATS_DECL(); 374 375 RTCRTPStreamStats(const RTCRTPStreamStats& other); 376 ~RTCRTPStreamStats() override; 377 378 RTCStatsMember<uint32_t> ssrc; 379 RTCStatsMember<std::string> kind; 380 // Obsolete: track_id 381 RTCStatsMember<std::string> track_id; 382 RTCStatsMember<std::string> transport_id; 383 RTCStatsMember<std::string> codec_id; 384 385 // Obsolete 386 RTCStatsMember<std::string> media_type; // renamed to kind. 387 388 protected: 389 RTCRTPStreamStats(const std::string& id, int64_t timestamp_us); 390 RTCRTPStreamStats(std::string&& id, int64_t timestamp_us); 391 }; 392 393 // https://www.w3.org/TR/webrtc-stats/#receivedrtpstats-dict* 394 class RTC_EXPORT RTCReceivedRtpStreamStats : public RTCRTPStreamStats { 395 public: 396 WEBRTC_RTCSTATS_DECL(); 397 398 RTCReceivedRtpStreamStats(const RTCReceivedRtpStreamStats& other); 399 ~RTCReceivedRtpStreamStats() override; 400 401 RTCStatsMember<double> jitter; 402 RTCStatsMember<int32_t> packets_lost; // Signed per RFC 3550 403 404 protected: 405 RTCReceivedRtpStreamStats(const std::string&& id, int64_t timestamp_us); 406 RTCReceivedRtpStreamStats(std::string&& id, int64_t timestamp_us); 407 }; 408 409 // https://www.w3.org/TR/webrtc-stats/#sentrtpstats-dict* 410 class RTC_EXPORT RTCSentRtpStreamStats : public RTCRTPStreamStats { 411 public: 412 WEBRTC_RTCSTATS_DECL(); 413 414 RTCSentRtpStreamStats(const RTCSentRtpStreamStats& other); 415 ~RTCSentRtpStreamStats() override; 416 417 RTCStatsMember<uint32_t> packets_sent; 418 RTCStatsMember<uint64_t> bytes_sent; 419 420 protected: 421 RTCSentRtpStreamStats(const std::string&& id, int64_t timestamp_us); 422 RTCSentRtpStreamStats(std::string&& id, int64_t timestamp_us); 423 }; 424 425 // https://w3c.github.io/webrtc-stats/#inboundrtpstats-dict* 426 class RTC_EXPORT RTCInboundRTPStreamStats final 427 : public RTCReceivedRtpStreamStats { 428 public: 429 WEBRTC_RTCSTATS_DECL(); 430 431 RTCInboundRTPStreamStats(const std::string& id, int64_t timestamp_us); 432 RTCInboundRTPStreamStats(std::string&& id, int64_t timestamp_us); 433 RTCInboundRTPStreamStats(const RTCInboundRTPStreamStats& other); 434 ~RTCInboundRTPStreamStats() override; 435 436 // TODO(https://crbug.com/webrtc/14174): Implement trackIdentifier and kind. 437 438 RTCStatsMember<std::string> track_identifier; 439 RTCStatsMember<std::string> mid; 440 RTCStatsMember<std::string> remote_id; 441 RTCStatsMember<uint32_t> packets_received; 442 RTCStatsMember<uint64_t> packets_discarded; 443 RTCStatsMember<uint64_t> fec_packets_received; 444 RTCStatsMember<uint64_t> fec_packets_discarded; 445 RTCStatsMember<uint64_t> bytes_received; 446 RTCStatsMember<uint64_t> header_bytes_received; 447 RTCStatsMember<double> last_packet_received_timestamp; 448 RTCStatsMember<double> jitter_buffer_delay; 449 RTCStatsMember<double> jitter_buffer_target_delay; 450 RTCStatsMember<double> jitter_buffer_minimum_delay; 451 RTCStatsMember<uint64_t> jitter_buffer_emitted_count; 452 RTCStatsMember<uint64_t> total_samples_received; 453 RTCStatsMember<uint64_t> concealed_samples; 454 RTCStatsMember<uint64_t> silent_concealed_samples; 455 RTCStatsMember<uint64_t> concealment_events; 456 RTCStatsMember<uint64_t> inserted_samples_for_deceleration; 457 RTCStatsMember<uint64_t> removed_samples_for_acceleration; 458 RTCStatsMember<double> audio_level; 459 RTCStatsMember<double> total_audio_energy; 460 RTCStatsMember<double> total_samples_duration; 461 // Stats below are only implemented or defined for video. 462 RTCStatsMember<int32_t> frames_received; 463 RTCStatsMember<uint32_t> frame_width; 464 RTCStatsMember<uint32_t> frame_height; 465 RTCStatsMember<double> frames_per_second; 466 RTCStatsMember<uint32_t> frames_decoded; 467 RTCStatsMember<uint32_t> key_frames_decoded; 468 RTCStatsMember<uint32_t> frames_dropped; 469 RTCStatsMember<double> total_decode_time; 470 RTCStatsMember<double> total_processing_delay; 471 RTCStatsMember<double> total_assembly_time; 472 RTCStatsMember<uint32_t> frames_assembled_from_multiple_packets; 473 RTCStatsMember<double> total_inter_frame_delay; 474 RTCStatsMember<double> total_squared_inter_frame_delay; 475 RTCStatsMember<uint32_t> pause_count; 476 RTCStatsMember<double> total_pauses_duration; 477 RTCStatsMember<uint32_t> freeze_count; 478 RTCStatsMember<double> total_freezes_duration; 479 // https://w3c.github.io/webrtc-provisional-stats/#dom-rtcinboundrtpstreamstats-contenttype 480 RTCStatsMember<std::string> content_type; 481 // Only populated if audio/video sync is enabled. 482 // TODO(https://crbug.com/webrtc/14177): Expose even if A/V sync is off? 483 RTCStatsMember<double> estimated_playout_timestamp; 484 // Only implemented for video. 485 // TODO(https://crbug.com/webrtc/14178): Also implement for audio. 486 RTCRestrictedStatsMember<std::string, 487 StatExposureCriteria::kHardwareCapability> 488 decoder_implementation; 489 // FIR and PLI counts are only defined for |kind == "video"|. 490 RTCStatsMember<uint32_t> fir_count; 491 RTCStatsMember<uint32_t> pli_count; 492 RTCStatsMember<uint32_t> nack_count; 493 RTCStatsMember<uint64_t> qp_sum; 494 // This is a remnant of the legacy getStats() API. When the "video-timing" 495 // header extension is used, 496 // https://webrtc.github.io/webrtc-org/experiments/rtp-hdrext/video-timing/, 497 // `googTimingFrameInfo` is exposed with the value of 498 // TimingFrameInfo::ToString(). 499 // TODO(https://crbug.com/webrtc/14586): Unship or standardize this metric. 500 RTCStatsMember<std::string> goog_timing_frame_info; 501 RTCRestrictedStatsMember<bool, StatExposureCriteria::kHardwareCapability> 502 power_efficient_decoder; 503 // Non-standard audio metrics. 504 RTCNonStandardStatsMember<uint64_t> jitter_buffer_flushes; 505 RTCNonStandardStatsMember<uint64_t> delayed_packet_outage_samples; 506 RTCNonStandardStatsMember<double> relative_packet_arrival_delay; 507 RTCNonStandardStatsMember<uint32_t> interruption_count; 508 RTCNonStandardStatsMember<double> total_interruption_duration; 509 510 // The former googMinPlayoutDelayMs (in seconds). 511 RTCNonStandardStatsMember<double> min_playout_delay; 512 }; 513 514 // https://w3c.github.io/webrtc-stats/#outboundrtpstats-dict* 515 class RTC_EXPORT RTCOutboundRTPStreamStats final : public RTCRTPStreamStats { 516 public: 517 WEBRTC_RTCSTATS_DECL(); 518 519 RTCOutboundRTPStreamStats(const std::string& id, int64_t timestamp_us); 520 RTCOutboundRTPStreamStats(std::string&& id, int64_t timestamp_us); 521 RTCOutboundRTPStreamStats(const RTCOutboundRTPStreamStats& other); 522 ~RTCOutboundRTPStreamStats() override; 523 524 RTCStatsMember<std::string> media_source_id; 525 RTCStatsMember<std::string> remote_id; 526 RTCStatsMember<std::string> mid; 527 RTCStatsMember<std::string> rid; 528 RTCStatsMember<uint32_t> packets_sent; 529 RTCStatsMember<uint64_t> retransmitted_packets_sent; 530 RTCStatsMember<uint64_t> bytes_sent; 531 RTCStatsMember<uint64_t> header_bytes_sent; 532 RTCStatsMember<uint64_t> retransmitted_bytes_sent; 533 RTCStatsMember<double> target_bitrate; 534 RTCStatsMember<uint32_t> frames_encoded; 535 RTCStatsMember<uint32_t> key_frames_encoded; 536 RTCStatsMember<double> total_encode_time; 537 RTCStatsMember<uint64_t> total_encoded_bytes_target; 538 RTCStatsMember<uint32_t> frame_width; 539 RTCStatsMember<uint32_t> frame_height; 540 RTCStatsMember<double> frames_per_second; 541 RTCStatsMember<uint32_t> frames_sent; 542 RTCStatsMember<uint32_t> huge_frames_sent; 543 RTCStatsMember<double> total_packet_send_delay; 544 // Enum type RTCQualityLimitationReason 545 RTCStatsMember<std::string> quality_limitation_reason; 546 RTCStatsMember<std::map<std::string, double>> quality_limitation_durations; 547 // https://w3c.github.io/webrtc-stats/#dom-rtcoutboundrtpstreamstats-qualitylimitationresolutionchanges 548 RTCStatsMember<uint32_t> quality_limitation_resolution_changes; 549 // https://w3c.github.io/webrtc-provisional-stats/#dom-rtcoutboundrtpstreamstats-contenttype 550 RTCStatsMember<std::string> content_type; 551 // Only implemented for video. 552 // TODO(https://crbug.com/webrtc/14178): Implement for audio as well. 553 RTCRestrictedStatsMember<std::string, 554 StatExposureCriteria::kHardwareCapability> 555 encoder_implementation; 556 // FIR and PLI counts are only defined for |kind == "video"|. 557 RTCStatsMember<uint32_t> fir_count; 558 RTCStatsMember<uint32_t> pli_count; 559 RTCStatsMember<uint32_t> nack_count; 560 RTCStatsMember<uint64_t> qp_sum; 561 RTCStatsMember<bool> active; 562 RTCRestrictedStatsMember<bool, StatExposureCriteria::kHardwareCapability> 563 power_efficient_encoder; 564 }; 565 566 // https://w3c.github.io/webrtc-stats/#remoteinboundrtpstats-dict* 567 class RTC_EXPORT RTCRemoteInboundRtpStreamStats final 568 : public RTCReceivedRtpStreamStats { 569 public: 570 WEBRTC_RTCSTATS_DECL(); 571 572 RTCRemoteInboundRtpStreamStats(const std::string& id, int64_t timestamp_us); 573 RTCRemoteInboundRtpStreamStats(std::string&& id, int64_t timestamp_us); 574 RTCRemoteInboundRtpStreamStats(const RTCRemoteInboundRtpStreamStats& other); 575 ~RTCRemoteInboundRtpStreamStats() override; 576 577 RTCStatsMember<std::string> local_id; 578 RTCStatsMember<double> round_trip_time; 579 RTCStatsMember<double> fraction_lost; 580 RTCStatsMember<double> total_round_trip_time; 581 RTCStatsMember<int32_t> round_trip_time_measurements; 582 }; 583 584 // https://w3c.github.io/webrtc-stats/#remoteoutboundrtpstats-dict* 585 class RTC_EXPORT RTCRemoteOutboundRtpStreamStats final 586 : public RTCSentRtpStreamStats { 587 public: 588 WEBRTC_RTCSTATS_DECL(); 589 590 RTCRemoteOutboundRtpStreamStats(const std::string& id, int64_t timestamp_us); 591 RTCRemoteOutboundRtpStreamStats(std::string&& id, int64_t timestamp_us); 592 RTCRemoteOutboundRtpStreamStats(const RTCRemoteOutboundRtpStreamStats& other); 593 ~RTCRemoteOutboundRtpStreamStats() override; 594 595 RTCStatsMember<std::string> local_id; 596 RTCStatsMember<double> remote_timestamp; 597 RTCStatsMember<uint64_t> reports_sent; 598 RTCStatsMember<double> round_trip_time; 599 RTCStatsMember<uint64_t> round_trip_time_measurements; 600 RTCStatsMember<double> total_round_trip_time; 601 }; 602 603 // https://w3c.github.io/webrtc-stats/#dom-rtcmediasourcestats 604 class RTC_EXPORT RTCMediaSourceStats : public RTCStats { 605 public: 606 WEBRTC_RTCSTATS_DECL(); 607 608 RTCMediaSourceStats(const RTCMediaSourceStats& other); 609 ~RTCMediaSourceStats() override; 610 611 RTCStatsMember<std::string> track_identifier; 612 RTCStatsMember<std::string> kind; 613 614 protected: 615 RTCMediaSourceStats(const std::string& id, int64_t timestamp_us); 616 RTCMediaSourceStats(std::string&& id, int64_t timestamp_us); 617 }; 618 619 // https://w3c.github.io/webrtc-stats/#dom-rtcaudiosourcestats 620 class RTC_EXPORT RTCAudioSourceStats final : public RTCMediaSourceStats { 621 public: 622 WEBRTC_RTCSTATS_DECL(); 623 624 RTCAudioSourceStats(const std::string& id, int64_t timestamp_us); 625 RTCAudioSourceStats(std::string&& id, int64_t timestamp_us); 626 RTCAudioSourceStats(const RTCAudioSourceStats& other); 627 ~RTCAudioSourceStats() override; 628 629 RTCStatsMember<double> audio_level; 630 RTCStatsMember<double> total_audio_energy; 631 RTCStatsMember<double> total_samples_duration; 632 RTCStatsMember<double> echo_return_loss; 633 RTCStatsMember<double> echo_return_loss_enhancement; 634 }; 635 636 // https://w3c.github.io/webrtc-stats/#dom-rtcvideosourcestats 637 class RTC_EXPORT RTCVideoSourceStats final : public RTCMediaSourceStats { 638 public: 639 WEBRTC_RTCSTATS_DECL(); 640 641 RTCVideoSourceStats(const std::string& id, int64_t timestamp_us); 642 RTCVideoSourceStats(std::string&& id, int64_t timestamp_us); 643 RTCVideoSourceStats(const RTCVideoSourceStats& other); 644 ~RTCVideoSourceStats() override; 645 646 RTCStatsMember<uint32_t> width; 647 RTCStatsMember<uint32_t> height; 648 RTCStatsMember<uint32_t> frames; 649 RTCStatsMember<double> frames_per_second; 650 }; 651 652 // https://w3c.github.io/webrtc-stats/#transportstats-dict* 653 class RTC_EXPORT RTCTransportStats final : public RTCStats { 654 public: 655 WEBRTC_RTCSTATS_DECL(); 656 657 RTCTransportStats(const std::string& id, int64_t timestamp_us); 658 RTCTransportStats(std::string&& id, int64_t timestamp_us); 659 RTCTransportStats(const RTCTransportStats& other); 660 ~RTCTransportStats() override; 661 662 RTCStatsMember<uint64_t> bytes_sent; 663 RTCStatsMember<uint64_t> packets_sent; 664 RTCStatsMember<uint64_t> bytes_received; 665 RTCStatsMember<uint64_t> packets_received; 666 RTCStatsMember<std::string> rtcp_transport_stats_id; 667 // Enum type RTCDtlsTransportState. 668 RTCStatsMember<std::string> dtls_state; 669 RTCStatsMember<std::string> selected_candidate_pair_id; 670 RTCStatsMember<std::string> local_certificate_id; 671 RTCStatsMember<std::string> remote_certificate_id; 672 RTCStatsMember<std::string> tls_version; 673 RTCStatsMember<std::string> dtls_cipher; 674 RTCStatsMember<std::string> dtls_role; 675 RTCStatsMember<std::string> srtp_cipher; 676 RTCStatsMember<uint32_t> selected_candidate_pair_changes; 677 RTCStatsMember<std::string> ice_role; 678 RTCStatsMember<std::string> ice_local_username_fragment; 679 RTCStatsMember<std::string> ice_state; 680 }; 681 682 } // namespace webrtc 683 684 #endif // API_STATS_RTCSTATS_OBJECTS_H_ 685