You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

914 lines
34 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  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. #include "api/stats/rtcstats_objects.h"
  11. #include <utility>
  12. #include "api/stats/rtc_stats.h"
  13. #include "rtc_base/checks.h"
  14. namespace webrtc {
  15. const char* const RTCDataChannelState::kConnecting = "connecting";
  16. const char* const RTCDataChannelState::kOpen = "open";
  17. const char* const RTCDataChannelState::kClosing = "closing";
  18. const char* const RTCDataChannelState::kClosed = "closed";
  19. const char* const RTCStatsIceCandidatePairState::kFrozen = "frozen";
  20. const char* const RTCStatsIceCandidatePairState::kWaiting = "waiting";
  21. const char* const RTCStatsIceCandidatePairState::kInProgress = "in-progress";
  22. const char* const RTCStatsIceCandidatePairState::kFailed = "failed";
  23. const char* const RTCStatsIceCandidatePairState::kSucceeded = "succeeded";
  24. // Strings defined in https://tools.ietf.org/html/rfc5245.
  25. const char* const RTCIceCandidateType::kHost = "host";
  26. const char* const RTCIceCandidateType::kSrflx = "srflx";
  27. const char* const RTCIceCandidateType::kPrflx = "prflx";
  28. const char* const RTCIceCandidateType::kRelay = "relay";
  29. const char* const RTCDtlsTransportState::kNew = "new";
  30. const char* const RTCDtlsTransportState::kConnecting = "connecting";
  31. const char* const RTCDtlsTransportState::kConnected = "connected";
  32. const char* const RTCDtlsTransportState::kClosed = "closed";
  33. const char* const RTCDtlsTransportState::kFailed = "failed";
  34. const char* const RTCMediaStreamTrackKind::kAudio = "audio";
  35. const char* const RTCMediaStreamTrackKind::kVideo = "video";
  36. // https://w3c.github.io/webrtc-stats/#dom-rtcnetworktype
  37. const char* const RTCNetworkType::kBluetooth = "bluetooth";
  38. const char* const RTCNetworkType::kCellular = "cellular";
  39. const char* const RTCNetworkType::kEthernet = "ethernet";
  40. const char* const RTCNetworkType::kWifi = "wifi";
  41. const char* const RTCNetworkType::kWimax = "wimax";
  42. const char* const RTCNetworkType::kVpn = "vpn";
  43. const char* const RTCNetworkType::kUnknown = "unknown";
  44. // https://w3c.github.io/webrtc-stats/#dom-rtcqualitylimitationreason
  45. const char* const RTCQualityLimitationReason::kNone = "none";
  46. const char* const RTCQualityLimitationReason::kCpu = "cpu";
  47. const char* const RTCQualityLimitationReason::kBandwidth = "bandwidth";
  48. const char* const RTCQualityLimitationReason::kOther = "other";
  49. // https://webrtc.org/experiments/rtp-hdrext/video-content-type/
  50. const char* const RTCContentType::kUnspecified = "unspecified";
  51. const char* const RTCContentType::kScreenshare = "screenshare";
  52. // clang-format off
  53. WEBRTC_RTCSTATS_IMPL(RTCCertificateStats, RTCStats, "certificate",
  54. &fingerprint,
  55. &fingerprint_algorithm,
  56. &base64_certificate,
  57. &issuer_certificate_id)
  58. // clang-format on
  59. RTCCertificateStats::RTCCertificateStats(const std::string& id,
  60. int64_t timestamp_us)
  61. : RTCCertificateStats(std::string(id), timestamp_us) {}
  62. RTCCertificateStats::RTCCertificateStats(std::string&& id, int64_t timestamp_us)
  63. : RTCStats(std::move(id), timestamp_us),
  64. fingerprint("fingerprint"),
  65. fingerprint_algorithm("fingerprintAlgorithm"),
  66. base64_certificate("base64Certificate"),
  67. issuer_certificate_id("issuerCertificateId") {}
  68. RTCCertificateStats::RTCCertificateStats(const RTCCertificateStats& other)
  69. : RTCStats(other.id(), other.timestamp_us()),
  70. fingerprint(other.fingerprint),
  71. fingerprint_algorithm(other.fingerprint_algorithm),
  72. base64_certificate(other.base64_certificate),
  73. issuer_certificate_id(other.issuer_certificate_id) {}
  74. RTCCertificateStats::~RTCCertificateStats() {}
  75. // clang-format off
  76. WEBRTC_RTCSTATS_IMPL(RTCCodecStats, RTCStats, "codec",
  77. &payload_type,
  78. &mime_type,
  79. &clock_rate,
  80. &channels,
  81. &sdp_fmtp_line)
  82. // clang-format on
  83. RTCCodecStats::RTCCodecStats(const std::string& id, int64_t timestamp_us)
  84. : RTCCodecStats(std::string(id), timestamp_us) {}
  85. RTCCodecStats::RTCCodecStats(std::string&& id, int64_t timestamp_us)
  86. : RTCStats(std::move(id), timestamp_us),
  87. payload_type("payloadType"),
  88. mime_type("mimeType"),
  89. clock_rate("clockRate"),
  90. channels("channels"),
  91. sdp_fmtp_line("sdpFmtpLine") {}
  92. RTCCodecStats::RTCCodecStats(const RTCCodecStats& other)
  93. : RTCStats(other.id(), other.timestamp_us()),
  94. payload_type(other.payload_type),
  95. mime_type(other.mime_type),
  96. clock_rate(other.clock_rate),
  97. channels(other.channels),
  98. sdp_fmtp_line(other.sdp_fmtp_line) {}
  99. RTCCodecStats::~RTCCodecStats() {}
  100. // clang-format off
  101. WEBRTC_RTCSTATS_IMPL(RTCDataChannelStats, RTCStats, "data-channel",
  102. &label,
  103. &protocol,
  104. &datachannelid,
  105. &state,
  106. &messages_sent,
  107. &bytes_sent,
  108. &messages_received,
  109. &bytes_received)
  110. // clang-format on
  111. RTCDataChannelStats::RTCDataChannelStats(const std::string& id,
  112. int64_t timestamp_us)
  113. : RTCDataChannelStats(std::string(id), timestamp_us) {}
  114. RTCDataChannelStats::RTCDataChannelStats(std::string&& id, int64_t timestamp_us)
  115. : RTCStats(std::move(id), timestamp_us),
  116. label("label"),
  117. protocol("protocol"),
  118. datachannelid("datachannelid"),
  119. state("state"),
  120. messages_sent("messagesSent"),
  121. bytes_sent("bytesSent"),
  122. messages_received("messagesReceived"),
  123. bytes_received("bytesReceived") {}
  124. RTCDataChannelStats::RTCDataChannelStats(const RTCDataChannelStats& other)
  125. : RTCStats(other.id(), other.timestamp_us()),
  126. label(other.label),
  127. protocol(other.protocol),
  128. datachannelid(other.datachannelid),
  129. state(other.state),
  130. messages_sent(other.messages_sent),
  131. bytes_sent(other.bytes_sent),
  132. messages_received(other.messages_received),
  133. bytes_received(other.bytes_received) {}
  134. RTCDataChannelStats::~RTCDataChannelStats() {}
  135. // clang-format off
  136. WEBRTC_RTCSTATS_IMPL(RTCIceCandidatePairStats, RTCStats, "candidate-pair",
  137. &transport_id,
  138. &local_candidate_id,
  139. &remote_candidate_id,
  140. &state,
  141. &priority,
  142. &nominated,
  143. &writable,
  144. &readable,
  145. &bytes_sent,
  146. &bytes_received,
  147. &total_round_trip_time,
  148. &current_round_trip_time,
  149. &available_outgoing_bitrate,
  150. &available_incoming_bitrate,
  151. &requests_received,
  152. &requests_sent,
  153. &responses_received,
  154. &responses_sent,
  155. &retransmissions_received,
  156. &retransmissions_sent,
  157. &consent_requests_received,
  158. &consent_requests_sent,
  159. &consent_responses_received,
  160. &consent_responses_sent)
  161. // clang-format on
  162. RTCIceCandidatePairStats::RTCIceCandidatePairStats(const std::string& id,
  163. int64_t timestamp_us)
  164. : RTCIceCandidatePairStats(std::string(id), timestamp_us) {}
  165. RTCIceCandidatePairStats::RTCIceCandidatePairStats(std::string&& id,
  166. int64_t timestamp_us)
  167. : RTCStats(std::move(id), timestamp_us),
  168. transport_id("transportId"),
  169. local_candidate_id("localCandidateId"),
  170. remote_candidate_id("remoteCandidateId"),
  171. state("state"),
  172. priority("priority"),
  173. nominated("nominated"),
  174. writable("writable"),
  175. readable("readable"),
  176. bytes_sent("bytesSent"),
  177. bytes_received("bytesReceived"),
  178. total_round_trip_time("totalRoundTripTime"),
  179. current_round_trip_time("currentRoundTripTime"),
  180. available_outgoing_bitrate("availableOutgoingBitrate"),
  181. available_incoming_bitrate("availableIncomingBitrate"),
  182. requests_received("requestsReceived"),
  183. requests_sent("requestsSent"),
  184. responses_received("responsesReceived"),
  185. responses_sent("responsesSent"),
  186. retransmissions_received("retransmissionsReceived"),
  187. retransmissions_sent("retransmissionsSent"),
  188. consent_requests_received("consentRequestsReceived"),
  189. consent_requests_sent("consentRequestsSent"),
  190. consent_responses_received("consentResponsesReceived"),
  191. consent_responses_sent("consentResponsesSent") {}
  192. RTCIceCandidatePairStats::RTCIceCandidatePairStats(
  193. const RTCIceCandidatePairStats& other)
  194. : RTCStats(other.id(), other.timestamp_us()),
  195. transport_id(other.transport_id),
  196. local_candidate_id(other.local_candidate_id),
  197. remote_candidate_id(other.remote_candidate_id),
  198. state(other.state),
  199. priority(other.priority),
  200. nominated(other.nominated),
  201. writable(other.writable),
  202. readable(other.readable),
  203. bytes_sent(other.bytes_sent),
  204. bytes_received(other.bytes_received),
  205. total_round_trip_time(other.total_round_trip_time),
  206. current_round_trip_time(other.current_round_trip_time),
  207. available_outgoing_bitrate(other.available_outgoing_bitrate),
  208. available_incoming_bitrate(other.available_incoming_bitrate),
  209. requests_received(other.requests_received),
  210. requests_sent(other.requests_sent),
  211. responses_received(other.responses_received),
  212. responses_sent(other.responses_sent),
  213. retransmissions_received(other.retransmissions_received),
  214. retransmissions_sent(other.retransmissions_sent),
  215. consent_requests_received(other.consent_requests_received),
  216. consent_requests_sent(other.consent_requests_sent),
  217. consent_responses_received(other.consent_responses_received),
  218. consent_responses_sent(other.consent_responses_sent) {}
  219. RTCIceCandidatePairStats::~RTCIceCandidatePairStats() {}
  220. // clang-format off
  221. WEBRTC_RTCSTATS_IMPL(RTCIceCandidateStats, RTCStats, "abstract-ice-candidate",
  222. &transport_id,
  223. &is_remote,
  224. &network_type,
  225. &ip,
  226. &port,
  227. &protocol,
  228. &relay_protocol,
  229. &candidate_type,
  230. &priority,
  231. &url,
  232. &deleted)
  233. // clang-format on
  234. RTCIceCandidateStats::RTCIceCandidateStats(const std::string& id,
  235. int64_t timestamp_us,
  236. bool is_remote)
  237. : RTCIceCandidateStats(std::string(id), timestamp_us, is_remote) {}
  238. RTCIceCandidateStats::RTCIceCandidateStats(std::string&& id,
  239. int64_t timestamp_us,
  240. bool is_remote)
  241. : RTCStats(std::move(id), timestamp_us),
  242. transport_id("transportId"),
  243. is_remote("isRemote", is_remote),
  244. network_type("networkType"),
  245. ip("ip"),
  246. port("port"),
  247. protocol("protocol"),
  248. relay_protocol("relayProtocol"),
  249. candidate_type("candidateType"),
  250. priority("priority"),
  251. url("url"),
  252. deleted("deleted", false) {}
  253. RTCIceCandidateStats::RTCIceCandidateStats(const RTCIceCandidateStats& other)
  254. : RTCStats(other.id(), other.timestamp_us()),
  255. transport_id(other.transport_id),
  256. is_remote(other.is_remote),
  257. network_type(other.network_type),
  258. ip(other.ip),
  259. port(other.port),
  260. protocol(other.protocol),
  261. relay_protocol(other.relay_protocol),
  262. candidate_type(other.candidate_type),
  263. priority(other.priority),
  264. url(other.url),
  265. deleted(other.deleted) {}
  266. RTCIceCandidateStats::~RTCIceCandidateStats() {}
  267. const char RTCLocalIceCandidateStats::kType[] = "local-candidate";
  268. RTCLocalIceCandidateStats::RTCLocalIceCandidateStats(const std::string& id,
  269. int64_t timestamp_us)
  270. : RTCIceCandidateStats(id, timestamp_us, false) {}
  271. RTCLocalIceCandidateStats::RTCLocalIceCandidateStats(std::string&& id,
  272. int64_t timestamp_us)
  273. : RTCIceCandidateStats(std::move(id), timestamp_us, false) {}
  274. std::unique_ptr<RTCStats> RTCLocalIceCandidateStats::copy() const {
  275. return std::unique_ptr<RTCStats>(new RTCLocalIceCandidateStats(*this));
  276. }
  277. const char* RTCLocalIceCandidateStats::type() const {
  278. return kType;
  279. }
  280. const char RTCRemoteIceCandidateStats::kType[] = "remote-candidate";
  281. RTCRemoteIceCandidateStats::RTCRemoteIceCandidateStats(const std::string& id,
  282. int64_t timestamp_us)
  283. : RTCIceCandidateStats(id, timestamp_us, true) {}
  284. RTCRemoteIceCandidateStats::RTCRemoteIceCandidateStats(std::string&& id,
  285. int64_t timestamp_us)
  286. : RTCIceCandidateStats(std::move(id), timestamp_us, true) {}
  287. std::unique_ptr<RTCStats> RTCRemoteIceCandidateStats::copy() const {
  288. return std::unique_ptr<RTCStats>(new RTCRemoteIceCandidateStats(*this));
  289. }
  290. const char* RTCRemoteIceCandidateStats::type() const {
  291. return kType;
  292. }
  293. // clang-format off
  294. WEBRTC_RTCSTATS_IMPL(RTCMediaStreamStats, RTCStats, "stream",
  295. &stream_identifier,
  296. &track_ids)
  297. // clang-format on
  298. RTCMediaStreamStats::RTCMediaStreamStats(const std::string& id,
  299. int64_t timestamp_us)
  300. : RTCMediaStreamStats(std::string(id), timestamp_us) {}
  301. RTCMediaStreamStats::RTCMediaStreamStats(std::string&& id, int64_t timestamp_us)
  302. : RTCStats(std::move(id), timestamp_us),
  303. stream_identifier("streamIdentifier"),
  304. track_ids("trackIds") {}
  305. RTCMediaStreamStats::RTCMediaStreamStats(const RTCMediaStreamStats& other)
  306. : RTCStats(other.id(), other.timestamp_us()),
  307. stream_identifier(other.stream_identifier),
  308. track_ids(other.track_ids) {}
  309. RTCMediaStreamStats::~RTCMediaStreamStats() {}
  310. // clang-format off
  311. WEBRTC_RTCSTATS_IMPL(RTCMediaStreamTrackStats, RTCStats, "track",
  312. &track_identifier,
  313. &media_source_id,
  314. &remote_source,
  315. &ended,
  316. &detached,
  317. &kind,
  318. &jitter_buffer_delay,
  319. &jitter_buffer_emitted_count,
  320. &frame_width,
  321. &frame_height,
  322. &frames_per_second,
  323. &frames_sent,
  324. &huge_frames_sent,
  325. &frames_received,
  326. &frames_decoded,
  327. &frames_dropped,
  328. &frames_corrupted,
  329. &partial_frames_lost,
  330. &full_frames_lost,
  331. &audio_level,
  332. &total_audio_energy,
  333. &echo_return_loss,
  334. &echo_return_loss_enhancement,
  335. &total_samples_received,
  336. &total_samples_duration,
  337. &concealed_samples,
  338. &silent_concealed_samples,
  339. &concealment_events,
  340. &inserted_samples_for_deceleration,
  341. &removed_samples_for_acceleration,
  342. &jitter_buffer_flushes,
  343. &delayed_packet_outage_samples,
  344. &relative_packet_arrival_delay,
  345. &interruption_count,
  346. &total_interruption_duration,
  347. &freeze_count,
  348. &pause_count,
  349. &total_freezes_duration,
  350. &total_pauses_duration,
  351. &total_frames_duration,
  352. &sum_squared_frame_durations)
  353. // clang-format on
  354. RTCMediaStreamTrackStats::RTCMediaStreamTrackStats(const std::string& id,
  355. int64_t timestamp_us,
  356. const char* kind)
  357. : RTCMediaStreamTrackStats(std::string(id), timestamp_us, kind) {}
  358. RTCMediaStreamTrackStats::RTCMediaStreamTrackStats(std::string&& id,
  359. int64_t timestamp_us,
  360. const char* kind)
  361. : RTCStats(std::move(id), timestamp_us),
  362. track_identifier("trackIdentifier"),
  363. media_source_id("mediaSourceId"),
  364. remote_source("remoteSource"),
  365. ended("ended"),
  366. detached("detached"),
  367. kind("kind", kind),
  368. jitter_buffer_delay("jitterBufferDelay"),
  369. jitter_buffer_emitted_count("jitterBufferEmittedCount"),
  370. frame_width("frameWidth"),
  371. frame_height("frameHeight"),
  372. frames_per_second("framesPerSecond"),
  373. frames_sent("framesSent"),
  374. huge_frames_sent("hugeFramesSent"),
  375. frames_received("framesReceived"),
  376. frames_decoded("framesDecoded"),
  377. frames_dropped("framesDropped"),
  378. frames_corrupted("framesCorrupted"),
  379. partial_frames_lost("partialFramesLost"),
  380. full_frames_lost("fullFramesLost"),
  381. audio_level("audioLevel"),
  382. total_audio_energy("totalAudioEnergy"),
  383. echo_return_loss("echoReturnLoss"),
  384. echo_return_loss_enhancement("echoReturnLossEnhancement"),
  385. total_samples_received("totalSamplesReceived"),
  386. total_samples_duration("totalSamplesDuration"),
  387. concealed_samples("concealedSamples"),
  388. silent_concealed_samples("silentConcealedSamples"),
  389. concealment_events("concealmentEvents"),
  390. inserted_samples_for_deceleration("insertedSamplesForDeceleration"),
  391. removed_samples_for_acceleration("removedSamplesForAcceleration"),
  392. jitter_buffer_flushes(
  393. "jitterBufferFlushes",
  394. {NonStandardGroupId::kRtcAudioJitterBufferMaxPackets}),
  395. delayed_packet_outage_samples(
  396. "delayedPacketOutageSamples",
  397. {NonStandardGroupId::kRtcAudioJitterBufferMaxPackets,
  398. NonStandardGroupId::kRtcStatsRelativePacketArrivalDelay}),
  399. relative_packet_arrival_delay(
  400. "relativePacketArrivalDelay",
  401. {NonStandardGroupId::kRtcStatsRelativePacketArrivalDelay}),
  402. interruption_count("interruptionCount"),
  403. total_interruption_duration("totalInterruptionDuration"),
  404. freeze_count("freezeCount"),
  405. pause_count("pauseCount"),
  406. total_freezes_duration("totalFreezesDuration"),
  407. total_pauses_duration("totalPausesDuration"),
  408. total_frames_duration("totalFramesDuration"),
  409. sum_squared_frame_durations("sumOfSquaredFramesDuration") {
  410. RTC_DCHECK(kind == RTCMediaStreamTrackKind::kAudio ||
  411. kind == RTCMediaStreamTrackKind::kVideo);
  412. }
  413. RTCMediaStreamTrackStats::RTCMediaStreamTrackStats(
  414. const RTCMediaStreamTrackStats& other)
  415. : RTCStats(other.id(), other.timestamp_us()),
  416. track_identifier(other.track_identifier),
  417. media_source_id(other.media_source_id),
  418. remote_source(other.remote_source),
  419. ended(other.ended),
  420. detached(other.detached),
  421. kind(other.kind),
  422. jitter_buffer_delay(other.jitter_buffer_delay),
  423. jitter_buffer_emitted_count(other.jitter_buffer_emitted_count),
  424. frame_width(other.frame_width),
  425. frame_height(other.frame_height),
  426. frames_per_second(other.frames_per_second),
  427. frames_sent(other.frames_sent),
  428. huge_frames_sent(other.huge_frames_sent),
  429. frames_received(other.frames_received),
  430. frames_decoded(other.frames_decoded),
  431. frames_dropped(other.frames_dropped),
  432. frames_corrupted(other.frames_corrupted),
  433. partial_frames_lost(other.partial_frames_lost),
  434. full_frames_lost(other.full_frames_lost),
  435. audio_level(other.audio_level),
  436. total_audio_energy(other.total_audio_energy),
  437. echo_return_loss(other.echo_return_loss),
  438. echo_return_loss_enhancement(other.echo_return_loss_enhancement),
  439. total_samples_received(other.total_samples_received),
  440. total_samples_duration(other.total_samples_duration),
  441. concealed_samples(other.concealed_samples),
  442. silent_concealed_samples(other.silent_concealed_samples),
  443. concealment_events(other.concealment_events),
  444. inserted_samples_for_deceleration(
  445. other.inserted_samples_for_deceleration),
  446. removed_samples_for_acceleration(other.removed_samples_for_acceleration),
  447. jitter_buffer_flushes(other.jitter_buffer_flushes),
  448. delayed_packet_outage_samples(other.delayed_packet_outage_samples),
  449. relative_packet_arrival_delay(other.relative_packet_arrival_delay),
  450. interruption_count(other.interruption_count),
  451. total_interruption_duration(other.total_interruption_duration),
  452. freeze_count(other.freeze_count),
  453. pause_count(other.pause_count),
  454. total_freezes_duration(other.total_freezes_duration),
  455. total_pauses_duration(other.total_pauses_duration),
  456. total_frames_duration(other.total_frames_duration),
  457. sum_squared_frame_durations(other.sum_squared_frame_durations) {}
  458. RTCMediaStreamTrackStats::~RTCMediaStreamTrackStats() {}
  459. // clang-format off
  460. WEBRTC_RTCSTATS_IMPL(RTCPeerConnectionStats, RTCStats, "peer-connection",
  461. &data_channels_opened,
  462. &data_channels_closed)
  463. // clang-format on
  464. RTCPeerConnectionStats::RTCPeerConnectionStats(const std::string& id,
  465. int64_t timestamp_us)
  466. : RTCPeerConnectionStats(std::string(id), timestamp_us) {}
  467. RTCPeerConnectionStats::RTCPeerConnectionStats(std::string&& id,
  468. int64_t timestamp_us)
  469. : RTCStats(std::move(id), timestamp_us),
  470. data_channels_opened("dataChannelsOpened"),
  471. data_channels_closed("dataChannelsClosed") {}
  472. RTCPeerConnectionStats::RTCPeerConnectionStats(
  473. const RTCPeerConnectionStats& other)
  474. : RTCStats(other.id(), other.timestamp_us()),
  475. data_channels_opened(other.data_channels_opened),
  476. data_channels_closed(other.data_channels_closed) {}
  477. RTCPeerConnectionStats::~RTCPeerConnectionStats() {}
  478. // clang-format off
  479. WEBRTC_RTCSTATS_IMPL(RTCRTPStreamStats, RTCStats, "rtp",
  480. &ssrc,
  481. &associate_stats_id,
  482. &is_remote,
  483. &media_type,
  484. &kind,
  485. &track_id,
  486. &transport_id,
  487. &codec_id,
  488. &fir_count,
  489. &pli_count,
  490. &nack_count,
  491. &sli_count,
  492. &qp_sum)
  493. // clang-format on
  494. RTCRTPStreamStats::RTCRTPStreamStats(const std::string& id,
  495. int64_t timestamp_us)
  496. : RTCRTPStreamStats(std::string(id), timestamp_us) {}
  497. RTCRTPStreamStats::RTCRTPStreamStats(std::string&& id, int64_t timestamp_us)
  498. : RTCStats(std::move(id), timestamp_us),
  499. ssrc("ssrc"),
  500. associate_stats_id("associateStatsId"),
  501. is_remote("isRemote", false),
  502. media_type("mediaType"),
  503. kind("kind"),
  504. track_id("trackId"),
  505. transport_id("transportId"),
  506. codec_id("codecId"),
  507. fir_count("firCount"),
  508. pli_count("pliCount"),
  509. nack_count("nackCount"),
  510. sli_count("sliCount"),
  511. qp_sum("qpSum") {}
  512. RTCRTPStreamStats::RTCRTPStreamStats(const RTCRTPStreamStats& other)
  513. : RTCStats(other.id(), other.timestamp_us()),
  514. ssrc(other.ssrc),
  515. associate_stats_id(other.associate_stats_id),
  516. is_remote(other.is_remote),
  517. media_type(other.media_type),
  518. kind(other.kind),
  519. track_id(other.track_id),
  520. transport_id(other.transport_id),
  521. codec_id(other.codec_id),
  522. fir_count(other.fir_count),
  523. pli_count(other.pli_count),
  524. nack_count(other.nack_count),
  525. sli_count(other.sli_count),
  526. qp_sum(other.qp_sum) {}
  527. RTCRTPStreamStats::~RTCRTPStreamStats() {}
  528. // clang-format off
  529. WEBRTC_RTCSTATS_IMPL(
  530. RTCInboundRTPStreamStats, RTCRTPStreamStats, "inbound-rtp",
  531. &packets_received,
  532. &bytes_received,
  533. &header_bytes_received,
  534. &packets_lost,
  535. &last_packet_received_timestamp,
  536. &jitter,
  537. &round_trip_time,
  538. &packets_discarded,
  539. &packets_repaired,
  540. &burst_packets_lost,
  541. &burst_packets_discarded,
  542. &burst_loss_count,
  543. &burst_discard_count,
  544. &burst_loss_rate,
  545. &burst_discard_rate,
  546. &gap_loss_rate,
  547. &gap_discard_rate,
  548. &frames_decoded,
  549. &key_frames_decoded,
  550. &total_decode_time,
  551. &content_type,
  552. &decoder_implementation)
  553. // clang-format on
  554. RTCInboundRTPStreamStats::RTCInboundRTPStreamStats(const std::string& id,
  555. int64_t timestamp_us)
  556. : RTCInboundRTPStreamStats(std::string(id), timestamp_us) {}
  557. RTCInboundRTPStreamStats::RTCInboundRTPStreamStats(std::string&& id,
  558. int64_t timestamp_us)
  559. : RTCRTPStreamStats(std::move(id), timestamp_us),
  560. packets_received("packetsReceived"),
  561. fec_packets_received("fecPacketsReceived"),
  562. fec_packets_discarded("fecPacketsDiscarded"),
  563. bytes_received("bytesReceived"),
  564. header_bytes_received("headerBytesReceived"),
  565. packets_lost("packetsLost"),
  566. last_packet_received_timestamp("lastPacketReceivedTimestamp"),
  567. jitter("jitter"),
  568. round_trip_time("roundTripTime"),
  569. packets_discarded("packetsDiscarded"),
  570. packets_repaired("packetsRepaired"),
  571. burst_packets_lost("burstPacketsLost"),
  572. burst_packets_discarded("burstPacketsDiscarded"),
  573. burst_loss_count("burstLossCount"),
  574. burst_discard_count("burstDiscardCount"),
  575. burst_loss_rate("burstLossRate"),
  576. burst_discard_rate("burstDiscardRate"),
  577. gap_loss_rate("gapLossRate"),
  578. gap_discard_rate("gapDiscardRate"),
  579. frames_decoded("framesDecoded"),
  580. key_frames_decoded("keyFramesDecoded"),
  581. total_decode_time("totalDecodeTime"),
  582. content_type("contentType"),
  583. decoder_implementation("decoderImplementation") {}
  584. RTCInboundRTPStreamStats::RTCInboundRTPStreamStats(
  585. const RTCInboundRTPStreamStats& other)
  586. : RTCRTPStreamStats(other),
  587. packets_received(other.packets_received),
  588. fec_packets_received(other.fec_packets_received),
  589. fec_packets_discarded(other.fec_packets_discarded),
  590. bytes_received(other.bytes_received),
  591. header_bytes_received(other.header_bytes_received),
  592. packets_lost(other.packets_lost),
  593. last_packet_received_timestamp(other.last_packet_received_timestamp),
  594. jitter(other.jitter),
  595. round_trip_time(other.round_trip_time),
  596. packets_discarded(other.packets_discarded),
  597. packets_repaired(other.packets_repaired),
  598. burst_packets_lost(other.burst_packets_lost),
  599. burst_packets_discarded(other.burst_packets_discarded),
  600. burst_loss_count(other.burst_loss_count),
  601. burst_discard_count(other.burst_discard_count),
  602. burst_loss_rate(other.burst_loss_rate),
  603. burst_discard_rate(other.burst_discard_rate),
  604. gap_loss_rate(other.gap_loss_rate),
  605. gap_discard_rate(other.gap_discard_rate),
  606. frames_decoded(other.frames_decoded),
  607. key_frames_decoded(other.key_frames_decoded),
  608. total_decode_time(other.total_decode_time),
  609. content_type(other.content_type),
  610. decoder_implementation(other.decoder_implementation) {}
  611. RTCInboundRTPStreamStats::~RTCInboundRTPStreamStats() {}
  612. // clang-format off
  613. WEBRTC_RTCSTATS_IMPL(
  614. RTCOutboundRTPStreamStats, RTCRTPStreamStats, "outbound-rtp",
  615. &media_source_id,
  616. &packets_sent,
  617. &retransmitted_packets_sent,
  618. &bytes_sent,
  619. &header_bytes_sent,
  620. &retransmitted_bytes_sent,
  621. &target_bitrate,
  622. &frames_encoded,
  623. &key_frames_encoded,
  624. &total_encode_time,
  625. &total_encoded_bytes_target,
  626. &total_packet_send_delay,
  627. &quality_limitation_reason,
  628. &quality_limitation_resolution_changes,
  629. &content_type,
  630. &encoder_implementation)
  631. // clang-format on
  632. RTCOutboundRTPStreamStats::RTCOutboundRTPStreamStats(const std::string& id,
  633. int64_t timestamp_us)
  634. : RTCOutboundRTPStreamStats(std::string(id), timestamp_us) {}
  635. RTCOutboundRTPStreamStats::RTCOutboundRTPStreamStats(std::string&& id,
  636. int64_t timestamp_us)
  637. : RTCRTPStreamStats(std::move(id), timestamp_us),
  638. media_source_id("mediaSourceId"),
  639. packets_sent("packetsSent"),
  640. retransmitted_packets_sent("retransmittedPacketsSent"),
  641. bytes_sent("bytesSent"),
  642. header_bytes_sent("headerBytesSent"),
  643. retransmitted_bytes_sent("retransmittedBytesSent"),
  644. target_bitrate("targetBitrate"),
  645. frames_encoded("framesEncoded"),
  646. key_frames_encoded("keyFramesEncoded"),
  647. total_encode_time("totalEncodeTime"),
  648. total_encoded_bytes_target("totalEncodedBytesTarget"),
  649. total_packet_send_delay("totalPacketSendDelay"),
  650. quality_limitation_reason("qualityLimitationReason"),
  651. quality_limitation_resolution_changes(
  652. "qualityLimitationResolutionChanges"),
  653. content_type("contentType"),
  654. encoder_implementation("encoderImplementation") {}
  655. RTCOutboundRTPStreamStats::RTCOutboundRTPStreamStats(
  656. const RTCOutboundRTPStreamStats& other)
  657. : RTCRTPStreamStats(other),
  658. media_source_id(other.media_source_id),
  659. packets_sent(other.packets_sent),
  660. retransmitted_packets_sent(other.retransmitted_packets_sent),
  661. bytes_sent(other.bytes_sent),
  662. header_bytes_sent(other.header_bytes_sent),
  663. retransmitted_bytes_sent(other.retransmitted_bytes_sent),
  664. target_bitrate(other.target_bitrate),
  665. frames_encoded(other.frames_encoded),
  666. key_frames_encoded(other.key_frames_encoded),
  667. total_encode_time(other.total_encode_time),
  668. total_encoded_bytes_target(other.total_encoded_bytes_target),
  669. total_packet_send_delay(other.total_packet_send_delay),
  670. quality_limitation_reason(other.quality_limitation_reason),
  671. quality_limitation_resolution_changes(
  672. other.quality_limitation_resolution_changes),
  673. content_type(other.content_type),
  674. encoder_implementation(other.encoder_implementation) {}
  675. RTCOutboundRTPStreamStats::~RTCOutboundRTPStreamStats() {}
  676. // clang-format off
  677. WEBRTC_RTCSTATS_IMPL(
  678. RTCRemoteInboundRtpStreamStats, RTCStats, "remote-inbound-rtp",
  679. &ssrc,
  680. &kind,
  681. &transport_id,
  682. &codec_id,
  683. &packets_lost,
  684. &jitter,
  685. &local_id,
  686. &round_trip_time)
  687. // clang-format on
  688. RTCRemoteInboundRtpStreamStats::RTCRemoteInboundRtpStreamStats(
  689. const std::string& id,
  690. int64_t timestamp_us)
  691. : RTCRemoteInboundRtpStreamStats(std::string(id), timestamp_us) {}
  692. RTCRemoteInboundRtpStreamStats::RTCRemoteInboundRtpStreamStats(
  693. std::string&& id,
  694. int64_t timestamp_us)
  695. : RTCStats(std::move(id), timestamp_us),
  696. ssrc("ssrc"),
  697. kind("kind"),
  698. transport_id("transportId"),
  699. codec_id("codecId"),
  700. packets_lost("packetsLost"),
  701. jitter("jitter"),
  702. local_id("localId"),
  703. round_trip_time("roundTripTime") {}
  704. RTCRemoteInboundRtpStreamStats::RTCRemoteInboundRtpStreamStats(
  705. const RTCRemoteInboundRtpStreamStats& other)
  706. : RTCStats(other),
  707. ssrc(other.ssrc),
  708. kind(other.kind),
  709. transport_id(other.transport_id),
  710. codec_id(other.codec_id),
  711. packets_lost(other.packets_lost),
  712. jitter(other.jitter),
  713. local_id(other.local_id),
  714. round_trip_time(other.round_trip_time) {}
  715. RTCRemoteInboundRtpStreamStats::~RTCRemoteInboundRtpStreamStats() {}
  716. // clang-format off
  717. WEBRTC_RTCSTATS_IMPL(RTCMediaSourceStats, RTCStats, "parent-media-source",
  718. &track_identifier,
  719. &kind)
  720. // clang-format on
  721. RTCMediaSourceStats::RTCMediaSourceStats(const std::string& id,
  722. int64_t timestamp_us)
  723. : RTCMediaSourceStats(std::string(id), timestamp_us) {}
  724. RTCMediaSourceStats::RTCMediaSourceStats(std::string&& id, int64_t timestamp_us)
  725. : RTCStats(std::move(id), timestamp_us),
  726. track_identifier("trackIdentifier"),
  727. kind("kind") {}
  728. RTCMediaSourceStats::RTCMediaSourceStats(const RTCMediaSourceStats& other)
  729. : RTCStats(other.id(), other.timestamp_us()),
  730. track_identifier(other.track_identifier),
  731. kind(other.kind) {}
  732. RTCMediaSourceStats::~RTCMediaSourceStats() {}
  733. // clang-format off
  734. WEBRTC_RTCSTATS_IMPL(RTCAudioSourceStats, RTCMediaSourceStats, "media-source",
  735. &audio_level,
  736. &total_audio_energy,
  737. &total_samples_duration)
  738. // clang-format on
  739. RTCAudioSourceStats::RTCAudioSourceStats(const std::string& id,
  740. int64_t timestamp_us)
  741. : RTCAudioSourceStats(std::string(id), timestamp_us) {}
  742. RTCAudioSourceStats::RTCAudioSourceStats(std::string&& id, int64_t timestamp_us)
  743. : RTCMediaSourceStats(std::move(id), timestamp_us),
  744. audio_level("audioLevel"),
  745. total_audio_energy("totalAudioEnergy"),
  746. total_samples_duration("totalSamplesDuration") {}
  747. RTCAudioSourceStats::RTCAudioSourceStats(const RTCAudioSourceStats& other)
  748. : RTCMediaSourceStats(other),
  749. audio_level(other.audio_level),
  750. total_audio_energy(other.total_audio_energy),
  751. total_samples_duration(other.total_samples_duration) {}
  752. RTCAudioSourceStats::~RTCAudioSourceStats() {}
  753. // clang-format off
  754. WEBRTC_RTCSTATS_IMPL(RTCVideoSourceStats, RTCMediaSourceStats, "media-source",
  755. &width,
  756. &height,
  757. &frames,
  758. &frames_per_second)
  759. // clang-format on
  760. RTCVideoSourceStats::RTCVideoSourceStats(const std::string& id,
  761. int64_t timestamp_us)
  762. : RTCVideoSourceStats(std::string(id), timestamp_us) {}
  763. RTCVideoSourceStats::RTCVideoSourceStats(std::string&& id, int64_t timestamp_us)
  764. : RTCMediaSourceStats(std::move(id), timestamp_us),
  765. width("width"),
  766. height("height"),
  767. frames("frames"),
  768. frames_per_second("framesPerSecond") {}
  769. RTCVideoSourceStats::RTCVideoSourceStats(const RTCVideoSourceStats& other)
  770. : RTCMediaSourceStats(other),
  771. width(other.width),
  772. height(other.height),
  773. frames(other.frames),
  774. frames_per_second(other.frames_per_second) {}
  775. RTCVideoSourceStats::~RTCVideoSourceStats() {}
  776. // clang-format off
  777. WEBRTC_RTCSTATS_IMPL(RTCTransportStats, RTCStats, "transport",
  778. &bytes_sent,
  779. &bytes_received,
  780. &rtcp_transport_stats_id,
  781. &dtls_state,
  782. &selected_candidate_pair_id,
  783. &local_certificate_id,
  784. &remote_certificate_id,
  785. &selected_candidate_pair_changes)
  786. // clang-format on
  787. RTCTransportStats::RTCTransportStats(const std::string& id,
  788. int64_t timestamp_us)
  789. : RTCTransportStats(std::string(id), timestamp_us) {}
  790. RTCTransportStats::RTCTransportStats(std::string&& id, int64_t timestamp_us)
  791. : RTCStats(std::move(id), timestamp_us),
  792. bytes_sent("bytesSent"),
  793. bytes_received("bytesReceived"),
  794. rtcp_transport_stats_id("rtcpTransportStatsId"),
  795. dtls_state("dtlsState"),
  796. selected_candidate_pair_id("selectedCandidatePairId"),
  797. local_certificate_id("localCertificateId"),
  798. remote_certificate_id("remoteCertificateId"),
  799. selected_candidate_pair_changes("selectedCandidatePairChanges") {}
  800. RTCTransportStats::RTCTransportStats(const RTCTransportStats& other)
  801. : RTCStats(other.id(), other.timestamp_us()),
  802. bytes_sent(other.bytes_sent),
  803. bytes_received(other.bytes_received),
  804. rtcp_transport_stats_id(other.rtcp_transport_stats_id),
  805. dtls_state(other.dtls_state),
  806. selected_candidate_pair_id(other.selected_candidate_pair_id),
  807. local_certificate_id(other.local_certificate_id),
  808. remote_certificate_id(other.remote_certificate_id),
  809. selected_candidate_pair_changes(other.selected_candidate_pair_changes) {}
  810. RTCTransportStats::~RTCTransportStats() {}
  811. } // namespace webrtc