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

Unified Diff: talk/app/webrtc/webrtcsession.cc

Issue 1397973002: Merging BaseSession code into WebRtcSession. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Removing obsolete unit test. Created 5 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: talk/app/webrtc/webrtcsession.cc
diff --git a/talk/app/webrtc/webrtcsession.cc b/talk/app/webrtc/webrtcsession.cc
index 2ab9a1e6969599983724f9ffdce7aebb91b5d418..9156318e062b02a19851009ab10a8fc8424633d3 100644
--- a/talk/app/webrtc/webrtcsession.cc
+++ b/talk/app/webrtc/webrtcsession.cc
@@ -63,6 +63,14 @@ using cricket::STUN_PORT_TYPE;
using cricket::RELAY_PORT_TYPE;
using cricket::PRFLX_PORT_TYPE;
+namespace {
+
+enum {
+ MSG_STATE = 0,
+};
+
+} // namespace
+
namespace webrtc {
// Error messages
@@ -330,7 +338,11 @@ static bool BadSdp(const std::string& source,
const std::string& reason,
std::string* err_desc) {
std::ostringstream desc;
- desc << "Failed to set " << source << " " << type << " sdp: " << reason;
+ desc << "Failed to set " << source;
+ if (!type.empty()) {
+ desc << " " << type;
+ }
+ desc << " sdp: " << reason;
if (err_desc) {
*err_desc = desc.str();
@@ -381,12 +393,12 @@ static bool BadAnswerSdp(cricket::ContentSource source,
return BadSdp(source, SessionDescriptionInterface::kAnswer, reason, err_desc);
}
-#define GET_STRING_OF_STATE(state) \
- case cricket::BaseSession::state: \
- result = #state; \
+#define GET_STRING_OF_STATE(state) \
+ case webrtc::WebRtcSession::state: \
+ result = #state; \
break;
-static std::string GetStateString(cricket::BaseSession::State state) {
+static std::string GetStateString(webrtc::WebRtcSession::State state) {
std::string result;
switch (state) {
GET_STRING_OF_STATE(STATE_INIT)
@@ -412,22 +424,19 @@ static std::string GetStateString(cricket::BaseSession::State state) {
return result;
}
-#define GET_STRING_OF_ERROR_CODE(err) \
- case cricket::BaseSession::err: \
- result = #err; \
+#define GET_STRING_OF_ERROR_CODE(err) \
+ case webrtc::WebRtcSession::err: \
+ result = #err; \
break;
-static std::string GetErrorCodeString(cricket::BaseSession::Error err) {
+static std::string GetErrorCodeString(webrtc::WebRtcSession::Error err) {
std::string result;
switch (err) {
GET_STRING_OF_ERROR_CODE(ERROR_NONE)
- GET_STRING_OF_ERROR_CODE(ERROR_TIME)
- GET_STRING_OF_ERROR_CODE(ERROR_RESPONSE)
- GET_STRING_OF_ERROR_CODE(ERROR_NETWORK)
GET_STRING_OF_ERROR_CODE(ERROR_CONTENT)
GET_STRING_OF_ERROR_CODE(ERROR_TRANSPORT)
default:
- ASSERT(false);
+ RTC_DCHECK(false);
break;
}
return result;
@@ -536,20 +545,21 @@ class IceRestartAnswerLatch {
bool ice_restart_;
};
-WebRtcSession::WebRtcSession(
- cricket::ChannelManager* channel_manager,
- rtc::Thread* signaling_thread,
- rtc::Thread* worker_thread,
- cricket::PortAllocator* port_allocator,
- MediaStreamSignaling* mediastream_signaling)
- : cricket::BaseSession(signaling_thread,
- worker_thread,
- port_allocator,
- rtc::ToString(rtc::CreateRandomId64() & LLONG_MAX),
- false),
+WebRtcSession::WebRtcSession(cricket::ChannelManager* channel_manager,
+ rtc::Thread* signaling_thread,
+ rtc::Thread* worker_thread,
+ cricket::PortAllocator* port_allocator,
+ MediaStreamSignaling* mediastream_signaling)
+ : signaling_thread_(signaling_thread),
+ worker_thread_(worker_thread),
+ port_allocator_(port_allocator),
// RFC 3264: The numeric value of the session id and version in the
// o line MUST be representable with a "64 bit signed integer".
// Due to this constraint session id |sid_| is max limited to LLONG_MAX.
+ sid_(rtc::ToString(rtc::CreateRandomId64() & LLONG_MAX)),
+ transport_controller_(new cricket::TransportController(signaling_thread,
+ worker_thread,
+ port_allocator)),
channel_manager_(channel_manager),
mediastream_signaling_(mediastream_signaling),
ice_observer_(NULL),
@@ -560,13 +570,14 @@ WebRtcSession::WebRtcSession(
data_channel_type_(cricket::DCT_NONE),
ice_restart_latch_(new IceRestartAnswerLatch),
metrics_observer_(NULL) {
- transport_controller()->SignalConnectionState.connect(
+ transport_controller_->SetIceRole(cricket::ICEROLE_CONTROLLED);
+ transport_controller_->SignalConnectionState.connect(
this, &WebRtcSession::OnTransportControllerConnectionState);
- transport_controller()->SignalReceiving.connect(
+ transport_controller_->SignalReceiving.connect(
this, &WebRtcSession::OnTransportControllerReceiving);
- transport_controller()->SignalGatheringState.connect(
+ transport_controller_->SignalGatheringState.connect(
this, &WebRtcSession::OnTransportControllerGatheringState);
- transport_controller()->SignalCandidatesGathered.connect(
+ transport_controller_->SignalCandidatesGathered.connect(
this, &WebRtcSession::OnTransportControllerCandidatesGathered);
}
@@ -589,6 +600,11 @@ WebRtcSession::~WebRtcSession() {
for (size_t i = 0; i < saved_candidates_.size(); ++i) {
delete saved_candidates_[i];
}
+
+ RTC_DCHECK(state_ != STATE_DEINIT);
+ LogState(state_, STATE_DEINIT);
+ state_ = STATE_DEINIT;
+ SignalState(this, state_);
}
bool WebRtcSession::Initialize(
@@ -598,7 +614,7 @@ bool WebRtcSession::Initialize(
const PeerConnectionInterface::RTCConfiguration& rtc_configuration) {
bundle_policy_ = rtc_configuration.bundle_policy;
rtcp_mux_policy_ = rtc_configuration.rtcp_mux_policy;
- transport_controller()->SetSslMaxProtocolVersion(options.ssl_max_version);
+ transport_controller_->SetSslMaxProtocolVersion(options.ssl_max_version);
// Obtain a certificate from RTCConfiguration if any were provided (optional).
rtc::scoped_refptr<rtc::RTCCertificate> certificate;
@@ -782,15 +798,6 @@ bool WebRtcSession::Initialize(
return true;
}
-cricket::IceConfig WebRtcSession::ParseIceConfig(
- const PeerConnectionInterface::RTCConfiguration& config) const {
- cricket::IceConfig ice_config;
- ice_config.receiving_timeout_ms = config.ice_connection_receiving_timeout;
- ice_config.gather_continually = (config.continual_gathering_policy ==
- PeerConnectionInterface::GATHER_CONTINUALLY);
- return ice_config;
-}
-
void WebRtcSession::Terminate() {
SetState(STATE_RECEIVEDTERMINATE);
RemoveUnusedChannels(NULL);
@@ -808,13 +815,13 @@ cricket::SecurePolicy WebRtcSession::SdesPolicy() const {
}
bool WebRtcSession::GetSslRole(rtc::SSLRole* role) {
- if (local_description() == NULL || remote_description() == NULL) {
+ if (!local_desc_ || !remote_desc_) {
LOG(LS_INFO) << "Local and Remote descriptions must be applied to get "
<< "SSL Role of the session.";
return false;
}
- return transport_controller()->GetSslRole(role);
+ return transport_controller_->GetSslRole(role);
}
void WebRtcSession::CreateOffer(
@@ -843,7 +850,8 @@ bool WebRtcSession::SetLocalDescription(SessionDescriptionInterface* desc,
// Update the initiator flag if this session is the initiator.
Action action = GetAction(desc->type());
if (state() == STATE_INIT && action == kOffer) {
- set_initiator(true);
+ initiator_ = true;
+ transport_controller_->SetIceRole(cricket::ICEROLE_CONTROLLING);
}
cricket::SecurePolicy sdes_policy =
@@ -854,24 +862,23 @@ bool WebRtcSession::SetLocalDescription(SessionDescriptionInterface* desc,
// Update the MediaContentDescription crypto settings as per the policy set.
UpdateSessionDescriptionSecurePolicy(crypto_required, desc->description());
- set_local_description(desc->description()->Copy());
local_desc_.reset(desc_temp.release());
// Transport and Media channels will be created only when offer is set.
- if (action == kOffer && !CreateChannels(local_desc_->description())) {
+ if (action == kOffer && !CreateChannels(base_local_description())) {
// TODO(mallinath) - Handle CreateChannel failure, as new local description
// is applied. Restore back to old description.
return BadLocalSdp(desc->type(), kCreateChannelFailed, err_desc);
}
// Remove unused channels if MediaContentDescription is rejected.
- RemoveUnusedChannels(local_desc_->description());
+ RemoveUnusedChannels(base_local_description());
if (!UpdateSessionState(action, cricket::CS_LOCAL, err_desc)) {
return false;
}
- if (remote_description()) {
+ if (remote_desc_) {
// Now that we have a local description, we can push down remote candidates
// that we stored, and those from the remote description.
if (!saved_candidates_.empty()) {
@@ -891,7 +898,7 @@ bool WebRtcSession::SetLocalDescription(SessionDescriptionInterface* desc,
if (data_channel_type_ == cricket::DCT_SCTP && GetSslRole(&role)) {
mediastream_signaling_->OnDtlsRoleReadyForSctp(role);
}
- if (error() != cricket::BaseSession::ERROR_NONE) {
+ if (error() != ERROR_NONE) {
return BadLocalSdp(desc->type(), GetSessionErrorMsg(), err_desc);
}
return true;
@@ -909,6 +916,10 @@ bool WebRtcSession::SetRemoteDescription(SessionDescriptionInterface* desc,
return false;
}
+ rtc::scoped_ptr<SessionDescriptionInterface> old_remote_desc(
+ remote_desc_.release());
+ remote_desc_.reset(desc_temp.release());
+
// Transport and Media channels will be created only when offer is set.
Action action = GetAction(desc->type());
if (action == kOffer && !CreateChannels(desc->description())) {
@@ -922,40 +933,38 @@ bool WebRtcSession::SetRemoteDescription(SessionDescriptionInterface* desc,
// NOTE: Candidates allocation will be initiated only when SetLocalDescription
// is called.
- set_remote_description(desc->description()->Copy());
if (!UpdateSessionState(action, cricket::CS_REMOTE, err_desc)) {
return false;
}
// Update remote MediaStreams.
mediastream_signaling_->OnRemoteDescriptionChanged(desc);
- if (local_description() && !UseCandidatesInSessionDescription(desc)) {
- return BadRemoteSdp(desc->type(), kInvalidCandidates, err_desc);
- }
// Copy all saved candidates.
CopySavedCandidates(desc);
+ if (local_desc_ && !UseCandidatesInSessionDescription(desc)) {
+ return BadRemoteSdp(desc->type(), kInvalidCandidates, err_desc);
+ }
+
// Check if this new SessionDescription contains new ice ufrag and password
// that indicates the remote peer requests ice restart.
bool ice_restart =
- ice_restart_latch_->CheckForRemoteIceRestart(remote_desc_.get(), desc);
+ ice_restart_latch_->CheckForRemoteIceRestart(old_remote_desc.get(), desc);
// We retain all received candidates only if ICE is not restarted.
// When ICE is restarted, all previous candidates belong to an old generation
// and should not be kept.
if (!ice_restart) {
WebRtcSessionDescriptionFactory::CopyCandidatesFromSessionDescription(
- remote_desc_.get(), desc);
+ old_remote_desc.get(), desc);
}
- remote_desc_.reset(desc_temp.release());
-
rtc::SSLRole role;
if (data_channel_type_ == cricket::DCT_SCTP && GetSslRole(&role)) {
mediastream_signaling_->OnDtlsRoleReadyForSctp(role);
}
- if (error() != cricket::BaseSession::ERROR_NONE) {
+ if (error() != ERROR_NONE) {
return BadRemoteSdp(desc->type(), GetSessionErrorMsg(), err_desc);
}
@@ -974,6 +983,48 @@ bool WebRtcSession::SetRemoteDescription(SessionDescriptionInterface* desc,
return true;
}
+void WebRtcSession::OnMessage(rtc::Message* pmsg) {
+ switch (pmsg->message_id) {
+ case MSG_STATE:
+ switch (state_) {
+ case STATE_SENTACCEPT:
+ case STATE_RECEIVEDACCEPT:
+ SetState(STATE_INPROGRESS);
+ break;
+
+ default:
+ // Explicitly ignoring some states here.
+ break;
+ }
+ break;
+ }
+}
+
+void WebRtcSession::LogState(State old_state, State new_state) {
+ LOG(LS_INFO) << "Session:" << id()
+ << " Old state:" << GetStateString(old_state)
+ << " New state:" << GetStateString(new_state);
+}
+
+void WebRtcSession::SetState(State state) {
+ ASSERT(signaling_thread_->IsCurrent());
+ if (state != state_) {
+ LogState(state_, state);
+ state_ = state;
+ SignalState(this, state_);
+ signaling_thread_->Post(this, MSG_STATE);
pthatcher1 2015/10/09 03:28:57 The whole point of this is to convert STATE_SENTAC
Taylor Brandstetter 2015/10/09 23:02:06 Done.
+ }
+}
+
+void WebRtcSession::SetError(Error error, const std::string& error_desc) {
+ ASSERT(signaling_thread_->IsCurrent());
+ if (error != error_) {
+ error_ = error;
+ error_desc_ = error_desc;
+ SignalError(this, error);
+ }
+}
+
bool WebRtcSession::UpdateSessionState(
Action action, cricket::ContentSource source,
std::string* err_desc) {
@@ -981,7 +1032,7 @@ bool WebRtcSession::UpdateSessionState(
// If there's already a pending error then no state transition should happen.
// But all call-sites should be verifying this before calling us!
- ASSERT(error() == cricket::BaseSession::ERROR_NONE);
+ ASSERT(error() == ERROR_NONE);
std::string td_err;
if (action == kOffer) {
if (!PushdownTransportDescription(source, cricket::CA_OFFER, &td_err)) {
@@ -990,9 +1041,9 @@ bool WebRtcSession::UpdateSessionState(
SetState(source == cricket::CS_LOCAL ?
STATE_SENTINITIATE : STATE_RECEIVEDINITIATE);
if (!PushdownMediaDescription(cricket::CA_OFFER, source, err_desc)) {
- SetError(BaseSession::ERROR_CONTENT, *err_desc);
+ SetError(ERROR_CONTENT, *err_desc);
}
- if (error() != cricket::BaseSession::ERROR_NONE) {
+ if (error() != ERROR_NONE) {
return BadOfferSdp(source, GetSessionErrorMsg(), err_desc);
}
} else if (action == kPrAnswer) {
@@ -1003,9 +1054,9 @@ bool WebRtcSession::UpdateSessionState(
SetState(source == cricket::CS_LOCAL ?
STATE_SENTPRACCEPT : STATE_RECEIVEDPRACCEPT);
if (!PushdownMediaDescription(cricket::CA_PRANSWER, source, err_desc)) {
- SetError(BaseSession::ERROR_CONTENT, *err_desc);
+ SetError(ERROR_CONTENT, *err_desc);
}
- if (error() != cricket::BaseSession::ERROR_NONE) {
+ if (error() != ERROR_NONE) {
return BadPranswerSdp(source, GetSessionErrorMsg(), err_desc);
}
} else if (action == kAnswer) {
@@ -1013,11 +1064,9 @@ bool WebRtcSession::UpdateSessionState(
return BadAnswerSdp(source, MakeTdErrorString(td_err), err_desc);
}
const cricket::ContentGroup* local_bundle =
- BaseSession::local_description()->GetGroupByName(
- cricket::GROUP_TYPE_BUNDLE);
+ base_local_description()->GetGroupByName(cricket::GROUP_TYPE_BUNDLE);
const cricket::ContentGroup* remote_bundle =
- BaseSession::remote_description()->GetGroupByName(
- cricket::GROUP_TYPE_BUNDLE);
+ base_remote_description()->GetGroupByName(cricket::GROUP_TYPE_BUNDLE);
if (local_bundle && remote_bundle) {
// The answerer decides the transport to bundle on
const cricket::ContentGroup* answer_bundle =
@@ -1031,15 +1080,27 @@ bool WebRtcSession::UpdateSessionState(
SetState(source == cricket::CS_LOCAL ?
STATE_SENTACCEPT : STATE_RECEIVEDACCEPT);
if (!PushdownMediaDescription(cricket::CA_ANSWER, source, err_desc)) {
- SetError(BaseSession::ERROR_CONTENT, *err_desc);
+ SetError(ERROR_CONTENT, *err_desc);
}
- if (error() != cricket::BaseSession::ERROR_NONE) {
+ if (error() != ERROR_NONE) {
return BadAnswerSdp(source, GetSessionErrorMsg(), err_desc);
}
}
return true;
}
+WebRtcSession::Action WebRtcSession::GetAction(const std::string& type) {
+ if (type == SessionDescriptionInterface::kOffer) {
+ return WebRtcSession::kOffer;
+ } else if (type == SessionDescriptionInterface::kPrAnswer) {
+ return WebRtcSession::kPrAnswer;
+ } else if (type == SessionDescriptionInterface::kAnswer) {
+ return WebRtcSession::kAnswer;
+ }
+ ASSERT(false && "unknown action type");
+ return WebRtcSession::kOffer;
+}
+
bool WebRtcSession::PushdownMediaDescription(
cricket::ContentAction action,
cricket::ContentSource source,
@@ -1061,19 +1122,76 @@ bool WebRtcSession::PushdownMediaDescription(
set_content(data_channel()));
}
-WebRtcSession::Action WebRtcSession::GetAction(const std::string& type) {
- if (type == SessionDescriptionInterface::kOffer) {
- return WebRtcSession::kOffer;
- } else if (type == SessionDescriptionInterface::kPrAnswer) {
- return WebRtcSession::kPrAnswer;
- } else if (type == SessionDescriptionInterface::kAnswer) {
- return WebRtcSession::kAnswer;
+bool WebRtcSession::PushdownTransportDescription(cricket::ContentSource source,
+ cricket::ContentAction action,
+ std::string* error_desc) {
+ RTC_DCHECK(signaling_thread()->IsCurrent());
+
+ if (source == cricket::CS_LOCAL) {
+ return PushdownLocalTransportDescription(base_local_description(), action,
+ error_desc);
}
- ASSERT(false && "unknown action type");
- return WebRtcSession::kOffer;
+ return PushdownRemoteTransportDescription(base_remote_description(), action,
+ error_desc);
}
-bool WebRtcSession::GetTransportStats(cricket::SessionStats* stats) {
+bool WebRtcSession::PushdownLocalTransportDescription(
+ const SessionDescription* sdesc,
+ cricket::ContentAction action,
+ std::string* err) {
+ RTC_DCHECK(signaling_thread()->IsCurrent());
+
+ if (!sdesc) {
+ return false;
+ }
+
+ for (const TransportInfo& tinfo : sdesc->transport_infos()) {
+ if (!transport_controller_->SetLocalTransportDescription(
+ tinfo.content_name, tinfo.description, action, err)) {
+ return false;
+ }
+ }
+
+ return true;
+}
+
+bool WebRtcSession::PushdownRemoteTransportDescription(
+ const SessionDescription* sdesc,
+ cricket::ContentAction action,
+ std::string* err) {
+ RTC_DCHECK(signaling_thread()->IsCurrent());
+
+ if (!sdesc) {
+ return false;
+ }
+
+ for (const TransportInfo& tinfo : sdesc->transport_infos()) {
+ if (!transport_controller_->SetRemoteTransportDescription(
+ tinfo.content_name, tinfo.description, action, err)) {
+ return false;
+ }
+ }
+
+ return true;
+}
+
+bool WebRtcSession::GetTransportDescription(
+ const SessionDescription* description,
+ const std::string& content_name,
+ cricket::TransportDescription* tdesc) {
+ if (!description || !tdesc) {
+ return false;
+ }
+ const TransportInfo* transport_info =
+ description->GetTransportInfoByName(content_name);
+ if (!transport_info) {
+ return false;
+ }
+ *tdesc = transport_info->description;
+ return true;
+}
+
+bool WebRtcSession::GetTransportStats(SessionStats* stats) {
ASSERT(signaling_thread()->IsCurrent());
return (GetChannelTransportStats(voice_channel(), stats) &&
GetChannelTransportStats(video_channel(), stats) &&
@@ -1081,7 +1199,7 @@ bool WebRtcSession::GetTransportStats(cricket::SessionStats* stats) {
}
bool WebRtcSession::GetChannelTransportStats(cricket::BaseChannel* ch,
- cricket::SessionStats* stats) {
+ SessionStats* stats) {
ASSERT(signaling_thread()->IsCurrent());
if (!ch) {
// Not using this channel.
@@ -1098,7 +1216,7 @@ bool WebRtcSession::GetChannelTransportStats(cricket::BaseChannel* ch,
}
cricket::TransportStats tstats;
- if (!transport_controller()->GetStats(transport_name, &tstats)) {
+ if (!transport_controller_->GetStats(transport_name, &tstats)) {
return false;
}
@@ -1110,14 +1228,14 @@ bool WebRtcSession::GetLocalCertificate(
const std::string& transport_name,
rtc::scoped_refptr<rtc::RTCCertificate>* certificate) {
ASSERT(signaling_thread()->IsCurrent());
- return transport_controller()->GetLocalCertificate(transport_name,
- certificate);
+ return transport_controller_->GetLocalCertificate(transport_name,
+ certificate);
}
bool WebRtcSession::GetRemoteSSLCertificate(const std::string& transport_name,
rtc::SSLCertificate** cert) {
ASSERT(signaling_thread()->IsCurrent());
- return transport_controller()->GetRemoteSSLCertificate(transport_name, cert);
+ return transport_controller_->GetRemoteSSLCertificate(transport_name, cert);
}
cricket::BaseChannel* WebRtcSession::GetChannel(
@@ -1213,17 +1331,36 @@ bool WebRtcSession::SetIceTransports(
ConvertIceTransportTypeToCandidateFilter(type));
}
+cricket::IceConfig WebRtcSession::ParseIceConfig(
+ const PeerConnectionInterface::RTCConfiguration& config) const {
+ cricket::IceConfig ice_config;
+ ice_config.receiving_timeout_ms = config.ice_connection_receiving_timeout;
+ ice_config.gather_continually = (config.continual_gathering_policy ==
+ PeerConnectionInterface::GATHER_CONTINUALLY);
+ return ice_config;
+}
+
+void WebRtcSession::SetIceConfig(const cricket::IceConfig& config) {
+ transport_controller_->SetIceConfig(config);
+}
+
+void WebRtcSession::MaybeStartGathering() {
+ transport_controller_->MaybeStartGathering();
+}
+
bool WebRtcSession::GetLocalTrackIdBySsrc(uint32_t ssrc,
std::string* track_id) {
- if (!base_local_description())
+ if (!local_desc_) {
return false;
+ }
return webrtc::GetTrackIdBySsrc(base_local_description(), ssrc, track_id);
}
bool WebRtcSession::GetRemoteTrackIdBySsrc(uint32_t ssrc,
std::string* track_id) {
- if (!base_remote_description())
+ if (!remote_desc_) {
return false;
+ }
return webrtc::GetTrackIdBySsrc(base_remote_description(), ssrc, track_id);
}
@@ -1480,7 +1617,7 @@ void WebRtcSession::ResetIceRestartLatch() {
void WebRtcSession::OnCertificateReady(
const rtc::scoped_refptr<rtc::RTCCertificate>& certificate) {
- transport_controller()->SetLocalCertificate(certificate);
+ transport_controller_->SetLocalCertificate(certificate);
}
bool WebRtcSession::waiting_for_certificate_for_testing() const {
@@ -1489,7 +1626,7 @@ bool WebRtcSession::waiting_for_certificate_for_testing() const {
const rtc::scoped_refptr<rtc::RTCCertificate>&
WebRtcSession::certificate_for_testing() {
- return transport_controller()->certificate_for_testing();
+ return transport_controller_->certificate_for_testing();
}
void WebRtcSession::SetIceConnectionState(
@@ -1642,8 +1779,9 @@ void WebRtcSession::EnableChannels() {
// Returns the media index for a local ice candidate given the content name.
bool WebRtcSession::GetLocalCandidateMediaIndex(const std::string& content_name,
int* sdp_mline_index) {
- if (!base_local_description() || !sdp_mline_index)
+ if (!local_desc_ || !sdp_mline_index) {
return false;
+ }
bool content_found = false;
const ContentInfos& contents = base_local_description()->contents();
@@ -1659,8 +1797,9 @@ bool WebRtcSession::GetLocalCandidateMediaIndex(const std::string& content_name,
bool WebRtcSession::UseCandidatesInSessionDescription(
const SessionDescriptionInterface* remote_desc) {
- if (!remote_desc)
+ if (!remote_desc) {
return true;
+ }
bool ret = true;
for (size_t m = 0; m < remote_desc->number_of_mediasections(); ++m) {
@@ -1703,8 +1842,8 @@ bool WebRtcSession::UseCandidate(
candidates.push_back(candidate->candidate());
// Invoking BaseSession method to handle remote candidates.
std::string error;
- if (transport_controller()->AddRemoteCandidates(content.name, candidates,
- &error)) {
+ if (transport_controller_->AddRemoteCandidates(content.name, candidates,
+ &error)) {
// Candidates successfully submitted for checking.
if (ice_connection_state_ == PeerConnectionInterface::kIceConnectionNew ||
ice_connection_state_ ==
@@ -1819,7 +1958,7 @@ bool WebRtcSession::CreateChannels(const SessionDescription* desc) {
bool WebRtcSession::CreateVoiceChannel(const cricket::ContentInfo* content) {
voice_channel_.reset(channel_manager_->CreateVoiceChannel(
- media_controller_.get(), transport_controller(), content->name, true,
+ media_controller_.get(), transport_controller_.get(), content->name, true,
audio_options_));
if (!voice_channel_) {
return false;
@@ -1832,7 +1971,7 @@ bool WebRtcSession::CreateVoiceChannel(const cricket::ContentInfo* content) {
bool WebRtcSession::CreateVideoChannel(const cricket::ContentInfo* content) {
video_channel_.reset(channel_manager_->CreateVideoChannel(
- media_controller_.get(), transport_controller(), content->name, true,
+ media_controller_.get(), transport_controller_.get(), content->name, true,
video_options_));
if (!video_channel_) {
return false;
@@ -1846,7 +1985,7 @@ bool WebRtcSession::CreateVideoChannel(const cricket::ContentInfo* content) {
bool WebRtcSession::CreateDataChannel(const cricket::ContentInfo* content) {
bool sctp = (data_channel_type_ == cricket::DCT_SCTP);
data_channel_.reset(channel_manager_->CreateDataChannel(
- transport_controller(), content->name, !sctp, data_channel_type_));
+ transport_controller_.get(), content->name, !sctp, data_channel_type_));
if (!data_channel_) {
return false;
}
@@ -1866,8 +2005,8 @@ bool WebRtcSession::CreateDataChannel(const cricket::ContentInfo* content) {
}
void WebRtcSession::OnDtlsSetupFailure(cricket::BaseChannel*, bool rtcp) {
- SetError(BaseSession::ERROR_TRANSPORT, rtcp ? kDtlsSetupFailureRtcp :
- kDtlsSetupFailureRtp);
+ SetError(ERROR_TRANSPORT,
+ rtcp ? kDtlsSetupFailureRtcp : kDtlsSetupFailureRtp);
}
void WebRtcSession::CopySavedCandidates(
@@ -1932,7 +2071,7 @@ bool WebRtcSession::ValidateSessionDescription(
const SessionDescriptionInterface* sdesc,
cricket::ContentSource source, std::string* err_desc) {
std::string type;
- if (error() != cricket::BaseSession::ERROR_NONE) {
+ if (error() != ERROR_NONE) {
return BadSdp(source, type, GetSessionErrorMsg(), err_desc);
}
@@ -1970,8 +2109,8 @@ bool WebRtcSession::ValidateSessionDescription(
// Verify m-lines in Answer when compared against Offer.
if (action == kAnswer) {
const cricket::SessionDescription* offer_desc =
- (source == cricket::CS_LOCAL) ? remote_description()->description() :
- local_description()->description();
+ (source == cricket::CS_LOCAL) ? base_remote_description()
+ : base_local_description();
if (!VerifyMediaDescriptions(sdesc->description(), offer_desc)) {
return BadAnswerSdp(source, kMlineMismatch, err_desc);
}
@@ -2029,10 +2168,11 @@ bool WebRtcSession::ReadyToUseRemoteCandidate(
*valid = true;;
const SessionDescriptionInterface* current_remote_desc =
- remote_desc ? remote_desc : remote_description();
+ remote_desc ? remote_desc : remote_desc_.get();
- if (!current_remote_desc)
+ if (!current_remote_desc) {
return false;
+ }
size_t mediacontent_index =
static_cast<size_t>(candidate->sdp_mline_index());
@@ -2053,7 +2193,7 @@ bool WebRtcSession::ReadyToUseRemoteCandidate(
return false;
}
- return transport_controller()->ReadyForRemoteCandidates(
+ return transport_controller_->ReadyForRemoteCandidates(
channel->transport_name());
}
@@ -2089,7 +2229,7 @@ void WebRtcSession::ReportTransportStats() {
}
for (const auto& name : transport_names) {
cricket::TransportStats stats;
- if (transport_controller()->GetStats(name, &stats)) {
+ if (transport_controller_->GetStats(name, &stats)) {
ReportBestConnectionState(stats);
ReportNegotiatedCiphers(stats);
}

Powered by Google App Engine
This is Rietveld 408576698