| 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..66f01b2faf22c0dccf3b9e6c10ad16f0fc898d25
|
| --- /dev/null
|
| +++ b/webrtc/p2p/base/udptransportchannel.h
|
| @@ -0,0 +1,104 @@
|
| +/*
|
| + * 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/optional.h"
|
| +#include "webrtc/base/thread_checker.h"
|
| +#include "webrtc/p2p/base/packettransportinterface.h"
|
| +
|
| +namespace rtc {
|
| +class AsyncPacketSocket;
|
| +class PhysicalSocketServer;
|
| +class SocketAddress;
|
| +class SocketServer;
|
| +class Thread;
|
| +}
|
| +
|
| +namespace cricket {
|
| +
|
| +enum UdpTransportState {
|
| + UDPTRANSPORT_STATE_INIT,
|
| + UDPTRANSPORT_STATE_CONNECTING,
|
| + UDPTRANSPORT_STATE_COMPLETED,
|
| + UDPTRANSPORT_STATE_FAILED
|
| +};
|
| +
|
| +class UdpTransportChannel : public rtc::PacketTransportInterface {
|
| + public:
|
| + UdpTransportChannel(const std::string& transport_name, int component);
|
| + UdpTransportChannel(const std::string& transport_name,
|
| + int component,
|
| + rtc::SocketServer* ss);
|
| + ~UdpTransportChannel();
|
| +
|
| + const std::string debug_name() const override { return debug_name_; }
|
| +
|
| + bool receiving() const override {
|
| + // TODO(johan): Implement method and signal.
|
| + return true;
|
| + }
|
| +
|
| + bool writable() const override;
|
| +
|
| + int SendPacket(const char* data,
|
| + size_t len,
|
| + const rtc::PacketOptions& options,
|
| + int flags) override;
|
| +
|
| + int SetOption(rtc::Socket::Option opt, int value) override { return 0; }
|
| +
|
| + int GetError() override { return send_error_; }
|
| +
|
| + UdpTransportState GetState() const {
|
| + RTC_DCHECK_RUN_ON(&network_thread_checker_);
|
| + return state_;
|
| + }
|
| +
|
| + // Check GetState() for resulting state.
|
| + void CreateSocket();
|
| +
|
| + void SetRemoteParameters(const rtc::SocketAddress& remote);
|
| +
|
| + // Returns default value, if local candidate is not set.
|
| + // Consider checking GetState() before calling local_parameters().
|
| + const rtc::SocketAddress& local_parameters();
|
| +
|
| + private:
|
| + void OnSocketReadPacket(rtc::AsyncPacketSocket* socket,
|
| + const char* data,
|
| + size_t len,
|
| + const rtc::SocketAddress& remote_addr,
|
| + const rtc::PacketTime& packet_time);
|
| + void OnSocketSentPacket(rtc::AsyncPacketSocket* socket,
|
| + const rtc::SentPacket& packet);
|
| + void SetTransportChannelState(
|
| + UdpTransportState state); // Set State and Signal.
|
| + UdpTransportState state_ = UDPTRANSPORT_STATE_INIT;
|
| + bool IsLocalConsistent();
|
| + void UpdateState();
|
| + void UpdateDebugName();
|
| + int send_error_ = 0;
|
| + std::string transport_name_;
|
| + std::string debug_name_;
|
| + int component_;
|
| + std::unique_ptr<rtc::AsyncPacketSocket> socket_;
|
| + rtc::Optional<rtc::SocketAddress> local_parameters_;
|
| + rtc::Optional<rtc::SocketAddress> remote_parameters_;
|
| + rtc::SocketServer* socket_server_;
|
| + rtc::ThreadChecker network_thread_checker_;
|
| +};
|
| +} // namespace cricket
|
| +
|
| +#endif // WEBRTC_P2P_BASE_UDPTRANSPORTCHANNEL_H_
|
|
|