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 26 matching lines...) Expand all Loading... |
37 #include "talk/app/webrtc/mediaconstraintsinterface.h" | 37 #include "talk/app/webrtc/mediaconstraintsinterface.h" |
38 #include "talk/app/webrtc/mediastreamsignaling.h" | 38 #include "talk/app/webrtc/mediastreamsignaling.h" |
39 #include "talk/app/webrtc/peerconnectioninterface.h" | 39 #include "talk/app/webrtc/peerconnectioninterface.h" |
40 #include "talk/app/webrtc/webrtcsessiondescriptionfactory.h" | 40 #include "talk/app/webrtc/webrtcsessiondescriptionfactory.h" |
41 #include "talk/media/base/constants.h" | 41 #include "talk/media/base/constants.h" |
42 #include "talk/media/base/videocapturer.h" | 42 #include "talk/media/base/videocapturer.h" |
43 #include "talk/session/media/channel.h" | 43 #include "talk/session/media/channel.h" |
44 #include "talk/session/media/channelmanager.h" | 44 #include "talk/session/media/channelmanager.h" |
45 #include "talk/session/media/mediasession.h" | 45 #include "talk/session/media/mediasession.h" |
46 #include "webrtc/base/basictypes.h" | 46 #include "webrtc/base/basictypes.h" |
| 47 #include "webrtc/base/checks.h" |
47 #include "webrtc/base/helpers.h" | 48 #include "webrtc/base/helpers.h" |
48 #include "webrtc/base/logging.h" | 49 #include "webrtc/base/logging.h" |
49 #include "webrtc/base/stringencode.h" | 50 #include "webrtc/base/stringencode.h" |
50 #include "webrtc/base/stringutils.h" | 51 #include "webrtc/base/stringutils.h" |
51 #include "webrtc/p2p/base/portallocator.h" | 52 #include "webrtc/p2p/base/portallocator.h" |
52 | 53 |
53 using cricket::ContentInfo; | 54 using cricket::ContentInfo; |
54 using cricket::ContentInfos; | 55 using cricket::ContentInfos; |
55 using cricket::MediaContentDescription; | 56 using cricket::MediaContentDescription; |
56 using cricket::SessionDescription; | 57 using cricket::SessionDescription; |
(...skipping 1328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1385 } | 1386 } |
1386 } | 1387 } |
1387 } | 1388 } |
1388 | 1389 |
1389 void WebRtcSession::OnTransportCompleted(cricket::Transport* transport) { | 1390 void WebRtcSession::OnTransportCompleted(cricket::Transport* transport) { |
1390 ASSERT(signaling_thread()->IsCurrent()); | 1391 ASSERT(signaling_thread()->IsCurrent()); |
1391 PeerConnectionInterface::IceConnectionState old_state = ice_connection_state_; | 1392 PeerConnectionInterface::IceConnectionState old_state = ice_connection_state_; |
1392 SetIceConnectionState(PeerConnectionInterface::kIceConnectionCompleted); | 1393 SetIceConnectionState(PeerConnectionInterface::kIceConnectionCompleted); |
1393 // Only report once when Ice connection is completed. | 1394 // Only report once when Ice connection is completed. |
1394 if (old_state != PeerConnectionInterface::kIceConnectionCompleted) { | 1395 if (old_state != PeerConnectionInterface::kIceConnectionCompleted) { |
1395 ReportBestConnectionState(transport); | 1396 cricket::TransportStats stats; |
| 1397 if (metrics_observer_ && transport->GetStats(&stats)) { |
| 1398 ReportBestConnectionState(stats); |
| 1399 ReportNegotiatedCiphers(stats); |
| 1400 } |
1396 } | 1401 } |
1397 } | 1402 } |
1398 | 1403 |
1399 void WebRtcSession::OnTransportFailed(cricket::Transport* transport) { | 1404 void WebRtcSession::OnTransportFailed(cricket::Transport* transport) { |
1400 ASSERT(signaling_thread()->IsCurrent()); | 1405 ASSERT(signaling_thread()->IsCurrent()); |
1401 SetIceConnectionState(PeerConnectionInterface::kIceConnectionFailed); | 1406 SetIceConnectionState(PeerConnectionInterface::kIceConnectionFailed); |
1402 } | 1407 } |
1403 | 1408 |
1404 void WebRtcSession::OnTransportProxyCandidatesReady( | 1409 void WebRtcSession::OnTransportProxyCandidatesReady( |
1405 cricket::TransportProxy* proxy, const cricket::Candidates& candidates) { | 1410 cricket::TransportProxy* proxy, const cricket::Candidates& candidates) { |
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1865 cricket::ContentInfo content = | 1870 cricket::ContentInfo content = |
1866 current_remote_desc->description()->contents()[mediacontent_index]; | 1871 current_remote_desc->description()->contents()[mediacontent_index]; |
1867 transport_proxy = GetTransportProxy(content.name); | 1872 transport_proxy = GetTransportProxy(content.name); |
1868 | 1873 |
1869 return transport_proxy && transport_proxy->local_description_set() && | 1874 return transport_proxy && transport_proxy->local_description_set() && |
1870 transport_proxy->remote_description_set(); | 1875 transport_proxy->remote_description_set(); |
1871 } | 1876 } |
1872 | 1877 |
1873 // Walk through the ConnectionInfos to gather best connection usage | 1878 // Walk through the ConnectionInfos to gather best connection usage |
1874 // for IPv4 and IPv6. | 1879 // for IPv4 and IPv6. |
1875 void WebRtcSession::ReportBestConnectionState(cricket::Transport* transport) { | 1880 void WebRtcSession::ReportBestConnectionState( |
1876 if (!metrics_observer_) { | 1881 const cricket::TransportStats& stats) { |
1877 return; | 1882 DCHECK(metrics_observer_ != NULL); |
1878 } | |
1879 | |
1880 cricket::TransportStats stats; | |
1881 if (!transport->GetStats(&stats)) { | |
1882 return; | |
1883 } | |
1884 | |
1885 for (cricket::TransportChannelStatsList::const_iterator it = | 1883 for (cricket::TransportChannelStatsList::const_iterator it = |
1886 stats.channel_stats.begin(); | 1884 stats.channel_stats.begin(); |
1887 it != stats.channel_stats.end(); ++it) { | 1885 it != stats.channel_stats.end(); ++it) { |
1888 for (cricket::ConnectionInfos::const_iterator it_info = | 1886 for (cricket::ConnectionInfos::const_iterator it_info = |
1889 it->connection_infos.begin(); | 1887 it->connection_infos.begin(); |
1890 it_info != it->connection_infos.end(); ++it_info) { | 1888 it_info != it->connection_infos.end(); ++it_info) { |
1891 if (!it_info->best_connection) { | 1889 if (!it_info->best_connection) { |
1892 continue; | 1890 continue; |
1893 } | 1891 } |
1894 if (it_info->local_candidate.address().family() == AF_INET) { | 1892 if (it_info->local_candidate.address().family() == AF_INET) { |
1895 metrics_observer_->IncrementCounter(kBestConnections_IPv4); | 1893 metrics_observer_->IncrementCounter(kBestConnections_IPv4); |
1896 } else if (it_info->local_candidate.address().family() == | 1894 } else if (it_info->local_candidate.address().family() == |
1897 AF_INET6) { | 1895 AF_INET6) { |
1898 metrics_observer_->IncrementCounter(kBestConnections_IPv6); | 1896 metrics_observer_->IncrementCounter(kBestConnections_IPv6); |
1899 } else { | 1897 } else { |
1900 ASSERT(false); | 1898 RTC_NOTREACHED(); |
1901 } | 1899 } |
1902 return; | 1900 return; |
1903 } | 1901 } |
1904 } | 1902 } |
1905 } | 1903 } |
1906 | 1904 |
| 1905 void WebRtcSession::ReportNegotiatedCiphers( |
| 1906 const cricket::TransportStats& stats) { |
| 1907 DCHECK(metrics_observer_ != NULL); |
| 1908 if (!dtls_enabled_ || stats.channel_stats.empty()) { |
| 1909 return; |
| 1910 } |
| 1911 |
| 1912 const std::string& srtp_cipher = stats.channel_stats[0].srtp_cipher; |
| 1913 const std::string& ssl_cipher = stats.channel_stats[0].ssl_cipher; |
| 1914 if (srtp_cipher.empty() && ssl_cipher.empty()) { |
| 1915 return; |
| 1916 } |
| 1917 |
| 1918 PeerConnectionMetricsName srtp_name; |
| 1919 PeerConnectionMetricsName ssl_name; |
| 1920 if (stats.content_name == cricket::CN_AUDIO) { |
| 1921 srtp_name = kAudioSrtpCipher; |
| 1922 ssl_name = kAudioSslCipher; |
| 1923 } else if (stats.content_name == cricket::CN_VIDEO) { |
| 1924 srtp_name = kVideoSrtpCipher; |
| 1925 ssl_name = kVideoSslCipher; |
| 1926 } else if (stats.content_name == cricket::CN_DATA) { |
| 1927 srtp_name = kDataSrtpCipher; |
| 1928 ssl_name = kDataSslCipher; |
| 1929 } else { |
| 1930 RTC_NOTREACHED(); |
| 1931 return; |
| 1932 } |
| 1933 |
| 1934 if (!srtp_cipher.empty()) { |
| 1935 metrics_observer_->AddHistogramSample(srtp_name, srtp_cipher); |
| 1936 } |
| 1937 if (!ssl_cipher.empty()) { |
| 1938 metrics_observer_->AddHistogramSample(ssl_name, ssl_cipher); |
| 1939 } |
| 1940 } |
| 1941 |
1907 } // namespace webrtc | 1942 } // namespace webrtc |
OLD | NEW |