OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 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 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
60 // SctpTransport are called with the recieved data] | 60 // SctpTransport are called with the recieved data] |
61 // TODO(zhihuang): Rename "channel" to "transport" on network-level. | 61 // TODO(zhihuang): Rename "channel" to "transport" on network-level. |
62 class SctpTransport : public SctpTransportInternal, | 62 class SctpTransport : public SctpTransportInternal, |
63 public sigslot::has_slots<> { | 63 public sigslot::has_slots<> { |
64 public: | 64 public: |
65 // |network_thread| is where packets will be processed and callbacks from | 65 // |network_thread| is where packets will be processed and callbacks from |
66 // this transport will be posted, and is the only thread on which public | 66 // this transport will be posted, and is the only thread on which public |
67 // methods can be called. | 67 // methods can be called. |
68 // |channel| is required (must not be null). | 68 // |channel| is required (must not be null). |
69 SctpTransport(rtc::Thread* network_thread, | 69 SctpTransport(rtc::Thread* network_thread, |
70 rtc::PacketTransportInterface* channel); | 70 rtc::PacketTransportInternal* channel); |
pthatcher1
2017/02/08 01:33:49
Why does an SctpTransport need the internal versio
Taylor Brandstetter
2017/02/10 00:19:45
Because it uses it to send and receive packets, an
| |
71 ~SctpTransport() override; | 71 ~SctpTransport() override; |
72 | 72 |
73 // SctpTransportInternal overrides (see sctptransportinternal.h for comments). | 73 // SctpTransportInternal overrides (see sctptransportinternal.h for comments). |
74 void SetTransportChannel(rtc::PacketTransportInterface* channel) override; | 74 void SetTransportChannel(rtc::PacketTransportInternal* channel) override; |
75 bool Start(int local_port, int remote_port) override; | 75 bool Start(int local_port, int remote_port) override; |
76 bool OpenStream(int sid) override; | 76 bool OpenStream(int sid) override; |
77 bool ResetStream(int sid) override; | 77 bool ResetStream(int sid) override; |
78 bool SendData(const SendDataParams& params, | 78 bool SendData(const SendDataParams& params, |
79 const rtc::CopyOnWriteBuffer& payload, | 79 const rtc::CopyOnWriteBuffer& payload, |
80 SendDataResult* result = nullptr) override; | 80 SendDataResult* result = nullptr) override; |
81 bool ReadyToSendData() override; | 81 bool ReadyToSendData() override; |
82 void set_debug_name_for_testing(const char* debug_name) override { | 82 void set_debug_name_for_testing(const char* debug_name) override { |
83 debug_name_ = debug_name; | 83 debug_name_ = debug_name; |
84 } | 84 } |
(...skipping 16 matching lines...) Expand all Loading... | |
101 // Sets |sock_ |to nullptr. | 101 // Sets |sock_ |to nullptr. |
102 void CloseSctpSocket(); | 102 void CloseSctpSocket(); |
103 | 103 |
104 // Sends a SCTP_RESET_STREAM for all streams in closing_ssids_. | 104 // Sends a SCTP_RESET_STREAM for all streams in closing_ssids_. |
105 bool SendQueuedStreamResets(); | 105 bool SendQueuedStreamResets(); |
106 | 106 |
107 // Sets the "ready to send" flag and fires signal if needed. | 107 // Sets the "ready to send" flag and fires signal if needed. |
108 void SetReadyToSendData(); | 108 void SetReadyToSendData(); |
109 | 109 |
110 // Callbacks from DTLS channel. | 110 // Callbacks from DTLS channel. |
111 void OnWritableState(rtc::PacketTransportInterface* transport); | 111 void OnWritableState(rtc::PacketTransportInternal* transport); |
112 virtual void OnPacketRead(rtc::PacketTransportInterface* transport, | 112 virtual void OnPacketRead(rtc::PacketTransportInternal* transport, |
113 const char* data, | 113 const char* data, |
114 size_t len, | 114 size_t len, |
115 const rtc::PacketTime& packet_time, | 115 const rtc::PacketTime& packet_time, |
116 int flags); | 116 int flags); |
117 | 117 |
118 // Methods related to usrsctp callbacks. | 118 // Methods related to usrsctp callbacks. |
119 void OnSendThresholdCallback(); | 119 void OnSendThresholdCallback(); |
120 sockaddr_conn GetSctpSockAddr(int port); | 120 sockaddr_conn GetSctpSockAddr(int port); |
121 | 121 |
122 // Called using |invoker_| to send packet on the network. | 122 // Called using |invoker_| to send packet on the network. |
(...skipping 10 matching lines...) Expand all Loading... | |
133 void OnNotificationAssocChange(const sctp_assoc_change& change); | 133 void OnNotificationAssocChange(const sctp_assoc_change& change); |
134 | 134 |
135 void OnStreamResetEvent(const struct sctp_stream_reset_event* evt); | 135 void OnStreamResetEvent(const struct sctp_stream_reset_event* evt); |
136 | 136 |
137 // Responsible for marshalling incoming data to the channels listeners, and | 137 // Responsible for marshalling incoming data to the channels listeners, and |
138 // outgoing data to the network interface. | 138 // outgoing data to the network interface. |
139 rtc::Thread* network_thread_; | 139 rtc::Thread* network_thread_; |
140 // Helps pass inbound/outbound packets asynchronously to the network thread. | 140 // Helps pass inbound/outbound packets asynchronously to the network thread. |
141 rtc::AsyncInvoker invoker_; | 141 rtc::AsyncInvoker invoker_; |
142 // Underlying DTLS channel. | 142 // Underlying DTLS channel. |
143 rtc::PacketTransportInterface* transport_channel_; | 143 rtc::PacketTransportInternal* transport_channel_; |
144 bool was_ever_writable_ = false; | 144 bool was_ever_writable_ = false; |
145 int local_port_ = kSctpDefaultPort; | 145 int local_port_ = kSctpDefaultPort; |
146 int remote_port_ = kSctpDefaultPort; | 146 int remote_port_ = kSctpDefaultPort; |
147 struct socket* sock_ = nullptr; // The socket created by usrsctp_socket(...). | 147 struct socket* sock_ = nullptr; // The socket created by usrsctp_socket(...). |
148 | 148 |
149 // Has Start been called? Don't create SCTP socket until it has. | 149 // Has Start been called? Don't create SCTP socket until it has. |
150 bool started_ = false; | 150 bool started_ = false; |
151 // Are we ready to queue data (SCTP socket created, and not blocked due to | 151 // Are we ready to queue data (SCTP socket created, and not blocked due to |
152 // congestion control)? Different than |transport_channel_|'s "ready to | 152 // congestion control)? Different than |transport_channel_|'s "ready to |
153 // send". | 153 // send". |
(...skipping 18 matching lines...) Expand all Loading... | |
172 | 172 |
173 RTC_DISALLOW_COPY_AND_ASSIGN(SctpTransport); | 173 RTC_DISALLOW_COPY_AND_ASSIGN(SctpTransport); |
174 }; | 174 }; |
175 | 175 |
176 class SctpTransportFactory : public SctpTransportInternalFactory { | 176 class SctpTransportFactory : public SctpTransportInternalFactory { |
177 public: | 177 public: |
178 explicit SctpTransportFactory(rtc::Thread* network_thread) | 178 explicit SctpTransportFactory(rtc::Thread* network_thread) |
179 : network_thread_(network_thread) {} | 179 : network_thread_(network_thread) {} |
180 | 180 |
181 std::unique_ptr<SctpTransportInternal> CreateSctpTransport( | 181 std::unique_ptr<SctpTransportInternal> CreateSctpTransport( |
182 rtc::PacketTransportInterface* channel) override { | 182 rtc::PacketTransportInternal* channel) override { |
183 return std::unique_ptr<SctpTransportInternal>( | 183 return std::unique_ptr<SctpTransportInternal>( |
184 new SctpTransport(network_thread_, channel)); | 184 new SctpTransport(network_thread_, channel)); |
185 } | 185 } |
186 | 186 |
187 private: | 187 private: |
188 rtc::Thread* network_thread_; | 188 rtc::Thread* network_thread_; |
189 }; | 189 }; |
190 | 190 |
191 } // namespace cricket | 191 } // namespace cricket |
192 | 192 |
193 #endif // WEBRTC_MEDIA_SCTP_SCTPTRANSPORT_H_ | 193 #endif // WEBRTC_MEDIA_SCTP_SCTPTRANSPORT_H_ |
OLD | NEW |