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; |
| 102 if (l == host && r == srflx) |
| 103 return kIceCandidatePairHostSrflx; |
| 104 if (l == host && r == relay) |
| 105 return kIceCandidatePairHostRelay; |
| 106 if (l == host && r == prflx) |
| 107 return kIceCandidatePairHostPrflx; |
| 108 if (l == srflx && r == host) |
| 109 return kIceCandidatePairSrflxHost; |
| 110 if (l == srflx && r == srflx) |
| 111 return kIceCandidatePairSrflxSrflx; |
| 112 if (l == srflx && r == relay) |
| 113 return kIceCandidatePairSrflxRelay; |
| 114 if (l == srflx && r == prflx) |
| 115 return kIceCandidatePairSrflxPrflx; |
| 116 if (l == relay && r == host) |
| 117 return kIceCandidatePairRelayHost; |
| 118 if (l == relay && r == srflx) |
| 119 return kIceCandidatePairRelaySrflx; |
| 120 if (l == relay && r == relay) |
| 121 return kIceCandidatePairRelayRelay; |
| 122 if (l == relay && r == prflx) |
| 123 return kIceCandidatePairRelayPrflx; |
| 124 if (l == prflx && r == host) |
| 125 return kIceCandidatePairPrflxHost; |
| 126 if (l == prflx && r == srflx) |
| 127 return kIceCandidatePairPrflxSrflx; |
| 128 if (l == prflx && r == relay) |
| 129 return kIceCandidatePairPrflxRelay; |
| 130 return kIceCandidatePairMax; |
| 131 } |
| 132 |
86 // Compares |answer| against |offer|. Comparision is done | 133 // Compares |answer| against |offer|. Comparision is done |
87 // for number of m-lines in answer against offer. If matches true will be | 134 // for number of m-lines in answer against offer. If matches true will be |
88 // returned otherwise false. | 135 // returned otherwise false. |
89 static bool VerifyMediaDescriptions( | 136 static bool VerifyMediaDescriptions( |
90 const SessionDescription* answer, const SessionDescription* offer) { | 137 const SessionDescription* answer, const SessionDescription* offer) { |
91 if (offer->contents().size() != answer->contents().size()) | 138 if (offer->contents().size() != answer->contents().size()) |
92 return false; | 139 return false; |
93 | 140 |
94 for (size_t i = 0; i < offer->contents().size(); ++i) { | 141 for (size_t i = 0; i < offer->contents().size(); ++i) { |
95 if ((offer->contents()[i].name) != answer->contents()[i].name) { | 142 if ((offer->contents()[i].name) != answer->contents()[i].name) { |
(...skipping 1818 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1914 DCHECK(metrics_observer_ != NULL); | 1961 DCHECK(metrics_observer_ != NULL); |
1915 for (cricket::TransportChannelStatsList::const_iterator it = | 1962 for (cricket::TransportChannelStatsList::const_iterator it = |
1916 stats.channel_stats.begin(); | 1963 stats.channel_stats.begin(); |
1917 it != stats.channel_stats.end(); ++it) { | 1964 it != stats.channel_stats.end(); ++it) { |
1918 for (cricket::ConnectionInfos::const_iterator it_info = | 1965 for (cricket::ConnectionInfos::const_iterator it_info = |
1919 it->connection_infos.begin(); | 1966 it->connection_infos.begin(); |
1920 it_info != it->connection_infos.end(); ++it_info) { | 1967 it_info != it->connection_infos.end(); ++it_info) { |
1921 if (!it_info->best_connection) { | 1968 if (!it_info->best_connection) { |
1922 continue; | 1969 continue; |
1923 } | 1970 } |
1924 if (it_info->local_candidate.address().family() == AF_INET) { | 1971 |
| 1972 PeerConnectionEnumCounterType type = kPeerConnectionEnumCounterMax; |
| 1973 const cricket::Candidate& local = it_info->local_candidate; |
| 1974 const cricket::Candidate& remote = it_info->remote_candidate; |
| 1975 |
| 1976 // Increment the counter for IceCandidatePairType. |
| 1977 if (local.protocol() == cricket::TCP_PROTOCOL_NAME || |
| 1978 (local.type() == RELAY_PORT_TYPE && |
| 1979 local.relay_protocol() == cricket::TCP_PROTOCOL_NAME)) { |
| 1980 type = kEnumCounterIceCandidatePairTypeTcp; |
| 1981 } else if (local.protocol() == cricket::UDP_PROTOCOL_NAME) { |
| 1982 type = kEnumCounterIceCandidatePairTypeUdp; |
| 1983 } else { |
| 1984 CHECK(0); |
| 1985 } |
| 1986 metrics_observer_->IncrementEnumCounter( |
| 1987 type, GetIceCandidatePairCounter(local, remote), |
| 1988 kIceCandidatePairMax); |
| 1989 |
| 1990 // Increment the counter for IP type. |
| 1991 if (local.address().family() == AF_INET) { |
| 1992 // TODO(guoweis): Remove this next line once IncrementEnumCounter |
| 1993 // implemented for PeerConnectionMetrics. |
1925 metrics_observer_->IncrementCounter(kBestConnections_IPv4); | 1994 metrics_observer_->IncrementCounter(kBestConnections_IPv4); |
1926 } else if (it_info->local_candidate.address().family() == | 1995 |
1927 AF_INET6) { | 1996 metrics_observer_->IncrementEnumCounter( |
| 1997 kEnumCounterAddressFamily, kBestConnections_IPv4, |
| 1998 kPeerConnectionAddressFamilyCounter_Max); |
| 1999 |
| 2000 } else if (local.address().family() == AF_INET6) { |
| 2001 // TODO(guoweis): Remove this next line. |
1928 metrics_observer_->IncrementCounter(kBestConnections_IPv6); | 2002 metrics_observer_->IncrementCounter(kBestConnections_IPv6); |
| 2003 |
| 2004 metrics_observer_->IncrementEnumCounter( |
| 2005 kEnumCounterAddressFamily, kBestConnections_IPv6, |
| 2006 kPeerConnectionAddressFamilyCounter_Max); |
1929 } else { | 2007 } else { |
1930 RTC_NOTREACHED(); | 2008 CHECK(0); |
1931 } | 2009 } |
| 2010 |
1932 return; | 2011 return; |
1933 } | 2012 } |
1934 } | 2013 } |
1935 } | 2014 } |
1936 | 2015 |
1937 void WebRtcSession::ReportNegotiatedCiphers( | 2016 void WebRtcSession::ReportNegotiatedCiphers( |
1938 const cricket::TransportStats& stats) { | 2017 const cricket::TransportStats& stats) { |
1939 DCHECK(metrics_observer_ != NULL); | 2018 DCHECK(metrics_observer_ != NULL); |
1940 if (!dtls_enabled_ || stats.channel_stats.empty()) { | 2019 if (!dtls_enabled_ || stats.channel_stats.empty()) { |
1941 return; | 2020 return; |
(...skipping 23 matching lines...) Expand all Loading... |
1965 | 2044 |
1966 if (!srtp_cipher.empty()) { | 2045 if (!srtp_cipher.empty()) { |
1967 metrics_observer_->AddHistogramSample(srtp_name, srtp_cipher); | 2046 metrics_observer_->AddHistogramSample(srtp_name, srtp_cipher); |
1968 } | 2047 } |
1969 if (!ssl_cipher.empty()) { | 2048 if (!ssl_cipher.empty()) { |
1970 metrics_observer_->AddHistogramSample(ssl_name, ssl_cipher); | 2049 metrics_observer_->AddHistogramSample(ssl_name, ssl_cipher); |
1971 } | 2050 } |
1972 } | 2051 } |
1973 | 2052 |
1974 } // namespace webrtc | 2053 } // namespace webrtc |
OLD | NEW |