| 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 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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); |
| 152 virtual bool SetRecvParameters(const DataRecvParameters& params); |
| 151 virtual bool AddSendStream(const StreamParams& sp); | 153 virtual bool AddSendStream(const StreamParams& sp); |
| 152 virtual bool RemoveSendStream(uint32 ssrc); | 154 virtual bool RemoveSendStream(uint32 ssrc); |
| 153 virtual bool AddRecvStream(const StreamParams& sp); | 155 virtual bool AddRecvStream(const StreamParams& sp); |
| 154 virtual bool RemoveRecvStream(uint32 ssrc); | 156 virtual bool RemoveRecvStream(uint32 ssrc); |
| 155 | 157 |
| 156 // 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 |
| 157 // OnSctpInboundData. Called from the worker thread. | 159 // OnSctpInboundData. Called from the worker thread. |
| 158 virtual void OnMessage(rtc::Message* msg); | 160 virtual void OnMessage(rtc::Message* msg); |
| 159 // 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 |
| 160 // sctp that will then post the network interface by OnMessage). | 162 // sctp that will then post the network interface by OnMessage). |
| 161 // Returns true iff successful data somewhere on the send-queue/network. | 163 // Returns true iff successful data somewhere on the send-queue/network. |
| 162 virtual bool SendData(const SendDataParams& params, | 164 virtual bool SendData(const SendDataParams& params, |
| 163 const rtc::Buffer& payload, | 165 const rtc::Buffer& payload, |
| 164 SendDataResult* result = NULL); | 166 SendDataResult* result = NULL); |
| 165 // A packet is received from the network interface. Posted to OnMessage. | 167 // A packet is received from the network interface. Posted to OnMessage. |
| 166 virtual void OnPacketReceived(rtc::Buffer* packet, | 168 virtual void OnPacketReceived(rtc::Buffer* packet, |
| 167 const rtc::PacketTime& packet_time); | 169 const rtc::PacketTime& packet_time); |
| 168 | 170 |
| 169 // Exposed to allow Post call from c-callbacks. | 171 // Exposed to allow Post call from c-callbacks. |
| 170 rtc::Thread* worker_thread() const { return worker_thread_; } | 172 rtc::Thread* worker_thread() const { return worker_thread_; } |
| 171 | 173 |
| 172 // TODO(ldixon): add a DataOptions class to mediachannel.h | |
| 173 virtual bool SetOptions(int options) { return false; } | |
| 174 | |
| 175 // Many of these things are unused by SCTP, but are needed to fulfill | 174 // Many of these things are unused by SCTP, but are needed to fulfill |
| 176 // the MediaChannel interface. | 175 // the MediaChannel interface. |
| 177 // TODO(pthatcher): Cleanup MediaChannel interface, or at least | |
| 178 // don't try calling these and return false. Right now, things | |
| 179 // don't work if we return false. | |
| 180 virtual bool SetMaxSendBandwidth(int bps) { return true; } | |
| 181 virtual bool SetRecvRtpHeaderExtensions( | |
| 182 const std::vector<RtpHeaderExtension>& extensions) { return true; } | |
| 183 virtual bool SetSendRtpHeaderExtensions( | |
| 184 const std::vector<RtpHeaderExtension>& extensions) { return true; } | |
| 185 virtual bool SetSendCodecs(const std::vector<DataCodec>& codecs); | |
| 186 virtual bool SetRecvCodecs(const std::vector<DataCodec>& codecs); | |
| 187 virtual void OnRtcpReceived(rtc::Buffer* packet, | 176 virtual void OnRtcpReceived(rtc::Buffer* packet, |
| 188 const rtc::PacketTime& packet_time) {} | 177 const rtc::PacketTime& packet_time) {} |
| 189 virtual void OnReadyToSend(bool ready) {} | 178 virtual void OnReadyToSend(bool ready) {} |
| 190 | 179 |
| 191 void OnSendThresholdCallback(); | 180 void OnSendThresholdCallback(); |
| 192 // Helper for debugging. | 181 // Helper for debugging. |
| 193 void set_debug_name(const std::string& debug_name) { | 182 void set_debug_name(const std::string& debug_name) { |
| 194 debug_name_ = debug_name; | 183 debug_name_ = debug_name; |
| 195 } | 184 } |
| 196 const std::string& debug_name() const { return debug_name_; } | 185 const std::string& debug_name() const { return debug_name_; } |
| 197 const struct socket* socket() const { return sock_; } | 186 const struct socket* socket() const { return sock_; } |
| 198 private: | 187 private: |
| 199 sockaddr_conn GetSctpSockAddr(int port); | 188 sockaddr_conn GetSctpSockAddr(int port); |
| 200 | 189 |
| 190 bool SetSendCodecs(const std::vector<DataCodec>& codecs); |
| 191 bool SetRecvCodecs(const std::vector<DataCodec>& codecs); |
| 192 |
| 201 // Creates the socket and connects. Sets sending_ to true. | 193 // Creates the socket and connects. Sets sending_ to true. |
| 202 bool Connect(); | 194 bool Connect(); |
| 203 // Closes the socket. Sets sending_ to false. | 195 // Closes the socket. Sets sending_ to false. |
| 204 void Disconnect(); | 196 void Disconnect(); |
| 205 | 197 |
| 206 // Returns false when openning the socket failed; when successfull sets | 198 // Returns false when openning the socket failed; when successfull sets |
| 207 // sending_ to true | 199 // sending_ to true |
| 208 bool OpenSctpSocket(); | 200 bool OpenSctpSocket(); |
| 209 // Sets sending_ to false and sock_ to NULL. | 201 // Sets sending_ to false and sock_ to NULL. |
| 210 void CloseSctpSocket(); | 202 void CloseSctpSocket(); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 255 StreamSet queued_reset_streams_; | 247 StreamSet queued_reset_streams_; |
| 256 StreamSet sent_reset_streams_; | 248 StreamSet sent_reset_streams_; |
| 257 | 249 |
| 258 // A human-readable name for debugging messages. | 250 // A human-readable name for debugging messages. |
| 259 std::string debug_name_; | 251 std::string debug_name_; |
| 260 }; | 252 }; |
| 261 | 253 |
| 262 } // namespace cricket | 254 } // namespace cricket |
| 263 | 255 |
| 264 #endif // TALK_MEDIA_SCTP_SCTPDATAENGINE_H_ | 256 #endif // TALK_MEDIA_SCTP_SCTPDATAENGINE_H_ |
| OLD | NEW |