rtcstats_objects.h 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639
  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. #ifndef API_STATS_RTCSTATS_OBJECTS_H_
  11. #define API_STATS_RTCSTATS_OBJECTS_H_
  12. #include <stdint.h>
  13. #include <memory>
  14. #include <string>
  15. #include <vector>
  16. #include "api/stats/rtc_stats.h"
  17. #include "rtc_base/system/rtc_export.h"
  18. namespace webrtc {
  19. // https://w3c.github.io/webrtc-pc/#idl-def-rtcdatachannelstate
  20. struct RTCDataChannelState {
  21. static const char* const kConnecting;
  22. static const char* const kOpen;
  23. static const char* const kClosing;
  24. static const char* const kClosed;
  25. };
  26. // https://w3c.github.io/webrtc-stats/#dom-rtcstatsicecandidatepairstate
  27. struct RTCStatsIceCandidatePairState {
  28. static const char* const kFrozen;
  29. static const char* const kWaiting;
  30. static const char* const kInProgress;
  31. static const char* const kFailed;
  32. static const char* const kSucceeded;
  33. };
  34. // https://w3c.github.io/webrtc-pc/#rtcicecandidatetype-enum
  35. struct RTCIceCandidateType {
  36. static const char* const kHost;
  37. static const char* const kSrflx;
  38. static const char* const kPrflx;
  39. static const char* const kRelay;
  40. };
  41. // https://w3c.github.io/webrtc-pc/#idl-def-rtcdtlstransportstate
  42. struct RTCDtlsTransportState {
  43. static const char* const kNew;
  44. static const char* const kConnecting;
  45. static const char* const kConnected;
  46. static const char* const kClosed;
  47. static const char* const kFailed;
  48. };
  49. // |RTCMediaStreamTrackStats::kind| is not an enum in the spec but the only
  50. // valid values are "audio" and "video".
  51. // https://w3c.github.io/webrtc-stats/#dom-rtcmediastreamtrackstats-kind
  52. struct RTCMediaStreamTrackKind {
  53. static const char* const kAudio;
  54. static const char* const kVideo;
  55. };
  56. // https://w3c.github.io/webrtc-stats/#dom-rtcnetworktype
  57. struct RTCNetworkType {
  58. static const char* const kBluetooth;
  59. static const char* const kCellular;
  60. static const char* const kEthernet;
  61. static const char* const kWifi;
  62. static const char* const kWimax;
  63. static const char* const kVpn;
  64. static const char* const kUnknown;
  65. };
  66. // https://w3c.github.io/webrtc-stats/#dom-rtcqualitylimitationreason
  67. struct RTCQualityLimitationReason {
  68. static const char* const kNone;
  69. static const char* const kCpu;
  70. static const char* const kBandwidth;
  71. static const char* const kOther;
  72. };
  73. // https://webrtc.org/experiments/rtp-hdrext/video-content-type/
  74. struct RTCContentType {
  75. static const char* const kUnspecified;
  76. static const char* const kScreenshare;
  77. };
  78. // https://w3c.github.io/webrtc-stats/#certificatestats-dict*
  79. class RTC_EXPORT RTCCertificateStats final : public RTCStats {
  80. public:
  81. WEBRTC_RTCSTATS_DECL();
  82. RTCCertificateStats(const std::string& id, int64_t timestamp_us);
  83. RTCCertificateStats(std::string&& id, int64_t timestamp_us);
  84. RTCCertificateStats(const RTCCertificateStats& other);
  85. ~RTCCertificateStats() override;
  86. RTCStatsMember<std::string> fingerprint;
  87. RTCStatsMember<std::string> fingerprint_algorithm;
  88. RTCStatsMember<std::string> base64_certificate;
  89. RTCStatsMember<std::string> issuer_certificate_id;
  90. };
  91. // https://w3c.github.io/webrtc-stats/#codec-dict*
  92. class RTC_EXPORT RTCCodecStats final : public RTCStats {
  93. public:
  94. WEBRTC_RTCSTATS_DECL();
  95. RTCCodecStats(const std::string& id, int64_t timestamp_us);
  96. RTCCodecStats(std::string&& id, int64_t timestamp_us);
  97. RTCCodecStats(const RTCCodecStats& other);
  98. ~RTCCodecStats() override;
  99. RTCStatsMember<uint32_t> payload_type;
  100. RTCStatsMember<std::string> mime_type;
  101. RTCStatsMember<uint32_t> clock_rate;
  102. RTCStatsMember<uint32_t> channels;
  103. RTCStatsMember<std::string> sdp_fmtp_line;
  104. };
  105. // https://w3c.github.io/webrtc-stats/#dcstats-dict*
  106. class RTC_EXPORT RTCDataChannelStats final : public RTCStats {
  107. public:
  108. WEBRTC_RTCSTATS_DECL();
  109. RTCDataChannelStats(const std::string& id, int64_t timestamp_us);
  110. RTCDataChannelStats(std::string&& id, int64_t timestamp_us);
  111. RTCDataChannelStats(const RTCDataChannelStats& other);
  112. ~RTCDataChannelStats() override;
  113. RTCStatsMember<std::string> label;
  114. RTCStatsMember<std::string> protocol;
  115. RTCStatsMember<int32_t> data_channel_identifier;
  116. // TODO(hbos): Support enum types? "RTCStatsMember<RTCDataChannelState>"?
  117. RTCStatsMember<std::string> state;
  118. RTCStatsMember<uint32_t> messages_sent;
  119. RTCStatsMember<uint64_t> bytes_sent;
  120. RTCStatsMember<uint32_t> messages_received;
  121. RTCStatsMember<uint64_t> bytes_received;
  122. };
  123. // https://w3c.github.io/webrtc-stats/#candidatepair-dict*
  124. // TODO(hbos): Tracking bug https://bugs.webrtc.org/7062
  125. class RTC_EXPORT RTCIceCandidatePairStats final : public RTCStats {
  126. public:
  127. WEBRTC_RTCSTATS_DECL();
  128. RTCIceCandidatePairStats(const std::string& id, int64_t timestamp_us);
  129. RTCIceCandidatePairStats(std::string&& id, int64_t timestamp_us);
  130. RTCIceCandidatePairStats(const RTCIceCandidatePairStats& other);
  131. ~RTCIceCandidatePairStats() override;
  132. RTCStatsMember<std::string> transport_id;
  133. RTCStatsMember<std::string> local_candidate_id;
  134. RTCStatsMember<std::string> remote_candidate_id;
  135. // TODO(hbos): Support enum types?
  136. // "RTCStatsMember<RTCStatsIceCandidatePairState>"?
  137. RTCStatsMember<std::string> state;
  138. RTCStatsMember<uint64_t> priority;
  139. RTCStatsMember<bool> nominated;
  140. // TODO(hbos): Collect this the way the spec describes it. We have a value for
  141. // it but it is not spec-compliant. https://bugs.webrtc.org/7062
  142. RTCStatsMember<bool> writable;
  143. // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7062
  144. RTCStatsMember<bool> readable;
  145. RTCStatsMember<uint64_t> bytes_sent;
  146. RTCStatsMember<uint64_t> bytes_received;
  147. RTCStatsMember<double> total_round_trip_time;
  148. RTCStatsMember<double> current_round_trip_time;
  149. RTCStatsMember<double> available_outgoing_bitrate;
  150. // TODO(hbos): Populate this value. It is wired up and collected the same way
  151. // "VideoBwe.googAvailableReceiveBandwidth" is, but that value is always
  152. // undefined. https://bugs.webrtc.org/7062
  153. RTCStatsMember<double> available_incoming_bitrate;
  154. RTCStatsMember<uint64_t> requests_received;
  155. RTCStatsMember<uint64_t> requests_sent;
  156. RTCStatsMember<uint64_t> responses_received;
  157. RTCStatsMember<uint64_t> responses_sent;
  158. // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7062
  159. RTCStatsMember<uint64_t> retransmissions_received;
  160. // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7062
  161. RTCStatsMember<uint64_t> retransmissions_sent;
  162. // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7062
  163. RTCStatsMember<uint64_t> consent_requests_received;
  164. RTCStatsMember<uint64_t> consent_requests_sent;
  165. // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7062
  166. RTCStatsMember<uint64_t> consent_responses_received;
  167. // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7062
  168. RTCStatsMember<uint64_t> consent_responses_sent;
  169. };
  170. // https://w3c.github.io/webrtc-stats/#icecandidate-dict*
  171. // TODO(hbos): |RTCStatsCollector| only collects candidates that are part of
  172. // ice candidate pairs, but there could be candidates not paired with anything.
  173. // crbug.com/632723
  174. // TODO(qingsi): Add the stats of STUN binding requests (keepalives) and collect
  175. // them in the new PeerConnection::GetStats.
  176. class RTC_EXPORT RTCIceCandidateStats : public RTCStats {
  177. public:
  178. WEBRTC_RTCSTATS_DECL();
  179. RTCIceCandidateStats(const RTCIceCandidateStats& other);
  180. ~RTCIceCandidateStats() override;
  181. RTCStatsMember<std::string> transport_id;
  182. RTCStatsMember<bool> is_remote;
  183. RTCStatsMember<std::string> network_type;
  184. RTCStatsMember<std::string> ip;
  185. RTCStatsMember<int32_t> port;
  186. RTCStatsMember<std::string> protocol;
  187. RTCStatsMember<std::string> relay_protocol;
  188. // TODO(hbos): Support enum types? "RTCStatsMember<RTCIceCandidateType>"?
  189. RTCStatsMember<std::string> candidate_type;
  190. RTCStatsMember<int32_t> priority;
  191. // TODO(hbos): Not collected by |RTCStatsCollector|. crbug.com/632723
  192. RTCStatsMember<std::string> url;
  193. // TODO(hbos): |deleted = true| case is not supported by |RTCStatsCollector|.
  194. // crbug.com/632723
  195. RTCStatsMember<bool> deleted; // = false
  196. protected:
  197. RTCIceCandidateStats(const std::string& id,
  198. int64_t timestamp_us,
  199. bool is_remote);
  200. RTCIceCandidateStats(std::string&& id, int64_t timestamp_us, bool is_remote);
  201. };
  202. // In the spec both local and remote varieties are of type RTCIceCandidateStats.
  203. // But here we define them as subclasses of |RTCIceCandidateStats| because the
  204. // |kType| need to be different ("RTCStatsType type") in the local/remote case.
  205. // https://w3c.github.io/webrtc-stats/#rtcstatstype-str*
  206. // This forces us to have to override copy() and type().
  207. class RTC_EXPORT RTCLocalIceCandidateStats final : public RTCIceCandidateStats {
  208. public:
  209. static const char kType[];
  210. RTCLocalIceCandidateStats(const std::string& id, int64_t timestamp_us);
  211. RTCLocalIceCandidateStats(std::string&& id, int64_t timestamp_us);
  212. std::unique_ptr<RTCStats> copy() const override;
  213. const char* type() const override;
  214. };
  215. class RTC_EXPORT RTCRemoteIceCandidateStats final
  216. : public RTCIceCandidateStats {
  217. public:
  218. static const char kType[];
  219. RTCRemoteIceCandidateStats(const std::string& id, int64_t timestamp_us);
  220. RTCRemoteIceCandidateStats(std::string&& id, int64_t timestamp_us);
  221. std::unique_ptr<RTCStats> copy() const override;
  222. const char* type() const override;
  223. };
  224. // https://w3c.github.io/webrtc-stats/#msstats-dict*
  225. // TODO(hbos): Tracking bug crbug.com/660827
  226. class RTC_EXPORT RTCMediaStreamStats final : public RTCStats {
  227. public:
  228. WEBRTC_RTCSTATS_DECL();
  229. RTCMediaStreamStats(const std::string& id, int64_t timestamp_us);
  230. RTCMediaStreamStats(std::string&& id, int64_t timestamp_us);
  231. RTCMediaStreamStats(const RTCMediaStreamStats& other);
  232. ~RTCMediaStreamStats() override;
  233. RTCStatsMember<std::string> stream_identifier;
  234. RTCStatsMember<std::vector<std::string>> track_ids;
  235. };
  236. // https://w3c.github.io/webrtc-stats/#mststats-dict*
  237. // TODO(hbos): Tracking bug crbug.com/659137
  238. class RTC_EXPORT RTCMediaStreamTrackStats final : public RTCStats {
  239. public:
  240. WEBRTC_RTCSTATS_DECL();
  241. RTCMediaStreamTrackStats(const std::string& id,
  242. int64_t timestamp_us,
  243. const char* kind);
  244. RTCMediaStreamTrackStats(std::string&& id,
  245. int64_t timestamp_us,
  246. const char* kind);
  247. RTCMediaStreamTrackStats(const RTCMediaStreamTrackStats& other);
  248. ~RTCMediaStreamTrackStats() override;
  249. RTCStatsMember<std::string> track_identifier;
  250. RTCStatsMember<std::string> media_source_id;
  251. RTCStatsMember<bool> remote_source;
  252. RTCStatsMember<bool> ended;
  253. // TODO(hbos): |RTCStatsCollector| does not return stats for detached tracks.
  254. // crbug.com/659137
  255. RTCStatsMember<bool> detached;
  256. // See |RTCMediaStreamTrackKind| for valid values.
  257. RTCStatsMember<std::string> kind;
  258. RTCStatsMember<double> jitter_buffer_delay;
  259. RTCStatsMember<uint64_t> jitter_buffer_emitted_count;
  260. // Video-only members
  261. RTCStatsMember<uint32_t> frame_width;
  262. RTCStatsMember<uint32_t> frame_height;
  263. // TODO(hbos): Not collected by |RTCStatsCollector|. crbug.com/659137
  264. RTCStatsMember<double> frames_per_second;
  265. RTCStatsMember<uint32_t> frames_sent;
  266. RTCStatsMember<uint32_t> huge_frames_sent;
  267. RTCStatsMember<uint32_t> frames_received;
  268. RTCStatsMember<uint32_t> frames_decoded;
  269. RTCStatsMember<uint32_t> frames_dropped;
  270. // TODO(hbos): Not collected by |RTCStatsCollector|. crbug.com/659137
  271. RTCStatsMember<uint32_t> frames_corrupted;
  272. // TODO(hbos): Not collected by |RTCStatsCollector|. crbug.com/659137
  273. RTCStatsMember<uint32_t> partial_frames_lost;
  274. // TODO(hbos): Not collected by |RTCStatsCollector|. crbug.com/659137
  275. RTCStatsMember<uint32_t> full_frames_lost;
  276. // Audio-only members
  277. RTCStatsMember<double> audio_level; // Receive-only
  278. RTCStatsMember<double> total_audio_energy; // Receive-only
  279. RTCStatsMember<double> echo_return_loss;
  280. RTCStatsMember<double> echo_return_loss_enhancement;
  281. RTCStatsMember<uint64_t> total_samples_received;
  282. RTCStatsMember<double> total_samples_duration; // Receive-only
  283. RTCStatsMember<uint64_t> concealed_samples;
  284. RTCStatsMember<uint64_t> silent_concealed_samples;
  285. RTCStatsMember<uint64_t> concealment_events;
  286. RTCStatsMember<uint64_t> inserted_samples_for_deceleration;
  287. RTCStatsMember<uint64_t> removed_samples_for_acceleration;
  288. // Non-standard audio-only member
  289. // TODO(kuddai): Add description to standard. crbug.com/webrtc/10042
  290. RTCNonStandardStatsMember<uint64_t> jitter_buffer_flushes;
  291. RTCNonStandardStatsMember<uint64_t> delayed_packet_outage_samples;
  292. RTCNonStandardStatsMember<double> relative_packet_arrival_delay;
  293. // Non-standard metric showing target delay of jitter buffer.
  294. // This value is increased by the target jitter buffer delay every time a
  295. // sample is emitted by the jitter buffer. The added target is the target
  296. // delay, in seconds, at the time that the sample was emitted from the jitter
  297. // buffer. (https://github.com/w3c/webrtc-provisional-stats/pull/20)
  298. // Currently it is implemented only for audio.
  299. // TODO(titovartem) implement for video streams when will be requested.
  300. RTCNonStandardStatsMember<double> jitter_buffer_target_delay;
  301. // TODO(henrik.lundin): Add description of the interruption metrics at
  302. // https://github.com/henbos/webrtc-provisional-stats/issues/17
  303. RTCNonStandardStatsMember<uint32_t> interruption_count;
  304. RTCNonStandardStatsMember<double> total_interruption_duration;
  305. // Non-standard video-only members.
  306. // https://henbos.github.io/webrtc-provisional-stats/#RTCVideoReceiverStats-dict*
  307. RTCNonStandardStatsMember<uint32_t> freeze_count;
  308. RTCNonStandardStatsMember<uint32_t> pause_count;
  309. RTCNonStandardStatsMember<double> total_freezes_duration;
  310. RTCNonStandardStatsMember<double> total_pauses_duration;
  311. RTCNonStandardStatsMember<double> total_frames_duration;
  312. RTCNonStandardStatsMember<double> sum_squared_frame_durations;
  313. };
  314. // https://w3c.github.io/webrtc-stats/#pcstats-dict*
  315. class RTC_EXPORT RTCPeerConnectionStats final : public RTCStats {
  316. public:
  317. WEBRTC_RTCSTATS_DECL();
  318. RTCPeerConnectionStats(const std::string& id, int64_t timestamp_us);
  319. RTCPeerConnectionStats(std::string&& id, int64_t timestamp_us);
  320. RTCPeerConnectionStats(const RTCPeerConnectionStats& other);
  321. ~RTCPeerConnectionStats() override;
  322. RTCStatsMember<uint32_t> data_channels_opened;
  323. RTCStatsMember<uint32_t> data_channels_closed;
  324. };
  325. // https://w3c.github.io/webrtc-stats/#streamstats-dict*
  326. // TODO(hbos): Tracking bug crbug.com/657854
  327. class RTC_EXPORT RTCRTPStreamStats : public RTCStats {
  328. public:
  329. WEBRTC_RTCSTATS_DECL();
  330. RTCRTPStreamStats(const RTCRTPStreamStats& other);
  331. ~RTCRTPStreamStats() override;
  332. RTCStatsMember<uint32_t> ssrc;
  333. // TODO(hbos): Remote case not supported by |RTCStatsCollector|.
  334. // crbug.com/657855, 657856
  335. RTCStatsMember<bool> is_remote; // = false
  336. RTCStatsMember<std::string> media_type; // renamed to kind.
  337. RTCStatsMember<std::string> kind;
  338. RTCStatsMember<std::string> track_id;
  339. RTCStatsMember<std::string> transport_id;
  340. RTCStatsMember<std::string> codec_id;
  341. // FIR and PLI counts are only defined for |media_type == "video"|.
  342. RTCStatsMember<uint32_t> fir_count;
  343. RTCStatsMember<uint32_t> pli_count;
  344. // TODO(hbos): NACK count should be collected by |RTCStatsCollector| for both
  345. // audio and video but is only defined in the "video" case. crbug.com/657856
  346. RTCStatsMember<uint32_t> nack_count;
  347. // TODO(hbos): Not collected by |RTCStatsCollector|. crbug.com/657854
  348. // SLI count is only defined for |media_type == "video"|.
  349. RTCStatsMember<uint32_t> sli_count;
  350. RTCStatsMember<uint64_t> qp_sum;
  351. protected:
  352. RTCRTPStreamStats(const std::string& id, int64_t timestamp_us);
  353. RTCRTPStreamStats(std::string&& id, int64_t timestamp_us);
  354. };
  355. // https://w3c.github.io/webrtc-stats/#inboundrtpstats-dict*
  356. // TODO(hbos): Support the remote case |is_remote = true|.
  357. // https://bugs.webrtc.org/7065
  358. class RTC_EXPORT RTCInboundRTPStreamStats final : public RTCRTPStreamStats {
  359. public:
  360. WEBRTC_RTCSTATS_DECL();
  361. RTCInboundRTPStreamStats(const std::string& id, int64_t timestamp_us);
  362. RTCInboundRTPStreamStats(std::string&& id, int64_t timestamp_us);
  363. RTCInboundRTPStreamStats(const RTCInboundRTPStreamStats& other);
  364. ~RTCInboundRTPStreamStats() override;
  365. RTCStatsMember<uint32_t> packets_received;
  366. RTCStatsMember<uint64_t> fec_packets_received;
  367. RTCStatsMember<uint64_t> fec_packets_discarded;
  368. RTCStatsMember<uint64_t> bytes_received;
  369. RTCStatsMember<uint64_t> header_bytes_received;
  370. RTCStatsMember<int32_t> packets_lost; // Signed per RFC 3550
  371. RTCStatsMember<double> last_packet_received_timestamp;
  372. // TODO(hbos): Collect and populate this value for both "audio" and "video",
  373. // currently not collected for "video". https://bugs.webrtc.org/7065
  374. RTCStatsMember<double> jitter;
  375. RTCStatsMember<double> jitter_buffer_delay;
  376. RTCStatsMember<uint64_t> jitter_buffer_emitted_count;
  377. RTCStatsMember<uint64_t> total_samples_received;
  378. RTCStatsMember<uint64_t> concealed_samples;
  379. RTCStatsMember<uint64_t> silent_concealed_samples;
  380. RTCStatsMember<uint64_t> concealment_events;
  381. RTCStatsMember<uint64_t> inserted_samples_for_deceleration;
  382. RTCStatsMember<uint64_t> removed_samples_for_acceleration;
  383. RTCStatsMember<double> audio_level;
  384. RTCStatsMember<double> total_audio_energy;
  385. RTCStatsMember<double> total_samples_duration;
  386. RTCStatsMember<int32_t> frames_received;
  387. // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7065
  388. RTCStatsMember<double> round_trip_time;
  389. // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7065
  390. RTCStatsMember<uint32_t> packets_discarded;
  391. // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7065
  392. RTCStatsMember<uint32_t> packets_repaired;
  393. // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7065
  394. RTCStatsMember<uint32_t> burst_packets_lost;
  395. // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7065
  396. RTCStatsMember<uint32_t> burst_packets_discarded;
  397. // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7065
  398. RTCStatsMember<uint32_t> burst_loss_count;
  399. // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7065
  400. RTCStatsMember<uint32_t> burst_discard_count;
  401. // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7065
  402. RTCStatsMember<double> burst_loss_rate;
  403. // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7065
  404. RTCStatsMember<double> burst_discard_rate;
  405. // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7065
  406. RTCStatsMember<double> gap_loss_rate;
  407. // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7065
  408. RTCStatsMember<double> gap_discard_rate;
  409. RTCStatsMember<uint32_t> frame_width;
  410. RTCStatsMember<uint32_t> frame_height;
  411. RTCStatsMember<uint32_t> frame_bit_depth;
  412. RTCStatsMember<double> frames_per_second;
  413. RTCStatsMember<uint32_t> frames_decoded;
  414. RTCStatsMember<uint32_t> key_frames_decoded;
  415. RTCStatsMember<uint32_t> frames_dropped;
  416. RTCStatsMember<double> total_decode_time;
  417. RTCStatsMember<double> total_inter_frame_delay;
  418. RTCStatsMember<double> total_squared_inter_frame_delay;
  419. // https://henbos.github.io/webrtc-provisional-stats/#dom-rtcinboundrtpstreamstats-contenttype
  420. RTCStatsMember<std::string> content_type;
  421. // TODO(asapersson): Currently only populated if audio/video sync is enabled.
  422. RTCStatsMember<double> estimated_playout_timestamp;
  423. // TODO(hbos): This is only implemented for video; implement it for audio as
  424. // well.
  425. RTCStatsMember<std::string> decoder_implementation;
  426. };
  427. // https://w3c.github.io/webrtc-stats/#outboundrtpstats-dict*
  428. // TODO(hbos): Support the remote case |is_remote = true|.
  429. // https://bugs.webrtc.org/7066
  430. class RTC_EXPORT RTCOutboundRTPStreamStats final : public RTCRTPStreamStats {
  431. public:
  432. WEBRTC_RTCSTATS_DECL();
  433. RTCOutboundRTPStreamStats(const std::string& id, int64_t timestamp_us);
  434. RTCOutboundRTPStreamStats(std::string&& id, int64_t timestamp_us);
  435. RTCOutboundRTPStreamStats(const RTCOutboundRTPStreamStats& other);
  436. ~RTCOutboundRTPStreamStats() override;
  437. RTCStatsMember<std::string> media_source_id;
  438. RTCStatsMember<std::string> remote_id;
  439. RTCStatsMember<std::string> rid;
  440. RTCStatsMember<uint32_t> packets_sent;
  441. RTCStatsMember<uint64_t> retransmitted_packets_sent;
  442. RTCStatsMember<uint64_t> bytes_sent;
  443. RTCStatsMember<uint64_t> header_bytes_sent;
  444. RTCStatsMember<uint64_t> retransmitted_bytes_sent;
  445. // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7066
  446. RTCStatsMember<double> target_bitrate;
  447. RTCStatsMember<uint32_t> frames_encoded;
  448. RTCStatsMember<uint32_t> key_frames_encoded;
  449. RTCStatsMember<double> total_encode_time;
  450. RTCStatsMember<uint64_t> total_encoded_bytes_target;
  451. RTCStatsMember<uint32_t> frame_width;
  452. RTCStatsMember<uint32_t> frame_height;
  453. RTCStatsMember<double> frames_per_second;
  454. RTCStatsMember<uint32_t> frames_sent;
  455. RTCStatsMember<uint32_t> huge_frames_sent;
  456. // TODO(https://crbug.com/webrtc/10635): This is only implemented for video;
  457. // implement it for audio as well.
  458. RTCStatsMember<double> total_packet_send_delay;
  459. // Enum type RTCQualityLimitationReason
  460. // TODO(https://crbug.com/webrtc/10686): Also expose
  461. // qualityLimitationDurations. Requires RTCStatsMember support for
  462. // "record<DOMString, double>", see https://crbug.com/webrtc/10685.
  463. RTCStatsMember<std::string> quality_limitation_reason;
  464. // https://w3c.github.io/webrtc-stats/#dom-rtcoutboundrtpstreamstats-qualitylimitationresolutionchanges
  465. RTCStatsMember<uint32_t> quality_limitation_resolution_changes;
  466. // https://henbos.github.io/webrtc-provisional-stats/#dom-rtcoutboundrtpstreamstats-contenttype
  467. RTCStatsMember<std::string> content_type;
  468. // TODO(hbos): This is only implemented for video; implement it for audio as
  469. // well.
  470. RTCStatsMember<std::string> encoder_implementation;
  471. };
  472. // TODO(https://crbug.com/webrtc/10671): Refactor the stats dictionaries to have
  473. // the same hierarchy as in the spec; implement RTCReceivedRtpStreamStats.
  474. // Several metrics are shared between "outbound-rtp", "remote-inbound-rtp",
  475. // "inbound-rtp" and "remote-outbound-rtp". In the spec there is a hierarchy of
  476. // dictionaries that minimizes defining the same metrics in multiple places.
  477. // From JavaScript this hierarchy is not observable and the spec's hierarchy is
  478. // purely editorial. In C++ non-final classes in the hierarchy could be used to
  479. // refer to different stats objects within the hierarchy.
  480. // https://w3c.github.io/webrtc-stats/#remoteinboundrtpstats-dict*
  481. class RTC_EXPORT RTCRemoteInboundRtpStreamStats final : public RTCStats {
  482. public:
  483. WEBRTC_RTCSTATS_DECL();
  484. RTCRemoteInboundRtpStreamStats(const std::string& id, int64_t timestamp_us);
  485. RTCRemoteInboundRtpStreamStats(std::string&& id, int64_t timestamp_us);
  486. RTCRemoteInboundRtpStreamStats(const RTCRemoteInboundRtpStreamStats& other);
  487. ~RTCRemoteInboundRtpStreamStats() override;
  488. // In the spec RTCRemoteInboundRtpStreamStats inherits from RTCRtpStreamStats
  489. // and RTCReceivedRtpStreamStats. The members here are listed based on where
  490. // they are defined in the spec.
  491. // RTCRtpStreamStats
  492. RTCStatsMember<uint32_t> ssrc;
  493. RTCStatsMember<std::string> kind;
  494. RTCStatsMember<std::string> transport_id;
  495. RTCStatsMember<std::string> codec_id;
  496. // RTCReceivedRtpStreamStats
  497. RTCStatsMember<int32_t> packets_lost;
  498. RTCStatsMember<double> jitter;
  499. // TODO(hbos): The following RTCReceivedRtpStreamStats metrics should also be
  500. // implemented: packetsReceived, packetsDiscarded, packetsRepaired,
  501. // burstPacketsLost, burstPacketsDiscarded, burstLossCount, burstDiscardCount,
  502. // burstLossRate, burstDiscardRate, gapLossRate and gapDiscardRate.
  503. // RTCRemoteInboundRtpStreamStats
  504. RTCStatsMember<std::string> local_id;
  505. RTCStatsMember<double> round_trip_time;
  506. // TODO(hbos): The following RTCRemoteInboundRtpStreamStats metric should also
  507. // be implemented: fractionLost.
  508. };
  509. // https://w3c.github.io/webrtc-stats/#dom-rtcmediasourcestats
  510. class RTC_EXPORT RTCMediaSourceStats : public RTCStats {
  511. public:
  512. WEBRTC_RTCSTATS_DECL();
  513. RTCMediaSourceStats(const RTCMediaSourceStats& other);
  514. ~RTCMediaSourceStats() override;
  515. RTCStatsMember<std::string> track_identifier;
  516. RTCStatsMember<std::string> kind;
  517. protected:
  518. RTCMediaSourceStats(const std::string& id, int64_t timestamp_us);
  519. RTCMediaSourceStats(std::string&& id, int64_t timestamp_us);
  520. };
  521. // https://w3c.github.io/webrtc-stats/#dom-rtcaudiosourcestats
  522. class RTC_EXPORT RTCAudioSourceStats final : public RTCMediaSourceStats {
  523. public:
  524. WEBRTC_RTCSTATS_DECL();
  525. RTCAudioSourceStats(const std::string& id, int64_t timestamp_us);
  526. RTCAudioSourceStats(std::string&& id, int64_t timestamp_us);
  527. RTCAudioSourceStats(const RTCAudioSourceStats& other);
  528. ~RTCAudioSourceStats() override;
  529. RTCStatsMember<double> audio_level;
  530. RTCStatsMember<double> total_audio_energy;
  531. RTCStatsMember<double> total_samples_duration;
  532. };
  533. // https://w3c.github.io/webrtc-stats/#dom-rtcvideosourcestats
  534. class RTC_EXPORT RTCVideoSourceStats final : public RTCMediaSourceStats {
  535. public:
  536. WEBRTC_RTCSTATS_DECL();
  537. RTCVideoSourceStats(const std::string& id, int64_t timestamp_us);
  538. RTCVideoSourceStats(std::string&& id, int64_t timestamp_us);
  539. RTCVideoSourceStats(const RTCVideoSourceStats& other);
  540. ~RTCVideoSourceStats() override;
  541. RTCStatsMember<uint32_t> width;
  542. RTCStatsMember<uint32_t> height;
  543. // TODO(hbos): Implement this metric.
  544. RTCStatsMember<uint32_t> frames;
  545. RTCStatsMember<uint32_t> frames_per_second;
  546. };
  547. // https://w3c.github.io/webrtc-stats/#transportstats-dict*
  548. class RTC_EXPORT RTCTransportStats final : public RTCStats {
  549. public:
  550. WEBRTC_RTCSTATS_DECL();
  551. RTCTransportStats(const std::string& id, int64_t timestamp_us);
  552. RTCTransportStats(std::string&& id, int64_t timestamp_us);
  553. RTCTransportStats(const RTCTransportStats& other);
  554. ~RTCTransportStats() override;
  555. RTCStatsMember<uint64_t> bytes_sent;
  556. RTCStatsMember<uint64_t> packets_sent;
  557. RTCStatsMember<uint64_t> bytes_received;
  558. RTCStatsMember<uint64_t> packets_received;
  559. RTCStatsMember<std::string> rtcp_transport_stats_id;
  560. // TODO(hbos): Support enum types? "RTCStatsMember<RTCDtlsTransportState>"?
  561. RTCStatsMember<std::string> dtls_state;
  562. RTCStatsMember<std::string> selected_candidate_pair_id;
  563. RTCStatsMember<std::string> local_certificate_id;
  564. RTCStatsMember<std::string> remote_certificate_id;
  565. RTCStatsMember<std::string> tls_version;
  566. RTCStatsMember<std::string> dtls_cipher;
  567. RTCStatsMember<std::string> srtp_cipher;
  568. RTCStatsMember<uint32_t> selected_candidate_pair_changes;
  569. };
  570. } // namespace webrtc
  571. #endif // API_STATS_RTCSTATS_OBJECTS_H_