#include "talk/p2p/base/session.h"
-#include "talk/base/bind.h"
-#include "talk/base/common.h"
-#include "talk/base/logging.h"
-#include "talk/base/helpers.h"
-#include "talk/base/scoped_ptr.h"
-#include "talk/base/sslstreamadapter.h"
-#include "talk/xmpp/constants.h"
-#include "talk/xmpp/jid.h"
#include "talk/p2p/base/dtlstransport.h"
#include "talk/p2p/base/p2ptransport.h"
#include "talk/p2p/base/sessionclient.h"
#include "talk/p2p/base/transport.h"
#include "talk/p2p/base/transportchannelproxy.h"
#include "talk/p2p/base/transportinfo.h"
+#include "talk/xmpp/constants.h"
+#include "talk/xmpp/jid.h"
+#include "webrtc/base/bind.h"
+#include "webrtc/base/common.h"
+#include "webrtc/base/helpers.h"
+#include "webrtc/base/logging.h"
+#include "webrtc/base/scoped_ptr.h"
+#include "webrtc/base/sslstreamadapter.h"
#include "talk/p2p/base/constants.h"
namespace cricket {
-using talk_base::Bind;
+using rtc::Bind;
bool BadMessage(const buzz::QName type,
const std::string& text,
}
}
-std::string TransportProxy::type() const {
+const std::string& TransportProxy::type() const {
return transport_->get()->type();
}
TransportChannel* TransportProxy::GetChannel(int component) {
- ASSERT(talk_base::Thread::Current() == worker_thread_);
+ ASSERT(rtc::Thread::Current() == worker_thread_);
return GetChannelProxy(component);
}
TransportChannel* TransportProxy::CreateChannel(
const std::string& name, int component) {
- ASSERT(talk_base::Thread::Current() == worker_thread_);
+ ASSERT(rtc::Thread::Current() == worker_thread_);
ASSERT(GetChannel(component) == NULL);
ASSERT(!transport_->get()->HasChannel(component));
}
void TransportProxy::DestroyChannel(int component) {
- ASSERT(talk_base::Thread::Current() == worker_thread_);
+ ASSERT(rtc::Thread::Current() == worker_thread_);
TransportChannel* channel = GetChannel(component);
if (channel) {
// If the state of TransportProxy is not NEGOTIATED
TransportChannelImpl* TransportProxy::GetOrCreateChannelProxyImpl_w(
int component) {
- ASSERT(talk_base::Thread::Current() == worker_thread_);
+ ASSERT(rtc::Thread::Current() == worker_thread_);
TransportChannelImpl* impl = transport_->get()->GetChannel(component);
if (impl == NULL) {
impl = transport_->get()->CreateChannel(component);
void TransportProxy::SetupChannelProxy_w(
int component, TransportChannelProxy* transproxy) {
- ASSERT(talk_base::Thread::Current() == worker_thread_);
+ ASSERT(rtc::Thread::Current() == worker_thread_);
TransportChannelImpl* impl = GetOrCreateChannelProxyImpl(component);
ASSERT(impl != NULL);
transproxy->SetImplementation(impl);
void TransportProxy::ReplaceChannelProxyImpl_w(TransportChannelProxy* proxy,
TransportChannelImpl* impl) {
- ASSERT(talk_base::Thread::Current() == worker_thread_);
+ ASSERT(rtc::Thread::Current() == worker_thread_);
ASSERT(proxy != NULL);
proxy->SetImplementation(impl);
}
if (action == CA_ANSWER) {
CompleteNegotiation();
}
- return transport_->get()->SetLocalTransportDescription(description,
- action,
- error_desc);
+ bool result = transport_->get()->SetLocalTransportDescription(description,
+ action,
+ error_desc);
+ if (result)
+ local_description_set_ = true;
+ return result;
}
bool TransportProxy::SetRemoteTransportDescription(
if (action == CA_ANSWER) {
CompleteNegotiation();
}
- return transport_->get()->SetRemoteTransportDescription(description,
- action,
- error_desc);
+ bool result = transport_->get()->SetRemoteTransportDescription(description,
+ action,
+ error_desc);
+ if (result)
+ remote_description_set_ = true;
+ return result;
}
void TransportProxy::OnSignalingReady() {
}
void TransportProxy::SetIdentity(
- talk_base::SSLIdentity* identity) {
+ rtc::SSLIdentity* identity) {
transport_->get()->SetIdentity(identity);
}
default:
break;
}
- return "STATE_" + talk_base::ToString(state);
+ return "STATE_" + rtc::ToString(state);
}
-BaseSession::BaseSession(talk_base::Thread* signaling_thread,
- talk_base::Thread* worker_thread,
+BaseSession::BaseSession(rtc::Thread* signaling_thread,
+ rtc::Thread* worker_thread,
PortAllocator* port_allocator,
const std::string& sid,
const std::string& content_type,
transport_type_(NS_GINGLE_P2P),
initiator_(initiator),
identity_(NULL),
- local_description_(NULL),
- remote_description_(NULL),
- ice_tiebreaker_(talk_base::CreateRandomId64()),
+ ice_tiebreaker_(rtc::CreateRandomId64()),
role_switch_(false) {
ASSERT(signaling_thread->IsCurrent());
}
iter != transports_.end(); ++iter) {
delete iter->second;
}
+}
+
+const SessionDescription* BaseSession::local_description() const {
+ // TODO(tommi): Assert on thread correctness.
+ return local_description_.get();
+}
+
+const SessionDescription* BaseSession::remote_description() const {
+ // TODO(tommi): Assert on thread correctness.
+ return remote_description_.get();
+}
- delete remote_description_;
- delete local_description_;
+SessionDescription* BaseSession::remote_description() {
+ // TODO(tommi): Assert on thread correctness.
+ return remote_description_.get();
}
-bool BaseSession::SetIdentity(talk_base::SSLIdentity* identity) {
+void BaseSession::set_local_description(const SessionDescription* sdesc) {
+ // TODO(tommi): Assert on thread correctness.
+ if (sdesc != local_description_.get())
+ local_description_.reset(sdesc);
+}
+
+void BaseSession::set_remote_description(SessionDescription* sdesc) {
+ // TODO(tommi): Assert on thread correctness.
+ if (sdesc != remote_description_)
+ remote_description_.reset(sdesc);
+}
+
+const SessionDescription* BaseSession::initiator_description() const {
+ // TODO(tommi): Assert on thread correctness.
+ return initiator_ ? local_description_.get() : remote_description_.get();
+}
+
+bool BaseSession::SetIdentity(rtc::SSLIdentity* identity) {
if (identity_)
return false;
identity_ = identity;
ContentAction action,
std::string* error_desc) {
if (source == CS_LOCAL) {
- return PushdownLocalTransportDescription(local_description_,
+ return PushdownLocalTransportDescription(local_description(),
action,
error_desc);
}
- return PushdownRemoteTransportDescription(remote_description_,
+ return PushdownRemoteTransportDescription(remote_description(),
action,
error_desc);
}
TransportProxy* transproxy = GetTransportProxy(content_name);
if (transproxy == NULL)
return NULL;
- else
- return transproxy->GetChannel(component);
+
+ return transproxy->GetChannel(component);
}
void BaseSession::DestroyChannel(const std::string& content_name,
this, &BaseSession::OnTransportCandidatesAllocationDone);
transport->SignalRoleConflict.connect(
this, &BaseSession::OnRoleConflict);
+ transport->SignalCompleted.connect(
+ this, &BaseSession::OnTransportCompleted);
+ transport->SignalFailed.connect(
+ this, &BaseSession::OnTransportFailed);
transproxy = new TransportProxy(worker_thread_, sid_, content_name,
new TransportWrapper(transport));
transproxy->SignalCandidatesReady.connect(
this, &BaseSession::OnTransportProxyCandidatesReady);
+ if (identity_)
+ transproxy->SetIdentity(identity_);
transports_[content_name] = transproxy;
return transproxy;
// Transport, since this removes the need to manually iterate over all
// the transports, as is needed to make sure signals are handled properly
// when BUNDLEing.
-#if 0
- ASSERT(!IsCandidateAllocationDone());
-#endif
+ // TODO(juberti): Per b/7998978, devs and QA are hitting this assert in ways
+ // that make it prohibitively difficult to run dbg builds. Disabled for now.
+ //ASSERT(!IsCandidateAllocationDone());
for (TransportMap::iterator iter = transports_.begin();
iter != transports_.end(); ++iter) {
if (iter->second->impl() == transport) {
<< " Transport:" << transport_type();
}
+// static
bool BaseSession::GetTransportDescription(const SessionDescription* description,
const std::string& content_name,
TransportDescription* tdesc) {
return true;
}
-void BaseSession::OnMessage(talk_base::Message *pmsg) {
+void BaseSession::OnMessage(rtc::Message *pmsg) {
switch (pmsg->message_id) {
case MSG_TIMEOUT:
// Session timeout has occured.
delete transport_parser_;
}
-bool Session::Initiate(const std::string &to,
+bool Session::Initiate(const std::string& to,
const SessionDescription* sdesc) {
ASSERT(signaling_thread()->IsCurrent());
SessionError error;
}
void Session::OnInitiateAcked() {
- // TODO: This is to work around server re-ordering
- // messages. We send the candidates once the session-initiate
- // is acked. Once we have fixed the server to guarantee message
- // order, we can remove this case.
+ // TODO: This is to work around server re-ordering
+ // messages. We send the candidates once the session-initiate
+ // is acked. Once we have fixed the server to guarantee message
+ // order, we can remove this case.
if (!initiate_acked_) {
initiate_acked_ = true;
SessionError error;
signaling_thread()->Post(this, MSG_ERROR);
}
-void Session::OnMessage(talk_base::Message* pmsg) {
+void Session::OnMessage(rtc::Message* pmsg) {
// preserve this because BaseSession::OnMessage may modify it
State orig_state = state();
bool Session::SendMessage(ActionType type, const XmlElements& action_elems,
const std::string& remote_name, SessionError* error) {
- talk_base::scoped_ptr<buzz::XmlElement> stanza(
+ rtc::scoped_ptr<buzz::XmlElement> stanza(
new buzz::XmlElement(buzz::QN_IQ));
SessionMessage msg(current_protocol_, type, id(), initiator_name());
template <typename Action>
bool Session::SendMessage(ActionType type, const Action& action,
SessionError* error) {
- talk_base::scoped_ptr<buzz::XmlElement> stanza(
+ rtc::scoped_ptr<buzz::XmlElement> stanza(
new buzz::XmlElement(buzz::QN_IQ));
if (!WriteActionMessage(type, action, stanza.get(), error))
return false;
}
void Session::SendAcknowledgementMessage(const buzz::XmlElement* stanza) {
- talk_base::scoped_ptr<buzz::XmlElement> ack(
+ rtc::scoped_ptr<buzz::XmlElement> ack(
new buzz::XmlElement(buzz::QN_IQ));
ack->SetAttr(buzz::QN_TO, remote_name());
ack->SetAttr(buzz::QN_ID, stanza->Attr(buzz::QN_ID));