blob: 4738fe89a89793e7f3993c843693927fc05ad7ba [file] [log] [blame]
hbosd565b732016-08-30 14:04:35 -07001/*
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
hbos74e1a4f2016-09-15 23:33:01 -070011#ifndef WEBRTC_API_STATS_RTCSTATS_OBJECTS_H_
12#define WEBRTC_API_STATS_RTCSTATS_OBJECTS_H_
hbosd565b732016-08-30 14:04:35 -070013
14#include <string>
15
hbos74e1a4f2016-09-15 23:33:01 -070016#include "webrtc/api/stats/rtcstats.h"
hbosd565b732016-08-30 14:04:35 -070017
18namespace webrtc {
19
hbosc47a0c32016-10-11 14:54:49 -070020// https://w3c.github.io/webrtc-stats/#dom-rtcstatsicecandidatepairstate
21struct RTCStatsIceCandidatePairState {
22 static const char* kFrozen;
23 static const char* kWaiting;
24 static const char* kInProgress;
25 static const char* kFailed;
26 static const char* kSucceeded;
27 static const char* kCancelled;
28};
29
hbosab9f6e42016-10-07 02:18:47 -070030// https://www.w3.org/TR/webrtc/#rtcicecandidatetype-enum
31struct RTCIceCandidateType {
32 static const char* kHost;
33 static const char* kSrflx;
34 static const char* kPrflx;
35 static const char* kRelay;
36};
37
hbosc47a0c32016-10-11 14:54:49 -070038class RTCIceCandidatePairStats : public RTCStats {
39 public:
40 WEBRTC_RTCSTATS_DECL();
41
42 RTCIceCandidatePairStats(const std::string& id, int64_t timestamp_us);
43 RTCIceCandidatePairStats(std::string&& id, int64_t timestamp_us);
44 RTCIceCandidatePairStats(const RTCIceCandidatePairStats& other);
45 ~RTCIceCandidatePairStats() override;
46
47 RTCStatsMember<std::string> transport_id;
48 RTCStatsMember<std::string> local_candidate_id;
49 RTCStatsMember<std::string> remote_candidate_id;
50 // TODO(hbos): Support enum types?
51 // "RTCStatsMember<RTCStatsIceCandidatePairState>"?
52 RTCStatsMember<std::string> state;
53 RTCStatsMember<uint64_t> priority;
54 RTCStatsMember<bool> nominated;
55 RTCStatsMember<bool> writable;
56 RTCStatsMember<bool> readable;
57 RTCStatsMember<uint64_t> bytes_sent;
58 RTCStatsMember<uint64_t> bytes_received;
59 RTCStatsMember<double> total_rtt;
60 RTCStatsMember<double> current_rtt;
61 RTCStatsMember<double> available_outgoing_bitrate;
62 RTCStatsMember<double> available_incoming_bitrate;
63 RTCStatsMember<uint64_t> requests_received;
64 RTCStatsMember<uint64_t> requests_sent;
65 RTCStatsMember<uint64_t> responses_received;
66 RTCStatsMember<uint64_t> responses_sent;
67 RTCStatsMember<uint64_t> retransmissions_received;
68 RTCStatsMember<uint64_t> retransmissions_sent;
69 RTCStatsMember<uint64_t> consent_requests_received;
70 RTCStatsMember<uint64_t> consent_requests_sent;
71 RTCStatsMember<uint64_t> consent_responses_received;
72 RTCStatsMember<uint64_t> consent_responses_sent;
73};
74
hbosab9f6e42016-10-07 02:18:47 -070075// https://w3c.github.io/webrtc-stats/#icecandidate-dict*
76class RTCIceCandidateStats : public RTCStats {
77 public:
78 WEBRTC_RTCSTATS_DECL();
79
80 RTCIceCandidateStats(const RTCIceCandidateStats& other);
81 ~RTCIceCandidateStats() override;
82
83 RTCStatsMember<std::string> ip;
84 RTCStatsMember<int32_t> port;
85 RTCStatsMember<std::string> protocol;
86 // TODO(hbos): Support enum types? "RTCStatsMember<RTCIceCandidateType>"?
87 RTCStatsMember<std::string> candidate_type;
88 RTCStatsMember<int32_t> priority;
89 RTCStatsMember<std::string> url;
90
91 protected:
92 RTCIceCandidateStats(const std::string& id, int64_t timestamp_us);
93 RTCIceCandidateStats(std::string&& id, int64_t timestamp_us);
94};
95
96// In the spec both local and remote varieties are of type RTCIceCandidateStats.
97// But here we define them as subclasses of |RTCIceCandidateStats| because the
98// |kType| need to be different ("RTCStatsType type") in the local/remote case.
99// https://w3c.github.io/webrtc-stats/#rtcstatstype-str*
100class RTCLocalIceCandidateStats final : public RTCIceCandidateStats {
101 public:
102 static const char kType[];
103 RTCLocalIceCandidateStats(const std::string& id, int64_t timestamp_us);
104 RTCLocalIceCandidateStats(std::string&& id, int64_t timestamp_us);
105 const char* type() const override;
106};
107
108class RTCRemoteIceCandidateStats final : public RTCIceCandidateStats {
109 public:
110 static const char kType[];
111 RTCRemoteIceCandidateStats(const std::string& id, int64_t timestamp_us);
112 RTCRemoteIceCandidateStats(std::string&& id, int64_t timestamp_us);
113 const char* type() const override;
114};
115
hbos6ab97ce2016-10-03 14:16:56 -0700116// https://w3c.github.io/webrtc-stats/#certificatestats-dict*
hbosab9f6e42016-10-07 02:18:47 -0700117class RTCCertificateStats final : public RTCStats {
hbos6ab97ce2016-10-03 14:16:56 -0700118 public:
hbosfc5e0502016-10-06 02:06:10 -0700119 WEBRTC_RTCSTATS_DECL();
120
hbos6ab97ce2016-10-03 14:16:56 -0700121 RTCCertificateStats(const std::string& id, int64_t timestamp_us);
122 RTCCertificateStats(std::string&& id, int64_t timestamp_us);
hbosfc5e0502016-10-06 02:06:10 -0700123 RTCCertificateStats(const RTCCertificateStats& other);
124 ~RTCCertificateStats() override;
hbos6ab97ce2016-10-03 14:16:56 -0700125
126 RTCStatsMember<std::string> fingerprint;
127 RTCStatsMember<std::string> fingerprint_algorithm;
128 RTCStatsMember<std::string> base64_certificate;
129 RTCStatsMember<std::string> issuer_certificate_id;
130};
131
132// https://w3c.github.io/webrtc-stats/#pcstats-dict*
133// TODO(hbos): Tracking bug crbug.com/636818
hbosab9f6e42016-10-07 02:18:47 -0700134class RTCPeerConnectionStats final : public RTCStats {
hbosd565b732016-08-30 14:04:35 -0700135 public:
hbosfc5e0502016-10-06 02:06:10 -0700136 WEBRTC_RTCSTATS_DECL();
137
hbos0e6758d2016-08-31 07:57:36 -0700138 RTCPeerConnectionStats(const std::string& id, int64_t timestamp_us);
139 RTCPeerConnectionStats(std::string&& id, int64_t timestamp_us);
hbosfc5e0502016-10-06 02:06:10 -0700140 RTCPeerConnectionStats(const RTCPeerConnectionStats& other);
141 ~RTCPeerConnectionStats() override;
hbosd565b732016-08-30 14:04:35 -0700142
143 RTCStatsMember<uint32_t> data_channels_opened;
144 RTCStatsMember<uint32_t> data_channels_closed;
145};
146
147} // namespace webrtc
148
hbos74e1a4f2016-09-15 23:33:01 -0700149#endif // WEBRTC_API_STATS_RTCSTATS_OBJECTS_H_