| 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 15 matching lines...) Expand all Loading... |
| 26 #include "third_party/WebKit/Source/Platform/chromium/public/WebRTCPeerConnectio
nHandlerClient.h" | 26 #include "third_party/WebKit/Source/Platform/chromium/public/WebRTCPeerConnectio
nHandlerClient.h" |
| 27 #include "third_party/WebKit/Source/Platform/chromium/public/WebRTCSessionDescri
ption.h" | 27 #include "third_party/WebKit/Source/Platform/chromium/public/WebRTCSessionDescri
ption.h" |
| 28 #include "third_party/WebKit/Source/Platform/chromium/public/WebRTCSessionDescri
ptionRequest.h" | 28 #include "third_party/WebKit/Source/Platform/chromium/public/WebRTCSessionDescri
ptionRequest.h" |
| 29 #include "third_party/WebKit/Source/Platform/chromium/public/WebRTCStatsRequest.
h" | 29 #include "third_party/WebKit/Source/Platform/chromium/public/WebRTCStatsRequest.
h" |
| 30 #include "third_party/WebKit/Source/Platform/chromium/public/WebRTCVoidRequest.h
" | 30 #include "third_party/WebKit/Source/Platform/chromium/public/WebRTCVoidRequest.h
" |
| 31 #include "third_party/WebKit/Source/Platform/chromium/public/WebURL.h" | 31 #include "third_party/WebKit/Source/Platform/chromium/public/WebURL.h" |
| 32 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" | 32 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" |
| 33 | 33 |
| 34 namespace content { | 34 namespace content { |
| 35 | 35 |
| 36 // Converter functions from libjingle types to WebKit types. | 36 // Converter functions from libjingle types to WebKit types. |
| 37 | 37 WebKit::WebRTCPeerConnectionHandlerClient::ICEGatheringState |
| 38 static WebKit::WebRTCPeerConnectionHandlerClient::ICEState | 38 GetWebKitIceGatheringState( |
| 39 GetWebKitIceState(webrtc::PeerConnectionInterface::IceState ice_state) { | 39 webrtc::PeerConnectionInterface::IceGatheringState state) { |
| 40 switch (ice_state) { | 40 using WebKit::WebRTCPeerConnectionHandlerClient; |
| 41 case webrtc::PeerConnectionInterface::kIceNew: | 41 switch (state) { |
| 42 return WebKit::WebRTCPeerConnectionHandlerClient::ICEStateNew; | 42 case webrtc::PeerConnectionInterface::kIceGatheringNew: |
| 43 case webrtc::PeerConnectionInterface::kIceGathering: | 43 return WebRTCPeerConnectionHandlerClient::ICEGatheringStateNew; |
| 44 return WebKit::WebRTCPeerConnectionHandlerClient::ICEStateGathering; | 44 case webrtc::PeerConnectionInterface::kIceGatheringGathering: |
| 45 case webrtc::PeerConnectionInterface::kIceWaiting: | 45 return WebRTCPeerConnectionHandlerClient::ICEGatheringStateGathering; |
| 46 return WebKit::WebRTCPeerConnectionHandlerClient::ICEStateWaiting; | 46 case webrtc::PeerConnectionInterface::kIceGatheringComplete: |
| 47 case webrtc::PeerConnectionInterface::kIceChecking: | 47 return WebRTCPeerConnectionHandlerClient::ICEGatheringStateComplete; |
| 48 return WebKit::WebRTCPeerConnectionHandlerClient::ICEStateChecking; | |
| 49 case webrtc::PeerConnectionInterface::kIceConnected: | |
| 50 return WebKit::WebRTCPeerConnectionHandlerClient::ICEStateConnected; | |
| 51 case webrtc::PeerConnectionInterface::kIceCompleted: | |
| 52 return WebKit::WebRTCPeerConnectionHandlerClient::ICEStateCompleted; | |
| 53 case webrtc::PeerConnectionInterface::kIceFailed: | |
| 54 return WebKit::WebRTCPeerConnectionHandlerClient::ICEStateFailed; | |
| 55 case webrtc::PeerConnectionInterface::kIceClosed: | |
| 56 return WebKit::WebRTCPeerConnectionHandlerClient::ICEStateClosed; | |
| 57 default: | 48 default: |
| 58 NOTREACHED(); | 49 NOTREACHED(); |
| 59 return WebKit::WebRTCPeerConnectionHandlerClient::ICEStateClosed; | 50 return WebRTCPeerConnectionHandlerClient::ICEGatheringStateNew; |
| 60 } | 51 } |
| 61 } | 52 } |
| 62 | 53 |
| 54 static WebKit::WebRTCPeerConnectionHandlerClient::ICEConnectionState |
| 55 GetWebKitIceConnectionState( |
| 56 webrtc::PeerConnectionInterface::IceConnectionState ice_state) { |
| 57 using WebKit::WebRTCPeerConnectionHandlerClient; |
| 58 switch (ice_state) { |
| 59 case webrtc::PeerConnectionInterface::kIceConnectionNew: |
| 60 return WebRTCPeerConnectionHandlerClient::ICEConnectionStateStarting; |
| 61 case webrtc::PeerConnectionInterface::kIceConnectionChecking: |
| 62 return WebRTCPeerConnectionHandlerClient::ICEConnectionStateChecking; |
| 63 case webrtc::PeerConnectionInterface::kIceConnectionConnected: |
| 64 return WebRTCPeerConnectionHandlerClient::ICEConnectionStateConnected; |
| 65 case webrtc::PeerConnectionInterface::kIceConnectionCompleted: |
| 66 return WebRTCPeerConnectionHandlerClient::ICEConnectionStateCompleted; |
| 67 case webrtc::PeerConnectionInterface::kIceConnectionFailed: |
| 68 return WebRTCPeerConnectionHandlerClient::ICEConnectionStateFailed; |
| 69 case webrtc::PeerConnectionInterface::kIceConnectionDisconnected: |
| 70 return WebRTCPeerConnectionHandlerClient::ICEConnectionStateDisconnected; |
| 71 case webrtc::PeerConnectionInterface::kIceConnectionClosed: |
| 72 return WebRTCPeerConnectionHandlerClient::ICEConnectionStateClosed; |
| 73 default: |
| 74 NOTREACHED(); |
| 75 return WebRTCPeerConnectionHandlerClient::ICEConnectionStateClosed; |
| 76 } |
| 77 } |
| 78 |
| 63 static WebKit::WebRTCPeerConnectionHandlerClient::SignalingState | 79 static WebKit::WebRTCPeerConnectionHandlerClient::SignalingState |
| 64 GetWebKitSignalingState(webrtc::PeerConnectionInterface::SignalingState state) { | 80 GetWebKitSignalingState(webrtc::PeerConnectionInterface::SignalingState state) { |
| 65 using WebKit::WebRTCPeerConnectionHandlerClient; | 81 using WebKit::WebRTCPeerConnectionHandlerClient; |
| 66 switch (state) { | 82 switch (state) { |
| 67 case webrtc::PeerConnectionInterface::kStable: | 83 case webrtc::PeerConnectionInterface::kStable: |
| 68 return WebRTCPeerConnectionHandlerClient::SignalingStateStable; | 84 return WebRTCPeerConnectionHandlerClient::SignalingStateStable; |
| 69 case webrtc::PeerConnectionInterface::kHaveLocalOffer: | 85 case webrtc::PeerConnectionInterface::kHaveLocalOffer: |
| 70 return WebRTCPeerConnectionHandlerClient::SignalingStateHaveLocalOffer; | 86 return WebRTCPeerConnectionHandlerClient::SignalingStateHaveLocalOffer; |
| 71 case webrtc::PeerConnectionInterface::kHaveLocalPrAnswer: | 87 case webrtc::PeerConnectionInterface::kHaveLocalPrAnswer: |
| 72 return WebRTCPeerConnectionHandlerClient::SignalingStateHaveLocalPrAnswer; | 88 return WebRTCPeerConnectionHandlerClient::SignalingStateHaveLocalPrAnswer; |
| (...skipping 544 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 617 | 633 |
| 618 if (peer_connection_tracker_) | 634 if (peer_connection_tracker_) |
| 619 peer_connection_tracker_->TrackStop(this); | 635 peer_connection_tracker_->TrackStop(this); |
| 620 } | 636 } |
| 621 | 637 |
| 622 void RTCPeerConnectionHandler::OnError() { | 638 void RTCPeerConnectionHandler::OnError() { |
| 623 // TODO(perkj): Implement. | 639 // TODO(perkj): Implement. |
| 624 NOTIMPLEMENTED(); | 640 NOTIMPLEMENTED(); |
| 625 } | 641 } |
| 626 | 642 |
| 627 void RTCPeerConnectionHandler::OnStateChange(StateType state_changed) { | 643 void RTCPeerConnectionHandler::OnSignalingChange( |
| 628 switch (state_changed) { | 644 webrtc::PeerConnectionInterface::SignalingState new_state) { |
| 629 case kSignalingState: { | 645 WebKit::WebRTCPeerConnectionHandlerClient::SignalingState state = |
| 630 WebKit::WebRTCPeerConnectionHandlerClient::SignalingState state = | 646 GetWebKitSignalingState(new_state); |
| 631 GetWebKitSignalingState(native_peer_connection_->signaling_state()); | 647 if (peer_connection_tracker_) |
| 632 if (peer_connection_tracker_) | 648 peer_connection_tracker_->TrackSignalingStateChange(this, state); |
| 633 peer_connection_tracker_->TrackSignalingStateChange(this, state); | 649 client_->didChangeSignalingState(state); |
| 650 } |
| 634 | 651 |
| 635 client_->didChangeSignalingState(state); | 652 // Called any time the IceConnectionState changes |
| 636 break; | 653 void RTCPeerConnectionHandler::OnIceConnectionChange( |
| 637 } | 654 webrtc::PeerConnectionInterface::IceConnectionState new_state) { |
| 638 case kIceState: { | 655 WebKit::WebRTCPeerConnectionHandlerClient::ICEConnectionState state = |
| 639 WebKit::WebRTCPeerConnectionHandlerClient::ICEState state = | 656 GetWebKitIceConnectionState(new_state); |
| 640 GetWebKitIceState(native_peer_connection_->ice_state()); | 657 // TODO(perkj): Add new ice connection state to the tracker. |
| 641 if (peer_connection_tracker_) | 658 client_->didChangeICEConnectionState(state); |
| 642 peer_connection_tracker_->TrackIceStateChange(this, state); | 659 } |
| 643 | 660 |
| 644 client_->didChangeICEState(state); | 661 // Called any time the IceGatheringState changes |
| 645 break; | 662 void RTCPeerConnectionHandler::OnIceGatheringChange( |
| 646 } | 663 webrtc::PeerConnectionInterface::IceGatheringState new_state) { |
| 647 default: | 664 WebKit::WebRTCPeerConnectionHandlerClient::ICEGatheringState state = |
| 648 NOTREACHED(); | 665 GetWebKitIceGatheringState(new_state); |
| 649 break; | 666 // TODO(perkj): Add new ice gathering state to the tracker. |
| 650 } | 667 client_->didChangeICEGatheringState(state); |
| 651 } | 668 } |
| 652 | 669 |
| 653 void RTCPeerConnectionHandler::OnAddStream( | 670 void RTCPeerConnectionHandler::OnAddStream( |
| 654 webrtc::MediaStreamInterface* stream_interface) { | 671 webrtc::MediaStreamInterface* stream_interface) { |
| 655 DCHECK(stream_interface); | 672 DCHECK(stream_interface); |
| 656 DCHECK(remote_streams_.find(stream_interface) == remote_streams_.end()); | 673 DCHECK(remote_streams_.find(stream_interface) == remote_streams_.end()); |
| 657 WebKit::WebMediaStream stream = | 674 WebKit::WebMediaStream stream = |
| 658 CreateWebKitStreamDescriptor(stream_interface); | 675 CreateWebKitStreamDescriptor(stream_interface); |
| 659 | 676 |
| 660 if (peer_connection_tracker_) | 677 if (peer_connection_tracker_) |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 698 web_candidate.initialize(UTF8ToUTF16(sdp), | 715 web_candidate.initialize(UTF8ToUTF16(sdp), |
| 699 UTF8ToUTF16(candidate->sdp_mid()), | 716 UTF8ToUTF16(candidate->sdp_mid()), |
| 700 candidate->sdp_mline_index()); | 717 candidate->sdp_mline_index()); |
| 701 if (peer_connection_tracker_) | 718 if (peer_connection_tracker_) |
| 702 peer_connection_tracker_->TrackAddIceCandidate( | 719 peer_connection_tracker_->TrackAddIceCandidate( |
| 703 this, web_candidate, PeerConnectionTracker::SOURCE_LOCAL); | 720 this, web_candidate, PeerConnectionTracker::SOURCE_LOCAL); |
| 704 | 721 |
| 705 client_->didGenerateICECandidate(web_candidate); | 722 client_->didGenerateICECandidate(web_candidate); |
| 706 } | 723 } |
| 707 | 724 |
| 708 void RTCPeerConnectionHandler::OnIceComplete() { | |
| 709 if (peer_connection_tracker_) | |
| 710 peer_connection_tracker_->TrackOnIceComplete(this); | |
| 711 // Generates a NULL ice candidate object. | |
| 712 WebKit::WebRTCICECandidate web_candidate; | |
| 713 client_->didGenerateICECandidate(web_candidate); | |
| 714 } | |
| 715 | |
| 716 void RTCPeerConnectionHandler::OnDataChannel( | 725 void RTCPeerConnectionHandler::OnDataChannel( |
| 717 webrtc::DataChannelInterface* data_channel) { | 726 webrtc::DataChannelInterface* data_channel) { |
| 718 if (peer_connection_tracker_) | 727 if (peer_connection_tracker_) |
| 719 peer_connection_tracker_->TrackCreateDataChannel( | 728 peer_connection_tracker_->TrackCreateDataChannel( |
| 720 this, data_channel, PeerConnectionTracker::SOURCE_REMOTE); | 729 this, data_channel, PeerConnectionTracker::SOURCE_REMOTE); |
| 721 | 730 |
| 722 DVLOG(1) << "RTCPeerConnectionHandler::OnDataChannel " | 731 DVLOG(1) << "RTCPeerConnectionHandler::OnDataChannel " |
| 723 << data_channel->label(); | 732 << data_channel->label(); |
| 724 client_->didAddRemoteDataChannel(new RtcDataChannelHandler(data_channel)); | 733 client_->didAddRemoteDataChannel(new RtcDataChannelHandler(data_channel)); |
| 725 } | 734 } |
| (...skipping 15 matching lines...) Expand all Loading... |
| 741 webrtc::SessionDescriptionInterface* native_desc = | 750 webrtc::SessionDescriptionInterface* native_desc = |
| 742 dependency_factory_->CreateSessionDescription(type, sdp, error); | 751 dependency_factory_->CreateSessionDescription(type, sdp, error); |
| 743 | 752 |
| 744 LOG_IF(ERROR, !native_desc) << "Failed to create native session description." | 753 LOG_IF(ERROR, !native_desc) << "Failed to create native session description." |
| 745 << " Type: " << type << " SDP: " << sdp; | 754 << " Type: " << type << " SDP: " << sdp; |
| 746 | 755 |
| 747 return native_desc; | 756 return native_desc; |
| 748 } | 757 } |
| 749 | 758 |
| 750 } // namespace content | 759 } // namespace content |
| OLD | NEW |