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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
57 // The highest stream ID (Sid) that SCTP allows, and the number of streams we | 57 // The highest stream ID (Sid) that SCTP allows, and the number of streams we |
58 // tell SCTP we're going to use. | 58 // tell SCTP we're going to use. |
59 const uint32 kMaxSctpSid = 1023; | 59 const uint32 kMaxSctpSid = 1023; |
60 | 60 |
61 // This is the default SCTP port to use. It is passed along the wire and the | 61 // This is the default SCTP port to use. It is passed along the wire and the |
62 // connectee and connector must be using the same port. It is not related to the | 62 // connectee and connector must be using the same port. It is not related to the |
63 // ports at the IP level. (Corresponds to: sockaddr_conn.sconn_port in | 63 // ports at the IP level. (Corresponds to: sockaddr_conn.sconn_port in |
64 // usrsctp.h) | 64 // usrsctp.h) |
65 const int kSctpDefaultPort = 5000; | 65 const int kSctpDefaultPort = 5000; |
66 | 66 |
67 class SctpDataMediaChannel; | |
68 | |
67 // A DataEngine that interacts with usrsctp. | 69 // A DataEngine that interacts with usrsctp. |
68 // | 70 // |
69 // From channel calls, data flows like this: | 71 // From channel calls, data flows like this: |
70 // [worker thread (although it can in princple be another thread)] | 72 // [worker thread (although it can in princple be another thread)] |
71 // 1. SctpDataMediaChannel::SendData(data) | 73 // 1. SctpDataMediaChannel::SendData(data) |
72 // 2. usrsctp_sendv(data) | 74 // 2. usrsctp_sendv(data) |
73 // [worker thread returns; sctp thread then calls the following] | 75 // [worker thread returns; sctp thread then calls the following] |
74 // 3. OnSctpOutboundPacket(wrapped_data) | 76 // 3. OnSctpOutboundPacket(wrapped_data) |
75 // [sctp thread returns having posted a message for the worker thread] | 77 // [sctp thread returns having posted a message for the worker thread] |
76 // 4. SctpDataMediaChannel::OnMessage(wrapped_data) | 78 // 4. SctpDataMediaChannel::OnMessage(wrapped_data) |
(...skipping 10 matching lines...) Expand all Loading... | |
87 // 13. SctpDataMediaChannel::OnDataFromSctpToChannel(data) | 89 // 13. SctpDataMediaChannel::OnDataFromSctpToChannel(data) |
88 // 14. SctpDataMediaChannel::SignalDataReceived(data) | 90 // 14. SctpDataMediaChannel::SignalDataReceived(data) |
89 // [from the same thread, methods registered/connected to | 91 // [from the same thread, methods registered/connected to |
90 // SctpDataMediaChannel are called with the recieved data] | 92 // SctpDataMediaChannel are called with the recieved data] |
91 class SctpDataEngine : public DataEngineInterface { | 93 class SctpDataEngine : public DataEngineInterface { |
92 public: | 94 public: |
93 SctpDataEngine(); | 95 SctpDataEngine(); |
94 virtual ~SctpDataEngine(); | 96 virtual ~SctpDataEngine(); |
95 | 97 |
96 virtual DataMediaChannel* CreateChannel(DataChannelType data_channel_type); | 98 virtual DataMediaChannel* CreateChannel(DataChannelType data_channel_type); |
97 | |
98 virtual const std::vector<DataCodec>& data_codecs() { return codecs_; } | 99 virtual const std::vector<DataCodec>& data_codecs() { return codecs_; } |
99 | 100 |
100 private: | 101 private: |
101 static int usrsctp_engines_count; | 102 static int usrsctp_engines_count; |
102 std::vector<DataCodec> codecs_; | 103 std::vector<DataCodec> codecs_; |
103 }; | 104 }; |
104 | 105 |
105 // TODO(ldixon): Make into a special type of TypedMessageData. | 106 // TODO(ldixon): Make into a special type of TypedMessageData. |
106 // Holds data to be passed on to a channel. | 107 // Holds data to be passed on to a channel. |
107 struct SctpInboundPacket; | 108 struct SctpInboundPacket; |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
182 virtual void OnRtcpReceived(rtc::Buffer* packet, | 183 virtual void OnRtcpReceived(rtc::Buffer* packet, |
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 |
193 const struct socket* socket() { return sock_; } | |
192 private: | 194 private: |
195 static std::vector<SctpDataMediaChannel*> sock_channel_map_; | |
193 sockaddr_conn GetSctpSockAddr(int port); | 196 sockaddr_conn GetSctpSockAddr(int port); |
194 | 197 |
195 // Creates the socket and connects. Sets sending_ to true. | 198 // Creates the socket and connects. Sets sending_ to true. |
196 bool Connect(); | 199 bool Connect(); |
197 // Closes the socket. Sets sending_ to false. | 200 // Closes the socket. Sets sending_ to false. |
198 void Disconnect(); | 201 void Disconnect(); |
199 | 202 |
200 // Returns false when openning the socket failed; when successfull sets | 203 // Returns false when openning the socket failed; when successfull sets |
201 // sending_ to true | 204 // sending_ to true |
202 bool OpenSctpSocket(); | 205 bool OpenSctpSocket(); |
(...skipping 12 matching lines...) Expand all Loading... | |
215 void OnPacketFromSctpToNetwork(rtc::Buffer* buffer); | 218 void OnPacketFromSctpToNetwork(rtc::Buffer* buffer); |
216 // Called by OnMessage to decide what to do with the packet. | 219 // Called by OnMessage to decide what to do with the packet. |
217 void OnInboundPacketFromSctpToChannel(SctpInboundPacket* packet); | 220 void OnInboundPacketFromSctpToChannel(SctpInboundPacket* packet); |
218 void OnDataFromSctpToChannel(const ReceiveDataParams& params, | 221 void OnDataFromSctpToChannel(const ReceiveDataParams& params, |
219 rtc::Buffer* buffer); | 222 rtc::Buffer* buffer); |
220 void OnNotificationFromSctp(rtc::Buffer* buffer); | 223 void OnNotificationFromSctp(rtc::Buffer* buffer); |
221 void OnNotificationAssocChange(const sctp_assoc_change& change); | 224 void OnNotificationAssocChange(const sctp_assoc_change& change); |
222 | 225 |
223 void OnStreamResetEvent(const struct sctp_stream_reset_event* evt); | 226 void OnStreamResetEvent(const struct sctp_stream_reset_event* evt); |
224 | 227 |
228 static int SendThresholdCallback(struct socket* sock, uint32_t sb_free); | |
229 static SctpDataMediaChannel* GetSctpChannel(struct socket* sock); | |
pthatcher1
2015/08/18 21:51:53
This looks like it's never called or implemented.
lally1
2015/08/24 15:46:39
Yup. Removed.
| |
230 | |
225 // Responsible for marshalling incoming data to the channels listeners, and | 231 // Responsible for marshalling incoming data to the channels listeners, and |
226 // outgoing data to the network interface. | 232 // outgoing data to the network interface. |
227 rtc::Thread* worker_thread_; | 233 rtc::Thread* worker_thread_; |
228 // The local and remote SCTP port to use. These are passed along the wire | 234 // 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 | 235 // 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 | 236 // related to the ports at the IP level. If set to -1, we default to |
231 // kSctpDefaultPort. | 237 // kSctpDefaultPort. |
232 int local_port_; | 238 int local_port_; |
233 int remote_port_; | 239 int remote_port_; |
234 struct socket* sock_; // The socket created by usrsctp_socket(...). | 240 struct socket* sock_; // The socket created by usrsctp_socket(...). |
(...skipping 14 matching lines...) Expand all Loading... | |
249 StreamSet queued_reset_streams_; | 255 StreamSet queued_reset_streams_; |
250 StreamSet sent_reset_streams_; | 256 StreamSet sent_reset_streams_; |
251 | 257 |
252 // A human-readable name for debugging messages. | 258 // A human-readable name for debugging messages. |
253 std::string debug_name_; | 259 std::string debug_name_; |
254 }; | 260 }; |
255 | 261 |
256 } // namespace cricket | 262 } // namespace cricket |
257 | 263 |
258 #endif // TALK_MEDIA_SCTP_SCTPDATAENGINE_H_ | 264 #endif // TALK_MEDIA_SCTP_SCTPDATAENGINE_H_ |
OLD | NEW |