| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 | 58 |
| 59 // TODO(deadbeef): Unify with PeerConnectionInterface::IceConnectionState | 59 // TODO(deadbeef): Unify with PeerConnectionInterface::IceConnectionState |
| 60 // once /talk/ and /webrtc/ are combined, and also switch to ENUM_NAME naming | 60 // once /talk/ and /webrtc/ are combined, and also switch to ENUM_NAME naming |
| 61 // style. | 61 // style. |
| 62 enum IceGatheringState { | 62 enum IceGatheringState { |
| 63 kIceGatheringNew = 0, | 63 kIceGatheringNew = 0, |
| 64 kIceGatheringGathering, | 64 kIceGatheringGathering, |
| 65 kIceGatheringComplete, | 65 kIceGatheringComplete, |
| 66 }; | 66 }; |
| 67 | 67 |
| 68 // For "writable", "readable", and "receiving", we need to differentiate between | 68 // For "writable" and "receiving", we need to differentiate between |
| 69 // none, all, and some. | 69 // none, all, and some. |
| 70 enum TransportState { | 70 enum TransportState { |
| 71 TRANSPORT_STATE_NONE = 0, | 71 TRANSPORT_STATE_NONE = 0, |
| 72 TRANSPORT_STATE_SOME, | 72 TRANSPORT_STATE_SOME, |
| 73 TRANSPORT_STATE_ALL | 73 TRANSPORT_STATE_ALL |
| 74 }; | 74 }; |
| 75 | 75 |
| 76 // When checking transport state, we need to differentiate between | 76 // When checking transport state, we need to differentiate between |
| 77 // "readable", "writable", or "receiving" check. | 77 // "writable" or "receiving" check. |
| 78 enum TransportStateType { | 78 enum TransportStateType { |
| 79 TRANSPORT_READABLE_STATE = 0, | 79 TRANSPORT_WRITABLE_STATE = 0, |
| 80 TRANSPORT_WRITABLE_STATE, | |
| 81 TRANSPORT_RECEIVING_STATE | 80 TRANSPORT_RECEIVING_STATE |
| 82 }; | 81 }; |
| 83 | 82 |
| 84 // Stats that we can return about the connections for a transport channel. | 83 // Stats that we can return about the connections for a transport channel. |
| 85 // TODO(hta): Rename to ConnectionStats | 84 // TODO(hta): Rename to ConnectionStats |
| 86 struct ConnectionInfo { | 85 struct ConnectionInfo { |
| 87 ConnectionInfo() | 86 ConnectionInfo() |
| 88 : best_connection(false), | 87 : best_connection(false), |
| 89 writable(false), | 88 writable(false), |
| 90 readable(false), | |
| 91 timeout(false), | 89 timeout(false), |
| 92 new_connection(false), | 90 new_connection(false), |
| 93 rtt(0), | 91 rtt(0), |
| 94 sent_total_bytes(0), | 92 sent_total_bytes(0), |
| 95 sent_bytes_second(0), | 93 sent_bytes_second(0), |
| 96 sent_discarded_packets(0), | 94 sent_discarded_packets(0), |
| 97 sent_total_packets(0), | 95 sent_total_packets(0), |
| 98 recv_total_bytes(0), | 96 recv_total_bytes(0), |
| 99 recv_bytes_second(0), | 97 recv_bytes_second(0), |
| 100 key(NULL) {} | 98 key(NULL) {} |
| 101 | 99 |
| 102 bool best_connection; // Is this the best connection we have? | 100 bool best_connection; // Is this the best connection we have? |
| 103 bool writable; // Has this connection received a STUN response? | 101 bool writable; // Has this connection received a STUN response? |
| 104 bool readable; // Has this connection received a STUN request? | 102 bool receiving; // Has this connection received anything? |
| 105 bool timeout; // Has this connection timed out? | 103 bool timeout; // Has this connection timed out? |
| 106 bool new_connection; // Is this a newly created connection? | 104 bool new_connection; // Is this a newly created connection? |
| 107 size_t rtt; // The STUN RTT for this connection. | 105 size_t rtt; // The STUN RTT for this connection. |
| 108 size_t sent_total_bytes; // Total bytes sent on this connection. | 106 size_t sent_total_bytes; // Total bytes sent on this connection. |
| 109 size_t sent_bytes_second; // Bps over the last measurement interval. | 107 size_t sent_bytes_second; // Bps over the last measurement interval. |
| 110 size_t sent_discarded_packets; // Number of outgoing packets discarded due to | 108 size_t sent_discarded_packets; // Number of outgoing packets discarded due to |
| 111 // socket errors. | 109 // socket errors. |
| 112 size_t sent_total_packets; // Number of total outgoing packets attempted for | 110 size_t sent_total_packets; // Number of total outgoing packets attempted for |
| 113 // sending. | 111 // sending. |
| 114 | 112 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 public: | 149 public: |
| 152 Transport(const std::string& name, PortAllocator* allocator); | 150 Transport(const std::string& name, PortAllocator* allocator); |
| 153 virtual ~Transport(); | 151 virtual ~Transport(); |
| 154 | 152 |
| 155 // Returns the name of this transport. | 153 // Returns the name of this transport. |
| 156 const std::string& name() const { return name_; } | 154 const std::string& name() const { return name_; } |
| 157 | 155 |
| 158 // Returns the port allocator object for this transport. | 156 // Returns the port allocator object for this transport. |
| 159 PortAllocator* port_allocator() { return allocator_; } | 157 PortAllocator* port_allocator() { return allocator_; } |
| 160 | 158 |
| 161 // Returns the readable and states of this manager. These bits are the ORs | 159 // Returns the states of this manager. These bits are the ORs |
| 162 // of the corresponding bits on the managed channels. Each time one of these | 160 // of the corresponding bits on the managed channels. Each time one of these |
| 163 // states changes, a signal is raised. | 161 // states changes, a signal is raised. |
| 164 // TODO: Replace uses of readable() and writable() with | 162 // TODO(honghaiz): Replace uses of writable() with any_channels_writable(). |
| 165 // any_channels_readable() and any_channels_writable(). | |
| 166 bool readable() const { return any_channels_readable(); } | |
| 167 bool writable() const { return any_channels_writable(); } | 163 bool writable() const { return any_channels_writable(); } |
| 168 bool was_writable() const { return was_writable_; } | 164 bool was_writable() const { return was_writable_; } |
| 169 bool any_channels_readable() const { | |
| 170 return (readable_ == TRANSPORT_STATE_SOME || | |
| 171 readable_ == TRANSPORT_STATE_ALL); | |
| 172 } | |
| 173 bool any_channels_writable() const { | 165 bool any_channels_writable() const { |
| 174 return (writable_ == TRANSPORT_STATE_SOME || | 166 return (writable_ == TRANSPORT_STATE_SOME || |
| 175 writable_ == TRANSPORT_STATE_ALL); | 167 writable_ == TRANSPORT_STATE_ALL); |
| 176 } | 168 } |
| 177 bool all_channels_readable() const { | |
| 178 return (readable_ == TRANSPORT_STATE_ALL); | |
| 179 } | |
| 180 bool all_channels_writable() const { | 169 bool all_channels_writable() const { |
| 181 return (writable_ == TRANSPORT_STATE_ALL); | 170 return (writable_ == TRANSPORT_STATE_ALL); |
| 182 } | 171 } |
| 183 bool any_channel_receiving() const { | 172 bool any_channel_receiving() const { |
| 184 return (receiving_ == TRANSPORT_STATE_SOME || | 173 return (receiving_ == TRANSPORT_STATE_SOME || |
| 185 receiving_ == TRANSPORT_STATE_ALL); | 174 receiving_ == TRANSPORT_STATE_ALL); |
| 186 } | 175 } |
| 187 bool ready_for_remote_candidates() const { | 176 bool ready_for_remote_candidates() const { |
| 188 return local_description_set_ && remote_description_set_; | 177 return local_description_set_ && remote_description_set_; |
| 189 } | 178 } |
| 190 | 179 |
| 191 bool AllChannelsCompleted() const; | 180 bool AllChannelsCompleted() const; |
| 192 bool AnyChannelFailed() const; | 181 bool AnyChannelFailed() const; |
| 193 | 182 |
| 194 IceGatheringState gathering_state() const { return gathering_state_; } | 183 IceGatheringState gathering_state() const { return gathering_state_; } |
| 195 | 184 |
| 196 sigslot::signal1<Transport*> SignalReadableState; | |
| 197 sigslot::signal1<Transport*> SignalWritableState; | 185 sigslot::signal1<Transport*> SignalWritableState; |
| 198 sigslot::signal1<Transport*> SignalReceivingState; | 186 sigslot::signal1<Transport*> SignalReceivingState; |
| 199 sigslot::signal1<Transport*> SignalCompleted; | 187 sigslot::signal1<Transport*> SignalCompleted; |
| 200 sigslot::signal1<Transport*> SignalFailed; | 188 sigslot::signal1<Transport*> SignalFailed; |
| 201 | 189 |
| 202 // Returns whether the client has requested the channels to connect. | 190 // Returns whether the client has requested the channels to connect. |
| 203 bool connect_requested() const { return connect_requested_; } | 191 bool connect_requested() const { return connect_requested_; } |
| 204 | 192 |
| 205 void SetIceRole(IceRole role); | 193 void SetIceRole(IceRole role); |
| 206 IceRole ice_role() const { return ice_role_; } | 194 IceRole ice_role() const { return ice_role_; } |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 352 TransportChannelImpl* operator->() const { return impl_; } | 340 TransportChannelImpl* operator->() const { return impl_; } |
| 353 | 341 |
| 354 private: | 342 private: |
| 355 TransportChannelImpl* impl_; | 343 TransportChannelImpl* impl_; |
| 356 int ref_; | 344 int ref_; |
| 357 }; | 345 }; |
| 358 | 346 |
| 359 // Candidate component => ChannelMapEntry | 347 // Candidate component => ChannelMapEntry |
| 360 typedef std::map<int, ChannelMapEntry> ChannelMap; | 348 typedef std::map<int, ChannelMapEntry> ChannelMap; |
| 361 | 349 |
| 362 // Called when the state of a channel changes. | 350 // Called when the write state of a channel changes. |
| 363 void OnChannelReadableState(TransportChannel* channel); | |
| 364 void OnChannelWritableState(TransportChannel* channel); | 351 void OnChannelWritableState(TransportChannel* channel); |
| 365 | 352 |
| 366 // Called when the receiving state of a channel changes. | 353 // Called when the receiving state of a channel changes. |
| 367 void OnChannelReceivingState(TransportChannel* channel); | 354 void OnChannelReceivingState(TransportChannel* channel); |
| 368 | 355 |
| 369 // Called when a channel starts finishes gathering candidates | 356 // Called when a channel starts finishes gathering candidates |
| 370 void OnChannelGatheringState(TransportChannelImpl* channel); | 357 void OnChannelGatheringState(TransportChannelImpl* channel); |
| 371 | 358 |
| 372 // Called when a candidate is ready from channel. | 359 // Called when a candidate is ready from channel. |
| 373 void OnChannelCandidateGathered(TransportChannelImpl* channel, | 360 void OnChannelCandidateGathered(TransportChannelImpl* channel, |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 420 // provide them in multiples. | 407 // provide them in multiples. |
| 421 std::vector<Candidate> ready_candidates_; | 408 std::vector<Candidate> ready_candidates_; |
| 422 | 409 |
| 423 RTC_DISALLOW_COPY_AND_ASSIGN(Transport); | 410 RTC_DISALLOW_COPY_AND_ASSIGN(Transport); |
| 424 }; | 411 }; |
| 425 | 412 |
| 426 | 413 |
| 427 } // namespace cricket | 414 } // namespace cricket |
| 428 | 415 |
| 429 #endif // WEBRTC_P2P_BASE_TRANSPORT_H_ | 416 #endif // WEBRTC_P2P_BASE_TRANSPORT_H_ |
| OLD | NEW |