blob: 4e8a3ee154a8343689608a0683cc172ac1f5ddc9 [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
hboscc555c52016-10-18 12:48:31 -070020// https://w3c.github.io/webrtc-pc/#idl-def-rtcdatachannelstate
21struct RTCDataChannelState {
22 static const char* kConnecting;
23 static const char* kOpen;
24 static const char* kClosing;
25 static const char* kClosed;
26};
27
hbosc47a0c32016-10-11 14:54:49 -070028// https://w3c.github.io/webrtc-stats/#dom-rtcstatsicecandidatepairstate
29struct RTCStatsIceCandidatePairState {
30 static const char* kFrozen;
31 static const char* kWaiting;
32 static const char* kInProgress;
33 static const char* kFailed;
34 static const char* kSucceeded;
35 static const char* kCancelled;
36};
37
hboscc555c52016-10-18 12:48:31 -070038// https://w3c.github.io/webrtc-pc/#rtcicecandidatetype-enum
hbosab9f6e42016-10-07 02:18:47 -070039struct RTCIceCandidateType {
40 static const char* kHost;
41 static const char* kSrflx;
42 static const char* kPrflx;
43 static const char* kRelay;
44};
45
hbos2fa7c672016-10-24 04:00:05 -070046// https://w3c.github.io/webrtc-stats/#certificatestats-dict*
47class RTCCertificateStats final : public RTCStats {
48 public:
49 WEBRTC_RTCSTATS_DECL();
50
51 RTCCertificateStats(const std::string& id, int64_t timestamp_us);
52 RTCCertificateStats(std::string&& id, int64_t timestamp_us);
53 RTCCertificateStats(const RTCCertificateStats& other);
54 ~RTCCertificateStats() override;
55
56 RTCStatsMember<std::string> fingerprint;
57 RTCStatsMember<std::string> fingerprint_algorithm;
58 RTCStatsMember<std::string> base64_certificate;
59 RTCStatsMember<std::string> issuer_certificate_id;
60};
61
62// https://w3c.github.io/webrtc-stats/#dcstats-dict*
63class RTCDataChannelStats final : public RTCStats {
64 public:
65 WEBRTC_RTCSTATS_DECL();
66
67 RTCDataChannelStats(const std::string& id, int64_t timestamp_us);
68 RTCDataChannelStats(std::string&& id, int64_t timestamp_us);
69 RTCDataChannelStats(const RTCDataChannelStats& other);
70 ~RTCDataChannelStats() override;
71
72 RTCStatsMember<std::string> label;
73 RTCStatsMember<std::string> protocol;
74 RTCStatsMember<int32_t> datachannelid;
75 // TODO(hbos): Support enum types? "RTCStatsMember<RTCDataChannelState>"?
76 RTCStatsMember<std::string> state;
77 RTCStatsMember<uint32_t> messages_sent;
78 RTCStatsMember<uint64_t> bytes_sent;
79 RTCStatsMember<uint32_t> messages_received;
80 RTCStatsMember<uint64_t> bytes_received;
81};
82
83// https://w3c.github.io/webrtc-stats/#candidatepair-dict*
84// TODO(hbos): Finish implementation. Tracking bug crbug.com/633550
hbosc47a0c32016-10-11 14:54:49 -070085class RTCIceCandidatePairStats : public RTCStats {
86 public:
87 WEBRTC_RTCSTATS_DECL();
88
89 RTCIceCandidatePairStats(const std::string& id, int64_t timestamp_us);
90 RTCIceCandidatePairStats(std::string&& id, int64_t timestamp_us);
91 RTCIceCandidatePairStats(const RTCIceCandidatePairStats& other);
92 ~RTCIceCandidatePairStats() override;
93
94 RTCStatsMember<std::string> transport_id;
95 RTCStatsMember<std::string> local_candidate_id;
96 RTCStatsMember<std::string> remote_candidate_id;
97 // TODO(hbos): Support enum types?
98 // "RTCStatsMember<RTCStatsIceCandidatePairState>"?
99 RTCStatsMember<std::string> state;
100 RTCStatsMember<uint64_t> priority;
101 RTCStatsMember<bool> nominated;
102 RTCStatsMember<bool> writable;
103 RTCStatsMember<bool> readable;
104 RTCStatsMember<uint64_t> bytes_sent;
105 RTCStatsMember<uint64_t> bytes_received;
106 RTCStatsMember<double> total_rtt;
107 RTCStatsMember<double> current_rtt;
108 RTCStatsMember<double> available_outgoing_bitrate;
109 RTCStatsMember<double> available_incoming_bitrate;
110 RTCStatsMember<uint64_t> requests_received;
111 RTCStatsMember<uint64_t> requests_sent;
112 RTCStatsMember<uint64_t> responses_received;
113 RTCStatsMember<uint64_t> responses_sent;
114 RTCStatsMember<uint64_t> retransmissions_received;
115 RTCStatsMember<uint64_t> retransmissions_sent;
116 RTCStatsMember<uint64_t> consent_requests_received;
117 RTCStatsMember<uint64_t> consent_requests_sent;
118 RTCStatsMember<uint64_t> consent_responses_received;
119 RTCStatsMember<uint64_t> consent_responses_sent;
120};
121
hbosab9f6e42016-10-07 02:18:47 -0700122// https://w3c.github.io/webrtc-stats/#icecandidate-dict*
hbos2fa7c672016-10-24 04:00:05 -0700123// TODO(hbos): Finish implementation. Tracking bug crbug.com/632723
hbosab9f6e42016-10-07 02:18:47 -0700124class RTCIceCandidateStats : public RTCStats {
125 public:
126 WEBRTC_RTCSTATS_DECL();
127
128 RTCIceCandidateStats(const RTCIceCandidateStats& other);
129 ~RTCIceCandidateStats() override;
130
131 RTCStatsMember<std::string> ip;
132 RTCStatsMember<int32_t> port;
133 RTCStatsMember<std::string> protocol;
134 // TODO(hbos): Support enum types? "RTCStatsMember<RTCIceCandidateType>"?
135 RTCStatsMember<std::string> candidate_type;
136 RTCStatsMember<int32_t> priority;
137 RTCStatsMember<std::string> url;
138
139 protected:
140 RTCIceCandidateStats(const std::string& id, int64_t timestamp_us);
141 RTCIceCandidateStats(std::string&& id, int64_t timestamp_us);
142};
143
144// In the spec both local and remote varieties are of type RTCIceCandidateStats.
145// But here we define them as subclasses of |RTCIceCandidateStats| because the
146// |kType| need to be different ("RTCStatsType type") in the local/remote case.
147// https://w3c.github.io/webrtc-stats/#rtcstatstype-str*
148class RTCLocalIceCandidateStats final : public RTCIceCandidateStats {
149 public:
150 static const char kType[];
151 RTCLocalIceCandidateStats(const std::string& id, int64_t timestamp_us);
152 RTCLocalIceCandidateStats(std::string&& id, int64_t timestamp_us);
153 const char* type() const override;
154};
155
156class RTCRemoteIceCandidateStats final : public RTCIceCandidateStats {
157 public:
158 static const char kType[];
159 RTCRemoteIceCandidateStats(const std::string& id, int64_t timestamp_us);
160 RTCRemoteIceCandidateStats(std::string&& id, int64_t timestamp_us);
161 const char* type() const override;
162};
163
hbos6ab97ce2016-10-03 14:16:56 -0700164// https://w3c.github.io/webrtc-stats/#pcstats-dict*
hbos2fa7c672016-10-24 04:00:05 -0700165// TODO(hbos): Finish implementation. Tracking bug crbug.com/636818
hbosab9f6e42016-10-07 02:18:47 -0700166class RTCPeerConnectionStats final : public RTCStats {
hbosd565b732016-08-30 14:04:35 -0700167 public:
hbosfc5e0502016-10-06 02:06:10 -0700168 WEBRTC_RTCSTATS_DECL();
169
hbos0e6758d2016-08-31 07:57:36 -0700170 RTCPeerConnectionStats(const std::string& id, int64_t timestamp_us);
171 RTCPeerConnectionStats(std::string&& id, int64_t timestamp_us);
hbosfc5e0502016-10-06 02:06:10 -0700172 RTCPeerConnectionStats(const RTCPeerConnectionStats& other);
173 ~RTCPeerConnectionStats() override;
hbosd565b732016-08-30 14:04:35 -0700174
175 RTCStatsMember<uint32_t> data_channels_opened;
176 RTCStatsMember<uint32_t> data_channels_closed;
177};
178
hbos2fa7c672016-10-24 04:00:05 -0700179// https://w3c.github.io/webrtc-stats/#transportstats-dict*
180class RTCTransportStats final : public RTCStats {
181 public:
182 WEBRTC_RTCSTATS_DECL();
183
184 RTCTransportStats(const std::string& id, int64_t timestamp_us);
185 RTCTransportStats(std::string&& id, int64_t timestamp_us);
186 RTCTransportStats(const RTCTransportStats& other);
187 ~RTCTransportStats() override;
188
189 RTCStatsMember<uint64_t> bytes_sent;
190 RTCStatsMember<uint64_t> bytes_received;
191 RTCStatsMember<std::string> rtcp_transport_stats_id;
192 RTCStatsMember<bool> active_connection;
193 RTCStatsMember<std::string> selected_candidate_pair_id;
194 RTCStatsMember<std::string> local_certificate_id;
195 RTCStatsMember<std::string> remote_certificate_id;
196};
197
hbosd565b732016-08-30 14:04:35 -0700198} // namespace webrtc
199
hbos74e1a4f2016-09-15 23:33:01 -0700200#endif // WEBRTC_API_STATS_RTCSTATS_OBJECTS_H_