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 623 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
634 return true; | 634 return true; |
635 } | 635 } |
636 | 636 |
637 bool RTCPeerConnectionHandler::addICECandidate( | 637 bool RTCPeerConnectionHandler::addICECandidate( |
638 const blink::WebRTCICECandidate& candidate) { | 638 const blink::WebRTCICECandidate& candidate) { |
639 scoped_ptr<webrtc::IceCandidateInterface> native_candidate( | 639 scoped_ptr<webrtc::IceCandidateInterface> native_candidate( |
640 dependency_factory_->CreateIceCandidate( | 640 dependency_factory_->CreateIceCandidate( |
641 base::UTF16ToUTF8(candidate.sdpMid()), | 641 base::UTF16ToUTF8(candidate.sdpMid()), |
642 candidate.sdpMLineIndex(), | 642 candidate.sdpMLineIndex(), |
643 base::UTF16ToUTF8(candidate.candidate()))); | 643 base::UTF16ToUTF8(candidate.candidate()))); |
644 if (!native_candidate) { | 644 bool return_value = false; |
| 645 |
| 646 if (native_candidate) { |
| 647 return_value = |
| 648 native_peer_connection_->AddIceCandidate(native_candidate.get()); |
| 649 LOG_IF(ERROR, !return_value) << "Error processing ICE candidate."; |
| 650 } else { |
645 LOG(ERROR) << "Could not create native ICE candidate."; | 651 LOG(ERROR) << "Could not create native ICE candidate."; |
646 return false; | |
647 } | 652 } |
648 | 653 |
649 bool return_value = | 654 if (peer_connection_tracker_) { |
650 native_peer_connection_->AddIceCandidate(native_candidate.get()); | |
651 LOG_IF(ERROR, !return_value) << "Error processing ICE candidate."; | |
652 | |
653 if (peer_connection_tracker_) | |
654 peer_connection_tracker_->TrackAddIceCandidate( | 655 peer_connection_tracker_->TrackAddIceCandidate( |
655 this, candidate, PeerConnectionTracker::SOURCE_REMOTE); | 656 this, candidate, PeerConnectionTracker::SOURCE_REMOTE, return_value); |
656 | 657 } |
657 return return_value; | 658 return return_value; |
658 } | 659 } |
659 | 660 |
660 void RTCPeerConnectionHandler::OnaddICECandidateResult( | 661 void RTCPeerConnectionHandler::OnaddICECandidateResult( |
661 const blink::WebRTCVoidRequest& webkit_request, bool result) { | 662 const blink::WebRTCVoidRequest& webkit_request, bool result) { |
662 if (!result) { | 663 if (!result) { |
663 // We don't have the actual error code from the libjingle, so for now | 664 // We don't have the actual error code from the libjingle, so for now |
664 // using a generic error string. | 665 // using a generic error string. |
665 return webkit_request.requestFailed( | 666 return webkit_request.requestFailed( |
666 base::UTF8ToUTF16("Error processing ICE candidate")); | 667 base::UTF8ToUTF16("Error processing ICE candidate")); |
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
954 if (!candidate->ToString(&sdp)) { | 955 if (!candidate->ToString(&sdp)) { |
955 NOTREACHED() << "OnIceCandidate: Could not get SDP string."; | 956 NOTREACHED() << "OnIceCandidate: Could not get SDP string."; |
956 return; | 957 return; |
957 } | 958 } |
958 blink::WebRTCICECandidate web_candidate; | 959 blink::WebRTCICECandidate web_candidate; |
959 web_candidate.initialize(base::UTF8ToUTF16(sdp), | 960 web_candidate.initialize(base::UTF8ToUTF16(sdp), |
960 base::UTF8ToUTF16(candidate->sdp_mid()), | 961 base::UTF8ToUTF16(candidate->sdp_mid()), |
961 candidate->sdp_mline_index()); | 962 candidate->sdp_mline_index()); |
962 if (peer_connection_tracker_) | 963 if (peer_connection_tracker_) |
963 peer_connection_tracker_->TrackAddIceCandidate( | 964 peer_connection_tracker_->TrackAddIceCandidate( |
964 this, web_candidate, PeerConnectionTracker::SOURCE_LOCAL); | 965 this, web_candidate, PeerConnectionTracker::SOURCE_LOCAL, true); |
965 | 966 |
966 client_->didGenerateICECandidate(web_candidate); | 967 client_->didGenerateICECandidate(web_candidate); |
967 } | 968 } |
968 | 969 |
969 void RTCPeerConnectionHandler::OnDataChannel( | 970 void RTCPeerConnectionHandler::OnDataChannel( |
970 webrtc::DataChannelInterface* data_channel) { | 971 webrtc::DataChannelInterface* data_channel) { |
971 if (peer_connection_tracker_) | 972 if (peer_connection_tracker_) |
972 peer_connection_tracker_->TrackCreateDataChannel( | 973 peer_connection_tracker_->TrackCreateDataChannel( |
973 this, data_channel, PeerConnectionTracker::SOURCE_REMOTE); | 974 this, data_channel, PeerConnectionTracker::SOURCE_REMOTE); |
974 | 975 |
(...skipping 21 matching lines...) Expand all Loading... |
996 webrtc::SessionDescriptionInterface* native_desc = | 997 webrtc::SessionDescriptionInterface* native_desc = |
997 dependency_factory_->CreateSessionDescription(type, sdp, error); | 998 dependency_factory_->CreateSessionDescription(type, sdp, error); |
998 | 999 |
999 LOG_IF(ERROR, !native_desc) << "Failed to create native session description." | 1000 LOG_IF(ERROR, !native_desc) << "Failed to create native session description." |
1000 << " Type: " << type << " SDP: " << sdp; | 1001 << " Type: " << type << " SDP: " << sdp; |
1001 | 1002 |
1002 return native_desc; | 1003 return native_desc; |
1003 } | 1004 } |
1004 | 1005 |
1005 } // namespace content | 1006 } // namespace content |
OLD | NEW |