| 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 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 case blink::WebRTCIceTransportsAll: | 164 case blink::WebRTCIceTransportsAll: |
| 165 config->type = webrtc::PeerConnectionInterface::kAll; | 165 config->type = webrtc::PeerConnectionInterface::kAll; |
| 166 break; | 166 break; |
| 167 default: | 167 default: |
| 168 NOTREACHED(); | 168 NOTREACHED(); |
| 169 } | 169 } |
| 170 } | 170 } |
| 171 | 171 |
| 172 class SessionDescriptionRequestTracker { | 172 class SessionDescriptionRequestTracker { |
| 173 public: | 173 public: |
| 174 SessionDescriptionRequestTracker(RTCPeerConnectionHandler* handler, | 174 SessionDescriptionRequestTracker( |
| 175 PeerConnectionTracker::Action action) | 175 const base::WeakPtr<RTCPeerConnectionHandler>& handler, |
| 176 : handler_(handler), action_(action) {} | 176 const base::WeakPtr<PeerConnectionTracker>& tracker, |
| 177 PeerConnectionTracker::Action action) |
| 178 : handler_(handler), tracker_(tracker), action_(action) {} |
| 177 | 179 |
| 178 void TrackOnSuccess(const webrtc::SessionDescriptionInterface* desc) { | 180 void TrackOnSuccess(const webrtc::SessionDescriptionInterface* desc) { |
| 179 DCHECK(thread_checker_.CalledOnValidThread()); | 181 DCHECK(thread_checker_.CalledOnValidThread()); |
| 180 std::string value; | 182 if (tracker_ && handler_) { |
| 181 if (desc) { | 183 std::string value; |
| 182 desc->ToString(&value); | 184 if (desc) { |
| 183 value = "type: " + desc->type() + ", sdp: " + value; | 185 desc->ToString(&value); |
| 184 } | 186 value = "type: " + desc->type() + ", sdp: " + value; |
| 185 if (handler_->peer_connection_tracker()) { | 187 } |
| 186 handler_->peer_connection_tracker()->TrackSessionDescriptionCallback( | 188 tracker_->TrackSessionDescriptionCallback( |
| 187 handler_, action_, "OnSuccess", value); | 189 handler_.get(), action_, "OnSuccess", value); |
| 188 } | 190 } |
| 189 } | 191 } |
| 190 | 192 |
| 191 void TrackOnFailure(const std::string& error) { | 193 void TrackOnFailure(const std::string& error) { |
| 192 DCHECK(thread_checker_.CalledOnValidThread()); | 194 DCHECK(thread_checker_.CalledOnValidThread()); |
| 193 if (handler_->peer_connection_tracker()) { | 195 if (handler_ && tracker_) { |
| 194 handler_->peer_connection_tracker()->TrackSessionDescriptionCallback( | 196 tracker_->TrackSessionDescriptionCallback( |
| 195 handler_, action_, "OnFailure", error); | 197 handler_.get(), action_, "OnFailure", error); |
| 196 } | 198 } |
| 197 } | 199 } |
| 198 | 200 |
| 199 private: | 201 private: |
| 200 RTCPeerConnectionHandler* handler_; | 202 const base::WeakPtr<RTCPeerConnectionHandler> handler_; |
| 203 const base::WeakPtr<PeerConnectionTracker> tracker_; |
| 201 PeerConnectionTracker::Action action_; | 204 PeerConnectionTracker::Action action_; |
| 202 base::ThreadChecker thread_checker_; | 205 base::ThreadChecker thread_checker_; |
| 203 }; | 206 }; |
| 204 | 207 |
| 205 // Class mapping responses from calls to libjingle CreateOffer/Answer and | 208 // Class mapping responses from calls to libjingle CreateOffer/Answer and |
| 206 // the blink::WebRTCSessionDescriptionRequest. | 209 // the blink::WebRTCSessionDescriptionRequest. |
| 207 class CreateSessionDescriptionRequest | 210 class CreateSessionDescriptionRequest |
| 208 : public webrtc::CreateSessionDescriptionObserver { | 211 : public webrtc::CreateSessionDescriptionObserver { |
| 209 public: | 212 public: |
| 210 explicit CreateSessionDescriptionRequest( | 213 explicit CreateSessionDescriptionRequest( |
| 211 const scoped_refptr<base::SingleThreadTaskRunner>& main_thread, | 214 const scoped_refptr<base::SingleThreadTaskRunner>& main_thread, |
| 212 const blink::WebRTCSessionDescriptionRequest& request, | 215 const blink::WebRTCSessionDescriptionRequest& request, |
| 213 RTCPeerConnectionHandler* handler, | 216 const base::WeakPtr<RTCPeerConnectionHandler>& handler, |
| 217 const base::WeakPtr<PeerConnectionTracker>& tracker, |
| 214 PeerConnectionTracker::Action action) | 218 PeerConnectionTracker::Action action) |
| 215 : main_thread_(main_thread), | 219 : main_thread_(main_thread), |
| 216 webkit_request_(request), | 220 webkit_request_(request), |
| 217 tracker_(handler, action) { | 221 tracker_(handler, tracker, action) { |
| 218 } | 222 } |
| 219 | 223 |
| 220 void OnSuccess(webrtc::SessionDescriptionInterface* desc) override { | 224 void OnSuccess(webrtc::SessionDescriptionInterface* desc) override { |
| 221 if (!main_thread_->BelongsToCurrentThread()) { | 225 if (!main_thread_->BelongsToCurrentThread()) { |
| 222 main_thread_->PostTask(FROM_HERE, | 226 main_thread_->PostTask(FROM_HERE, |
| 223 base::Bind(&CreateSessionDescriptionRequest::OnSuccess, this, desc)); | 227 base::Bind(&CreateSessionDescriptionRequest::OnSuccess, this, desc)); |
| 224 return; | 228 return; |
| 225 } | 229 } |
| 226 | 230 |
| 227 tracker_.TrackOnSuccess(desc); | 231 tracker_.TrackOnSuccess(desc); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 248 }; | 252 }; |
| 249 | 253 |
| 250 // Class mapping responses from calls to libjingle | 254 // Class mapping responses from calls to libjingle |
| 251 // SetLocalDescription/SetRemoteDescription and a blink::WebRTCVoidRequest. | 255 // SetLocalDescription/SetRemoteDescription and a blink::WebRTCVoidRequest. |
| 252 class SetSessionDescriptionRequest | 256 class SetSessionDescriptionRequest |
| 253 : public webrtc::SetSessionDescriptionObserver { | 257 : public webrtc::SetSessionDescriptionObserver { |
| 254 public: | 258 public: |
| 255 explicit SetSessionDescriptionRequest( | 259 explicit SetSessionDescriptionRequest( |
| 256 const scoped_refptr<base::SingleThreadTaskRunner>& main_thread, | 260 const scoped_refptr<base::SingleThreadTaskRunner>& main_thread, |
| 257 const blink::WebRTCVoidRequest& request, | 261 const blink::WebRTCVoidRequest& request, |
| 258 RTCPeerConnectionHandler* handler, | 262 const base::WeakPtr<RTCPeerConnectionHandler>& handler, |
| 263 const base::WeakPtr<PeerConnectionTracker>& tracker, |
| 259 PeerConnectionTracker::Action action) | 264 PeerConnectionTracker::Action action) |
| 260 : main_thread_(main_thread), | 265 : main_thread_(main_thread), |
| 261 webkit_request_(request), | 266 webkit_request_(request), |
| 262 tracker_(handler, action) { | 267 tracker_(handler, tracker, action) { |
| 263 } | 268 } |
| 264 | 269 |
| 265 void OnSuccess() override { | 270 void OnSuccess() override { |
| 266 if (!main_thread_->BelongsToCurrentThread()) { | 271 if (!main_thread_->BelongsToCurrentThread()) { |
| 267 main_thread_->PostTask(FROM_HERE, | 272 main_thread_->PostTask(FROM_HERE, |
| 268 base::Bind(&SetSessionDescriptionRequest::OnSuccess, this)); | 273 base::Bind(&SetSessionDescriptionRequest::OnSuccess, this)); |
| 269 return; | 274 return; |
| 270 } | 275 } |
| 271 tracker_.TrackOnSuccess(NULL); | 276 tracker_.TrackOnSuccess(NULL); |
| 272 webkit_request_.requestSucceeded(); | 277 webkit_request_.requestSucceeded(); |
| (...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 611 }; | 616 }; |
| 612 | 617 |
| 613 RTCPeerConnectionHandler::RTCPeerConnectionHandler( | 618 RTCPeerConnectionHandler::RTCPeerConnectionHandler( |
| 614 blink::WebRTCPeerConnectionHandlerClient* client, | 619 blink::WebRTCPeerConnectionHandlerClient* client, |
| 615 PeerConnectionDependencyFactory* dependency_factory, | 620 PeerConnectionDependencyFactory* dependency_factory, |
| 616 const scoped_refptr<base::SingleThreadTaskRunner>& signaling_thread) | 621 const scoped_refptr<base::SingleThreadTaskRunner>& signaling_thread) |
| 617 : client_(client), | 622 : client_(client), |
| 618 dependency_factory_(dependency_factory), | 623 dependency_factory_(dependency_factory), |
| 619 frame_(NULL), | 624 frame_(NULL), |
| 620 signaling_thread_(signaling_thread), | 625 signaling_thread_(signaling_thread), |
| 621 peer_connection_tracker_(NULL), | |
| 622 num_data_channels_created_(0), | 626 num_data_channels_created_(0), |
| 623 num_local_candidates_ipv4_(0), | 627 num_local_candidates_ipv4_(0), |
| 624 num_local_candidates_ipv6_(0), | 628 num_local_candidates_ipv6_(0), |
| 625 weak_factory_(this) { | 629 weak_factory_(this) { |
| 626 g_peer_connection_handlers.Get().insert(this); | 630 g_peer_connection_handlers.Get().insert(this); |
| 627 } | 631 } |
| 628 | 632 |
| 629 RTCPeerConnectionHandler::~RTCPeerConnectionHandler() { | 633 RTCPeerConnectionHandler::~RTCPeerConnectionHandler() { |
| 630 DCHECK(thread_checker_.CalledOnValidThread()); | 634 DCHECK(thread_checker_.CalledOnValidThread()); |
| 631 g_peer_connection_handlers.Get().erase(this); | 635 g_peer_connection_handlers.Get().erase(this); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 681 frame_ = frame; | 685 frame_ = frame; |
| 682 } | 686 } |
| 683 | 687 |
| 684 bool RTCPeerConnectionHandler::initialize( | 688 bool RTCPeerConnectionHandler::initialize( |
| 685 const blink::WebRTCConfiguration& server_configuration, | 689 const blink::WebRTCConfiguration& server_configuration, |
| 686 const blink::WebMediaConstraints& options) { | 690 const blink::WebMediaConstraints& options) { |
| 687 DCHECK(thread_checker_.CalledOnValidThread()); | 691 DCHECK(thread_checker_.CalledOnValidThread()); |
| 688 DCHECK(frame_); | 692 DCHECK(frame_); |
| 689 | 693 |
| 690 peer_connection_tracker_ = | 694 peer_connection_tracker_ = |
| 691 RenderThreadImpl::current()->peer_connection_tracker(); | 695 RenderThreadImpl::current()->peer_connection_tracker()->AsWeakPtr(); |
| 692 | 696 |
| 693 webrtc::PeerConnectionInterface::RTCConfiguration config; | 697 webrtc::PeerConnectionInterface::RTCConfiguration config; |
| 694 GetNativeRtcConfiguration(server_configuration, &config); | 698 GetNativeRtcConfiguration(server_configuration, &config); |
| 695 | 699 |
| 696 RTCMediaConstraints constraints(options); | 700 RTCMediaConstraints constraints(options); |
| 697 | 701 |
| 698 peer_connection_observer_ = new Observer(weak_factory_.GetWeakPtr()); | 702 peer_connection_observer_ = new Observer(weak_factory_.GetWeakPtr()); |
| 699 native_peer_connection_ = dependency_factory_->CreatePeerConnection( | 703 native_peer_connection_ = dependency_factory_->CreatePeerConnection( |
| 700 config, &constraints, frame_, peer_connection_observer_.get()); | 704 config, &constraints, frame_, peer_connection_observer_.get()); |
| 701 | 705 |
| 702 if (!native_peer_connection_.get()) { | 706 if (!native_peer_connection_.get()) { |
| 703 LOG(ERROR) << "Failed to initialize native PeerConnection."; | 707 LOG(ERROR) << "Failed to initialize native PeerConnection."; |
| 704 return false; | 708 return false; |
| 705 } | 709 } |
| 706 | 710 |
| 707 if (peer_connection_tracker_) { | 711 if (peer_connection_tracker_) { |
| 708 peer_connection_tracker_->RegisterPeerConnection( | 712 peer_connection_tracker_->RegisterPeerConnection( |
| 709 this, config, constraints, frame_); | 713 this, config, constraints, frame_); |
| 710 } | 714 } |
| 711 | 715 |
| 712 uma_observer_ = new rtc::RefCountedObject<PeerConnectionUMAObserver>(); | 716 uma_observer_ = new rtc::RefCountedObject<PeerConnectionUMAObserver>(); |
| 713 native_peer_connection_->RegisterUMAObserver(uma_observer_.get()); | 717 native_peer_connection_->RegisterUMAObserver(uma_observer_.get()); |
| 714 return true; | 718 return true; |
| 715 } | 719 } |
| 716 | 720 |
| 717 bool RTCPeerConnectionHandler::InitializeForTest( | 721 bool RTCPeerConnectionHandler::InitializeForTest( |
| 718 const blink::WebRTCConfiguration& server_configuration, | 722 const blink::WebRTCConfiguration& server_configuration, |
| 719 const blink::WebMediaConstraints& options, | 723 const blink::WebMediaConstraints& options, |
| 720 PeerConnectionTracker* peer_connection_tracker) { | 724 const base::WeakPtr<PeerConnectionTracker>& peer_connection_tracker) { |
| 721 DCHECK(thread_checker_.CalledOnValidThread()); | 725 DCHECK(thread_checker_.CalledOnValidThread()); |
| 722 webrtc::PeerConnectionInterface::RTCConfiguration config; | 726 webrtc::PeerConnectionInterface::RTCConfiguration config; |
| 723 GetNativeRtcConfiguration(server_configuration, &config); | 727 GetNativeRtcConfiguration(server_configuration, &config); |
| 724 | 728 |
| 725 peer_connection_observer_ = new Observer(weak_factory_.GetWeakPtr()); | 729 peer_connection_observer_ = new Observer(weak_factory_.GetWeakPtr()); |
| 726 RTCMediaConstraints constraints(options); | 730 RTCMediaConstraints constraints(options); |
| 727 native_peer_connection_ = dependency_factory_->CreatePeerConnection( | 731 native_peer_connection_ = dependency_factory_->CreatePeerConnection( |
| 728 config, &constraints, NULL, peer_connection_observer_.get()); | 732 config, &constraints, NULL, peer_connection_observer_.get()); |
| 729 if (!native_peer_connection_.get()) { | 733 if (!native_peer_connection_.get()) { |
| 730 LOG(ERROR) << "Failed to initialize native PeerConnection."; | 734 LOG(ERROR) << "Failed to initialize native PeerConnection."; |
| 731 return false; | 735 return false; |
| 732 } | 736 } |
| 733 peer_connection_tracker_ = peer_connection_tracker; | 737 peer_connection_tracker_ = peer_connection_tracker; |
| 734 return true; | 738 return true; |
| 735 } | 739 } |
| 736 | 740 |
| 737 void RTCPeerConnectionHandler::createOffer( | 741 void RTCPeerConnectionHandler::createOffer( |
| 738 const blink::WebRTCSessionDescriptionRequest& request, | 742 const blink::WebRTCSessionDescriptionRequest& request, |
| 739 const blink::WebMediaConstraints& options) { | 743 const blink::WebMediaConstraints& options) { |
| 740 DCHECK(thread_checker_.CalledOnValidThread()); | 744 DCHECK(thread_checker_.CalledOnValidThread()); |
| 741 TRACE_EVENT0("webrtc", "RTCPeerConnectionHandler::createOffer"); | 745 TRACE_EVENT0("webrtc", "RTCPeerConnectionHandler::createOffer"); |
| 742 | 746 |
| 743 scoped_refptr<CreateSessionDescriptionRequest> description_request( | 747 scoped_refptr<CreateSessionDescriptionRequest> description_request( |
| 744 new rtc::RefCountedObject<CreateSessionDescriptionRequest>( | 748 new rtc::RefCountedObject<CreateSessionDescriptionRequest>( |
| 745 base::ThreadTaskRunnerHandle::Get(), request, this, | 749 base::ThreadTaskRunnerHandle::Get(), request, |
| 750 weak_factory_.GetWeakPtr(), peer_connection_tracker_, |
| 746 PeerConnectionTracker::ACTION_CREATE_OFFER)); | 751 PeerConnectionTracker::ACTION_CREATE_OFFER)); |
| 747 | 752 |
| 748 RTCMediaConstraints constraints(options); | 753 RTCMediaConstraints constraints(options); |
| 749 native_peer_connection_->CreateOffer(description_request.get(), &constraints); | 754 native_peer_connection_->CreateOffer(description_request.get(), &constraints); |
| 750 | 755 |
| 751 if (peer_connection_tracker_) | 756 if (peer_connection_tracker_) |
| 752 peer_connection_tracker_->TrackCreateOffer(this, constraints); | 757 peer_connection_tracker_->TrackCreateOffer(this, constraints); |
| 753 } | 758 } |
| 754 | 759 |
| 755 void RTCPeerConnectionHandler::createOffer( | 760 void RTCPeerConnectionHandler::createOffer( |
| 756 const blink::WebRTCSessionDescriptionRequest& request, | 761 const blink::WebRTCSessionDescriptionRequest& request, |
| 757 const blink::WebRTCOfferOptions& options) { | 762 const blink::WebRTCOfferOptions& options) { |
| 758 DCHECK(thread_checker_.CalledOnValidThread()); | 763 DCHECK(thread_checker_.CalledOnValidThread()); |
| 759 TRACE_EVENT0("webrtc", "RTCPeerConnectionHandler::createOffer"); | 764 TRACE_EVENT0("webrtc", "RTCPeerConnectionHandler::createOffer"); |
| 760 | 765 |
| 761 scoped_refptr<CreateSessionDescriptionRequest> description_request( | 766 scoped_refptr<CreateSessionDescriptionRequest> description_request( |
| 762 new rtc::RefCountedObject<CreateSessionDescriptionRequest>( | 767 new rtc::RefCountedObject<CreateSessionDescriptionRequest>( |
| 763 base::ThreadTaskRunnerHandle::Get(), request, this, | 768 base::ThreadTaskRunnerHandle::Get(), request, |
| 769 weak_factory_.GetWeakPtr(), peer_connection_tracker_, |
| 764 PeerConnectionTracker::ACTION_CREATE_OFFER)); | 770 PeerConnectionTracker::ACTION_CREATE_OFFER)); |
| 765 | 771 |
| 766 RTCMediaConstraints constraints; | 772 RTCMediaConstraints constraints; |
| 767 ConvertOfferOptionsToConstraints(options, &constraints); | 773 ConvertOfferOptionsToConstraints(options, &constraints); |
| 768 native_peer_connection_->CreateOffer(description_request.get(), &constraints); | 774 native_peer_connection_->CreateOffer(description_request.get(), &constraints); |
| 769 | 775 |
| 770 if (peer_connection_tracker_) | 776 if (peer_connection_tracker_) |
| 771 peer_connection_tracker_->TrackCreateOffer(this, constraints); | 777 peer_connection_tracker_->TrackCreateOffer(this, constraints); |
| 772 } | 778 } |
| 773 | 779 |
| 774 void RTCPeerConnectionHandler::createAnswer( | 780 void RTCPeerConnectionHandler::createAnswer( |
| 775 const blink::WebRTCSessionDescriptionRequest& request, | 781 const blink::WebRTCSessionDescriptionRequest& request, |
| 776 const blink::WebMediaConstraints& options) { | 782 const blink::WebMediaConstraints& options) { |
| 777 DCHECK(thread_checker_.CalledOnValidThread()); | 783 DCHECK(thread_checker_.CalledOnValidThread()); |
| 778 TRACE_EVENT0("webrtc", "RTCPeerConnectionHandler::createAnswer"); | 784 TRACE_EVENT0("webrtc", "RTCPeerConnectionHandler::createAnswer"); |
| 779 scoped_refptr<CreateSessionDescriptionRequest> description_request( | 785 scoped_refptr<CreateSessionDescriptionRequest> description_request( |
| 780 new rtc::RefCountedObject<CreateSessionDescriptionRequest>( | 786 new rtc::RefCountedObject<CreateSessionDescriptionRequest>( |
| 781 base::ThreadTaskRunnerHandle::Get(), request, this, | 787 base::ThreadTaskRunnerHandle::Get(), request, |
| 788 weak_factory_.GetWeakPtr(), peer_connection_tracker_, |
| 782 PeerConnectionTracker::ACTION_CREATE_ANSWER)); | 789 PeerConnectionTracker::ACTION_CREATE_ANSWER)); |
| 783 RTCMediaConstraints constraints(options); | 790 RTCMediaConstraints constraints(options); |
| 784 native_peer_connection_->CreateAnswer(description_request.get(), | 791 native_peer_connection_->CreateAnswer(description_request.get(), |
| 785 &constraints); | 792 &constraints); |
| 786 | 793 |
| 787 if (peer_connection_tracker_) | 794 if (peer_connection_tracker_) |
| 788 peer_connection_tracker_->TrackCreateAnswer(this, constraints); | 795 peer_connection_tracker_->TrackCreateAnswer(this, constraints); |
| 789 } | 796 } |
| 790 | 797 |
| 791 void RTCPeerConnectionHandler::setLocalDescription( | 798 void RTCPeerConnectionHandler::setLocalDescription( |
| (...skipping 20 matching lines...) Expand all Loading... |
| 812 return; | 819 return; |
| 813 } | 820 } |
| 814 | 821 |
| 815 if (peer_connection_tracker_) { | 822 if (peer_connection_tracker_) { |
| 816 peer_connection_tracker_->TrackSetSessionDescription( | 823 peer_connection_tracker_->TrackSetSessionDescription( |
| 817 this, sdp, type, PeerConnectionTracker::SOURCE_LOCAL); | 824 this, sdp, type, PeerConnectionTracker::SOURCE_LOCAL); |
| 818 } | 825 } |
| 819 | 826 |
| 820 scoped_refptr<SetSessionDescriptionRequest> set_request( | 827 scoped_refptr<SetSessionDescriptionRequest> set_request( |
| 821 new rtc::RefCountedObject<SetSessionDescriptionRequest>( | 828 new rtc::RefCountedObject<SetSessionDescriptionRequest>( |
| 822 base::ThreadTaskRunnerHandle::Get(), request, this, | 829 base::ThreadTaskRunnerHandle::Get(), request, |
| 830 weak_factory_.GetWeakPtr(), peer_connection_tracker_, |
| 823 PeerConnectionTracker::ACTION_SET_LOCAL_DESCRIPTION)); | 831 PeerConnectionTracker::ACTION_SET_LOCAL_DESCRIPTION)); |
| 824 | 832 |
| 825 // TODO(tommi): Run this on the signaling thread. | 833 // TODO(tommi): Run this on the signaling thread. |
| 826 native_peer_connection_->SetLocalDescription(set_request.get(), native_desc); | 834 native_peer_connection_->SetLocalDescription(set_request.get(), native_desc); |
| 827 } | 835 } |
| 828 | 836 |
| 829 void RTCPeerConnectionHandler::setRemoteDescription( | 837 void RTCPeerConnectionHandler::setRemoteDescription( |
| 830 const blink::WebRTCVoidRequest& request, | 838 const blink::WebRTCVoidRequest& request, |
| 831 const blink::WebRTCSessionDescription& description) { | 839 const blink::WebRTCSessionDescription& description) { |
| 832 DCHECK(thread_checker_.CalledOnValidThread()); | 840 DCHECK(thread_checker_.CalledOnValidThread()); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 849 return; | 857 return; |
| 850 } | 858 } |
| 851 | 859 |
| 852 if (peer_connection_tracker_) { | 860 if (peer_connection_tracker_) { |
| 853 peer_connection_tracker_->TrackSetSessionDescription( | 861 peer_connection_tracker_->TrackSetSessionDescription( |
| 854 this, sdp, type, PeerConnectionTracker::SOURCE_REMOTE); | 862 this, sdp, type, PeerConnectionTracker::SOURCE_REMOTE); |
| 855 } | 863 } |
| 856 | 864 |
| 857 scoped_refptr<SetSessionDescriptionRequest> set_request( | 865 scoped_refptr<SetSessionDescriptionRequest> set_request( |
| 858 new rtc::RefCountedObject<SetSessionDescriptionRequest>( | 866 new rtc::RefCountedObject<SetSessionDescriptionRequest>( |
| 859 base::ThreadTaskRunnerHandle::Get(), request, this, | 867 base::ThreadTaskRunnerHandle::Get(), request, |
| 868 weak_factory_.GetWeakPtr(), peer_connection_tracker_, |
| 860 PeerConnectionTracker::ACTION_SET_REMOTE_DESCRIPTION)); | 869 PeerConnectionTracker::ACTION_SET_REMOTE_DESCRIPTION)); |
| 861 // TODO(tommi): Run this on the signaling thread. | 870 // TODO(tommi): Run this on the signaling thread. |
| 862 native_peer_connection_->SetRemoteDescription(set_request.get(), native_desc); | 871 native_peer_connection_->SetRemoteDescription(set_request.get(), native_desc); |
| 863 } | 872 } |
| 864 | 873 |
| 865 blink::WebRTCSessionDescription | 874 blink::WebRTCSessionDescription |
| 866 RTCPeerConnectionHandler::localDescription() { | 875 RTCPeerConnectionHandler::localDescription() { |
| 867 DCHECK(thread_checker_.CalledOnValidThread()); | 876 DCHECK(thread_checker_.CalledOnValidThread()); |
| 868 TRACE_EVENT0("webrtc", "RTCPeerConnectionHandler::localDescription"); | 877 TRACE_EVENT0("webrtc", "RTCPeerConnectionHandler::localDescription"); |
| 869 const webrtc::SessionDescriptionInterface* native_desc = | 878 const webrtc::SessionDescriptionInterface* native_desc = |
| (...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1212 | 1221 |
| 1213 void RTCPeerConnectionHandler::OnRenegotiationNeeded() { | 1222 void RTCPeerConnectionHandler::OnRenegotiationNeeded() { |
| 1214 DCHECK(thread_checker_.CalledOnValidThread()); | 1223 DCHECK(thread_checker_.CalledOnValidThread()); |
| 1215 TRACE_EVENT0("webrtc", "RTCPeerConnectionHandler::OnRenegotiationNeeded"); | 1224 TRACE_EVENT0("webrtc", "RTCPeerConnectionHandler::OnRenegotiationNeeded"); |
| 1216 if (peer_connection_tracker_) | 1225 if (peer_connection_tracker_) |
| 1217 peer_connection_tracker_->TrackOnRenegotiationNeeded(this); | 1226 peer_connection_tracker_->TrackOnRenegotiationNeeded(this); |
| 1218 if (client_) | 1227 if (client_) |
| 1219 client_->negotiationNeeded(); | 1228 client_->negotiationNeeded(); |
| 1220 } | 1229 } |
| 1221 | 1230 |
| 1222 PeerConnectionTracker* RTCPeerConnectionHandler::peer_connection_tracker() { | |
| 1223 DCHECK(thread_checker_.CalledOnValidThread()); | |
| 1224 return peer_connection_tracker_; | |
| 1225 } | |
| 1226 | |
| 1227 void RTCPeerConnectionHandler::OnAddStream( | 1231 void RTCPeerConnectionHandler::OnAddStream( |
| 1228 scoped_ptr<RemoteMediaStreamImpl> stream) { | 1232 scoped_ptr<RemoteMediaStreamImpl> stream) { |
| 1229 DCHECK(thread_checker_.CalledOnValidThread()); | 1233 DCHECK(thread_checker_.CalledOnValidThread()); |
| 1230 DCHECK(remote_streams_.find(stream->webrtc_stream().get()) == | 1234 DCHECK(remote_streams_.find(stream->webrtc_stream().get()) == |
| 1231 remote_streams_.end()); | 1235 remote_streams_.end()); |
| 1232 DCHECK(stream->webkit_stream().extraData()) << "Initialization not done"; | 1236 DCHECK(stream->webkit_stream().extraData()) << "Initialization not done"; |
| 1233 TRACE_EVENT0("webrtc", "RTCPeerConnectionHandler::OnAddStreamImpl"); | 1237 TRACE_EVENT0("webrtc", "RTCPeerConnectionHandler::OnAddStreamImpl"); |
| 1234 | 1238 |
| 1235 // Ownership is with remote_streams_ now. | 1239 // Ownership is with remote_streams_ now. |
| 1236 RemoteMediaStreamImpl* s = stream.release(); | 1240 RemoteMediaStreamImpl* s = stream.release(); |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1329 webrtc::SessionDescriptionInterface* native_desc = | 1333 webrtc::SessionDescriptionInterface* native_desc = |
| 1330 dependency_factory_->CreateSessionDescription(type, sdp, error); | 1334 dependency_factory_->CreateSessionDescription(type, sdp, error); |
| 1331 | 1335 |
| 1332 LOG_IF(ERROR, !native_desc) << "Failed to create native session description." | 1336 LOG_IF(ERROR, !native_desc) << "Failed to create native session description." |
| 1333 << " Type: " << type << " SDP: " << sdp; | 1337 << " Type: " << type << " SDP: " << sdp; |
| 1334 | 1338 |
| 1335 return native_desc; | 1339 return native_desc; |
| 1336 } | 1340 } |
| 1337 | 1341 |
| 1338 } // namespace content | 1342 } // namespace content |
| OLD | NEW |