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 #define CANDIDATE_PAIR_TYPE_ENTRY(local_type, remote_type, endpoint_type) \ | |
92 if (local.type() == local_type##_PORT_TYPE && \ | |
93 remote.type() == remote_type##_PORT_TYPE) { \ | |
94 return endpoint_type; \ | |
95 } | |
96 | |
97 IceCandidatePairType GetIceCandidatePairCounter( | |
98 const cricket::Candidate& local, | |
99 const cricket::Candidate& remote) { | |
100 CANDIDATE_PAIR_TYPE_ENTRY(LOCAL, LOCAL, kIceCandidatePairHostHost); | |
pthatcher1
2015/08/19 02:47:53
I still think this would be better than the macro:
guoweis_webrtc
2015/08/19 18:25:52
Done.
| |
101 CANDIDATE_PAIR_TYPE_ENTRY(LOCAL, STUN, kIceCandidatePairHostSrflx); | |
102 CANDIDATE_PAIR_TYPE_ENTRY(LOCAL, RELAY, kIceCandidatePairHostRelay); | |
103 CANDIDATE_PAIR_TYPE_ENTRY(LOCAL, PRFLX, kIceCandidatePairHostPrflx); | |
104 CANDIDATE_PAIR_TYPE_ENTRY(STUN, LOCAL, kIceCandidatePairSrflxHost); | |
105 CANDIDATE_PAIR_TYPE_ENTRY(STUN, STUN, kIceCandidatePairSrflxSrflx); | |
106 CANDIDATE_PAIR_TYPE_ENTRY(STUN, RELAY, kIceCandidatePairSrflxRelay); | |
107 CANDIDATE_PAIR_TYPE_ENTRY(STUN, PRFLX, kIceCandidatePairSrflxPrflx); | |
108 CANDIDATE_PAIR_TYPE_ENTRY(RELAY, LOCAL, kIceCandidatePairRelayHost); | |
109 CANDIDATE_PAIR_TYPE_ENTRY(RELAY, STUN, kIceCandidatePairRelaySrflx); | |
110 CANDIDATE_PAIR_TYPE_ENTRY(RELAY, RELAY, kIceCandidatePairRelayRelay); | |
111 CANDIDATE_PAIR_TYPE_ENTRY(RELAY, PRFLX, kIceCandidatePairRelayPrflx); | |
112 CANDIDATE_PAIR_TYPE_ENTRY(PRFLX, LOCAL, kIceCandidatePairPrflxHost); | |
113 CANDIDATE_PAIR_TYPE_ENTRY(PRFLX, STUN, kIceCandidatePairPrflxSrflx); | |
114 CANDIDATE_PAIR_TYPE_ENTRY(PRFLX, RELAY, kIceCandidatePairPrflxRelay); | |
115 return kIceCandidatePairMax; | |
116 } | |
117 | |
86 // Compares |answer| against |offer|. Comparision is done | 118 // Compares |answer| against |offer|. Comparision is done |
87 // for number of m-lines in answer against offer. If matches true will be | 119 // for number of m-lines in answer against offer. If matches true will be |
88 // returned otherwise false. | 120 // returned otherwise false. |
89 static bool VerifyMediaDescriptions( | 121 static bool VerifyMediaDescriptions( |
90 const SessionDescription* answer, const SessionDescription* offer) { | 122 const SessionDescription* answer, const SessionDescription* offer) { |
91 if (offer->contents().size() != answer->contents().size()) | 123 if (offer->contents().size() != answer->contents().size()) |
92 return false; | 124 return false; |
93 | 125 |
94 for (size_t i = 0; i < offer->contents().size(); ++i) { | 126 for (size_t i = 0; i < offer->contents().size(); ++i) { |
95 if ((offer->contents()[i].name) != answer->contents()[i].name) { | 127 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); | 1941 DCHECK(metrics_observer_ != NULL); |
1910 for (cricket::TransportChannelStatsList::const_iterator it = | 1942 for (cricket::TransportChannelStatsList::const_iterator it = |
1911 stats.channel_stats.begin(); | 1943 stats.channel_stats.begin(); |
1912 it != stats.channel_stats.end(); ++it) { | 1944 it != stats.channel_stats.end(); ++it) { |
1913 for (cricket::ConnectionInfos::const_iterator it_info = | 1945 for (cricket::ConnectionInfos::const_iterator it_info = |
1914 it->connection_infos.begin(); | 1946 it->connection_infos.begin(); |
1915 it_info != it->connection_infos.end(); ++it_info) { | 1947 it_info != it->connection_infos.end(); ++it_info) { |
1916 if (!it_info->best_connection) { | 1948 if (!it_info->best_connection) { |
1917 continue; | 1949 continue; |
1918 } | 1950 } |
1919 if (it_info->local_candidate.address().family() == AF_INET) { | 1951 |
1952 PeerConnectionEnumCounterType type = kPeerConnectionEnumCounter_Max; | |
1953 const cricket::Candidate& local = it_info->local_candidate; | |
1954 const cricket::Candidate& remote = it_info->remote_candidate; | |
1955 | |
1956 // Increment the counter for IceCandidatePairType. | |
1957 if (local.protocol() == cricket::TCP_PROTOCOL_NAME || | |
1958 (local.type() == RELAY_PORT_TYPE && | |
1959 local.relay_protocol() == cricket::TCP_PROTOCOL_NAME)) { | |
1960 type = kEnumCounterIceCandidatePairTypeTcp; | |
1961 } else if (local.protocol() == cricket::UDP_PROTOCOL_NAME) { | |
1962 type = kEnumCounterIceCandidatePairTypeUdp; | |
1963 } else { | |
1964 DCHECK(0); | |
1965 } | |
1966 metrics_observer_->IncrementEnumCounter( | |
1967 type, GetIceCandidatePairCounter(local, remote), | |
1968 kIceCandidatePairMax); | |
1969 | |
1970 // Increment the counter for IP type. | |
1971 if (local.address().family() == AF_INET) { | |
1972 // TODO(guoweis): Remove this next line once IncrementEnumCounter | |
1973 // implemented for PeerConnectionMetrics. | |
1920 metrics_observer_->IncrementCounter(kBestConnections_IPv4); | 1974 metrics_observer_->IncrementCounter(kBestConnections_IPv4); |
1921 } else if (it_info->local_candidate.address().family() == | 1975 |
1922 AF_INET6) { | 1976 metrics_observer_->IncrementEnumCounter( |
1977 kEnumCounterAddressFamily, kBestConnections_IPv4, | |
1978 kPeerConnectionAddressFamilyCounter_Max); | |
1979 | |
1980 } else if (local.address().family() == AF_INET6) { | |
1981 // TODO(guoweis): Remove this next line. | |
1923 metrics_observer_->IncrementCounter(kBestConnections_IPv6); | 1982 metrics_observer_->IncrementCounter(kBestConnections_IPv6); |
1983 | |
1984 metrics_observer_->IncrementEnumCounter( | |
1985 kEnumCounterAddressFamily, kBestConnections_IPv6, | |
1986 kPeerConnectionAddressFamilyCounter_Max); | |
1924 } else { | 1987 } else { |
1925 RTC_NOTREACHED(); | 1988 RTC_NOTREACHED(); |
1926 } | 1989 } |
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 |