blob: e827d011ea9499b3eff8fead60d3c03d8de5d1f8 [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
hbosab9f6e42016-10-07 02:18:47 -070020// https://www.w3.org/TR/webrtc/#rtcicecandidatetype-enum
21struct RTCIceCandidateType {
22 static const char* kHost;
23 static const char* kSrflx;
24 static const char* kPrflx;
25 static const char* kRelay;
26};
27
28// https://w3c.github.io/webrtc-stats/#icecandidate-dict*
29class RTCIceCandidateStats : public RTCStats {
30 public:
31 WEBRTC_RTCSTATS_DECL();
32
33 RTCIceCandidateStats(const RTCIceCandidateStats& other);
34 ~RTCIceCandidateStats() override;
35
36 RTCStatsMember<std::string> ip;
37 RTCStatsMember<int32_t> port;
38 RTCStatsMember<std::string> protocol;
39 // TODO(hbos): Support enum types? "RTCStatsMember<RTCIceCandidateType>"?
40 RTCStatsMember<std::string> candidate_type;
41 RTCStatsMember<int32_t> priority;
42 RTCStatsMember<std::string> url;
43
44 protected:
45 RTCIceCandidateStats(const std::string& id, int64_t timestamp_us);
46 RTCIceCandidateStats(std::string&& id, int64_t timestamp_us);
47};
48
49// In the spec both local and remote varieties are of type RTCIceCandidateStats.
50// But here we define them as subclasses of |RTCIceCandidateStats| because the
51// |kType| need to be different ("RTCStatsType type") in the local/remote case.
52// https://w3c.github.io/webrtc-stats/#rtcstatstype-str*
53class RTCLocalIceCandidateStats final : public RTCIceCandidateStats {
54 public:
55 static const char kType[];
56 RTCLocalIceCandidateStats(const std::string& id, int64_t timestamp_us);
57 RTCLocalIceCandidateStats(std::string&& id, int64_t timestamp_us);
58 const char* type() const override;
59};
60
61class RTCRemoteIceCandidateStats final : public RTCIceCandidateStats {
62 public:
63 static const char kType[];
64 RTCRemoteIceCandidateStats(const std::string& id, int64_t timestamp_us);
65 RTCRemoteIceCandidateStats(std::string&& id, int64_t timestamp_us);
66 const char* type() const override;
67};
68
hbos6ab97ce2016-10-03 14:16:56 -070069// https://w3c.github.io/webrtc-stats/#certificatestats-dict*
hbosab9f6e42016-10-07 02:18:47 -070070class RTCCertificateStats final : public RTCStats {
hbos6ab97ce2016-10-03 14:16:56 -070071 public:
hbosfc5e0502016-10-06 02:06:10 -070072 WEBRTC_RTCSTATS_DECL();
73
hbos6ab97ce2016-10-03 14:16:56 -070074 RTCCertificateStats(const std::string& id, int64_t timestamp_us);
75 RTCCertificateStats(std::string&& id, int64_t timestamp_us);
hbosfc5e0502016-10-06 02:06:10 -070076 RTCCertificateStats(const RTCCertificateStats& other);
77 ~RTCCertificateStats() override;
hbos6ab97ce2016-10-03 14:16:56 -070078
79 RTCStatsMember<std::string> fingerprint;
80 RTCStatsMember<std::string> fingerprint_algorithm;
81 RTCStatsMember<std::string> base64_certificate;
82 RTCStatsMember<std::string> issuer_certificate_id;
83};
84
85// https://w3c.github.io/webrtc-stats/#pcstats-dict*
86// TODO(hbos): Tracking bug crbug.com/636818
hbosab9f6e42016-10-07 02:18:47 -070087class RTCPeerConnectionStats final : public RTCStats {
hbosd565b732016-08-30 14:04:35 -070088 public:
hbosfc5e0502016-10-06 02:06:10 -070089 WEBRTC_RTCSTATS_DECL();
90
hbos0e6758d2016-08-31 07:57:36 -070091 RTCPeerConnectionStats(const std::string& id, int64_t timestamp_us);
92 RTCPeerConnectionStats(std::string&& id, int64_t timestamp_us);
hbosfc5e0502016-10-06 02:06:10 -070093 RTCPeerConnectionStats(const RTCPeerConnectionStats& other);
94 ~RTCPeerConnectionStats() override;
hbosd565b732016-08-30 14:04:35 -070095
96 RTCStatsMember<uint32_t> data_channels_opened;
97 RTCStatsMember<uint32_t> data_channels_closed;
98};
99
100} // namespace webrtc
101
hbos74e1a4f2016-09-15 23:33:01 -0700102#endif // WEBRTC_API_STATS_RTCSTATS_OBJECTS_H_