2013-07-10 02:45:36 +02:00
|
|
|
/*
|
|
|
|
* libjingle
|
|
|
|
* Copyright 2004--2005, Google Inc.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions are met:
|
|
|
|
*
|
|
|
|
* 1. Redistributions of source code must retain the above copyright notice,
|
|
|
|
* this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
|
|
* this list of conditions and the following disclaimer in the documentation
|
|
|
|
* and/or other materials provided with the distribution.
|
|
|
|
* 3. The name of the author may not be used to endorse or promote products
|
|
|
|
* derived from this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
|
|
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
|
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
|
|
|
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
|
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
|
|
|
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
|
|
|
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
|
|
|
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
|
|
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef TALK_P2P_BASE_TRANSPORTCHANNELPROXY_H_
|
|
|
|
#define TALK_P2P_BASE_TRANSPORTCHANNELPROXY_H_
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <utility>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
#include "talk/p2p/base/transportchannel.h"
|
2014-08-13 19:26:08 +02:00
|
|
|
#include "webrtc/base/messagehandler.h"
|
2013-07-10 02:45:36 +02:00
|
|
|
|
2014-07-29 19:36:52 +02:00
|
|
|
namespace rtc {
|
2013-07-10 02:45:36 +02:00
|
|
|
class Thread;
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace cricket {
|
|
|
|
|
|
|
|
class TransportChannelImpl;
|
|
|
|
|
|
|
|
// Proxies calls between the client and the transport channel implementation.
|
|
|
|
// This is needed because clients are allowed to create channels before the
|
|
|
|
// network negotiation is complete. Hence, we create a proxy up front, and
|
|
|
|
// when negotiation completes, connect the proxy to the implementaiton.
|
|
|
|
class TransportChannelProxy : public TransportChannel,
|
2014-07-29 19:36:52 +02:00
|
|
|
public rtc::MessageHandler {
|
2013-07-10 02:45:36 +02:00
|
|
|
public:
|
|
|
|
TransportChannelProxy(const std::string& content_name,
|
|
|
|
const std::string& name,
|
|
|
|
int component);
|
|
|
|
virtual ~TransportChannelProxy();
|
|
|
|
|
|
|
|
const std::string& name() const { return name_; }
|
|
|
|
TransportChannelImpl* impl() { return impl_; }
|
|
|
|
|
|
|
|
// Sets the implementation to which we will proxy.
|
|
|
|
void SetImplementation(TransportChannelImpl* impl);
|
|
|
|
|
|
|
|
// Implementation of the TransportChannel interface. These simply forward to
|
|
|
|
// the implementation.
|
2013-09-23 22:34:45 +02:00
|
|
|
virtual int SendPacket(const char* data, size_t len,
|
2014-07-29 19:36:52 +02:00
|
|
|
const rtc::PacketOptions& options,
|
2013-09-23 22:34:45 +02:00
|
|
|
int flags);
|
2014-07-29 19:36:52 +02:00
|
|
|
virtual int SetOption(rtc::Socket::Option opt, int value);
|
2013-07-10 02:45:36 +02:00
|
|
|
virtual int GetError();
|
2013-08-12 23:18:15 +02:00
|
|
|
virtual IceRole GetIceRole() const;
|
2013-07-10 02:45:36 +02:00
|
|
|
virtual bool GetStats(ConnectionInfos* infos);
|
|
|
|
virtual bool IsDtlsActive() const;
|
2014-07-29 19:36:52 +02:00
|
|
|
virtual bool GetSslRole(rtc::SSLRole* role) const;
|
|
|
|
virtual bool SetSslRole(rtc::SSLRole role);
|
2013-07-10 02:45:36 +02:00
|
|
|
virtual bool SetSrtpCiphers(const std::vector<std::string>& ciphers);
|
|
|
|
virtual bool GetSrtpCipher(std::string* cipher);
|
2014-07-29 19:36:52 +02:00
|
|
|
virtual bool GetLocalIdentity(rtc::SSLIdentity** identity) const;
|
|
|
|
virtual bool GetRemoteCertificate(rtc::SSLCertificate** cert) const;
|
2013-07-10 02:45:36 +02:00
|
|
|
virtual bool ExportKeyingMaterial(const std::string& label,
|
|
|
|
const uint8* context,
|
|
|
|
size_t context_len,
|
|
|
|
bool use_context,
|
|
|
|
uint8* result,
|
|
|
|
size_t result_len);
|
|
|
|
|
|
|
|
private:
|
|
|
|
// Catch signals from the implementation channel. These just forward to the
|
|
|
|
// client (after updating our state to match).
|
|
|
|
void OnReadableState(TransportChannel* channel);
|
|
|
|
void OnWritableState(TransportChannel* channel);
|
|
|
|
void OnReadPacket(TransportChannel* channel, const char* data, size_t size,
|
2014-07-29 19:36:52 +02:00
|
|
|
const rtc::PacketTime& packet_time, int flags);
|
2013-07-10 02:45:36 +02:00
|
|
|
void OnReadyToSend(TransportChannel* channel);
|
|
|
|
void OnRouteChange(TransportChannel* channel, const Candidate& candidate);
|
|
|
|
|
2014-07-29 19:36:52 +02:00
|
|
|
void OnMessage(rtc::Message* message);
|
2013-07-10 02:45:36 +02:00
|
|
|
|
2014-07-29 19:36:52 +02:00
|
|
|
typedef std::pair<rtc::Socket::Option, int> OptionPair;
|
2013-07-10 02:45:36 +02:00
|
|
|
typedef std::vector<OptionPair> OptionList;
|
|
|
|
std::string name_;
|
2014-07-29 19:36:52 +02:00
|
|
|
rtc::Thread* worker_thread_;
|
2013-07-10 02:45:36 +02:00
|
|
|
TransportChannelImpl* impl_;
|
|
|
|
OptionList pending_options_;
|
|
|
|
std::vector<std::string> pending_srtp_ciphers_;
|
|
|
|
|
|
|
|
DISALLOW_EVIL_CONSTRUCTORS(TransportChannelProxy);
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace cricket
|
|
|
|
|
|
|
|
#endif // TALK_P2P_BASE_TRANSPORTCHANNELPROXY_H_
|