Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(433)

Side by Side Diff: webrtc/api/peerconnection.cc

Issue 2019423006: Adding more detail to MessageQueue::Dispatch logging. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright 2012 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after
553 for (const auto& receiver : receivers_) { 553 for (const auto& receiver : receivers_) {
554 receiver->Stop(); 554 receiver->Stop();
555 } 555 }
556 // Destroy stats_ because it depends on session_. 556 // Destroy stats_ because it depends on session_.
557 stats_.reset(nullptr); 557 stats_.reset(nullptr);
558 // Now destroy session_ before destroying other members, 558 // Now destroy session_ before destroying other members,
559 // because its destruction fires signals (such as VoiceChannelDestroyed) 559 // because its destruction fires signals (such as VoiceChannelDestroyed)
560 // which will trigger some final actions in PeerConnection... 560 // which will trigger some final actions in PeerConnection...
561 session_.reset(nullptr); 561 session_.reset(nullptr);
562 // port_allocator_ lives on the worker thread and should be destroyed there. 562 // port_allocator_ lives on the worker thread and should be destroyed there.
563 worker_thread()->Invoke<void>([this] { port_allocator_.reset(nullptr); }); 563 worker_thread()->Invoke<void>(FROM_HERE,
564 [this] { port_allocator_.reset(nullptr); });
564 } 565 }
565 566
566 bool PeerConnection::Initialize( 567 bool PeerConnection::Initialize(
567 const PeerConnectionInterface::RTCConfiguration& configuration, 568 const PeerConnectionInterface::RTCConfiguration& configuration,
568 std::unique_ptr<cricket::PortAllocator> allocator, 569 std::unique_ptr<cricket::PortAllocator> allocator,
569 std::unique_ptr<DtlsIdentityStoreInterface> dtls_identity_store, 570 std::unique_ptr<DtlsIdentityStoreInterface> dtls_identity_store,
570 PeerConnectionObserver* observer) { 571 PeerConnectionObserver* observer) {
571 TRACE_EVENT0("webrtc", "PeerConnection::Initialize"); 572 TRACE_EVENT0("webrtc", "PeerConnection::Initialize");
572 RTC_DCHECK(observer != nullptr); 573 RTC_DCHECK(observer != nullptr);
573 if (!observer) { 574 if (!observer) {
574 return false; 575 return false;
575 } 576 }
576 observer_ = observer; 577 observer_ = observer;
577 578
578 port_allocator_ = std::move(allocator); 579 port_allocator_ = std::move(allocator);
579 580
580 // The port allocator lives on the worker thread and should be initialized 581 // The port allocator lives on the worker thread and should be initialized
581 // there. 582 // there.
582 if (!worker_thread()->Invoke<bool>(rtc::Bind( 583 if (!worker_thread()->Invoke<bool>(
583 &PeerConnection::InitializePortAllocator_w, this, configuration))) { 584 FROM_HERE, rtc::Bind(&PeerConnection::InitializePortAllocator_w, this,
585 configuration))) {
584 return false; 586 return false;
585 } 587 }
586 588
587 media_controller_.reset( 589 media_controller_.reset(
588 factory_->CreateMediaController(configuration.media_config)); 590 factory_->CreateMediaController(configuration.media_config));
589 591
590 session_.reset( 592 session_.reset(
591 new WebRtcSession(media_controller_.get(), factory_->signaling_thread(), 593 new WebRtcSession(media_controller_.get(), factory_->signaling_thread(),
592 factory_->worker_thread(), port_allocator_.get())); 594 factory_->worker_thread(), port_allocator_.get()));
593 stats_.reset(new StatsCollector(this)); 595 stats_.reset(new StatsCollector(this));
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
814 MediaStreamTrackInterface* track, 816 MediaStreamTrackInterface* track,
815 StatsOutputLevel level) { 817 StatsOutputLevel level) {
816 TRACE_EVENT0("webrtc", "PeerConnection::GetStats"); 818 TRACE_EVENT0("webrtc", "PeerConnection::GetStats");
817 RTC_DCHECK(signaling_thread()->IsCurrent()); 819 RTC_DCHECK(signaling_thread()->IsCurrent());
818 if (!VERIFY(observer != NULL)) { 820 if (!VERIFY(observer != NULL)) {
819 LOG(LS_ERROR) << "GetStats - observer is NULL."; 821 LOG(LS_ERROR) << "GetStats - observer is NULL.";
820 return false; 822 return false;
821 } 823 }
822 824
823 stats_->UpdateStats(level); 825 stats_->UpdateStats(level);
824 signaling_thread()->Post(this, MSG_GETSTATS, 826 signaling_thread()->Post(FROM_HERE, this, MSG_GETSTATS,
825 new GetStatsMsg(observer, track)); 827 new GetStatsMsg(observer, track));
826 return true; 828 return true;
827 } 829 }
828 830
829 PeerConnectionInterface::SignalingState PeerConnection::signaling_state() { 831 PeerConnectionInterface::SignalingState PeerConnection::signaling_state() {
830 return signaling_state_; 832 return signaling_state_;
831 } 833 }
832 834
833 PeerConnectionInterface::IceState PeerConnection::ice_state() { 835 PeerConnectionInterface::IceState PeerConnection::ice_state() {
834 return ice_state_; 836 return ice_state_;
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
1043 const cricket::DataContentDescription* data_desc = 1045 const cricket::DataContentDescription* data_desc =
1044 static_cast<const cricket::DataContentDescription*>( 1046 static_cast<const cricket::DataContentDescription*>(
1045 data_content->description); 1047 data_content->description);
1046 if (rtc::starts_with(data_desc->protocol().data(), 1048 if (rtc::starts_with(data_desc->protocol().data(),
1047 cricket::kMediaProtocolRtpPrefix)) { 1049 cricket::kMediaProtocolRtpPrefix)) {
1048 UpdateLocalRtpDataChannels(data_desc->streams()); 1050 UpdateLocalRtpDataChannels(data_desc->streams());
1049 } 1051 }
1050 } 1052 }
1051 1053
1052 SetSessionDescriptionMsg* msg = new SetSessionDescriptionMsg(observer); 1054 SetSessionDescriptionMsg* msg = new SetSessionDescriptionMsg(observer);
1053 signaling_thread()->Post(this, MSG_SET_SESSIONDESCRIPTION_SUCCESS, msg); 1055 signaling_thread()->Post(FROM_HERE, this, MSG_SET_SESSIONDESCRIPTION_SUCCESS,
1056 msg);
1054 1057
1055 // MaybeStartGathering needs to be called after posting 1058 // MaybeStartGathering needs to be called after posting
1056 // MSG_SET_SESSIONDESCRIPTION_SUCCESS, so that we don't signal any candidates 1059 // MSG_SET_SESSIONDESCRIPTION_SUCCESS, so that we don't signal any candidates
1057 // before signaling that SetLocalDescription completed. 1060 // before signaling that SetLocalDescription completed.
1058 session_->MaybeStartGathering(); 1061 session_->MaybeStartGathering();
1059 } 1062 }
1060 1063
1061 void PeerConnection::SetRemoteDescription( 1064 void PeerConnection::SetRemoteDescription(
1062 SetSessionDescriptionObserver* observer, 1065 SetSessionDescriptionObserver* observer,
1063 SessionDescriptionInterface* desc) { 1066 SessionDescriptionInterface* desc) {
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
1150 // Iterate new_streams and notify the observer about new MediaStreams. 1153 // Iterate new_streams and notify the observer about new MediaStreams.
1151 for (size_t i = 0; i < new_streams->count(); ++i) { 1154 for (size_t i = 0; i < new_streams->count(); ++i) {
1152 MediaStreamInterface* new_stream = new_streams->at(i); 1155 MediaStreamInterface* new_stream = new_streams->at(i);
1153 stats_->AddStream(new_stream); 1156 stats_->AddStream(new_stream);
1154 observer_->OnAddStream(new_stream); 1157 observer_->OnAddStream(new_stream);
1155 } 1158 }
1156 1159
1157 UpdateEndedRemoteMediaStreams(); 1160 UpdateEndedRemoteMediaStreams();
1158 1161
1159 SetSessionDescriptionMsg* msg = new SetSessionDescriptionMsg(observer); 1162 SetSessionDescriptionMsg* msg = new SetSessionDescriptionMsg(observer);
1160 signaling_thread()->Post(this, MSG_SET_SESSIONDESCRIPTION_SUCCESS, msg); 1163 signaling_thread()->Post(FROM_HERE, this, MSG_SET_SESSIONDESCRIPTION_SUCCESS,
1164 msg);
1161 } 1165 }
1162 1166
1163 bool PeerConnection::SetConfiguration(const RTCConfiguration& configuration) { 1167 bool PeerConnection::SetConfiguration(const RTCConfiguration& configuration) {
1164 TRACE_EVENT0("webrtc", "PeerConnection::SetConfiguration"); 1168 TRACE_EVENT0("webrtc", "PeerConnection::SetConfiguration");
1165 if (port_allocator_) { 1169 if (port_allocator_) {
1166 if (!worker_thread()->Invoke<bool>( 1170 if (!worker_thread()->Invoke<bool>(
1167 rtc::Bind(&PeerConnection::ReconfigurePortAllocator_w, this, 1171 FROM_HERE, rtc::Bind(&PeerConnection::ReconfigurePortAllocator_w,
1168 configuration))) { 1172 this, configuration))) {
1169 return false; 1173 return false;
1170 } 1174 }
1171 } 1175 }
1172 1176
1173 // TODO(deadbeef): Shouldn't have to hop to the worker thread twice... 1177 // TODO(deadbeef): Shouldn't have to hop to the worker thread twice...
1174 session_->SetIceConfig(session_->ParseIceConfig(configuration)); 1178 session_->SetIceConfig(session_->ParseIceConfig(configuration));
1175 return true; 1179 return true;
1176 } 1180 }
1177 1181
1178 bool PeerConnection::AddIceCandidate( 1182 bool PeerConnection::AddIceCandidate(
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
1465 } 1469 }
1466 (*sender)->Stop(); 1470 (*sender)->Stop();
1467 senders_.erase(sender); 1471 senders_.erase(sender);
1468 } 1472 }
1469 1473
1470 void PeerConnection::PostSetSessionDescriptionFailure( 1474 void PeerConnection::PostSetSessionDescriptionFailure(
1471 SetSessionDescriptionObserver* observer, 1475 SetSessionDescriptionObserver* observer,
1472 const std::string& error) { 1476 const std::string& error) {
1473 SetSessionDescriptionMsg* msg = new SetSessionDescriptionMsg(observer); 1477 SetSessionDescriptionMsg* msg = new SetSessionDescriptionMsg(observer);
1474 msg->error = error; 1478 msg->error = error;
1475 signaling_thread()->Post(this, MSG_SET_SESSIONDESCRIPTION_FAILED, msg); 1479 signaling_thread()->Post(FROM_HERE, this, MSG_SET_SESSIONDESCRIPTION_FAILED,
1480 msg);
1476 } 1481 }
1477 1482
1478 void PeerConnection::PostCreateSessionDescriptionFailure( 1483 void PeerConnection::PostCreateSessionDescriptionFailure(
1479 CreateSessionDescriptionObserver* observer, 1484 CreateSessionDescriptionObserver* observer,
1480 const std::string& error) { 1485 const std::string& error) {
1481 CreateSessionDescriptionMsg* msg = new CreateSessionDescriptionMsg(observer); 1486 CreateSessionDescriptionMsg* msg = new CreateSessionDescriptionMsg(observer);
1482 msg->error = error; 1487 msg->error = error;
1483 signaling_thread()->Post(this, MSG_CREATE_SESSIONDESCRIPTION_FAILED, msg); 1488 signaling_thread()->Post(FROM_HERE, this,
1489 MSG_CREATE_SESSIONDESCRIPTION_FAILED, msg);
1484 } 1490 }
1485 1491
1486 bool PeerConnection::GetOptionsForOffer( 1492 bool PeerConnection::GetOptionsForOffer(
1487 const PeerConnectionInterface::RTCOfferAnswerOptions& rtc_options, 1493 const PeerConnectionInterface::RTCOfferAnswerOptions& rtc_options,
1488 cricket::MediaSessionOptions* session_options) { 1494 cricket::MediaSessionOptions* session_options) {
1489 // TODO(deadbeef): Once we have transceivers, enumerate them here instead of 1495 // TODO(deadbeef): Once we have transceivers, enumerate them here instead of
1490 // ContentInfos. 1496 // ContentInfos.
1491 if (session_->local_description()) { 1497 if (session_->local_description()) {
1492 for (const cricket::ContentInfo& content : 1498 for (const cricket::ContentInfo& content :
1493 session_->local_description()->description()->contents()) { 1499 session_->local_description()->description()->contents()) {
(...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after
1965 for (auto it = sctp_data_channels_.begin(); it != sctp_data_channels_.end(); 1971 for (auto it = sctp_data_channels_.begin(); it != sctp_data_channels_.end();
1966 ++it) { 1972 ++it) {
1967 if (it->get() == channel) { 1973 if (it->get() == channel) {
1968 if (channel->id() >= 0) { 1974 if (channel->id() >= 0) {
1969 sid_allocator_.ReleaseSid(channel->id()); 1975 sid_allocator_.ReleaseSid(channel->id());
1970 } 1976 }
1971 // Since this method is triggered by a signal from the DataChannel, 1977 // Since this method is triggered by a signal from the DataChannel,
1972 // we can't free it directly here; we need to free it asynchronously. 1978 // we can't free it directly here; we need to free it asynchronously.
1973 sctp_data_channels_to_free_.push_back(*it); 1979 sctp_data_channels_to_free_.push_back(*it);
1974 sctp_data_channels_.erase(it); 1980 sctp_data_channels_.erase(it);
1975 signaling_thread()->Post(this, MSG_FREE_DATACHANNELS, nullptr); 1981 signaling_thread()->Post(FROM_HERE, this, MSG_FREE_DATACHANNELS, nullptr);
1976 return; 1982 return;
1977 } 1983 }
1978 } 1984 }
1979 } 1985 }
1980 1986
1981 void PeerConnection::OnVoiceChannelDestroyed() { 1987 void PeerConnection::OnVoiceChannelDestroyed() {
1982 StopReceivers(cricket::MEDIA_TYPE_AUDIO); 1988 StopReceivers(cricket::MEDIA_TYPE_AUDIO);
1983 } 1989 }
1984 1990
1985 void PeerConnection::OnVideoChannelDestroyed() { 1991 void PeerConnection::OnVideoChannelDestroyed() {
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
2137 port_allocator_->set_candidate_filter( 2143 port_allocator_->set_candidate_filter(
2138 ConvertIceTransportTypeToCandidateFilter(configuration.type)); 2144 ConvertIceTransportTypeToCandidateFilter(configuration.type));
2139 // Call this last since it may create pooled allocator sessions using the 2145 // Call this last since it may create pooled allocator sessions using the
2140 // candidate filter set above. 2146 // candidate filter set above.
2141 port_allocator_->SetConfiguration(stun_servers, turn_servers, 2147 port_allocator_->SetConfiguration(stun_servers, turn_servers,
2142 configuration.ice_candidate_pool_size); 2148 configuration.ice_candidate_pool_size);
2143 return true; 2149 return true;
2144 } 2150 }
2145 2151
2146 } // namespace webrtc 2152 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698