| Index: webrtc/p2p/base/udptransportchannel.h
|
| diff --git a/webrtc/p2p/base/udptransportchannel.h b/webrtc/p2p/base/udptransportchannel.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..a99153bee28ed894b6eb1e77cf62c661f6d779dc
|
| --- /dev/null
|
| +++ b/webrtc/p2p/base/udptransportchannel.h
|
| @@ -0,0 +1,169 @@
|
| +/*
|
| + * Copyright 2016 The WebRTC project authors. All Rights Reserved.
|
| + *
|
| + * Use of this source code is governed by a BSD-style license
|
| + * that can be found in the LICENSE file in the root of the source
|
| + * tree. An additional intellectual property rights grant can be found
|
| + * in the file PATENTS. All contributing project authors may
|
| + * be found in the AUTHORS file in the root of the source tree.
|
| + */
|
| +
|
| +#ifndef WEBRTC_P2P_BASE_UDPTRANSPORTCHANNEL_H_
|
| +#define WEBRTC_P2P_BASE_UDPTRANSPORTCHANNEL_H_
|
| +
|
| +#include <memory>
|
| +#include <string>
|
| +
|
| +#include "webrtc/base/socketaddress.h"
|
| +#include "webrtc/base/thread_checker.h"
|
| +#include "webrtc/p2p/base/transportchannel.h"
|
| +#include "webrtc/p2p/base/transportchannelimpl.h"
|
| +
|
| +namespace rtc {
|
| +class AsyncUDPSocket;
|
| +class PhysicalSocketServer;
|
| +class SocketServer;
|
| +class Thread;
|
| +}
|
| +
|
| +namespace cricket {
|
| +
|
| +class UdpTransportChannel : public TransportChannelImpl {
|
| + public:
|
| + UdpTransportChannel(const std::string& transport_name, int component);
|
| + UdpTransportChannel(const std::string& transport_name,
|
| + int component,
|
| + rtc::SocketServer* ss);
|
| + ~UdpTransportChannel();
|
| + int SendPacket(const char* data,
|
| + size_t len,
|
| + const rtc::PacketOptions& options,
|
| + int flags) override;
|
| + TransportChannelState GetState() const override {
|
| + RTC_DCHECK_RUN_ON(&network_thread_checker_);
|
| + return state_;
|
| + }
|
| +
|
| + int SetOption(rtc::Socket::Option opt, int value) override { return 0; }
|
| +
|
| + int GetError() override { return send_error_; }
|
| +
|
| + bool GetStats(ConnectionInfos* infos) override { return false; }
|
| +
|
| + bool IsDtlsActive() const override {
|
| + // TODO(johan) remove, when PacketTransportInterface is available.
|
| + return false;
|
| + }
|
| +
|
| + bool GetSslRole(rtc::SSLRole* role) const override {
|
| + RTC_NOTREACHED();
|
| + return false;
|
| + }
|
| +
|
| + rtc::scoped_refptr<rtc::RTCCertificate> GetLocalCertificate() const override {
|
| + RTC_NOTREACHED();
|
| + return nullptr;
|
| + }
|
| +
|
| + std::unique_ptr<rtc::SSLCertificate> GetRemoteSSLCertificate()
|
| + const override {
|
| + RTC_NOTREACHED();
|
| + return nullptr;
|
| + }
|
| +
|
| + bool ExportKeyingMaterial(const std::string& label,
|
| + const uint8_t* context,
|
| + size_t context_len,
|
| + bool use_context,
|
| + uint8_t* result,
|
| + size_t result_len) override {
|
| + RTC_NOTREACHED();
|
| + return false;
|
| + }
|
| +
|
| + // TransportChannelImpl overrides
|
| + IceRole GetIceRole() const override {
|
| + RTC_NOTREACHED();
|
| + return ICEROLE_UNKNOWN;
|
| + }
|
| +
|
| + // TODO(johan): Remove all ICE- and DTLS-specific methods.
|
| + void SetIceRole(IceRole role) override { RTC_NOTREACHED(); }
|
| +
|
| + void SetIceTiebreaker(uint64_t tiebreaker) override { RTC_NOTREACHED(); }
|
| +
|
| + void SetIceParameters(const IceParameters& ice_params) override {
|
| + RTC_NOTREACHED();
|
| + }
|
| +
|
| + void SetRemoteIceParameters(const IceParameters& ice_params) override {
|
| + RTC_NOTREACHED();
|
| + }
|
| +
|
| + void SetRemoteIceMode(IceMode mode) override { RTC_NOTREACHED(); }
|
| +
|
| + void SetIceConfig(const IceConfig& config) override { RTC_NOTREACHED(); }
|
| +
|
| + void MaybeStartGathering() override;
|
| +
|
| + void AddRemoteCandidate(const Candidate& candidate) override;
|
| +
|
| + // TransportChannelImpl overrides
|
| + void RemoveRemoteCandidate(const Candidate& candidate) override {
|
| + RTC_NOTREACHED();
|
| + }
|
| +
|
| + IceGatheringState gathering_state() const override {
|
| + RTC_DCHECK_RUN_ON(&network_thread_checker_);
|
| + return gathering_state_;
|
| + }
|
| +
|
| + bool SetLocalCertificate(
|
| + const rtc::scoped_refptr<rtc::RTCCertificate>& certificate) override {
|
| + RTC_NOTREACHED();
|
| + return false;
|
| + }
|
| +
|
| + bool SetRemoteFingerprint(const std::string& digest_alg,
|
| + const uint8_t* digest,
|
| + size_t digest_len) override {
|
| + RTC_NOTREACHED();
|
| + return false;
|
| + }
|
| +
|
| + bool SetSslRole(rtc::SSLRole role) override {
|
| + RTC_NOTREACHED();
|
| + return false;
|
| + }
|
| +
|
| + void SetMetricsObserver(webrtc::MetricsObserverInterface* observer) override {
|
| + }
|
| +
|
| + private:
|
| + void OnSocketReadPacket(rtc::AsyncPacketSocket* socket,
|
| + const char* data,
|
| + size_t len,
|
| + const rtc::SocketAddress& remote_addr,
|
| + const rtc::PacketTime& packet_time);
|
| + bool TryAllocateSockets();
|
| + void SetGatheringState(
|
| + IceGatheringState gathering_state); // Set State and Signal.
|
| + void SetTransportChannelState(
|
| + TransportChannelState new_tch_state); // Set State and Signal.
|
| + TransportChannelState state_ = STATE_INIT;
|
| + IceGatheringState gathering_state_ = kIceGatheringNew;
|
| + bool IsLocalConsistent();
|
| + bool IsRemoteConsistent();
|
| + void UpdateState();
|
| + int send_error_ = 0;
|
| + std::unique_ptr<rtc::AsyncUDPSocket> socket_;
|
| + // TODO(johan): use a non-ICE datatype for paramters with
|
| + // PacketTransportInterface.
|
| + rtc::Optional<Candidate> local_parameters_;
|
| + rtc::Optional<Candidate> remote_parameters_;
|
| + rtc::SocketServer* socket_server_;
|
| + rtc::ThreadChecker network_thread_checker_;
|
| +};
|
| +} // namespace cricket
|
| +
|
| +#endif // WEBRTC_P2P_BASE_UDPTRANSPORTCHANNEL_H_
|
|
|