OLD | NEW |
---|---|
1 /* | 1 /* |
2 * libjingle | 2 * libjingle |
3 * Copyright 2012 Google Inc. and Robin Seggelmann | 3 * Copyright 2012 Google Inc. and Robin Seggelmann |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are met: | 6 * modification, are permitted provided that the following conditions are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright notice, | 8 * 1. Redistributions of source code must retain the above copyright notice, |
9 * this list of conditions and the following disclaimer. | 9 * this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright notice, | 10 * 2. Redistributions in binary form must reproduce the above copyright notice, |
(...skipping 11 matching lines...) Expand all Loading... | |
22 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, | 22 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
23 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR | 23 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR |
24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF | 24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 */ | 26 */ |
27 | 27 |
28 #ifndef TALK_MEDIA_SCTP_SCTPDATAENGINE_H_ | 28 #ifndef TALK_MEDIA_SCTP_SCTPDATAENGINE_H_ |
29 #define TALK_MEDIA_SCTP_SCTPDATAENGINE_H_ | 29 #define TALK_MEDIA_SCTP_SCTPDATAENGINE_H_ |
30 | 30 |
31 #include <errno.h> | 31 #include <errno.h> |
32 #include <map> | |
32 #include <string> | 33 #include <string> |
33 #include <vector> | 34 #include <vector> |
34 | 35 |
35 namespace cricket { | 36 namespace cricket { |
36 // Some ERRNO values get re-#defined to WSA* equivalents in some talk/ | 37 // Some ERRNO values get re-#defined to WSA* equivalents in some talk/ |
37 // headers. We save the original ones in an enum. | 38 // headers. We save the original ones in an enum. |
38 enum PreservedErrno { | 39 enum PreservedErrno { |
39 SCTP_EINPROGRESS = EINPROGRESS, | 40 SCTP_EINPROGRESS = EINPROGRESS, |
40 SCTP_EWOULDBLOCK = EWOULDBLOCK | 41 SCTP_EWOULDBLOCK = EWOULDBLOCK |
41 }; | 42 }; |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
183 const rtc::PacketTime& packet_time) {} | 184 const rtc::PacketTime& packet_time) {} |
184 virtual void OnReadyToSend(bool ready) {} | 185 virtual void OnReadyToSend(bool ready) {} |
185 | 186 |
186 // Helper for debugging. | 187 // Helper for debugging. |
187 void set_debug_name(const std::string& debug_name) { | 188 void set_debug_name(const std::string& debug_name) { |
188 debug_name_ = debug_name; | 189 debug_name_ = debug_name; |
189 } | 190 } |
190 const std::string& debug_name() const { return debug_name_; } | 191 const std::string& debug_name() const { return debug_name_; } |
191 | 192 |
192 private: | 193 private: |
194 // Maps sockets back to their SctpDataMediaChannels. For usrsctp | |
195 // send-threshold callbacks, we only get the socket* on invocation, but | |
196 // need to find the SctpDataMediaChannels. We can get that through the | |
197 // library, but would cost us an allocation/free each time the callback is | |
198 // invoked. | |
199 typedef std::map<struct socket*, SctpDataMediaChannel*> SocketChannelMap; | |
200 static SocketChannelMap sock_channel_map_; | |
pthatcher1
2015/08/05 21:42:55
Instead of being a static member of the SctpDataMe
lally1
2015/08/18 20:38:56
That makes a lot of sense, but the SctpDataMediaCh
pthatcher1
2015/08/18 21:51:52
We could add SctpDataMediaChannel::SignalDestroyed
| |
193 sockaddr_conn GetSctpSockAddr(int port); | 201 sockaddr_conn GetSctpSockAddr(int port); |
194 | 202 |
195 // Creates the socket and connects. Sets sending_ to true. | 203 // Creates the socket and connects. Sets sending_ to true. |
196 bool Connect(); | 204 bool Connect(); |
197 // Closes the socket. Sets sending_ to false. | 205 // Closes the socket. Sets sending_ to false. |
198 void Disconnect(); | 206 void Disconnect(); |
199 | 207 |
200 // Returns false when openning the socket failed; when successfull sets | 208 // Returns false when openning the socket failed; when successfull sets |
201 // sending_ to true | 209 // sending_ to true |
202 bool OpenSctpSocket(); | 210 bool OpenSctpSocket(); |
(...skipping 12 matching lines...) Expand all Loading... | |
215 void OnPacketFromSctpToNetwork(rtc::Buffer* buffer); | 223 void OnPacketFromSctpToNetwork(rtc::Buffer* buffer); |
216 // Called by OnMessage to decide what to do with the packet. | 224 // Called by OnMessage to decide what to do with the packet. |
217 void OnInboundPacketFromSctpToChannel(SctpInboundPacket* packet); | 225 void OnInboundPacketFromSctpToChannel(SctpInboundPacket* packet); |
218 void OnDataFromSctpToChannel(const ReceiveDataParams& params, | 226 void OnDataFromSctpToChannel(const ReceiveDataParams& params, |
219 rtc::Buffer* buffer); | 227 rtc::Buffer* buffer); |
220 void OnNotificationFromSctp(rtc::Buffer* buffer); | 228 void OnNotificationFromSctp(rtc::Buffer* buffer); |
221 void OnNotificationAssocChange(const sctp_assoc_change& change); | 229 void OnNotificationAssocChange(const sctp_assoc_change& change); |
222 | 230 |
223 void OnStreamResetEvent(const struct sctp_stream_reset_event* evt); | 231 void OnStreamResetEvent(const struct sctp_stream_reset_event* evt); |
224 | 232 |
233 static int SendThresholdCallback(struct socket* sock, uint32_t sb_free); | |
234 | |
225 // Responsible for marshalling incoming data to the channels listeners, and | 235 // Responsible for marshalling incoming data to the channels listeners, and |
226 // outgoing data to the network interface. | 236 // outgoing data to the network interface. |
227 rtc::Thread* worker_thread_; | 237 rtc::Thread* worker_thread_; |
228 // The local and remote SCTP port to use. These are passed along the wire | 238 // The local and remote SCTP port to use. These are passed along the wire |
229 // and the listener and connector must be using the same port. It is not | 239 // and the listener and connector must be using the same port. It is not |
230 // related to the ports at the IP level. If set to -1, we default to | 240 // related to the ports at the IP level. If set to -1, we default to |
231 // kSctpDefaultPort. | 241 // kSctpDefaultPort. |
232 int local_port_; | 242 int local_port_; |
233 int remote_port_; | 243 int remote_port_; |
234 struct socket* sock_; // The socket created by usrsctp_socket(...). | 244 struct socket* sock_; // The socket created by usrsctp_socket(...). |
(...skipping 14 matching lines...) Expand all Loading... | |
249 StreamSet queued_reset_streams_; | 259 StreamSet queued_reset_streams_; |
250 StreamSet sent_reset_streams_; | 260 StreamSet sent_reset_streams_; |
251 | 261 |
252 // A human-readable name for debugging messages. | 262 // A human-readable name for debugging messages. |
253 std::string debug_name_; | 263 std::string debug_name_; |
254 }; | 264 }; |
255 | 265 |
256 } // namespace cricket | 266 } // namespace cricket |
257 | 267 |
258 #endif // TALK_MEDIA_SCTP_SCTPDATAENGINE_H_ | 268 #endif // TALK_MEDIA_SCTP_SCTPDATAENGINE_H_ |
OLD | NEW |