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; | |
pthatcher1
2015/08/18 18:06:23
I think you could do
using HOST = cricket::LOCAL
guoweis_webrtc
2015/08/18 22:33:57
doesn't alias only work for type?
pthatcher1
2015/08/19 02:47:52
Yeah, you're right. I thought it was more powerfu
| |
61 using cricket::STUN_PORT_TYPE; | |
62 using cricket::RELAY_PORT_TYPE; | |
63 using cricket::PRFLX_PORT_TYPE; | |
64 using webrtc::IceCandidatePairType; | |
65 | |
60 namespace webrtc { | 66 namespace webrtc { |
61 | 67 |
62 // Error messages | 68 // Error messages |
63 const char kBundleWithoutRtcpMux[] = "RTCP-MUX must be enabled when BUNDLE " | 69 const char kBundleWithoutRtcpMux[] = "RTCP-MUX must be enabled when BUNDLE " |
64 "is enabled."; | 70 "is enabled."; |
65 const char kCreateChannelFailed[] = "Failed to create channels."; | 71 const char kCreateChannelFailed[] = "Failed to create channels."; |
66 const char kInvalidCandidates[] = "Description contains invalid candidates."; | 72 const char kInvalidCandidates[] = "Description contains invalid candidates."; |
67 const char kInvalidSdp[] = "Invalid session description."; | 73 const char kInvalidSdp[] = "Invalid session description."; |
68 const char kMlineMismatch[] = | 74 const char kMlineMismatch[] = |
69 "Offer and answer descriptions m-lines are not matching. Rejecting answer."; | 75 "Offer and answer descriptions m-lines are not matching. Rejecting answer."; |
70 const char kPushDownTDFailed[] = | 76 const char kPushDownTDFailed[] = |
71 "Failed to push down transport description:"; | 77 "Failed to push down transport description:"; |
72 const char kSdpWithoutDtlsFingerprint[] = | 78 const char kSdpWithoutDtlsFingerprint[] = |
73 "Called with SDP without DTLS fingerprint."; | 79 "Called with SDP without DTLS fingerprint."; |
74 const char kSdpWithoutSdesCrypto[] = | 80 const char kSdpWithoutSdesCrypto[] = |
75 "Called with SDP without SDES crypto."; | 81 "Called with SDP without SDES crypto."; |
76 const char kSdpWithoutIceUfragPwd[] = | 82 const char kSdpWithoutIceUfragPwd[] = |
77 "Called with SDP without ice-ufrag and ice-pwd."; | 83 "Called with SDP without ice-ufrag and ice-pwd."; |
78 const char kSessionError[] = "Session error code: "; | 84 const char kSessionError[] = "Session error code: "; |
79 const char kSessionErrorDesc[] = "Session error description: "; | 85 const char kSessionErrorDesc[] = "Session error description: "; |
80 const char kDtlsSetupFailureRtp[] = | 86 const char kDtlsSetupFailureRtp[] = |
81 "Couldn't set up DTLS-SRTP on RTP channel."; | 87 "Couldn't set up DTLS-SRTP on RTP channel."; |
82 const char kDtlsSetupFailureRtcp[] = | 88 const char kDtlsSetupFailureRtcp[] = |
83 "Couldn't set up DTLS-SRTP on RTCP channel."; | 89 "Couldn't set up DTLS-SRTP on RTCP channel."; |
84 const int kMaxUnsignalledRecvStreams = 20; | 90 const int kMaxUnsignalledRecvStreams = 20; |
85 | 91 |
92 #define CANDIDATE_PAIR_TYPE_ENTRY(local_type, remote_type, endpoint_type) \ | |
93 if (local.type() == local_type##_PORT_TYPE && \ | |
94 remote.type() == remote_type##_PORT_TYPE) { \ | |
95 return endpoint_type; \ | |
96 } | |
97 | |
98 IceCandidatePairType GetIceCandidatePairCounter( | |
99 const cricket::Candidate& local, | |
100 const cricket::Candidate& remote) { | |
101 CANDIDATE_PAIR_TYPE_ENTRY(LOCAL, LOCAL, kIceCandidatePair_Host_Host); | |
pthatcher1
2015/08/18 18:06:22
I think removing the macro and just doing this mig
| |
102 CANDIDATE_PAIR_TYPE_ENTRY(LOCAL, STUN, kIceCandidatePair_Host_Srflx); | |
103 CANDIDATE_PAIR_TYPE_ENTRY(LOCAL, RELAY, kIceCandidatePair_Host_Relay); | |
104 CANDIDATE_PAIR_TYPE_ENTRY(LOCAL, PRFLX, kIceCandidatePair_Host_Prflx); | |
105 CANDIDATE_PAIR_TYPE_ENTRY(STUN, LOCAL, kIceCandidatePair_Srflx_Host); | |
106 CANDIDATE_PAIR_TYPE_ENTRY(STUN, STUN, kIceCandidatePair_Srflx_Srflx); | |
107 CANDIDATE_PAIR_TYPE_ENTRY(STUN, RELAY, kIceCandidatePair_Srflx_Relay); | |
108 CANDIDATE_PAIR_TYPE_ENTRY(STUN, PRFLX, kIceCandidatePair_Srflx_Prflx); | |
109 CANDIDATE_PAIR_TYPE_ENTRY(RELAY, LOCAL, kIceCandidatePair_Relay_Host); | |
110 CANDIDATE_PAIR_TYPE_ENTRY(RELAY, STUN, kIceCandidatePair_Relay_Srflx); | |
111 CANDIDATE_PAIR_TYPE_ENTRY(RELAY, RELAY, kIceCandidatePair_Relay_Relay); | |
112 CANDIDATE_PAIR_TYPE_ENTRY(RELAY, PRFLX, kIceCandidatePair_Relay_Prflx); | |
113 CANDIDATE_PAIR_TYPE_ENTRY(PRFLX, LOCAL, kIceCandidatePair_Prflx_Host); | |
114 CANDIDATE_PAIR_TYPE_ENTRY(PRFLX, STUN, kIceCandidatePair_Prflx_Srflx); | |
115 CANDIDATE_PAIR_TYPE_ENTRY(PRFLX, RELAY, kIceCandidatePair_Prflx_Relay); | |
116 return kIceCandidatePair_Max; | |
117 } | |
118 | |
86 // Compares |answer| against |offer|. Comparision is done | 119 // Compares |answer| against |offer|. Comparision is done |
87 // for number of m-lines in answer against offer. If matches true will be | 120 // for number of m-lines in answer against offer. If matches true will be |
88 // returned otherwise false. | 121 // returned otherwise false. |
89 static bool VerifyMediaDescriptions( | 122 static bool VerifyMediaDescriptions( |
90 const SessionDescription* answer, const SessionDescription* offer) { | 123 const SessionDescription* answer, const SessionDescription* offer) { |
91 if (offer->contents().size() != answer->contents().size()) | 124 if (offer->contents().size() != answer->contents().size()) |
92 return false; | 125 return false; |
93 | 126 |
94 for (size_t i = 0; i < offer->contents().size(); ++i) { | 127 for (size_t i = 0; i < offer->contents().size(); ++i) { |
95 if ((offer->contents()[i].name) != answer->contents()[i].name) { | 128 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); | 1942 DCHECK(metrics_observer_ != NULL); |
1910 for (cricket::TransportChannelStatsList::const_iterator it = | 1943 for (cricket::TransportChannelStatsList::const_iterator it = |
1911 stats.channel_stats.begin(); | 1944 stats.channel_stats.begin(); |
1912 it != stats.channel_stats.end(); ++it) { | 1945 it != stats.channel_stats.end(); ++it) { |
1913 for (cricket::ConnectionInfos::const_iterator it_info = | 1946 for (cricket::ConnectionInfos::const_iterator it_info = |
1914 it->connection_infos.begin(); | 1947 it->connection_infos.begin(); |
1915 it_info != it->connection_infos.end(); ++it_info) { | 1948 it_info != it->connection_infos.end(); ++it_info) { |
1916 if (!it_info->best_connection) { | 1949 if (!it_info->best_connection) { |
1917 continue; | 1950 continue; |
1918 } | 1951 } |
1952 | |
1953 PeerConnectionEnumCounterType type = kPeerConnectionEnumCounter_Max; | |
1954 int counter = -1; | |
1955 | |
1956 // Increment the counter for IceCandidatePairType. | |
pthatcher1
2015/08/18 18:06:23
Having an
const Candidate& local = it_info->local
guoweis_webrtc
2015/08/18 22:33:57
Done.
| |
1957 if (it_info->local_candidate.protocol() == cricket::TCP_PROTOCOL_NAME || | |
pthatcher1
2015/08/18 18:06:22
Might as well add a "using TCP = cricket::TCP_PROT
| |
1958 (it_info->local_candidate.type() == RELAY_PORT_TYPE && | |
1959 it_info->local_candidate.relay_protocol() == | |
1960 cricket::TCP_PROTOCOL_NAME)) { | |
1961 type = kPeerConnectionEnumCounter_IceCandidatePairTypeTcp; | |
1962 } else if (it_info->local_candidate.protocol() == | |
1963 cricket::UDP_PROTOCOL_NAME) { | |
pthatcher1
2015/08/18 18:06:23
And "using UDP = circket::UDP_PROTOCOL_NAME"
| |
1964 type = kPeerConnectionEnumCounter_IceCandidatePairTypeUdp; | |
1965 } else { | |
1966 DCHECK(0); | |
pthatcher1
2015/08/18 18:06:22
Should we record a kPeerConnectionEnumCounter_Unkn
guoweis_webrtc
2015/08/18 22:33:57
This is too specific and I don't think UMA is desi
pthatcher1
2015/08/19 02:47:52
Sorry, I meant kPeerConnectionEnumCounter_IceCandi
guoweis_webrtc
2015/08/19 18:25:52
What's the goal here? To catch a bug? I don't thin
pthatcher2
2015/08/19 18:39:41
The goal was to measure how often we screwed up th
| |
1967 } | |
1968 metrics_observer_->IncrementEnumCounter( | |
1969 type, GetIceCandidatePairCounter(it_info->local_candidate, | |
1970 it_info->remote_candidate), | |
1971 kIceCandidatePair_Max); | |
1972 | |
1973 // Increment the counter for IP type. | |
1919 if (it_info->local_candidate.address().family() == AF_INET) { | 1974 if (it_info->local_candidate.address().family() == AF_INET) { |
1975 counter = kBestConnections_IPv4; | |
1976 // TODO(guoweis): Remove this once IncrementEnumCounter implemented for | |
1977 // PeerConnectionMetrics. | |
1920 metrics_observer_->IncrementCounter(kBestConnections_IPv4); | 1978 metrics_observer_->IncrementCounter(kBestConnections_IPv4); |
1921 } else if (it_info->local_candidate.address().family() == | 1979 } else if (it_info->local_candidate.address().family() == |
1922 AF_INET6) { | 1980 AF_INET6) { |
1981 counter = kBestConnections_IPv6; | |
1982 // TODO(guoweis): Remove this. | |
1923 metrics_observer_->IncrementCounter(kBestConnections_IPv6); | 1983 metrics_observer_->IncrementCounter(kBestConnections_IPv6); |
1924 } else { | 1984 } else { |
1925 RTC_NOTREACHED(); | 1985 RTC_NOTREACHED(); |
1926 } | 1986 } |
1987 metrics_observer_->IncrementEnumCounter( | |
1988 kPeerConnectionEnumCounter_AddressFamily, counter, | |
1989 kPeerConnectionAddressFamilyCounter_Max); | |
pthatcher1
2015/08/18 18:06:23
Instead of setting counter in two places and then
guoweis_webrtc
2015/08/18 22:33:57
Done.
| |
1990 | |
1927 return; | 1991 return; |
1928 } | 1992 } |
1929 } | 1993 } |
1930 } | 1994 } |
1931 | 1995 |
1932 void WebRtcSession::ReportNegotiatedCiphers( | 1996 void WebRtcSession::ReportNegotiatedCiphers( |
1933 const cricket::TransportStats& stats) { | 1997 const cricket::TransportStats& stats) { |
1934 DCHECK(metrics_observer_ != NULL); | 1998 DCHECK(metrics_observer_ != NULL); |
1935 if (!dtls_enabled_ || stats.channel_stats.empty()) { | 1999 if (!dtls_enabled_ || stats.channel_stats.empty()) { |
1936 return; | 2000 return; |
(...skipping 23 matching lines...) Expand all Loading... | |
1960 | 2024 |
1961 if (!srtp_cipher.empty()) { | 2025 if (!srtp_cipher.empty()) { |
1962 metrics_observer_->AddHistogramSample(srtp_name, srtp_cipher); | 2026 metrics_observer_->AddHistogramSample(srtp_name, srtp_cipher); |
1963 } | 2027 } |
1964 if (!ssl_cipher.empty()) { | 2028 if (!ssl_cipher.empty()) { |
1965 metrics_observer_->AddHistogramSample(ssl_name, ssl_cipher); | 2029 metrics_observer_->AddHistogramSample(ssl_name, ssl_cipher); |
1966 } | 2030 } |
1967 } | 2031 } |
1968 | 2032 |
1969 } // namespace webrtc | 2033 } // namespace webrtc |
OLD | NEW |