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.

606 lines
25 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. #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. // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7061
  103. RTCStatsMember<uint32_t> channels;
  104. // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7061
  105. RTCStatsMember<std::string> sdp_fmtp_line;
  106. };
  107. // https://w3c.github.io/webrtc-stats/#dcstats-dict*
  108. class RTC_EXPORT RTCDataChannelStats final : public RTCStats {
  109. public:
  110. WEBRTC_RTCSTATS_DECL();
  111. RTCDataChannelStats(const std::string& id, int64_t timestamp_us);
  112. RTCDataChannelStats(std::string&& id, int64_t timestamp_us);
  113. RTCDataChannelStats(const RTCDataChannelStats& other);
  114. ~RTCDataChannelStats() override;
  115. RTCStatsMember<std::string> label;
  116. RTCStatsMember<std::string> protocol;
  117. RTCStatsMember<int32_t> datachannelid;
  118. // TODO(hbos): Support enum types? "RTCStatsMember<RTCDataChannelState>"?
  119. RTCStatsMember<std::string> state;
  120. RTCStatsMember<uint32_t> messages_sent;
  121. RTCStatsMember<uint64_t> bytes_sent;
  122. RTCStatsMember<uint32_t> messages_received;
  123. RTCStatsMember<uint64_t> bytes_received;
  124. };
  125. // https://w3c.github.io/webrtc-stats/#candidatepair-dict*
  126. // TODO(hbos): Tracking bug https://bugs.webrtc.org/7062
  127. class RTC_EXPORT RTCIceCandidatePairStats final : public RTCStats {
  128. public:
  129. WEBRTC_RTCSTATS_DECL();
  130. RTCIceCandidatePairStats(const std::string& id, int64_t timestamp_us);
  131. RTCIceCandidatePairStats(std::string&& id, int64_t timestamp_us);
  132. RTCIceCandidatePairStats(const RTCIceCandidatePairStats& other);
  133. ~RTCIceCandidatePairStats() override;
  134. RTCStatsMember<std::string> transport_id;
  135. RTCStatsMember<std::string> local_candidate_id;
  136. RTCStatsMember<std::string> remote_candidate_id;
  137. // TODO(hbos): Support enum types?
  138. // "RTCStatsMember<RTCStatsIceCandidatePairState>"?
  139. RTCStatsMember<std::string> state;
  140. RTCStatsMember<uint64_t> priority;
  141. RTCStatsMember<bool> nominated;
  142. // TODO(hbos): Collect this the way the spec describes it. We have a value for
  143. // it but it is not spec-compliant. https://bugs.webrtc.org/7062
  144. RTCStatsMember<bool> writable;
  145. // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7062
  146. RTCStatsMember<bool> readable;
  147. RTCStatsMember<uint64_t> bytes_sent;
  148. RTCStatsMember<uint64_t> bytes_received;
  149. RTCStatsMember<double> total_round_trip_time;
  150. RTCStatsMember<double> current_round_trip_time;
  151. RTCStatsMember<double> available_outgoing_bitrate;
  152. // TODO(hbos): Populate this value. It is wired up and collected the same way
  153. // "VideoBwe.googAvailableReceiveBandwidth" is, but that value is always
  154. // undefined. https://bugs.webrtc.org/7062
  155. RTCStatsMember<double> available_incoming_bitrate;
  156. RTCStatsMember<uint64_t> requests_received;
  157. RTCStatsMember<uint64_t> requests_sent;
  158. RTCStatsMember<uint64_t> responses_received;
  159. RTCStatsMember<uint64_t> responses_sent;
  160. // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7062
  161. RTCStatsMember<uint64_t> retransmissions_received;
  162. // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7062
  163. RTCStatsMember<uint64_t> retransmissions_sent;
  164. // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7062
  165. RTCStatsMember<uint64_t> consent_requests_received;
  166. RTCStatsMember<uint64_t> consent_requests_sent;
  167. // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7062
  168. RTCStatsMember<uint64_t> consent_responses_received;
  169. // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7062
  170. RTCStatsMember<uint64_t> consent_responses_sent;
  171. };
  172. // https://w3c.github.io/webrtc-stats/#icecandidate-dict*
  173. // TODO(hbos): |RTCStatsCollector| only collects candidates that are part of
  174. // ice candidate pairs, but there could be candidates not paired with anything.
  175. // crbug.com/632723
  176. // TODO(qingsi): Add the stats of STUN binding requests (keepalives) and collect
  177. // them in the new PeerConnection::GetStats.
  178. class RTC_EXPORT RTCIceCandidateStats : public RTCStats {
  179. public:
  180. WEBRTC_RTCSTATS_DECL();
  181. RTCIceCandidateStats(const RTCIceCandidateStats& other);
  182. ~RTCIceCandidateStats() override;
  183. RTCStatsMember<std::string> transport_id;
  184. RTCStatsMember<bool> is_remote;
  185. RTCStatsMember<std::string> network_type;
  186. RTCStatsMember<std::string> ip;
  187. RTCStatsMember<int32_t> port;
  188. RTCStatsMember<std::string> protocol;
  189. RTCStatsMember<std::string> relay_protocol;
  190. // TODO(hbos): Support enum types? "RTCStatsMember<RTCIceCandidateType>"?
  191. RTCStatsMember<std::string> candidate_type;
  192. RTCStatsMember<int32_t> priority;
  193. // TODO(hbos): Not collected by |RTCStatsCollector|. crbug.com/632723
  194. RTCStatsMember<std::string> url;
  195. // TODO(hbos): |deleted = true| case is not supported by |RTCStatsCollector|.
  196. // crbug.com/632723
  197. RTCStatsMember<bool> deleted; // = false
  198. protected:
  199. RTCIceCandidateStats(const std::string& id,
  200. int64_t timestamp_us,
  201. bool is_remote);
  202. RTCIceCandidateStats(std::string&& id, int64_t timestamp_us, bool is_remote);
  203. };
  204. // In the spec both local and remote varieties are of type RTCIceCandidateStats.
  205. // But here we define them as subclasses of |RTCIceCandidateStats| because the
  206. // |kType| need to be different ("RTCStatsType type") in the local/remote case.
  207. // https://w3c.github.io/webrtc-stats/#rtcstatstype-str*
  208. // This forces us to have to override copy() and type().
  209. class RTC_EXPORT RTCLocalIceCandidateStats final : public RTCIceCandidateStats {
  210. public:
  211. static const char kType[];
  212. RTCLocalIceCandidateStats(const std::string& id, int64_t timestamp_us);
  213. RTCLocalIceCandidateStats(std::string&& id, int64_t timestamp_us);
  214. std::unique_ptr<RTCStats> copy() const override;
  215. const char* type() const override;
  216. };
  217. class RTC_EXPORT RTCRemoteIceCandidateStats final
  218. : public RTCIceCandidateStats {
  219. public:
  220. static const char kType[];
  221. RTCRemoteIceCandidateStats(const std::string& id, int64_t timestamp_us);
  222. RTCRemoteIceCandidateStats(std::string&& id, int64_t timestamp_us);
  223. std::unique_ptr<RTCStats> copy() const override;
  224. const char* type() const override;
  225. };
  226. // https://w3c.github.io/webrtc-stats/#msstats-dict*
  227. // TODO(hbos): Tracking bug crbug.com/660827
  228. class RTC_EXPORT RTCMediaStreamStats final : public RTCStats {
  229. public:
  230. WEBRTC_RTCSTATS_DECL();
  231. RTCMediaStreamStats(const std::string& id, int64_t timestamp_us);
  232. RTCMediaStreamStats(std::string&& id, int64_t timestamp_us);
  233. RTCMediaStreamStats(const RTCMediaStreamStats& other);
  234. ~RTCMediaStreamStats() override;
  235. RTCStatsMember<std::string> stream_identifier;
  236. RTCStatsMember<std::vector<std::string>> track_ids;
  237. };
  238. // https://w3c.github.io/webrtc-stats/#mststats-dict*
  239. // TODO(hbos): Tracking bug crbug.com/659137
  240. class RTC_EXPORT RTCMediaStreamTrackStats final : public RTCStats {
  241. public:
  242. WEBRTC_RTCSTATS_DECL();
  243. RTCMediaStreamTrackStats(const std::string& id,
  244. int64_t timestamp_us,
  245. const char* kind);
  246. RTCMediaStreamTrackStats(std::string&& id,
  247. int64_t timestamp_us,
  248. const char* kind);
  249. RTCMediaStreamTrackStats(const RTCMediaStreamTrackStats& other);
  250. ~RTCMediaStreamTrackStats() override;
  251. RTCStatsMember<std::string> track_identifier;
  252. RTCStatsMember<std::string> media_source_id;
  253. RTCStatsMember<bool> remote_source;
  254. RTCStatsMember<bool> ended;
  255. // TODO(hbos): |RTCStatsCollector| does not return stats for detached tracks.
  256. // crbug.com/659137
  257. RTCStatsMember<bool> detached;
  258. // See |RTCMediaStreamTrackKind| for valid values.
  259. RTCStatsMember<std::string> kind;
  260. // TODO(gustaf): Implement jitter_buffer_delay for video (currently
  261. // implemented for audio only).
  262. // https://crbug.com/webrtc/8318
  263. RTCStatsMember<double> jitter_buffer_delay;
  264. RTCStatsMember<uint64_t> jitter_buffer_emitted_count;
  265. // Video-only members
  266. RTCStatsMember<uint32_t> frame_width;
  267. RTCStatsMember<uint32_t> frame_height;
  268. // TODO(hbos): Not collected by |RTCStatsCollector|. crbug.com/659137
  269. RTCStatsMember<double> frames_per_second;
  270. RTCStatsMember<uint32_t> frames_sent;
  271. RTCStatsMember<uint32_t> huge_frames_sent;
  272. RTCStatsMember<uint32_t> frames_received;
  273. RTCStatsMember<uint32_t> frames_decoded;
  274. RTCStatsMember<uint32_t> frames_dropped;
  275. // TODO(hbos): Not collected by |RTCStatsCollector|. crbug.com/659137
  276. RTCStatsMember<uint32_t> frames_corrupted;
  277. // TODO(hbos): Not collected by |RTCStatsCollector|. crbug.com/659137
  278. RTCStatsMember<uint32_t> partial_frames_lost;
  279. // TODO(hbos): Not collected by |RTCStatsCollector|. crbug.com/659137
  280. RTCStatsMember<uint32_t> full_frames_lost;
  281. // Audio-only members
  282. RTCStatsMember<double> audio_level; // Receive-only
  283. RTCStatsMember<double> total_audio_energy; // Receive-only
  284. RTCStatsMember<double> echo_return_loss;
  285. RTCStatsMember<double> echo_return_loss_enhancement;
  286. RTCStatsMember<uint64_t> total_samples_received;
  287. RTCStatsMember<double> total_samples_duration; // Receive-only
  288. RTCStatsMember<uint64_t> concealed_samples;
  289. RTCStatsMember<uint64_t> silent_concealed_samples;
  290. RTCStatsMember<uint64_t> concealment_events;
  291. RTCStatsMember<uint64_t> inserted_samples_for_deceleration;
  292. RTCStatsMember<uint64_t> removed_samples_for_acceleration;
  293. // Non-standard audio-only member
  294. // TODO(kuddai): Add description to standard. crbug.com/webrtc/10042
  295. RTCNonStandardStatsMember<uint64_t> jitter_buffer_flushes;
  296. RTCNonStandardStatsMember<uint64_t> delayed_packet_outage_samples;
  297. RTCNonStandardStatsMember<double> relative_packet_arrival_delay;
  298. // TODO(henrik.lundin): Add description of the interruption metrics at
  299. // https://github.com/henbos/webrtc-provisional-stats/issues/17
  300. RTCNonStandardStatsMember<uint32_t> interruption_count;
  301. RTCNonStandardStatsMember<double> total_interruption_duration;
  302. // Non-standard video-only members.
  303. // https://henbos.github.io/webrtc-provisional-stats/#RTCVideoReceiverStats-dict*
  304. RTCNonStandardStatsMember<uint32_t> freeze_count;
  305. RTCNonStandardStatsMember<uint32_t> pause_count;
  306. RTCNonStandardStatsMember<double> total_freezes_duration;
  307. RTCNonStandardStatsMember<double> total_pauses_duration;
  308. RTCNonStandardStatsMember<double> total_frames_duration;
  309. RTCNonStandardStatsMember<double> sum_squared_frame_durations;
  310. };
  311. // https://w3c.github.io/webrtc-stats/#pcstats-dict*
  312. class RTC_EXPORT RTCPeerConnectionStats final : public RTCStats {
  313. public:
  314. WEBRTC_RTCSTATS_DECL();
  315. RTCPeerConnectionStats(const std::string& id, int64_t timestamp_us);
  316. RTCPeerConnectionStats(std::string&& id, int64_t timestamp_us);
  317. RTCPeerConnectionStats(const RTCPeerConnectionStats& other);
  318. ~RTCPeerConnectionStats() override;
  319. RTCStatsMember<uint32_t> data_channels_opened;
  320. RTCStatsMember<uint32_t> data_channels_closed;
  321. };
  322. // https://w3c.github.io/webrtc-stats/#streamstats-dict*
  323. // TODO(hbos): Tracking bug crbug.com/657854
  324. class RTC_EXPORT RTCRTPStreamStats : public RTCStats {
  325. public:
  326. WEBRTC_RTCSTATS_DECL();
  327. RTCRTPStreamStats(const RTCRTPStreamStats& other);
  328. ~RTCRTPStreamStats() override;
  329. RTCStatsMember<uint32_t> ssrc;
  330. // TODO(hbos): When the remote case is supported |RTCStatsCollector| needs to
  331. // set this. crbug.com/657855, 657856
  332. RTCStatsMember<std::string> associate_stats_id;
  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. // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7065
  376. RTCStatsMember<double> round_trip_time;
  377. // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7065
  378. RTCStatsMember<uint32_t> packets_discarded;
  379. // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7065
  380. RTCStatsMember<uint32_t> packets_repaired;
  381. // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7065
  382. RTCStatsMember<uint32_t> burst_packets_lost;
  383. // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7065
  384. RTCStatsMember<uint32_t> burst_packets_discarded;
  385. // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7065
  386. RTCStatsMember<uint32_t> burst_loss_count;
  387. // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7065
  388. RTCStatsMember<uint32_t> burst_discard_count;
  389. // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7065
  390. RTCStatsMember<double> burst_loss_rate;
  391. // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7065
  392. RTCStatsMember<double> burst_discard_rate;
  393. // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7065
  394. RTCStatsMember<double> gap_loss_rate;
  395. // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7065
  396. RTCStatsMember<double> gap_discard_rate;
  397. RTCStatsMember<uint32_t> frames_decoded;
  398. RTCStatsMember<uint32_t> key_frames_decoded;
  399. RTCStatsMember<double> total_decode_time;
  400. // https://henbos.github.io/webrtc-provisional-stats/#dom-rtcinboundrtpstreamstats-contenttype
  401. RTCStatsMember<std::string> content_type;
  402. // TODO(hbos): This is only implemented for video; implement it for audio as
  403. // well.
  404. RTCStatsMember<std::string> decoder_implementation;
  405. };
  406. // https://w3c.github.io/webrtc-stats/#outboundrtpstats-dict*
  407. // TODO(hbos): Support the remote case |is_remote = true|.
  408. // https://bugs.webrtc.org/7066
  409. class RTC_EXPORT RTCOutboundRTPStreamStats final : public RTCRTPStreamStats {
  410. public:
  411. WEBRTC_RTCSTATS_DECL();
  412. RTCOutboundRTPStreamStats(const std::string& id, int64_t timestamp_us);
  413. RTCOutboundRTPStreamStats(std::string&& id, int64_t timestamp_us);
  414. RTCOutboundRTPStreamStats(const RTCOutboundRTPStreamStats& other);
  415. ~RTCOutboundRTPStreamStats() override;
  416. RTCStatsMember<std::string> media_source_id;
  417. RTCStatsMember<uint32_t> packets_sent;
  418. RTCStatsMember<uint64_t> retransmitted_packets_sent;
  419. RTCStatsMember<uint64_t> bytes_sent;
  420. RTCStatsMember<uint64_t> header_bytes_sent;
  421. RTCStatsMember<uint64_t> retransmitted_bytes_sent;
  422. // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7066
  423. RTCStatsMember<double> target_bitrate;
  424. RTCStatsMember<uint32_t> frames_encoded;
  425. RTCStatsMember<uint32_t> key_frames_encoded;
  426. RTCStatsMember<double> total_encode_time;
  427. RTCStatsMember<uint64_t> total_encoded_bytes_target;
  428. // TODO(https://crbug.com/webrtc/10635): This is only implemented for video;
  429. // implement it for audio as well.
  430. RTCStatsMember<double> total_packet_send_delay;
  431. // Enum type RTCQualityLimitationReason
  432. // TODO(https://crbug.com/webrtc/10686): Also expose
  433. // qualityLimitationDurations. Requires RTCStatsMember support for
  434. // "record<DOMString, double>", see https://crbug.com/webrtc/10685.
  435. RTCStatsMember<std::string> quality_limitation_reason;
  436. // https://w3c.github.io/webrtc-stats/#dom-rtcoutboundrtpstreamstats-qualitylimitationresolutionchanges
  437. RTCStatsMember<uint32_t> quality_limitation_resolution_changes;
  438. // https://henbos.github.io/webrtc-provisional-stats/#dom-rtcoutboundrtpstreamstats-contenttype
  439. RTCStatsMember<std::string> content_type;
  440. // TODO(hbos): This is only implemented for video; implement it for audio as
  441. // well.
  442. RTCStatsMember<std::string> encoder_implementation;
  443. };
  444. // TODO(https://crbug.com/webrtc/10671): Refactor the stats dictionaries to have
  445. // the same hierarchy as in the spec; implement RTCReceivedRtpStreamStats.
  446. // Several metrics are shared between "outbound-rtp", "remote-inbound-rtp",
  447. // "inbound-rtp" and "remote-outbound-rtp". In the spec there is a hierarchy of
  448. // dictionaries that minimizes defining the same metrics in multiple places.
  449. // From JavaScript this hierarchy is not observable and the spec's hierarchy is
  450. // purely editorial. In C++ non-final classes in the hierarchy could be used to
  451. // refer to different stats objects within the hierarchy.
  452. // https://w3c.github.io/webrtc-stats/#remoteinboundrtpstats-dict*
  453. class RTC_EXPORT RTCRemoteInboundRtpStreamStats final : public RTCStats {
  454. public:
  455. WEBRTC_RTCSTATS_DECL();
  456. RTCRemoteInboundRtpStreamStats(const std::string& id, int64_t timestamp_us);
  457. RTCRemoteInboundRtpStreamStats(std::string&& id, int64_t timestamp_us);
  458. RTCRemoteInboundRtpStreamStats(const RTCRemoteInboundRtpStreamStats& other);
  459. ~RTCRemoteInboundRtpStreamStats() override;
  460. // In the spec RTCRemoteInboundRtpStreamStats inherits from RTCRtpStreamStats
  461. // and RTCReceivedRtpStreamStats. The members here are listed based on where
  462. // they are defined in the spec.
  463. // RTCRtpStreamStats
  464. RTCStatsMember<uint32_t> ssrc;
  465. RTCStatsMember<std::string> kind;
  466. RTCStatsMember<std::string> transport_id;
  467. RTCStatsMember<std::string> codec_id;
  468. // RTCReceivedRtpStreamStats
  469. RTCStatsMember<int32_t> packets_lost;
  470. RTCStatsMember<double> jitter;
  471. // TODO(hbos): The following RTCReceivedRtpStreamStats metrics should also be
  472. // implemented: packetsReceived, packetsDiscarded, packetsRepaired,
  473. // burstPacketsLost, burstPacketsDiscarded, burstLossCount, burstDiscardCount,
  474. // burstLossRate, burstDiscardRate, gapLossRate and gapDiscardRate.
  475. // RTCRemoteInboundRtpStreamStats
  476. RTCStatsMember<std::string> local_id;
  477. RTCStatsMember<double> round_trip_time;
  478. // TODO(hbos): The following RTCRemoteInboundRtpStreamStats metric should also
  479. // be implemented: fractionLost.
  480. };
  481. // https://w3c.github.io/webrtc-stats/#dom-rtcmediasourcestats
  482. class RTC_EXPORT RTCMediaSourceStats : public RTCStats {
  483. public:
  484. WEBRTC_RTCSTATS_DECL();
  485. RTCMediaSourceStats(const RTCMediaSourceStats& other);
  486. ~RTCMediaSourceStats() override;
  487. RTCStatsMember<std::string> track_identifier;
  488. RTCStatsMember<std::string> kind;
  489. protected:
  490. RTCMediaSourceStats(const std::string& id, int64_t timestamp_us);
  491. RTCMediaSourceStats(std::string&& id, int64_t timestamp_us);
  492. };
  493. // https://w3c.github.io/webrtc-stats/#dom-rtcaudiosourcestats
  494. class RTC_EXPORT RTCAudioSourceStats final : public RTCMediaSourceStats {
  495. public:
  496. WEBRTC_RTCSTATS_DECL();
  497. RTCAudioSourceStats(const std::string& id, int64_t timestamp_us);
  498. RTCAudioSourceStats(std::string&& id, int64_t timestamp_us);
  499. RTCAudioSourceStats(const RTCAudioSourceStats& other);
  500. ~RTCAudioSourceStats() override;
  501. RTCStatsMember<double> audio_level;
  502. RTCStatsMember<double> total_audio_energy;
  503. RTCStatsMember<double> total_samples_duration;
  504. };
  505. // https://w3c.github.io/webrtc-stats/#dom-rtcvideosourcestats
  506. class RTC_EXPORT RTCVideoSourceStats final : public RTCMediaSourceStats {
  507. public:
  508. WEBRTC_RTCSTATS_DECL();
  509. RTCVideoSourceStats(const std::string& id, int64_t timestamp_us);
  510. RTCVideoSourceStats(std::string&& id, int64_t timestamp_us);
  511. RTCVideoSourceStats(const RTCVideoSourceStats& other);
  512. ~RTCVideoSourceStats() override;
  513. RTCStatsMember<uint32_t> width;
  514. RTCStatsMember<uint32_t> height;
  515. // TODO(hbos): Implement this metric.
  516. RTCStatsMember<uint32_t> frames;
  517. RTCStatsMember<uint32_t> frames_per_second;
  518. };
  519. // https://w3c.github.io/webrtc-stats/#transportstats-dict*
  520. class RTC_EXPORT RTCTransportStats final : public RTCStats {
  521. public:
  522. WEBRTC_RTCSTATS_DECL();
  523. RTCTransportStats(const std::string& id, int64_t timestamp_us);
  524. RTCTransportStats(std::string&& id, int64_t timestamp_us);
  525. RTCTransportStats(const RTCTransportStats& other);
  526. ~RTCTransportStats() override;
  527. RTCStatsMember<uint64_t> bytes_sent;
  528. RTCStatsMember<uint64_t> bytes_received;
  529. RTCStatsMember<std::string> rtcp_transport_stats_id;
  530. // TODO(hbos): Support enum types? "RTCStatsMember<RTCDtlsTransportState>"?
  531. RTCStatsMember<std::string> dtls_state;
  532. RTCStatsMember<std::string> selected_candidate_pair_id;
  533. RTCStatsMember<std::string> local_certificate_id;
  534. RTCStatsMember<std::string> remote_certificate_id;
  535. RTCStatsMember<uint32_t> selected_candidate_pair_changes;
  536. };
  537. } // namespace webrtc
  538. #endif // API_STATS_RTCSTATS_OBJECTS_H_