1 /* 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 14 #include "api/peer_connection_interface.h" 15 16 namespace webrtc { 17 18 class PeerConnectionObserver; 19 20 // A bit in the usage pattern is registered when its defining event occurs 21 // at least once. 22 enum 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, 28 // |SetLocalDescription| returns successfully. 29 SET_LOCAL_DESCRIPTION_SUCCEEDED = 0x20, 30 // |SetRemoteDescription| returns successfully. 31 SET_REMOTE_DESCRIPTION_SUCCEEDED = 0x40, 32 // A local candidate (with type host, server-reflexive, or relay) is 33 // collected. 34 CANDIDATE_COLLECTED = 0x80, 35 // A remote candidate is successfully added via |AddIceCandidate|. 36 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 67 class 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_ 78