blob: c4a8918ac232498bce04cbe192add6ebfbfb05fa [file] [log] [blame]
Harald Alvestrand44d0dff2020-10-09 05:43:53 +00001/*
2 * Copyright 2020 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
11#ifndef PC_USAGE_PATTERN_H_
12#define PC_USAGE_PATTERN_H_
13
14namespace webrtc {
15
16class PeerConnectionObserver;
17
18// A bit in the usage pattern is registered when its defining event occurs
19// at least once.
20enum class UsageEvent : int {
21 TURN_SERVER_ADDED = 0x01,
22 STUN_SERVER_ADDED = 0x02,
23 DATA_ADDED = 0x04,
24 AUDIO_ADDED = 0x08,
25 VIDEO_ADDED = 0x10,
26 // |SetLocalDescription| returns successfully.
27 SET_LOCAL_DESCRIPTION_SUCCEEDED = 0x20,
28 // |SetRemoteDescription| returns successfully.
29 SET_REMOTE_DESCRIPTION_SUCCEEDED = 0x40,
30 // A local candidate (with type host, server-reflexive, or relay) is
31 // collected.
32 CANDIDATE_COLLECTED = 0x80,
33 // A remote candidate is successfully added via |AddIceCandidate|.
34 ADD_ICE_CANDIDATE_SUCCEEDED = 0x100,
35 ICE_STATE_CONNECTED = 0x200,
36 CLOSE_CALLED = 0x400,
37 // A local candidate with private IP is collected.
38 PRIVATE_CANDIDATE_COLLECTED = 0x800,
39 // A remote candidate with private IP is added, either via AddiceCandidate
40 // or from the remote description.
41 REMOTE_PRIVATE_CANDIDATE_ADDED = 0x1000,
42 // A local mDNS candidate is collected.
43 MDNS_CANDIDATE_COLLECTED = 0x2000,
44 // A remote mDNS candidate is added, either via AddIceCandidate or from the
45 // remote description.
46 REMOTE_MDNS_CANDIDATE_ADDED = 0x4000,
47 // A local candidate with IPv6 address is collected.
48 IPV6_CANDIDATE_COLLECTED = 0x8000,
49 // A remote candidate with IPv6 address is added, either via AddIceCandidate
50 // or from the remote description.
51 REMOTE_IPV6_CANDIDATE_ADDED = 0x10000,
52 // A remote candidate (with type host, server-reflexive, or relay) is
53 // successfully added, either via AddIceCandidate or from the remote
54 // description.
55 REMOTE_CANDIDATE_ADDED = 0x20000,
56 // An explicit host-host candidate pair is selected, i.e. both the local and
57 // the remote candidates have the host type. This does not include candidate
58 // pairs formed with equivalent prflx remote candidates, e.g. a host-prflx
59 // pair where the prflx candidate has the same base as a host candidate of
60 // the remote peer.
61 DIRECT_CONNECTION_SELECTED = 0x40000,
62 MAX_VALUE = 0x80000,
63};
64
65class UsagePattern {
66 public:
67 void NoteUsageEvent(UsageEvent event);
68 void ReportUsagePattern(PeerConnectionObserver* observer) const;
69
70 private:
71 int usage_event_accumulator_ = 0;
72};
73
74} // namespace webrtc
75#endif // PC_USAGE_PATTERN_H_