Chromium Code Reviews| Index: webrtc/p2p/rawudp/rawudptransportchannel.h |
| diff --git a/webrtc/p2p/rawudp/rawudptransportchannel.h b/webrtc/p2p/rawudp/rawudptransportchannel.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..e5100d0586d9a50e649547d84f2a262d58198eca |
| --- /dev/null |
| +++ b/webrtc/p2p/rawudp/rawudptransportchannel.h |
| @@ -0,0 +1,192 @@ |
| +/* |
| + * 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_RAWUDP_RAWUDPTRANSPORTCHANNEL_H_ |
| +#define WEBRTC_P2P_RAWUDP_RAWUDPTRANSPORTCHANNEL_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 RawUdpCandidate : public Candidate { |
|
Taylor Brandstetter
2016/10/07 18:24:03
The Candidate struct already has an IP/port/protoc
johan
2016/10/11 13:36:10
Acknowledged.
|
| + // TODO(johan) add Rtcp sockaddr to candidate |
|
pthatcher1
2016/10/07 17:36:36
Style: "TODO(johan): Add RTCP port."
Actually, a
|
| +}; |
| + |
| +class RawUdpTransportChannel : public TransportChannelImpl { |
|
pthatcher1
2016/10/07 17:36:37
Why bother with TransportChannelImpl? Why not use
johan
2016/10/11 13:36:10
Currently TransportController::CreateTransportChan
|
| + public: |
| + RawUdpTransportChannel(const std::string& transport_name, int component); |
| + // TODO(johan): replace raw pointers by (weak) references to std::shared_ptr, |
| + // when available |
|
pthatcher1
2016/10/07 17:36:36
Style: "TODO(johan): Replace raw pointers by (weak
Taylor Brandstetter
2016/10/07 18:24:03
Do we really plan to do this? It's the first I've
pthatcher1
2016/10/07 21:15:39
There are a few other places in the code with comm
johan
2016/10/11 13:36:10
Here the shared pointer would just by my personal
|
| + RawUdpTransportChannel(const std::string& transport_name, |
| + int component, |
| + rtc::SocketServer* ss); |
| + ~RawUdpTransportChannel(); |
| + int SendPacket(const char* data, |
| + size_t len, |
| + const rtc::PacketOptions& options, |
| + int flags) override; |
| + int Recv(); |
| + void OnSocketReadPacket(rtc::AsyncPacketSocket* socket, |
| + const char* data, |
| + size_t len, |
| + const rtc::SocketAddress& remote_addr, |
| + const rtc::PacketTime& packet_time, |
| + bool is_rtcp); |
| + void OnRtpSocketReadPacket(rtc::AsyncPacketSocket* socket, |
| + const char* data, |
| + size_t len, |
| + const rtc::SocketAddress& remote_addr, |
| + const rtc::PacketTime& packet_time); |
|
Taylor Brandstetter
2016/10/07 18:24:03
To match our current design, a transport channel w
johan
2016/10/11 13:36:10
Ack on "should not be public".
See my other commen
|
| + void OnRtcpSocketReadPacket(rtc::AsyncPacketSocket* socket, |
| + const char* data, |
| + size_t len, |
| + const rtc::SocketAddress& remote_addr, |
| + const rtc::PacketTime& packet_time); |
|
pthatcher1
2016/10/07 17:36:37
Can you put a comment some where that says somethi
|
| + int SetRemoteAddr(const char* addr); |
|
pthatcher1
2016/10/07 17:36:36
I'd prefer you have a SetRemoteParameters(const Ud
Taylor Brandstetter
2016/10/07 18:24:03
You could use an rtc::SocketAddress here. And can
johan
2016/10/11 13:36:10
Blame me, I had already removed this method's impl
|
| + TransportChannelState GetState() const override; |
| + |
| + int SetOption(rtc::Socket::Option opt, int value) override { |
| + RTC_NOTREACHED(); |
| + return 0; |
| + } |
|
pthatcher1
2016/10/07 17:36:36
That's not going to work. SetOption is definitely
johan
2016/10/11 13:36:10
Acknowledged.
|
| + |
| + int GetError() override { |
| + RTC_NOTREACHED(); |
| + return 0; |
|
pthatcher1
2016/10/07 17:36:37
Same here
johan
2016/10/11 13:36:10
Acknowledged.
|
| + } |
| + |
| + bool GetStats(ConnectionInfos* infos) override { |
| + RTC_NOTREACHED(); |
| + return false; |
| + } |
|
pthatcher1
2016/10/07 17:36:36
And here
johan
2016/10/11 13:36:10
Acknowledged.
|
| + |
| + bool IsDtlsActive() const override { |
| + RTC_NOTREACHED(); |
| + return false; |
|
pthatcher1
2016/10/07 17:36:37
And here. Although removing it would be even bett
johan
2016/10/11 13:36:10
Replacing the RTC_NOTREACHED() by a method removal
|
| + } |
| + |
| + bool GetSslRole(rtc::SSLRole* role) const override { |
| + RTC_NOTREACHED(); |
|
pthatcher1
2016/10/07 17:36:37
This one should stay, and the next few, unless you
johan
2016/10/11 13:36:10
Acknowledged.
|
| + 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; |
| + } |
| + |
| + 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(); } |
|
pthatcher1
2016/10/07 17:36:37
FYI, we're currently refactoring all of this. Can
johan
2016/10/11 13:36:10
Adding the TODO with next patch set. Maybe switchi
|
| + |
| + void MaybeStartGathering() override; |
| + |
| + void AddRemoteCandidate(const Candidate& candidate) override; |
|
pthatcher1
2016/10/07 17:36:36
Shouldn't the "remote candidate" be contained in t
johan
2016/10/11 13:36:10
Currently AddRemoteCandidate() is TransportControl
|
| + |
| + // TransportChannelImpl overrides |
| + void RemoveRemoteCandidate(const Candidate& candidate) override { |
| + // TODO(johan) implement |
|
pthatcher1
2016/10/07 17:36:36
Why would you implement this? It's an ICE thing.
johan
2016/10/11 13:36:10
Removing the TODO.
|
| + RTC_NOTREACHED(); |
| + } |
| + |
| + IceGatheringState gathering_state() const override; |
| + |
| + 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 { |
| + RTC_NOTREACHED(); |
|
pthatcher1
2016/10/07 17:36:37
I don't think you should have this NOTREACHED().
johan
2016/10/11 13:36:10
Acknowledged.
|
| + } |
| + |
| + // TODO(johan) make this private, once addcandidate is working |
| + bool SetRemoteAddrAndPorts(const char* ip_addr, int rtp_port); |
|
pthatcher1
2016/10/07 17:36:36
I think you should not implement AddCandidate, and
johan
2016/10/11 13:36:10
My fault. This declaration is a left-over from my
|
| + |
| + private: |
| + bool TryAllocateSockets(); |
| + void SetGatheringState( |
| + IceGatheringState new_gathering_state); // Set State and Signal |
|
Taylor Brandstetter
2016/10/07 18:24:03
nit: "Set state and signal."
johan
2016/10/11 13:36:10
Acknowledged.
|
| + void SetTransportChannelState( |
| + TransportChannelState new_tch_state); // Set State and Signal |
| + TransportChannelState tch_state_; |
|
pthatcher1
2016/10/07 17:36:37
Just state_ is enough.
johan
2016/10/11 13:36:10
Acknowledged.
|
| + IceGatheringState gathering_state_; |
|
johan
2016/10/11 13:36:10
Whether gathering_state_ is required depends on in
|
| + void UpdateWritableState(); |
|
pthatcher1
2016/10/07 17:36:36
I don't think you need UpdateWritableState(), beca
johan
2016/10/11 13:36:10
cricket::TransportChannel has a non virtual method
|
| + std::unique_ptr<rtc::AsyncUDPSocket> rtp_socket_; |
| + std::unique_ptr<rtc::AsyncUDPSocket> rtcp_socket_; |
|
pthatcher1
2016/10/07 17:36:37
As I mentioned, a transport channel should have on
|
| + Candidate local_candidate_; |
| + Candidate remote_candidate_; |
|
pthatcher1
2016/10/07 17:36:37
This should be local_parameters_ and remote_parame
|
| + rtc::SocketAddress remote_addr_; |
|
pthatcher1
2016/10/07 17:36:36
remote_addr_ should be a part of remote_parameters
|
| + rtc::SocketServer* socket_server_; |
| + rtc::ThreadChecker network_thread_checker_; |
| +}; |
| +} // namespace cricket |
| + |
| +#endif // WEBRTC_P2P_RAWUDP_RAWUDPTRANSPORTCHANNEL_H_ |