#include <string>
#include <vector>
-#include "talk/base/buffer.h"
-#include "talk/base/fakesslidentity.h"
-#include "talk/base/sigslot.h"
-#include "talk/base/sslfingerprint.h"
-#include "talk/base/messagequeue.h"
#include "talk/p2p/base/session.h"
#include "talk/p2p/base/transport.h"
#include "talk/p2p/base/transportchannel.h"
#include "talk/p2p/base/transportchannelimpl.h"
+#include "webrtc/base/buffer.h"
+#include "webrtc/base/fakesslidentity.h"
+#include "webrtc/base/messagequeue.h"
+#include "webrtc/base/sigslot.h"
+#include "webrtc/base/sslfingerprint.h"
namespace cricket {
class FakeTransport;
-struct PacketMessageData : public talk_base::MessageData {
+struct PacketMessageData : public rtc::MessageData {
PacketMessageData(const char* data, size_t len) : packet(data, len) {
}
- talk_base::Buffer packet;
+ rtc::Buffer packet;
};
// Fake transport channel class, which can be passed to anything that needs a
// transport channel. Can be informed of another FakeTransportChannel via
// SetDestination.
class FakeTransportChannel : public TransportChannelImpl,
- public talk_base::MessageHandler {
+ public rtc::MessageHandler {
public:
explicit FakeTransportChannel(Transport* transport,
const std::string& content_name,
ice_proto_(ICEPROTO_HYBRID),
remote_ice_mode_(ICEMODE_FULL),
dtls_fingerprint_("", NULL, 0),
- ssl_role_(talk_base::SSL_CLIENT) {
+ ssl_role_(rtc::SSL_CLIENT),
+ connection_count_(0) {
}
~FakeTransportChannel() {
Reset();
const std::string& ice_pwd() const { return ice_pwd_; }
const std::string& remote_ice_ufrag() const { return remote_ice_ufrag_; }
const std::string& remote_ice_pwd() const { return remote_ice_pwd_; }
- const talk_base::SSLFingerprint& dtls_fingerprint() const {
+ const rtc::SSLFingerprint& dtls_fingerprint() const {
return dtls_fingerprint_;
}
virtual void SetIceRole(IceRole role) { role_ = role; }
virtual IceRole GetIceRole() const { return role_; }
+ virtual size_t GetConnectionCount() const { return connection_count_; }
virtual void SetIceTiebreaker(uint64 tiebreaker) { tiebreaker_ = tiebreaker; }
+ virtual bool GetIceProtocolType(IceProtocolType* type) const {
+ *type = ice_proto_;
+ return true;
+ }
virtual void SetIceProtocolType(IceProtocolType type) { ice_proto_ = type; }
virtual void SetIceCredentials(const std::string& ice_ufrag,
const std::string& ice_pwd) {
virtual void SetRemoteIceMode(IceMode mode) { remote_ice_mode_ = mode; }
virtual bool SetRemoteFingerprint(const std::string& alg, const uint8* digest,
size_t digest_len) {
- dtls_fingerprint_ = talk_base::SSLFingerprint(alg, digest, digest_len);
+ dtls_fingerprint_ = rtc::SSLFingerprint(alg, digest, digest_len);
return true;
}
- virtual bool SetSslRole(talk_base::SSLRole role) {
+ virtual bool SetSslRole(rtc::SSLRole role) {
ssl_role_ = role;
return true;
}
- virtual bool GetSslRole(talk_base::SSLRole* role) const {
+ virtual bool GetSslRole(rtc::SSLRole* role) const {
*role = ssl_role_;
return true;
}
}
}
+ void SetConnectionCount(size_t connection_count) {
+ size_t old_connection_count = connection_count_;
+ connection_count_ = connection_count;
+ if (connection_count_ < old_connection_count)
+ SignalConnectionRemoved(this);
+ }
+
virtual int SendPacket(const char* data, size_t len,
- talk_base::DiffServCodePoint dscp, int flags) {
+ const rtc::PacketOptions& options, int flags) {
if (state_ != STATE_CONNECTED) {
return -1;
}
PacketMessageData* packet = new PacketMessageData(data, len);
if (async_) {
- talk_base::Thread::Current()->Post(this, 0, packet);
+ rtc::Thread::Current()->Post(this, 0, packet);
} else {
- talk_base::Thread::Current()->Send(this, 0, packet);
+ rtc::Thread::Current()->Send(this, 0, packet);
}
return static_cast<int>(len);
}
- virtual int SetOption(talk_base::Socket::Option opt, int value) {
+ virtual int SetOption(rtc::Socket::Option opt, int value) {
return true;
}
virtual int GetError() {
virtual void OnCandidate(const Candidate& candidate) {
}
- virtual void OnMessage(talk_base::Message* msg) {
+ virtual void OnMessage(rtc::Message* msg) {
PacketMessageData* data = static_cast<PacketMessageData*>(
msg->pdata);
dest_->SignalReadPacket(dest_, data->packet.data(),
data->packet.length(),
- talk_base::CreatePacketTime(0), 0);
+ rtc::CreatePacketTime(0), 0);
delete data;
}
- bool SetLocalIdentity(talk_base::SSLIdentity* identity) {
+ bool SetLocalIdentity(rtc::SSLIdentity* identity) {
identity_ = identity;
return true;
}
- void SetRemoteCertificate(talk_base::FakeSSLCertificate* cert) {
+ void SetRemoteCertificate(rtc::FakeSSLCertificate* cert) {
remote_cert_ = cert;
}
return false;
}
- virtual bool GetLocalIdentity(talk_base::SSLIdentity** identity) const {
+ virtual bool GetLocalIdentity(rtc::SSLIdentity** identity) const {
if (!identity_)
return false;
return true;
}
- virtual bool GetRemoteCertificate(talk_base::SSLCertificate** cert) const {
+ virtual bool GetRemoteCertificate(rtc::SSLCertificate** cert) const {
if (!remote_cert_)
return false;
FakeTransportChannel* dest_;
State state_;
bool async_;
- talk_base::SSLIdentity* identity_;
- talk_base::FakeSSLCertificate* remote_cert_;
+ rtc::SSLIdentity* identity_;
+ rtc::FakeSSLCertificate* remote_cert_;
bool do_dtls_;
std::vector<std::string> srtp_ciphers_;
std::string chosen_srtp_cipher_;
std::string remote_ice_ufrag_;
std::string remote_ice_pwd_;
IceMode remote_ice_mode_;
- talk_base::SSLFingerprint dtls_fingerprint_;
- talk_base::SSLRole ssl_role_;
+ rtc::SSLFingerprint dtls_fingerprint_;
+ rtc::SSLRole ssl_role_;
+ size_t connection_count_;
};
// Fake transport class, which can be passed to anything that needs a Transport.
class FakeTransport : public Transport {
public:
typedef std::map<int, FakeTransportChannel*> ChannelMap;
- FakeTransport(talk_base::Thread* signaling_thread,
- talk_base::Thread* worker_thread,
+ FakeTransport(rtc::Thread* signaling_thread,
+ rtc::Thread* worker_thread,
const std::string& content_name,
PortAllocator* alllocator = NULL)
: Transport(signaling_thread, worker_thread,
}
}
- void set_identity(talk_base::SSLIdentity* identity) {
+ void set_identity(rtc::SSLIdentity* identity) {
identity_ = identity;
}
channels_.erase(channel->component());
delete channel;
}
- virtual void SetIdentity_w(talk_base::SSLIdentity* identity) {
+ virtual void SetIdentity_w(rtc::SSLIdentity* identity) {
identity_ = identity;
}
- virtual bool GetIdentity_w(talk_base::SSLIdentity** identity) {
+ virtual bool GetIdentity_w(rtc::SSLIdentity** identity) {
if (!identity_)
return false;
ChannelMap channels_;
FakeTransport* dest_;
bool async_;
- talk_base::SSLIdentity* identity_;
+ rtc::SSLIdentity* identity_;
};
// Fake session class, which can be passed into a BaseChannel object for
class FakeSession : public BaseSession {
public:
explicit FakeSession()
- : BaseSession(talk_base::Thread::Current(),
- talk_base::Thread::Current(),
+ : BaseSession(rtc::Thread::Current(),
+ rtc::Thread::Current(),
NULL, "", "", true),
fail_create_channel_(false) {
}
explicit FakeSession(bool initiator)
- : BaseSession(talk_base::Thread::Current(),
- talk_base::Thread::Current(),
+ : BaseSession(rtc::Thread::Current(),
+ rtc::Thread::Current(),
NULL, "", "", initiator),
fail_create_channel_(false) {
}
- FakeSession(talk_base::Thread* worker_thread, bool initiator)
- : BaseSession(talk_base::Thread::Current(),
+ FakeSession(rtc::Thread* worker_thread, bool initiator)
+ : BaseSession(rtc::Thread::Current(),
worker_thread,
NULL, "", "", initiator),
fail_create_channel_(false) {
}
// TODO: Hoist this into Session when we re-work the Session code.
- void set_ssl_identity(talk_base::SSLIdentity* identity) {
+ void set_ssl_identity(rtc::SSLIdentity* identity) {
for (TransportMap::const_iterator it = transport_proxies().begin();
it != transport_proxies().end(); ++it) {
// We know that we have a FakeTransport*