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