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