#ifndef TALK_P2P_BASE_TRANSPORT_H_
#define TALK_P2P_BASE_TRANSPORT_H_
-#include <string>
#include <map>
+#include <string>
#include <vector>
-#include "talk/base/criticalsection.h"
-#include "talk/base/messagequeue.h"
-#include "talk/base/sigslot.h"
-#include "talk/base/sslstreamadapter.h"
#include "talk/p2p/base/candidate.h"
#include "talk/p2p/base/constants.h"
#include "talk/p2p/base/sessiondescription.h"
#include "talk/p2p/base/transportinfo.h"
+#include "webrtc/base/criticalsection.h"
+#include "webrtc/base/messagequeue.h"
+#include "webrtc/base/sigslot.h"
+#include "webrtc/base/sslstreamadapter.h"
-namespace talk_base {
+namespace rtc {
class Thread;
}
bool ParseAddress(const buzz::XmlElement* elem,
const buzz::QName& address_name,
const buzz::QName& port_name,
- talk_base::SocketAddress* address,
+ rtc::SocketAddress* address,
ParseError* error);
virtual ~TransportParser() {}
TransportChannelStatsList channel_stats;
};
-class Transport : public talk_base::MessageHandler,
+bool BadTransportDescription(const std::string& desc, std::string* err_desc);
+
+bool IceCredentialsChanged(const std::string& old_ufrag,
+ const std::string& old_pwd,
+ const std::string& new_ufrag,
+ const std::string& new_pwd);
+
+class Transport : public rtc::MessageHandler,
public sigslot::has_slots<> {
public:
- Transport(talk_base::Thread* signaling_thread,
- talk_base::Thread* worker_thread,
+ Transport(rtc::Thread* signaling_thread,
+ rtc::Thread* worker_thread,
const std::string& content_name,
const std::string& type,
PortAllocator* allocator);
virtual ~Transport();
// Returns the signaling thread. The app talks to Transport on this thread.
- talk_base::Thread* signaling_thread() { return signaling_thread_; }
+ rtc::Thread* signaling_thread() { return signaling_thread_; }
// Returns the worker thread. The actual networking is done on this thread.
- talk_base::Thread* worker_thread() { return worker_thread_; }
+ rtc::Thread* worker_thread() { return worker_thread_; }
// Returns the content_name of this transport.
const std::string& content_name() const { return content_name_; }
}
sigslot::signal1<Transport*> SignalReadableState;
sigslot::signal1<Transport*> SignalWritableState;
+ sigslot::signal1<Transport*> SignalCompleted;
+ sigslot::signal1<Transport*> SignalFailed;
// Returns whether the client has requested the channels to connect.
bool connect_requested() const { return connect_requested_; }
uint64 IceTiebreaker() { return tiebreaker_; }
// Must be called before applying local session description.
- void SetIdentity(talk_base::SSLIdentity* identity);
+ void SetIdentity(rtc::SSLIdentity* identity);
// Get a copy of the local identity provided by SetIdentity.
- bool GetIdentity(talk_base::SSLIdentity** identity);
+ bool GetIdentity(rtc::SSLIdentity** identity);
// Get a copy of the remote certificate in use by the specified channel.
- bool GetRemoteCertificate(talk_base::SSLCertificate** cert);
+ bool GetRemoteCertificate(rtc::SSLCertificate** cert);
TransportProtocol protocol() const { return protocol_; }
// Set the local TransportDescription to be used by TransportChannels.
// This should be called before ConnectChannels().
bool SetLocalTransportDescription(const TransportDescription& description,
- ContentAction action);
+ ContentAction action,
+ std::string* error_desc);
// Set the remote TransportDescription to be used by TransportChannels.
bool SetRemoteTransportDescription(const TransportDescription& description,
- ContentAction action);
+ ContentAction action,
+ std::string* error_desc);
// Tells all current and future channels to start connecting. When the first
// channel begins connecting, the following signal is raised.
// Forwards the signal from TransportChannel to BaseSession.
sigslot::signal0<> SignalRoleConflict;
- virtual bool GetSslRole(talk_base::SSLRole* ssl_role) const;
+ virtual bool GetSslRole(rtc::SSLRole* ssl_role) const;
protected:
// These are called by Create/DestroyChannel above in order to create or
return remote_description_.get();
}
- virtual void SetIdentity_w(talk_base::SSLIdentity* identity) {}
+ virtual void SetIdentity_w(rtc::SSLIdentity* identity) {}
- virtual bool GetIdentity_w(talk_base::SSLIdentity** identity) {
+ virtual bool GetIdentity_w(rtc::SSLIdentity** identity) {
return false;
}
// Pushes down the transport parameters from the local description, such
// as the ICE ufrag and pwd.
// Derived classes can override, but must call the base as well.
- virtual bool ApplyLocalTransportDescription_w(TransportChannelImpl*
- channel);
+ virtual bool ApplyLocalTransportDescription_w(TransportChannelImpl* channel,
+ std::string* error_desc);
// Pushes down remote ice credentials from the remote description to the
// transport channel.
- virtual bool ApplyRemoteTransportDescription_w(TransportChannelImpl* ch);
+ virtual bool ApplyRemoteTransportDescription_w(TransportChannelImpl* ch,
+ std::string* error_desc);
// Negotiates the transport parameters based on the current local and remote
// transport description, such at the version of ICE to use, and whether DTLS
// should be activated.
// Derived classes can negotiate their specific parameters here, but must call
// the base as well.
- virtual bool NegotiateTransportDescription_w(ContentAction local_role);
+ virtual bool NegotiateTransportDescription_w(ContentAction local_role,
+ std::string* error_desc);
// Pushes down the transport parameters obtained via negotiation.
// Derived classes can set their specific parameters here, but must call the
// base as well.
virtual bool ApplyNegotiatedTransportDescription_w(
- TransportChannelImpl* channel);
+ TransportChannelImpl* channel, std::string* error_desc);
- virtual bool GetSslRole_w(talk_base::SSLRole* ssl_role) const {
+ virtual bool GetSslRole_w(rtc::SSLRole* ssl_role) const {
return false;
}
void OnChannelCandidatesAllocationDone(TransportChannelImpl* channel);
// Called when there is ICE role change.
void OnRoleConflict(TransportChannelImpl* channel);
+ // Called when the channel removes a connection.
+ void OnChannelConnectionRemoved(TransportChannelImpl* channel);
// Dispatches messages to the appropriate handler (below).
- void OnMessage(talk_base::Message* msg);
+ void OnMessage(rtc::Message* msg);
// These are versions of the above methods that are called only on a
// particular thread (s = signaling, w = worker). The above methods post or
void SetIceRole_w(IceRole role);
void SetRemoteIceMode_w(IceMode mode);
bool SetLocalTransportDescription_w(const TransportDescription& desc,
- ContentAction action);
+ ContentAction action,
+ std::string* error_desc);
bool SetRemoteTransportDescription_w(const TransportDescription& desc,
- ContentAction action);
+ ContentAction action,
+ std::string* error_desc);
bool GetStats_w(TransportStats* infos);
- bool GetRemoteCertificate_w(talk_base::SSLCertificate** cert);
+ bool GetRemoteCertificate_w(rtc::SSLCertificate** cert);
+ // Sends SignalCompleted if we are now in that state.
+ void MaybeCompleted_w();
- talk_base::Thread* signaling_thread_;
- talk_base::Thread* worker_thread_;
+ rtc::Thread* signaling_thread_;
+ rtc::Thread* worker_thread_;
std::string content_name_;
std::string type_;
PortAllocator* allocator_;
uint64 tiebreaker_;
TransportProtocol protocol_;
IceMode remote_ice_mode_;
- talk_base::scoped_ptr<TransportDescription> local_description_;
- talk_base::scoped_ptr<TransportDescription> remote_description_;
+ rtc::scoped_ptr<TransportDescription> local_description_;
+ rtc::scoped_ptr<TransportDescription> remote_description_;
ChannelMap channels_;
// Buffers the ready_candidates so that SignalCanidatesReady can
// provide them in multiples.
std::vector<Candidate> ready_candidates_;
// Protects changes to channels and messages
- talk_base::CriticalSection crit_;
+ rtc::CriticalSection crit_;
DISALLOW_EVIL_CONSTRUCTORS(Transport);
};