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", | |
juberti2
2014/09/25 20:10:43
Remind me, is the goal to count all candidates? Or
| |
901 num_local_candidates_ipv4_); | |
902 | |
903 UMA_HISTOGRAM_COUNTS_100("WebRTC.PeerConnection.IPv6LocalCandidates", | |
904 num_local_candidates_ipv6_); | |
897 } | 905 } |
898 | 906 |
899 blink::WebRTCPeerConnectionHandlerClient::ICEGatheringState state = | 907 blink::WebRTCPeerConnectionHandlerClient::ICEGatheringState state = |
900 GetWebKitIceGatheringState(new_state); | 908 GetWebKitIceGatheringState(new_state); |
901 if (peer_connection_tracker_) | 909 if (peer_connection_tracker_) |
902 peer_connection_tracker_->TrackIceGatheringStateChange(this, state); | 910 peer_connection_tracker_->TrackIceGatheringStateChange(this, state); |
903 client_->didChangeICEGatheringState(state); | 911 client_->didChangeICEGatheringState(state); |
904 } | 912 } |
905 | 913 |
906 void RTCPeerConnectionHandler::OnAddStream( | 914 void RTCPeerConnectionHandler::OnAddStream( |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
961 return; | 969 return; |
962 } | 970 } |
963 blink::WebRTCICECandidate web_candidate; | 971 blink::WebRTCICECandidate web_candidate; |
964 web_candidate.initialize(base::UTF8ToUTF16(sdp), | 972 web_candidate.initialize(base::UTF8ToUTF16(sdp), |
965 base::UTF8ToUTF16(candidate->sdp_mid()), | 973 base::UTF8ToUTF16(candidate->sdp_mid()), |
966 candidate->sdp_mline_index()); | 974 candidate->sdp_mline_index()); |
967 if (peer_connection_tracker_) | 975 if (peer_connection_tracker_) |
968 peer_connection_tracker_->TrackAddIceCandidate( | 976 peer_connection_tracker_->TrackAddIceCandidate( |
969 this, web_candidate, PeerConnectionTracker::SOURCE_LOCAL, true); | 977 this, web_candidate, PeerConnectionTracker::SOURCE_LOCAL, true); |
970 | 978 |
979 if (candidate->candidate().address().family() == AF_INET) { | |
980 num_local_candidates_ipv4_++; | |
juberti2
2014/09/25 20:05:56
Need to reset this when gathering restarts
| |
981 } else if (candidate->candidate().address().family() == AF_INET6) { | |
982 num_local_candidates_ipv6_++; | |
983 } else { | |
984 NOTREACHED(); | |
985 } | |
986 | |
971 client_->didGenerateICECandidate(web_candidate); | 987 client_->didGenerateICECandidate(web_candidate); |
972 } | 988 } |
973 | 989 |
974 void RTCPeerConnectionHandler::OnDataChannel( | 990 void RTCPeerConnectionHandler::OnDataChannel( |
975 webrtc::DataChannelInterface* data_channel) { | 991 webrtc::DataChannelInterface* data_channel) { |
976 if (peer_connection_tracker_) | 992 if (peer_connection_tracker_) |
977 peer_connection_tracker_->TrackCreateDataChannel( | 993 peer_connection_tracker_->TrackCreateDataChannel( |
978 this, data_channel, PeerConnectionTracker::SOURCE_REMOTE); | 994 this, data_channel, PeerConnectionTracker::SOURCE_REMOTE); |
979 | 995 |
980 DVLOG(1) << "RTCPeerConnectionHandler::OnDataChannel " | 996 DVLOG(1) << "RTCPeerConnectionHandler::OnDataChannel " |
(...skipping 20 matching lines...) Expand all Loading... | |
1001 webrtc::SessionDescriptionInterface* native_desc = | 1017 webrtc::SessionDescriptionInterface* native_desc = |
1002 dependency_factory_->CreateSessionDescription(type, sdp, error); | 1018 dependency_factory_->CreateSessionDescription(type, sdp, error); |
1003 | 1019 |
1004 LOG_IF(ERROR, !native_desc) << "Failed to create native session description." | 1020 LOG_IF(ERROR, !native_desc) << "Failed to create native session description." |
1005 << " Type: " << type << " SDP: " << sdp; | 1021 << " Type: " << type << " SDP: " << sdp; |
1006 | 1022 |
1007 return native_desc; | 1023 return native_desc; |
1008 } | 1024 } |
1009 | 1025 |
1010 } // namespace content | 1026 } // namespace content |
OLD | NEW |