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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 STATE_FAILED | 44 STATE_FAILED |
45 }; | 45 }; |
46 | 46 |
47 // A TransportChannel represents one logical stream of packets that are sent | 47 // A TransportChannel represents one logical stream of packets that are sent |
48 // between the two sides of a session. | 48 // between the two sides of a session. |
49 class TransportChannel : public sigslot::has_slots<> { | 49 class TransportChannel : public sigslot::has_slots<> { |
50 public: | 50 public: |
51 explicit TransportChannel(const std::string& transport_name, int component) | 51 explicit TransportChannel(const std::string& transport_name, int component) |
52 : transport_name_(transport_name), | 52 : transport_name_(transport_name), |
53 component_(component), | 53 component_(component), |
54 readable_(false), | |
55 writable_(false), | 54 writable_(false), |
56 receiving_(false) {} | 55 receiving_(false) {} |
57 virtual ~TransportChannel() {} | 56 virtual ~TransportChannel() {} |
58 | 57 |
59 // TODO(guoweis) - Make this pure virtual once all subclasses of | 58 // TODO(guoweis) - Make this pure virtual once all subclasses of |
60 // TransportChannel have this defined. | 59 // TransportChannel have this defined. |
61 virtual TransportChannelState GetState() const { | 60 virtual TransportChannelState GetState() const { |
62 return TransportChannelState::STATE_CONNECTING; | 61 return TransportChannelState::STATE_CONNECTING; |
63 } | 62 } |
64 | 63 |
65 // TODO(mallinath) - Remove this API, as it's no longer useful. | 64 // TODO(mallinath) - Remove this API, as it's no longer useful. |
66 // Returns the session id of this channel. | 65 // Returns the session id of this channel. |
67 virtual const std::string SessionId() const { return std::string(); } | 66 virtual const std::string SessionId() const { return std::string(); } |
68 | 67 |
69 const std::string& transport_name() const { return transport_name_; } | 68 const std::string& transport_name() const { return transport_name_; } |
70 int component() const { return component_; } | 69 int component() const { return component_; } |
71 | 70 |
72 // Returns the readable and states of this channel. Each time one of these | 71 // Returns the states of this channel. Each time one of these states changes, |
73 // states changes, a signal is raised. These states are aggregated by the | 72 // a signal is raised. These states are aggregated by the TransportManager. |
74 // TransportManager. | |
75 bool readable() const { return readable_; } | |
76 bool writable() const { return writable_; } | 73 bool writable() const { return writable_; } |
77 bool receiving() const { return receiving_; } | 74 bool receiving() const { return receiving_; } |
78 sigslot::signal1<TransportChannel*> SignalReadableState; | |
79 sigslot::signal1<TransportChannel*> SignalWritableState; | 75 sigslot::signal1<TransportChannel*> SignalWritableState; |
80 // Emitted when the TransportChannel's ability to send has changed. | 76 // Emitted when the TransportChannel's ability to send has changed. |
81 sigslot::signal1<TransportChannel*> SignalReadyToSend; | 77 sigslot::signal1<TransportChannel*> SignalReadyToSend; |
82 sigslot::signal1<TransportChannel*> SignalReceivingState; | 78 sigslot::signal1<TransportChannel*> SignalReceivingState; |
83 | 79 |
84 // Attempts to send the given packet. The return value is < 0 on failure. | 80 // Attempts to send the given packet. The return value is < 0 on failure. |
85 // TODO: Remove the default argument once channel code is updated. | 81 // TODO: Remove the default argument once channel code is updated. |
86 virtual int SendPacket(const char* data, size_t len, | 82 virtual int SendPacket(const char* data, size_t len, |
87 const rtc::PacketOptions& options, | 83 const rtc::PacketOptions& options, |
88 int flags = 0) = 0; | 84 int flags = 0) = 0; |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 // indicates where and how we are currently sending media. | 135 // indicates where and how we are currently sending media. |
140 sigslot::signal2<TransportChannel*, const Candidate&> SignalRouteChange; | 136 sigslot::signal2<TransportChannel*, const Candidate&> SignalRouteChange; |
141 | 137 |
142 // Invoked when the channel is being destroyed. | 138 // Invoked when the channel is being destroyed. |
143 sigslot::signal1<TransportChannel*> SignalDestroyed; | 139 sigslot::signal1<TransportChannel*> SignalDestroyed; |
144 | 140 |
145 // Debugging description of this transport channel. | 141 // Debugging description of this transport channel. |
146 std::string ToString() const; | 142 std::string ToString() const; |
147 | 143 |
148 protected: | 144 protected: |
149 // Sets the readable state, signaling if necessary. | |
150 void set_readable(bool readable); | |
151 | 145 |
152 // Sets the writable state, signaling if necessary. | 146 // Sets the writable state, signaling if necessary. |
153 void set_writable(bool writable); | 147 void set_writable(bool writable); |
154 | 148 |
155 // Sets the receiving state, signaling if necessary. | 149 // Sets the receiving state, signaling if necessary. |
156 void set_receiving(bool receiving); | 150 void set_receiving(bool receiving); |
157 | 151 |
158 private: | 152 private: |
159 // Used mostly for debugging. | 153 // Used mostly for debugging. |
160 std::string transport_name_; | 154 std::string transport_name_; |
161 int component_; | 155 int component_; |
162 bool readable_; | |
163 bool writable_; | 156 bool writable_; |
164 bool receiving_; | 157 bool receiving_; |
165 | 158 |
166 RTC_DISALLOW_COPY_AND_ASSIGN(TransportChannel); | 159 RTC_DISALLOW_COPY_AND_ASSIGN(TransportChannel); |
167 }; | 160 }; |
168 | 161 |
169 } // namespace cricket | 162 } // namespace cricket |
170 | 163 |
171 #endif // WEBRTC_P2P_BASE_TRANSPORTCHANNEL_H_ | 164 #endif // WEBRTC_P2P_BASE_TRANSPORTCHANNEL_H_ |
OLD | NEW |