OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/renderer/media/rtc_peer_connection_handler.h" | 5 #include "content/renderer/media/rtc_peer_connection_handler.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <utility> | 8 #include <utility> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
383 | 383 |
384 } // namespace | 384 } // namespace |
385 | 385 |
386 RTCPeerConnectionHandler::RTCPeerConnectionHandler( | 386 RTCPeerConnectionHandler::RTCPeerConnectionHandler( |
387 blink::WebRTCPeerConnectionHandlerClient* client, | 387 blink::WebRTCPeerConnectionHandlerClient* client, |
388 PeerConnectionDependencyFactory* dependency_factory) | 388 PeerConnectionDependencyFactory* dependency_factory) |
389 : client_(client), | 389 : client_(client), |
390 dependency_factory_(dependency_factory), | 390 dependency_factory_(dependency_factory), |
391 frame_(NULL), | 391 frame_(NULL), |
392 peer_connection_tracker_(NULL), | 392 peer_connection_tracker_(NULL), |
393 num_data_channels_created_(0) { | 393 num_data_channels_created_(0), |
| 394 num_local_candidates_ipv4_(0), |
| 395 num_local_candidates_ipv6_(0) { |
394 g_peer_connection_handlers.Get().insert(this); | 396 g_peer_connection_handlers.Get().insert(this); |
395 } | 397 } |
396 | 398 |
397 RTCPeerConnectionHandler::~RTCPeerConnectionHandler() { | 399 RTCPeerConnectionHandler::~RTCPeerConnectionHandler() { |
398 g_peer_connection_handlers.Get().erase(this); | 400 g_peer_connection_handlers.Get().erase(this); |
399 if (peer_connection_tracker_) | 401 if (peer_connection_tracker_) |
400 peer_connection_tracker_->UnregisterPeerConnection(this); | 402 peer_connection_tracker_->UnregisterPeerConnection(this); |
401 STLDeleteValues(&remote_streams_); | 403 STLDeleteValues(&remote_streams_); |
402 | 404 |
403 UMA_HISTOGRAM_COUNTS_10000( | 405 UMA_HISTOGRAM_COUNTS_10000( |
(...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
887 } | 889 } |
888 | 890 |
889 // Called any time the IceGatheringState changes | 891 // Called any time the IceGatheringState changes |
890 void RTCPeerConnectionHandler::OnIceGatheringChange( | 892 void RTCPeerConnectionHandler::OnIceGatheringChange( |
891 webrtc::PeerConnectionInterface::IceGatheringState new_state) { | 893 webrtc::PeerConnectionInterface::IceGatheringState new_state) { |
892 if (new_state == webrtc::PeerConnectionInterface::kIceGatheringComplete) { | 894 if (new_state == webrtc::PeerConnectionInterface::kIceGatheringComplete) { |
893 // If ICE gathering is completed, generate a NULL ICE candidate, | 895 // If ICE gathering is completed, generate a NULL ICE candidate, |
894 // to signal end of candidates. | 896 // to signal end of candidates. |
895 blink::WebRTCICECandidate null_candidate; | 897 blink::WebRTCICECandidate null_candidate; |
896 client_->didGenerateICECandidate(null_candidate); | 898 client_->didGenerateICECandidate(null_candidate); |
| 899 |
| 900 UMA_HISTOGRAM_COUNTS_100("WebRTC.PeerConnection.IPv4LocalCandidates", |
| 901 num_local_candidates_ipv4_); |
| 902 |
| 903 UMA_HISTOGRAM_COUNTS_100("WebRTC.PeerConnection.IPv6LocalCandidates", |
| 904 num_local_candidates_ipv6_); |
| 905 } else if (new_state == |
| 906 webrtc::PeerConnectionInterface::kIceGatheringGathering) { |
| 907 // ICE restarts will change gathering state back to "gathering", |
| 908 // reset the counter. |
| 909 num_local_candidates_ipv6_ = 0; |
| 910 num_local_candidates_ipv4_ = 0; |
897 } | 911 } |
898 | 912 |
899 blink::WebRTCPeerConnectionHandlerClient::ICEGatheringState state = | 913 blink::WebRTCPeerConnectionHandlerClient::ICEGatheringState state = |
900 GetWebKitIceGatheringState(new_state); | 914 GetWebKitIceGatheringState(new_state); |
901 if (peer_connection_tracker_) | 915 if (peer_connection_tracker_) |
902 peer_connection_tracker_->TrackIceGatheringStateChange(this, state); | 916 peer_connection_tracker_->TrackIceGatheringStateChange(this, state); |
903 client_->didChangeICEGatheringState(state); | 917 client_->didChangeICEGatheringState(state); |
904 } | 918 } |
905 | 919 |
906 void RTCPeerConnectionHandler::OnAddStream( | 920 void RTCPeerConnectionHandler::OnAddStream( |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
961 return; | 975 return; |
962 } | 976 } |
963 blink::WebRTCICECandidate web_candidate; | 977 blink::WebRTCICECandidate web_candidate; |
964 web_candidate.initialize(base::UTF8ToUTF16(sdp), | 978 web_candidate.initialize(base::UTF8ToUTF16(sdp), |
965 base::UTF8ToUTF16(candidate->sdp_mid()), | 979 base::UTF8ToUTF16(candidate->sdp_mid()), |
966 candidate->sdp_mline_index()); | 980 candidate->sdp_mline_index()); |
967 if (peer_connection_tracker_) | 981 if (peer_connection_tracker_) |
968 peer_connection_tracker_->TrackAddIceCandidate( | 982 peer_connection_tracker_->TrackAddIceCandidate( |
969 this, web_candidate, PeerConnectionTracker::SOURCE_LOCAL, true); | 983 this, web_candidate, PeerConnectionTracker::SOURCE_LOCAL, true); |
970 | 984 |
| 985 // Only the first m line's first component is tracked to avoid |
| 986 // miscounting when doing BUNDLE or rtcp mux. |
| 987 if (candidate->sdp_mline_index() == 0 && |
| 988 candidate->candidate().component() == 1) { |
| 989 if (candidate->candidate().address().family() == AF_INET) { |
| 990 num_local_candidates_ipv4_++; |
| 991 } else if (candidate->candidate().address().family() == AF_INET6) { |
| 992 num_local_candidates_ipv6_++; |
| 993 } else { |
| 994 NOTREACHED(); |
| 995 } |
| 996 } |
971 client_->didGenerateICECandidate(web_candidate); | 997 client_->didGenerateICECandidate(web_candidate); |
972 } | 998 } |
973 | 999 |
974 void RTCPeerConnectionHandler::OnDataChannel( | 1000 void RTCPeerConnectionHandler::OnDataChannel( |
975 webrtc::DataChannelInterface* data_channel) { | 1001 webrtc::DataChannelInterface* data_channel) { |
976 if (peer_connection_tracker_) | 1002 if (peer_connection_tracker_) |
977 peer_connection_tracker_->TrackCreateDataChannel( | 1003 peer_connection_tracker_->TrackCreateDataChannel( |
978 this, data_channel, PeerConnectionTracker::SOURCE_REMOTE); | 1004 this, data_channel, PeerConnectionTracker::SOURCE_REMOTE); |
979 | 1005 |
980 DVLOG(1) << "RTCPeerConnectionHandler::OnDataChannel " | 1006 DVLOG(1) << "RTCPeerConnectionHandler::OnDataChannel " |
(...skipping 20 matching lines...) Expand all Loading... |
1001 webrtc::SessionDescriptionInterface* native_desc = | 1027 webrtc::SessionDescriptionInterface* native_desc = |
1002 dependency_factory_->CreateSessionDescription(type, sdp, error); | 1028 dependency_factory_->CreateSessionDescription(type, sdp, error); |
1003 | 1029 |
1004 LOG_IF(ERROR, !native_desc) << "Failed to create native session description." | 1030 LOG_IF(ERROR, !native_desc) << "Failed to create native session description." |
1005 << " Type: " << type << " SDP: " << sdp; | 1031 << " Type: " << type << " SDP: " << sdp; |
1006 | 1032 |
1007 return native_desc; | 1033 return native_desc; |
1008 } | 1034 } |
1009 | 1035 |
1010 } // namespace content | 1036 } // namespace content |
OLD | NEW |