blob: ad6a39cdfeccd337e9088299e20e0732e84302f0 [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
hbosc47a0c32016-10-11 14:54:49 -070046class RTCIceCandidatePairStats : public RTCStats {
47 public:
48 WEBRTC_RTCSTATS_DECL();
49
50 RTCIceCandidatePairStats(const std::string& id, int64_t timestamp_us);
51 RTCIceCandidatePairStats(std::string&& id, int64_t timestamp_us);
52 RTCIceCandidatePairStats(const RTCIceCandidatePairStats& other);
53 ~RTCIceCandidatePairStats() override;
54
55 RTCStatsMember<std::string> transport_id;
56 RTCStatsMember<std::string> local_candidate_id;
57 RTCStatsMember<std::string> remote_candidate_id;
58 // TODO(hbos): Support enum types?
59 // "RTCStatsMember<RTCStatsIceCandidatePairState>"?
60 RTCStatsMember<std::string> state;
61 RTCStatsMember<uint64_t> priority;
62 RTCStatsMember<bool> nominated;
63 RTCStatsMember<bool> writable;
64 RTCStatsMember<bool> readable;
65 RTCStatsMember<uint64_t> bytes_sent;
66 RTCStatsMember<uint64_t> bytes_received;
67 RTCStatsMember<double> total_rtt;
68 RTCStatsMember<double> current_rtt;
69 RTCStatsMember<double> available_outgoing_bitrate;
70 RTCStatsMember<double> available_incoming_bitrate;
71 RTCStatsMember<uint64_t> requests_received;
72 RTCStatsMember<uint64_t> requests_sent;
73 RTCStatsMember<uint64_t> responses_received;
74 RTCStatsMember<uint64_t> responses_sent;
75 RTCStatsMember<uint64_t> retransmissions_received;
76 RTCStatsMember<uint64_t> retransmissions_sent;
77 RTCStatsMember<uint64_t> consent_requests_received;
78 RTCStatsMember<uint64_t> consent_requests_sent;
79 RTCStatsMember<uint64_t> consent_responses_received;
80 RTCStatsMember<uint64_t> consent_responses_sent;
81};
82
hbosab9f6e42016-10-07 02:18:47 -070083// https://w3c.github.io/webrtc-stats/#icecandidate-dict*
84class RTCIceCandidateStats : public RTCStats {
85 public:
86 WEBRTC_RTCSTATS_DECL();
87
88 RTCIceCandidateStats(const RTCIceCandidateStats& other);
89 ~RTCIceCandidateStats() override;
90
91 RTCStatsMember<std::string> ip;
92 RTCStatsMember<int32_t> port;
93 RTCStatsMember<std::string> protocol;
94 // TODO(hbos): Support enum types? "RTCStatsMember<RTCIceCandidateType>"?
95 RTCStatsMember<std::string> candidate_type;
96 RTCStatsMember<int32_t> priority;
97 RTCStatsMember<std::string> url;
98
99 protected:
100 RTCIceCandidateStats(const std::string& id, int64_t timestamp_us);
101 RTCIceCandidateStats(std::string&& id, int64_t timestamp_us);
102};
103
104// In the spec both local and remote varieties are of type RTCIceCandidateStats.
105// But here we define them as subclasses of |RTCIceCandidateStats| because the
106// |kType| need to be different ("RTCStatsType type") in the local/remote case.
107// https://w3c.github.io/webrtc-stats/#rtcstatstype-str*
108class RTCLocalIceCandidateStats final : public RTCIceCandidateStats {
109 public:
110 static const char kType[];
111 RTCLocalIceCandidateStats(const std::string& id, int64_t timestamp_us);
112 RTCLocalIceCandidateStats(std::string&& id, int64_t timestamp_us);
113 const char* type() const override;
114};
115
116class RTCRemoteIceCandidateStats final : public RTCIceCandidateStats {
117 public:
118 static const char kType[];
119 RTCRemoteIceCandidateStats(const std::string& id, int64_t timestamp_us);
120 RTCRemoteIceCandidateStats(std::string&& id, int64_t timestamp_us);
121 const char* type() const override;
122};
123
hbos6ab97ce2016-10-03 14:16:56 -0700124// https://w3c.github.io/webrtc-stats/#certificatestats-dict*
hbosab9f6e42016-10-07 02:18:47 -0700125class RTCCertificateStats final : public RTCStats {
hbos6ab97ce2016-10-03 14:16:56 -0700126 public:
hbosfc5e0502016-10-06 02:06:10 -0700127 WEBRTC_RTCSTATS_DECL();
128
hbos6ab97ce2016-10-03 14:16:56 -0700129 RTCCertificateStats(const std::string& id, int64_t timestamp_us);
130 RTCCertificateStats(std::string&& id, int64_t timestamp_us);
hbosfc5e0502016-10-06 02:06:10 -0700131 RTCCertificateStats(const RTCCertificateStats& other);
132 ~RTCCertificateStats() override;
hbos6ab97ce2016-10-03 14:16:56 -0700133
134 RTCStatsMember<std::string> fingerprint;
135 RTCStatsMember<std::string> fingerprint_algorithm;
136 RTCStatsMember<std::string> base64_certificate;
137 RTCStatsMember<std::string> issuer_certificate_id;
138};
139
hboscc555c52016-10-18 12:48:31 -0700140// https://w3c.github.io/webrtc-stats/#dcstats-dict*
141class RTCDataChannelStats final : public RTCStats {
142 public:
143 WEBRTC_RTCSTATS_DECL();
144
145 RTCDataChannelStats(const std::string& id, int64_t timestamp_us);
146 RTCDataChannelStats(std::string&& id, int64_t timestamp_us);
147 RTCDataChannelStats(const RTCDataChannelStats& other);
148 ~RTCDataChannelStats() override;
149
150 RTCStatsMember<std::string> label;
151 RTCStatsMember<std::string> protocol;
152 RTCStatsMember<int32_t> datachannelid;
153 // TODO(hbos): Support enum types? "RTCStatsMember<RTCDataChannelState>"?
154 RTCStatsMember<std::string> state;
155 RTCStatsMember<uint32_t> messages_sent;
156 RTCStatsMember<uint64_t> bytes_sent;
157 RTCStatsMember<uint32_t> messages_received;
158 RTCStatsMember<uint64_t> bytes_received;
159};
160
hbos6ab97ce2016-10-03 14:16:56 -0700161// https://w3c.github.io/webrtc-stats/#pcstats-dict*
162// TODO(hbos): Tracking bug crbug.com/636818
hbosab9f6e42016-10-07 02:18:47 -0700163class RTCPeerConnectionStats final : public RTCStats {
hbosd565b732016-08-30 14:04:35 -0700164 public:
hbosfc5e0502016-10-06 02:06:10 -0700165 WEBRTC_RTCSTATS_DECL();
166
hbos0e6758d2016-08-31 07:57:36 -0700167 RTCPeerConnectionStats(const std::string& id, int64_t timestamp_us);
168 RTCPeerConnectionStats(std::string&& id, int64_t timestamp_us);
hbosfc5e0502016-10-06 02:06:10 -0700169 RTCPeerConnectionStats(const RTCPeerConnectionStats& other);
170 ~RTCPeerConnectionStats() override;
hbosd565b732016-08-30 14:04:35 -0700171
172 RTCStatsMember<uint32_t> data_channels_opened;
173 RTCStatsMember<uint32_t> data_channels_closed;
174};
175
176} // namespace webrtc
177
hbos74e1a4f2016-09-15 23:33:01 -0700178#endif // WEBRTC_API_STATS_RTCSTATS_OBJECTS_H_