OLD | NEW |
---|---|
1 /* | 1 /* |
2 * libjingle | 2 * libjingle |
3 * Copyright 2012 Google Inc. | 3 * Copyright 2012 Google Inc. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are met: | 6 * modification, are permitted provided that the following conditions are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright notice, | 8 * 1. Redistributions of source code must retain the above copyright notice, |
9 * this list of conditions and the following disclaimer. | 9 * this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright notice, | 10 * 2. Redistributions in binary form must reproduce the above copyright notice, |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
50 #include "webrtc/base/stringencode.h" | 50 #include "webrtc/base/stringencode.h" |
51 #include "webrtc/base/stringutils.h" | 51 #include "webrtc/base/stringutils.h" |
52 #include "webrtc/p2p/base/portallocator.h" | 52 #include "webrtc/p2p/base/portallocator.h" |
53 | 53 |
54 using cricket::ContentInfo; | 54 using cricket::ContentInfo; |
55 using cricket::ContentInfos; | 55 using cricket::ContentInfos; |
56 using cricket::MediaContentDescription; | 56 using cricket::MediaContentDescription; |
57 using cricket::SessionDescription; | 57 using cricket::SessionDescription; |
58 using cricket::TransportInfo; | 58 using cricket::TransportInfo; |
59 | 59 |
60 using cricket::LOCAL_PORT_TYPE; | |
61 using cricket::STUN_PORT_TYPE; | |
62 using cricket::RELAY_PORT_TYPE; | |
63 using cricket::PRFLX_PORT_TYPE; | |
64 | |
60 namespace webrtc { | 65 namespace webrtc { |
61 | 66 |
62 // Error messages | 67 // Error messages |
63 const char kBundleWithoutRtcpMux[] = "RTCP-MUX must be enabled when BUNDLE " | 68 const char kBundleWithoutRtcpMux[] = "RTCP-MUX must be enabled when BUNDLE " |
64 "is enabled."; | 69 "is enabled."; |
65 const char kCreateChannelFailed[] = "Failed to create channels."; | 70 const char kCreateChannelFailed[] = "Failed to create channels."; |
66 const char kInvalidCandidates[] = "Description contains invalid candidates."; | 71 const char kInvalidCandidates[] = "Description contains invalid candidates."; |
67 const char kInvalidSdp[] = "Invalid session description."; | 72 const char kInvalidSdp[] = "Invalid session description."; |
68 const char kMlineMismatch[] = | 73 const char kMlineMismatch[] = |
69 "Offer and answer descriptions m-lines are not matching. Rejecting answer."; | 74 "Offer and answer descriptions m-lines are not matching. Rejecting answer."; |
70 const char kPushDownTDFailed[] = | 75 const char kPushDownTDFailed[] = |
71 "Failed to push down transport description:"; | 76 "Failed to push down transport description:"; |
72 const char kSdpWithoutDtlsFingerprint[] = | 77 const char kSdpWithoutDtlsFingerprint[] = |
73 "Called with SDP without DTLS fingerprint."; | 78 "Called with SDP without DTLS fingerprint."; |
74 const char kSdpWithoutSdesCrypto[] = | 79 const char kSdpWithoutSdesCrypto[] = |
75 "Called with SDP without SDES crypto."; | 80 "Called with SDP without SDES crypto."; |
76 const char kSdpWithoutIceUfragPwd[] = | 81 const char kSdpWithoutIceUfragPwd[] = |
77 "Called with SDP without ice-ufrag and ice-pwd."; | 82 "Called with SDP without ice-ufrag and ice-pwd."; |
78 const char kSessionError[] = "Session error code: "; | 83 const char kSessionError[] = "Session error code: "; |
79 const char kSessionErrorDesc[] = "Session error description: "; | 84 const char kSessionErrorDesc[] = "Session error description: "; |
80 const char kDtlsSetupFailureRtp[] = | 85 const char kDtlsSetupFailureRtp[] = |
81 "Couldn't set up DTLS-SRTP on RTP channel."; | 86 "Couldn't set up DTLS-SRTP on RTP channel."; |
82 const char kDtlsSetupFailureRtcp[] = | 87 const char kDtlsSetupFailureRtcp[] = |
83 "Couldn't set up DTLS-SRTP on RTCP channel."; | 88 "Couldn't set up DTLS-SRTP on RTCP channel."; |
84 const int kMaxUnsignalledRecvStreams = 20; | 89 const int kMaxUnsignalledRecvStreams = 20; |
85 | 90 |
91 IceCandidatePairType GetIceCandidatePairCounter( | |
92 const cricket::Candidate& local, | |
93 const cricket::Candidate& remote) { | |
94 const auto& l = local.type(); | |
95 const auto& r = remote.type(); | |
96 const auto& host = LOCAL_PORT_TYPE; | |
97 const auto& srflx = STUN_PORT_TYPE; | |
98 const auto& relay = RELAY_PORT_TYPE; | |
99 const auto& prflx = PRFLX_PORT_TYPE; | |
100 if (l == host && r == host) | |
101 return kIceCandidatePairHostHost; | |
pthatcher2
2015/08/19 18:39:42
host host is here twice.
guoweis_webrtc
2015/08/19 19:03:24
Done.
| |
102 if (l == host && r == host) | |
103 return kIceCandidatePairHostHost; | |
104 if (l == host && r == srflx) | |
105 return kIceCandidatePairHostSrflx; | |
106 if (l == host && r == relay) | |
107 return kIceCandidatePairHostRelay; | |
108 if (l == host && r == prflx) | |
109 return kIceCandidatePairHostPrflx; | |
110 if (l == srflx && r == host) | |
111 return kIceCandidatePairSrflxHost; | |
112 if (l == srflx && r == srflx) | |
113 return kIceCandidatePairSrflxSrflx; | |
114 if (l == srflx && r == relay) | |
115 return kIceCandidatePairSrflxRelay; | |
116 if (l == srflx && r == prflx) | |
117 return kIceCandidatePairSrflxPrflx; | |
118 if (l == relay && r == host) | |
119 return kIceCandidatePairRelayHost; | |
120 if (l == relay && r == srflx) | |
121 return kIceCandidatePairRelaySrflx; | |
122 if (l == relay && r == relay) | |
123 return kIceCandidatePairRelayRelay; | |
124 if (l == relay && r == prflx) | |
125 return kIceCandidatePairRelayPrflx; | |
126 if (l == prflx && r == host) | |
127 return kIceCandidatePairPrflxHost; | |
128 if (l == prflx && r == srflx) | |
129 return kIceCandidatePairPrflxSrflx; | |
130 if (l == prflx && r == relay) | |
131 return kIceCandidatePairPrflxRelay; | |
132 return kIceCandidatePairMax; | |
133 } | |
134 | |
86 // Compares |answer| against |offer|. Comparision is done | 135 // Compares |answer| against |offer|. Comparision is done |
87 // for number of m-lines in answer against offer. If matches true will be | 136 // for number of m-lines in answer against offer. If matches true will be |
88 // returned otherwise false. | 137 // returned otherwise false. |
89 static bool VerifyMediaDescriptions( | 138 static bool VerifyMediaDescriptions( |
90 const SessionDescription* answer, const SessionDescription* offer) { | 139 const SessionDescription* answer, const SessionDescription* offer) { |
91 if (offer->contents().size() != answer->contents().size()) | 140 if (offer->contents().size() != answer->contents().size()) |
92 return false; | 141 return false; |
93 | 142 |
94 for (size_t i = 0; i < offer->contents().size(); ++i) { | 143 for (size_t i = 0; i < offer->contents().size(); ++i) { |
95 if ((offer->contents()[i].name) != answer->contents()[i].name) { | 144 if ((offer->contents()[i].name) != answer->contents()[i].name) { |
(...skipping 1813 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1909 DCHECK(metrics_observer_ != NULL); | 1958 DCHECK(metrics_observer_ != NULL); |
1910 for (cricket::TransportChannelStatsList::const_iterator it = | 1959 for (cricket::TransportChannelStatsList::const_iterator it = |
1911 stats.channel_stats.begin(); | 1960 stats.channel_stats.begin(); |
1912 it != stats.channel_stats.end(); ++it) { | 1961 it != stats.channel_stats.end(); ++it) { |
1913 for (cricket::ConnectionInfos::const_iterator it_info = | 1962 for (cricket::ConnectionInfos::const_iterator it_info = |
1914 it->connection_infos.begin(); | 1963 it->connection_infos.begin(); |
1915 it_info != it->connection_infos.end(); ++it_info) { | 1964 it_info != it->connection_infos.end(); ++it_info) { |
1916 if (!it_info->best_connection) { | 1965 if (!it_info->best_connection) { |
1917 continue; | 1966 continue; |
1918 } | 1967 } |
1919 if (it_info->local_candidate.address().family() == AF_INET) { | 1968 |
1920 metrics_observer_->IncrementCounter(kBestConnections_IPv4); | 1969 PeerConnectionEnumCounterType type = kPeerConnectionEnumCounterMax; |
1921 } else if (it_info->local_candidate.address().family() == | 1970 const cricket::Candidate& local = it_info->local_candidate; |
1922 AF_INET6) { | 1971 const cricket::Candidate& remote = it_info->remote_candidate; |
1923 metrics_observer_->IncrementCounter(kBestConnections_IPv6); | 1972 |
1973 // Increment the counter for IceCandidatePairType. | |
1974 if (local.protocol() == cricket::TCP_PROTOCOL_NAME || | |
1975 (local.type() == RELAY_PORT_TYPE && | |
1976 local.relay_protocol() == cricket::TCP_PROTOCOL_NAME)) { | |
1977 type = kEnumCounterIceCandidatePairTypeTcp; | |
1978 } else if (local.protocol() == cricket::UDP_PROTOCOL_NAME) { | |
1979 type = kEnumCounterIceCandidatePairTypeUdp; | |
1924 } else { | 1980 } else { |
1925 RTC_NOTREACHED(); | 1981 RTC_NOTREACHED(); |
1926 } | 1982 } |
1983 metrics_observer_->IncrementEnumCounter( | |
1984 type, GetIceCandidatePairCounter(local, remote), | |
1985 kIceCandidatePairMax); | |
1986 | |
1987 // Increment the counter for IP type. | |
1988 if (local.address().family() == AF_INET) { | |
1989 // TODO(guoweis): Remove this next line once IncrementEnumCounter | |
1990 // implemented for PeerConnectionMetrics. | |
1991 metrics_observer_->IncrementCounter(kBestConnections_IPv4); | |
1992 | |
1993 metrics_observer_->IncrementEnumCounter( | |
1994 kEnumCounterAddressFamily, kBestConnections_IPv4, | |
1995 kPeerConnectionAddressFamilyCounter_Max); | |
1996 | |
1997 } else if (local.address().family() == AF_INET6) { | |
1998 // TODO(guoweis): Remove this next line. | |
1999 metrics_observer_->IncrementCounter(kBestConnections_IPv6); | |
2000 | |
2001 metrics_observer_->IncrementEnumCounter( | |
2002 kEnumCounterAddressFamily, kBestConnections_IPv6, | |
2003 kPeerConnectionAddressFamilyCounter_Max); | |
2004 } else { | |
2005 RTC_NOTREACHED(); | |
2006 } | |
2007 | |
1927 return; | 2008 return; |
1928 } | 2009 } |
1929 } | 2010 } |
1930 } | 2011 } |
1931 | 2012 |
1932 void WebRtcSession::ReportNegotiatedCiphers( | 2013 void WebRtcSession::ReportNegotiatedCiphers( |
1933 const cricket::TransportStats& stats) { | 2014 const cricket::TransportStats& stats) { |
1934 DCHECK(metrics_observer_ != NULL); | 2015 DCHECK(metrics_observer_ != NULL); |
1935 if (!dtls_enabled_ || stats.channel_stats.empty()) { | 2016 if (!dtls_enabled_ || stats.channel_stats.empty()) { |
1936 return; | 2017 return; |
(...skipping 23 matching lines...) Expand all Loading... | |
1960 | 2041 |
1961 if (!srtp_cipher.empty()) { | 2042 if (!srtp_cipher.empty()) { |
1962 metrics_observer_->AddHistogramSample(srtp_name, srtp_cipher); | 2043 metrics_observer_->AddHistogramSample(srtp_name, srtp_cipher); |
1963 } | 2044 } |
1964 if (!ssl_cipher.empty()) { | 2045 if (!ssl_cipher.empty()) { |
1965 metrics_observer_->AddHistogramSample(ssl_name, ssl_cipher); | 2046 metrics_observer_->AddHistogramSample(ssl_name, ssl_cipher); |
1966 } | 2047 } |
1967 } | 2048 } |
1968 | 2049 |
1969 } // namespace webrtc | 2050 } // namespace webrtc |
OLD | NEW |