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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 | 49 |
50 // Defined by "usrsctplib/usrsctp.h" | 50 // Defined by "usrsctplib/usrsctp.h" |
51 struct sockaddr_conn; | 51 struct sockaddr_conn; |
52 struct sctp_assoc_change; | 52 struct sctp_assoc_change; |
53 struct sctp_stream_reset_event; | 53 struct sctp_stream_reset_event; |
54 // Defined by <sys/socket.h> | 54 // Defined by <sys/socket.h> |
55 struct socket; | 55 struct socket; |
56 namespace cricket { | 56 namespace cricket { |
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_t 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; | 67 class SctpDataMediaChannel; |
68 | 68 |
69 // A DataEngine that interacts with usrsctp. | 69 // A DataEngine that interacts with usrsctp. |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 // Matches the PPIDs in mozilla source and | 127 // Matches the PPIDs in mozilla source and |
128 // https://datatracker.ietf.org/doc/draft-ietf-rtcweb-data-protocol Sec. 9 | 128 // https://datatracker.ietf.org/doc/draft-ietf-rtcweb-data-protocol Sec. 9 |
129 // They're not yet assigned by IANA. | 129 // They're not yet assigned by IANA. |
130 PPID_CONTROL = 50, | 130 PPID_CONTROL = 50, |
131 PPID_BINARY_PARTIAL = 52, | 131 PPID_BINARY_PARTIAL = 52, |
132 PPID_BINARY_LAST = 53, | 132 PPID_BINARY_LAST = 53, |
133 PPID_TEXT_PARTIAL = 54, | 133 PPID_TEXT_PARTIAL = 54, |
134 PPID_TEXT_LAST = 51 | 134 PPID_TEXT_LAST = 51 |
135 }; | 135 }; |
136 | 136 |
137 typedef std::set<uint32> StreamSet; | 137 typedef std::set<uint32_t> StreamSet; |
138 | 138 |
139 // Given a thread which will be used to post messages (received data) to this | 139 // Given a thread which will be used to post messages (received data) to this |
140 // SctpDataMediaChannel instance. | 140 // SctpDataMediaChannel instance. |
141 explicit SctpDataMediaChannel(rtc::Thread* thread); | 141 explicit SctpDataMediaChannel(rtc::Thread* thread); |
142 virtual ~SctpDataMediaChannel(); | 142 virtual ~SctpDataMediaChannel(); |
143 | 143 |
144 // When SetSend is set to true, connects. When set to false, disconnects. | 144 // When SetSend is set to true, connects. When set to false, disconnects. |
145 // Calling: "SetSend(true); SetSend(false); SetSend(true);" will connect, | 145 // Calling: "SetSend(true); SetSend(false); SetSend(true);" will connect, |
146 // disconnect, and reconnect. | 146 // disconnect, and reconnect. |
147 virtual bool SetSend(bool send); | 147 virtual bool SetSend(bool send); |
148 // Unless SetReceive(true) is called, received packets will be discarded. | 148 // Unless SetReceive(true) is called, received packets will be discarded. |
149 virtual bool SetReceive(bool receive); | 149 virtual bool SetReceive(bool receive); |
150 | 150 |
151 virtual bool SetSendParameters(const DataSendParameters& params); | 151 virtual bool SetSendParameters(const DataSendParameters& params); |
152 virtual bool SetRecvParameters(const DataRecvParameters& params); | 152 virtual bool SetRecvParameters(const DataRecvParameters& params); |
153 virtual bool AddSendStream(const StreamParams& sp); | 153 virtual bool AddSendStream(const StreamParams& sp); |
154 virtual bool RemoveSendStream(uint32 ssrc); | 154 virtual bool RemoveSendStream(uint32_t ssrc); |
155 virtual bool AddRecvStream(const StreamParams& sp); | 155 virtual bool AddRecvStream(const StreamParams& sp); |
156 virtual bool RemoveRecvStream(uint32 ssrc); | 156 virtual bool RemoveRecvStream(uint32_t ssrc); |
157 | 157 |
158 // Called when Sctp gets data. The data may be a notification or data for | 158 // Called when Sctp gets data. The data may be a notification or data for |
159 // OnSctpInboundData. Called from the worker thread. | 159 // OnSctpInboundData. Called from the worker thread. |
160 virtual void OnMessage(rtc::Message* msg); | 160 virtual void OnMessage(rtc::Message* msg); |
161 // Send data down this channel (will be wrapped as SCTP packets then given to | 161 // Send data down this channel (will be wrapped as SCTP packets then given to |
162 // sctp that will then post the network interface by OnMessage). | 162 // sctp that will then post the network interface by OnMessage). |
163 // Returns true iff successful data somewhere on the send-queue/network. | 163 // Returns true iff successful data somewhere on the send-queue/network. |
164 virtual bool SendData(const SendDataParams& params, | 164 virtual bool SendData(const SendDataParams& params, |
165 const rtc::Buffer& payload, | 165 const rtc::Buffer& payload, |
166 SendDataResult* result = NULL); | 166 SendDataResult* result = NULL); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 bool OpenSctpSocket(); | 200 bool OpenSctpSocket(); |
201 // Sets sending_ to false and sock_ to NULL. | 201 // Sets sending_ to false and sock_ to NULL. |
202 void CloseSctpSocket(); | 202 void CloseSctpSocket(); |
203 | 203 |
204 // Sends a SCTP_RESET_STREAM for all streams in closing_ssids_. | 204 // Sends a SCTP_RESET_STREAM for all streams in closing_ssids_. |
205 bool SendQueuedStreamResets(); | 205 bool SendQueuedStreamResets(); |
206 | 206 |
207 // Adds a stream. | 207 // Adds a stream. |
208 bool AddStream(const StreamParams &sp); | 208 bool AddStream(const StreamParams &sp); |
209 // Queues a stream for reset. | 209 // Queues a stream for reset. |
210 bool ResetStream(uint32 ssrc); | 210 bool ResetStream(uint32_t ssrc); |
211 | 211 |
212 // Called by OnMessage to send packet on the network. | 212 // Called by OnMessage to send packet on the network. |
213 void OnPacketFromSctpToNetwork(rtc::Buffer* buffer); | 213 void OnPacketFromSctpToNetwork(rtc::Buffer* buffer); |
214 // Called by OnMessage to decide what to do with the packet. | 214 // Called by OnMessage to decide what to do with the packet. |
215 void OnInboundPacketFromSctpToChannel(SctpInboundPacket* packet); | 215 void OnInboundPacketFromSctpToChannel(SctpInboundPacket* packet); |
216 void OnDataFromSctpToChannel(const ReceiveDataParams& params, | 216 void OnDataFromSctpToChannel(const ReceiveDataParams& params, |
217 rtc::Buffer* buffer); | 217 rtc::Buffer* buffer); |
218 void OnNotificationFromSctp(rtc::Buffer* buffer); | 218 void OnNotificationFromSctp(rtc::Buffer* buffer); |
219 void OnNotificationAssocChange(const sctp_assoc_change& change); | 219 void OnNotificationAssocChange(const sctp_assoc_change& change); |
220 | 220 |
(...skipping 26 matching lines...) Expand all Loading... |
247 StreamSet queued_reset_streams_; | 247 StreamSet queued_reset_streams_; |
248 StreamSet sent_reset_streams_; | 248 StreamSet sent_reset_streams_; |
249 | 249 |
250 // A human-readable name for debugging messages. | 250 // A human-readable name for debugging messages. |
251 std::string debug_name_; | 251 std::string debug_name_; |
252 }; | 252 }; |
253 | 253 |
254 } // namespace cricket | 254 } // namespace cricket |
255 | 255 |
256 #endif // TALK_MEDIA_SCTP_SCTPDATAENGINE_H_ | 256 #endif // TALK_MEDIA_SCTP_SCTPDATAENGINE_H_ |
OLD | NEW |