| 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 | 174 // TODO(ldixon): add a DataOptions class to mediachannel.h |
| 173 virtual bool SetOptions(int options) { return false; } | |
| 174 virtual int GetOptions() const { return 0; } | 175 virtual int GetOptions() const { return 0; } |
| 175 | 176 |
| 176 // Many of these things are unused by SCTP, but are needed to fulfill | 177 // Many of these things are unused by SCTP, but are needed to fulfill |
| 177 // the MediaChannel interface. | 178 // the MediaChannel interface. |
| 178 // TODO(pthatcher): Cleanup MediaChannel interface, or at least | |
| 179 // don't try calling these and return false. Right now, things | |
| 180 // don't work if we return false. | |
| 181 virtual bool SetMaxSendBandwidth(int bps) { return true; } | |
| 182 virtual bool SetRecvRtpHeaderExtensions( | |
| 183 const std::vector<RtpHeaderExtension>& extensions) { return true; } | |
| 184 virtual bool SetSendRtpHeaderExtensions( | |
| 185 const std::vector<RtpHeaderExtension>& extensions) { return true; } | |
| 186 virtual bool SetSendCodecs(const std::vector<DataCodec>& codecs); | |
| 187 virtual bool SetRecvCodecs(const std::vector<DataCodec>& codecs); | |
| 188 virtual void OnRtcpReceived(rtc::Buffer* packet, | 179 virtual void OnRtcpReceived(rtc::Buffer* packet, |
| 189 const rtc::PacketTime& packet_time) {} | 180 const rtc::PacketTime& packet_time) {} |
| 190 virtual void OnReadyToSend(bool ready) {} | 181 virtual void OnReadyToSend(bool ready) {} |
| 191 | 182 |
| 192 void OnSendThresholdCallback(); | 183 void OnSendThresholdCallback(); |
| 193 // Helper for debugging. | 184 // Helper for debugging. |
| 194 void set_debug_name(const std::string& debug_name) { | 185 void set_debug_name(const std::string& debug_name) { |
| 195 debug_name_ = debug_name; | 186 debug_name_ = debug_name; |
| 196 } | 187 } |
| 197 const std::string& debug_name() const { return debug_name_; } | 188 const std::string& debug_name() const { return debug_name_; } |
| 198 const struct socket* socket() const { return sock_; } | 189 const struct socket* socket() const { return sock_; } |
| 199 private: | 190 private: |
| 200 sockaddr_conn GetSctpSockAddr(int port); | 191 sockaddr_conn GetSctpSockAddr(int port); |
| 201 | 192 |
| 193 bool SetSendCodecs(const std::vector<DataCodec>& codecs); |
| 194 bool SetRecvCodecs(const std::vector<DataCodec>& codecs); |
| 195 |
| 202 // Creates the socket and connects. Sets sending_ to true. | 196 // Creates the socket and connects. Sets sending_ to true. |
| 203 bool Connect(); | 197 bool Connect(); |
| 204 // Closes the socket. Sets sending_ to false. | 198 // Closes the socket. Sets sending_ to false. |
| 205 void Disconnect(); | 199 void Disconnect(); |
| 206 | 200 |
| 207 // Returns false when openning the socket failed; when successfull sets | 201 // Returns false when openning the socket failed; when successfull sets |
| 208 // sending_ to true | 202 // sending_ to true |
| 209 bool OpenSctpSocket(); | 203 bool OpenSctpSocket(); |
| 210 // Sets sending_ to false and sock_ to NULL. | 204 // Sets sending_ to false and sock_ to NULL. |
| 211 void CloseSctpSocket(); | 205 void CloseSctpSocket(); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 StreamSet queued_reset_streams_; | 250 StreamSet queued_reset_streams_; |
| 257 StreamSet sent_reset_streams_; | 251 StreamSet sent_reset_streams_; |
| 258 | 252 |
| 259 // A human-readable name for debugging messages. | 253 // A human-readable name for debugging messages. |
| 260 std::string debug_name_; | 254 std::string debug_name_; |
| 261 }; | 255 }; |
| 262 | 256 |
| 263 } // namespace cricket | 257 } // namespace cricket |
| 264 | 258 |
| 265 #endif // TALK_MEDIA_SCTP_SCTPDATAENGINE_H_ | 259 #endif // TALK_MEDIA_SCTP_SCTPDATAENGINE_H_ |
| OLD | NEW |