Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(123)

Side by Side Diff: webrtc/p2p/base/dtlstransportchannel.h

Issue 1246913005: TransportController refactoring (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright 2011 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2011 The WebRTC Project Authors. All rights reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #ifndef WEBRTC_P2P_BASE_DTLSTRANSPORTCHANNEL_H_ 11 #ifndef WEBRTC_P2P_BASE_DTLSTRANSPORTCHANNEL_H_
12 #define WEBRTC_P2P_BASE_DTLSTRANSPORTCHANNEL_H_ 12 #define WEBRTC_P2P_BASE_DTLSTRANSPORTCHANNEL_H_
13 13
14 #include <string> 14 #include <string>
15 #include <vector> 15 #include <vector>
16 16
17 #include "webrtc/p2p/base/transportchannelimpl.h" 17 #include "webrtc/p2p/base/transportchannelimpl.h"
18 #include "webrtc/base/buffer.h" 18 #include "webrtc/base/buffer.h"
19 #include "webrtc/base/bufferqueue.h" 19 #include "webrtc/base/bufferqueue.h"
20 #include "webrtc/base/scoped_ptr.h" 20 #include "webrtc/base/scoped_ptr.h"
21 #include "webrtc/base/sslstreamadapter.h" 21 #include "webrtc/base/sslstreamadapter.h"
22 #include "webrtc/base/stream.h" 22 #include "webrtc/base/stream.h"
23 23
24 namespace cricket { 24 namespace cricket {
25 25
26 // A bridge between a packet-oriented/channel-type interface on 26 // A bridge between a packet-oriented/channel-type interface on
27 // the bottom and a StreamInterface on the top. 27 // the bottom and a StreamInterface on the top.
28 class StreamInterfaceChannel : public rtc::StreamInterface { 28 class StreamInterfaceChannel : public rtc::StreamInterface {
29 public: 29 public:
30 StreamInterfaceChannel(TransportChannel* channel); 30 explicit StreamInterfaceChannel(TransportChannel* channel);
31 31
32 // Push in a packet; this gets pulled out from Read(). 32 // Push in a packet; this gets pulled out from Read().
33 bool OnPacketReceived(const char* data, size_t size); 33 bool OnPacketReceived(const char* data, size_t size);
34 34
35 // Implementations of StreamInterface 35 // Implementations of StreamInterface
36 virtual rtc::StreamState GetState() const { return state_; } 36 virtual rtc::StreamState GetState() const { return state_; }
37 virtual void Close() { state_ = rtc::SS_CLOSED; } 37 virtual void Close() { state_ = rtc::SS_CLOSED; }
38 virtual rtc::StreamResult Read(void* buffer, size_t buffer_len, 38 virtual rtc::StreamResult Read(void* buffer, size_t buffer_len,
39 size_t* read, int* error); 39 size_t* read, int* error);
40 virtual rtc::StreamResult Write(const void* data, size_t data_len, 40 virtual rtc::StreamResult Write(const void* data, size_t data_len,
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 virtual void SetRemoteIceCredentials(const std::string& ice_ufrag, 184 virtual void SetRemoteIceCredentials(const std::string& ice_ufrag,
185 const std::string& ice_pwd) { 185 const std::string& ice_pwd) {
186 channel_->SetRemoteIceCredentials(ice_ufrag, ice_pwd); 186 channel_->SetRemoteIceCredentials(ice_ufrag, ice_pwd);
187 } 187 }
188 virtual void SetRemoteIceMode(IceMode mode) { 188 virtual void SetRemoteIceMode(IceMode mode) {
189 channel_->SetRemoteIceMode(mode); 189 channel_->SetRemoteIceMode(mode);
190 } 190 }
191 191
192 virtual void Connect(); 192 virtual void Connect();
193 193
194 virtual void OnSignalingReady() { 194 virtual IceGatheringState gathering_state() const {
195 channel_->OnSignalingReady(); 195 return channel_->gathering_state();
196 } 196 }
197 virtual void OnCandidate(const Candidate& candidate) { 197
198 channel_->OnCandidate(candidate); 198 virtual void AddRemoteCandidate(const Candidate& candidate) {
199 channel_->AddRemoteCandidate(candidate);
199 } 200 }
200 201
201 void SetReceivingTimeout(int receiving_timeout_ms) { 202 void SetReceivingTimeout(int receiving_timeout_ms) {
202 channel_->SetReceivingTimeout(receiving_timeout_ms); 203 channel_->SetReceivingTimeout(receiving_timeout_ms);
203 } 204 }
204 205
205 // Needed by DtlsTransport. 206 // Needed by DtlsTransport.
206 TransportChannelImpl* channel() { return channel_; } 207 TransportChannelImpl* channel() { return channel_; }
207 208
208 private: 209 private:
209 void OnReadableState(TransportChannel* channel); 210 void OnReadableState(TransportChannel* channel);
210 void OnWritableState(TransportChannel* channel); 211 void OnWritableState(TransportChannel* channel);
211 void OnReadPacket(TransportChannel* channel, const char* data, size_t size, 212 void OnReadPacket(TransportChannel* channel, const char* data, size_t size,
212 const rtc::PacketTime& packet_time, int flags); 213 const rtc::PacketTime& packet_time, int flags);
213 void OnReadyToSend(TransportChannel* channel); 214 void OnReadyToSend(TransportChannel* channel);
214 void OnReceivingState(TransportChannel* channel); 215 void OnReceivingState(TransportChannel* channel);
215 void OnDtlsEvent(rtc::StreamInterface* stream_, int sig, int err); 216 void OnDtlsEvent(rtc::StreamInterface* stream_, int sig, int err);
216 bool SetupDtls(); 217 bool SetupDtls();
217 bool MaybeStartDtls(); 218 bool MaybeStartDtls();
218 bool HandleDtlsPacket(const char* data, size_t size); 219 bool HandleDtlsPacket(const char* data, size_t size);
219 void OnRequestSignaling(TransportChannelImpl* channel); 220 void OnGatheringState(TransportChannelImpl* channel);
220 void OnCandidateReady(TransportChannelImpl* channel, const Candidate& c); 221 void OnCandidateGathered(TransportChannelImpl* channel, const Candidate& c);
221 void OnCandidatesAllocationDone(TransportChannelImpl* channel);
222 void OnRoleConflict(TransportChannelImpl* channel); 222 void OnRoleConflict(TransportChannelImpl* channel);
223 void OnRouteChange(TransportChannel* channel, const Candidate& candidate); 223 void OnRouteChange(TransportChannel* channel, const Candidate& candidate);
224 void OnConnectionRemoved(TransportChannelImpl* channel); 224 void OnConnectionRemoved(TransportChannelImpl* channel);
225 225
226 Transport* transport_; // The transport_ that created us. 226 Transport* transport_; // The transport_ that created us.
227 rtc::Thread* worker_thread_; // Everything should occur on this thread. 227 rtc::Thread* worker_thread_; // Everything should occur on this thread.
228 TransportChannelImpl* channel_; // Underlying channel, owned by transport_. 228 TransportChannelImpl* channel_; // Underlying channel, owned by transport_.
229 rtc::scoped_ptr<rtc::SSLStreamAdapter> dtls_; // The DTLS stream 229 rtc::scoped_ptr<rtc::SSLStreamAdapter> dtls_; // The DTLS stream
230 StreamInterfaceChannel* downward_; // Wrapper for channel_, owned by dtls_. 230 StreamInterfaceChannel* downward_; // Wrapper for channel_, owned by dtls_.
231 std::vector<std::string> srtp_ciphers_; // SRTP ciphers to use with DTLS. 231 std::vector<std::string> srtp_ciphers_; // SRTP ciphers to use with DTLS.
232 State dtls_state_; 232 State dtls_state_;
233 rtc::SSLIdentity* local_identity_; 233 rtc::SSLIdentity* local_identity_;
234 rtc::SSLRole ssl_role_; 234 rtc::SSLRole ssl_role_;
235 rtc::SSLProtocolVersion ssl_max_version_; 235 rtc::SSLProtocolVersion ssl_max_version_;
236 rtc::Buffer remote_fingerprint_value_; 236 rtc::Buffer remote_fingerprint_value_;
237 std::string remote_fingerprint_algorithm_; 237 std::string remote_fingerprint_algorithm_;
238 238
239 DISALLOW_COPY_AND_ASSIGN(DtlsTransportChannelWrapper); 239 DISALLOW_COPY_AND_ASSIGN(DtlsTransportChannelWrapper);
240 }; 240 };
241 241
242 } // namespace cricket 242 } // namespace cricket
243 243
244 #endif // WEBRTC_P2P_BASE_DTLSTRANSPORTCHANNEL_H_ 244 #endif // WEBRTC_P2P_BASE_DTLSTRANSPORTCHANNEL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698