OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright 2017 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2017 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 |
11 #ifndef WEBRTC_P2P_BASE_FAKEICETRANSPORT_H_ | 11 #ifndef WEBRTC_P2P_BASE_FAKEICETRANSPORT_H_ |
12 #define WEBRTC_P2P_BASE_FAKEICETRANSPORT_H_ | 12 #define WEBRTC_P2P_BASE_FAKEICETRANSPORT_H_ |
13 | 13 |
14 #include <string> | 14 #include <string> |
15 | 15 |
16 #include "webrtc/base/asyncinvoker.h" | 16 #include "webrtc/base/asyncinvoker.h" |
17 #include "webrtc/base/copyonwritebuffer.h" | 17 #include "webrtc/base/copyonwritebuffer.h" |
18 #include "webrtc/media/base/rtputils.h" | |
joachim
2017/02/28 00:11:45
This dependency is invalid ("media" depends on "p2
joachim
2017/02/28 13:09:32
That should have been "p2p/base", not "/base".
Taylor Brandstetter
2017/02/28 22:53:40
I don't quite understand why this dependency is ne
| |
18 #include "webrtc/p2p/base/icetransportinternal.h" | 19 #include "webrtc/p2p/base/icetransportinternal.h" |
19 | 20 |
20 namespace cricket { | 21 namespace cricket { |
21 | 22 |
22 class FakeIceTransport : public IceTransportInternal { | 23 class FakeIceTransport : public IceTransportInternal { |
23 public: | 24 public: |
24 explicit FakeIceTransport(const std::string& name, int component) | 25 explicit FakeIceTransport(const std::string& name, int component) |
25 : name_(name), component_(component) {} | 26 : name_(name), component_(component) {} |
26 ~FakeIceTransport() override { | 27 ~FakeIceTransport() override { |
27 if (dest_ && dest_->dest_ == this) { | 28 if (dest_ && dest_->dest_ == this) { |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
165 size_t len, | 166 size_t len, |
166 const rtc::PacketOptions& options, | 167 const rtc::PacketOptions& options, |
167 int flags) override { | 168 int flags) override { |
168 if (!dest_) { | 169 if (!dest_) { |
169 return -1; | 170 return -1; |
170 } | 171 } |
171 rtc::CopyOnWriteBuffer packet(data, len); | 172 rtc::CopyOnWriteBuffer packet(data, len); |
172 if (async_) { | 173 if (async_) { |
173 invoker_.AsyncInvokeDelayed<void>( | 174 invoker_.AsyncInvokeDelayed<void>( |
174 RTC_FROM_HERE, rtc::Thread::Current(), | 175 RTC_FROM_HERE, rtc::Thread::Current(), |
175 rtc::Bind(&FakeIceTransport::SendPacketInternal, this, packet), | 176 rtc::Bind(&FakeIceTransport::SendPacketInternal, this, packet, |
177 options), | |
176 async_delay_ms_); | 178 async_delay_ms_); |
177 } else { | 179 } else { |
178 SendPacketInternal(packet); | 180 SendPacketInternal(packet, options); |
179 } | 181 } |
180 rtc::SentPacket sent_packet(options.packet_id, rtc::TimeMillis()); | 182 rtc::SentPacket sent_packet(options.packet_id, rtc::TimeMillis()); |
181 SignalSentPacket(this, sent_packet); | 183 SignalSentPacket(this, sent_packet); |
182 return static_cast<int>(len); | 184 return static_cast<int>(len); |
183 } | 185 } |
184 int SetOption(rtc::Socket::Option opt, int value) override { return true; } | 186 int SetOption(rtc::Socket::Option opt, int value) override { return true; } |
185 bool GetOption(rtc::Socket::Option opt, int* value) override { return true; } | 187 bool GetOption(rtc::Socket::Option opt, int* value) override { return true; } |
186 int GetError() override { return 0; } | 188 int GetError() override { return 0; } |
187 | 189 |
188 private: | 190 private: |
(...skipping 10 matching lines...) Expand all Loading... | |
199 } | 201 } |
200 | 202 |
201 void set_receiving(bool receiving) { | 203 void set_receiving(bool receiving) { |
202 if (receiving_ == receiving) { | 204 if (receiving_ == receiving) { |
203 return; | 205 return; |
204 } | 206 } |
205 receiving_ = receiving; | 207 receiving_ = receiving; |
206 SignalReceivingState(this); | 208 SignalReceivingState(this); |
207 } | 209 } |
208 | 210 |
209 void SendPacketInternal(const rtc::CopyOnWriteBuffer& packet) { | 211 void SendPacketInternal(const rtc::CopyOnWriteBuffer& packet, |
212 const rtc::PacketOptions& options) { | |
210 if (dest_) { | 213 if (dest_) { |
211 dest_->SignalReadPacket(dest_, packet.data<char>(), packet.size(), | 214 rtc::CopyOnWriteBuffer data(packet); |
215 cricket::ApplyPacketOptions( | |
216 reinterpret_cast<uint8_t*>(data.data<char>()), data.size(), | |
217 options.packet_time_params, 0); | |
218 dest_->SignalReadPacket(dest_, data.data<char>(), data.size(), | |
212 rtc::CreatePacketTime(0), 0); | 219 rtc::CreatePacketTime(0), 0); |
213 } | 220 } |
214 } | 221 } |
215 | 222 |
216 rtc::AsyncInvoker invoker_; | 223 rtc::AsyncInvoker invoker_; |
217 std::string name_; | 224 std::string name_; |
218 int component_; | 225 int component_; |
219 FakeIceTransport* dest_ = nullptr; | 226 FakeIceTransport* dest_ = nullptr; |
220 bool async_ = false; | 227 bool async_ = false; |
221 int async_delay_ms_ = 0; | 228 int async_delay_ms_ = 0; |
222 Candidates remote_candidates_; | 229 Candidates remote_candidates_; |
223 IceConfig ice_config_; | 230 IceConfig ice_config_; |
224 IceRole role_ = ICEROLE_UNKNOWN; | 231 IceRole role_ = ICEROLE_UNKNOWN; |
225 uint64_t tiebreaker_ = 0; | 232 uint64_t tiebreaker_ = 0; |
226 std::string ice_ufrag_; | 233 std::string ice_ufrag_; |
227 std::string ice_pwd_; | 234 std::string ice_pwd_; |
228 std::string remote_ice_ufrag_; | 235 std::string remote_ice_ufrag_; |
229 std::string remote_ice_pwd_; | 236 std::string remote_ice_pwd_; |
230 IceMode remote_ice_mode_ = ICEMODE_FULL; | 237 IceMode remote_ice_mode_ = ICEMODE_FULL; |
231 size_t connection_count_ = 0; | 238 size_t connection_count_ = 0; |
232 IceGatheringState gathering_state_ = kIceGatheringNew; | 239 IceGatheringState gathering_state_ = kIceGatheringNew; |
233 bool had_connection_ = false; | 240 bool had_connection_ = false; |
234 bool writable_ = false; | 241 bool writable_ = false; |
235 bool receiving_ = false; | 242 bool receiving_ = false; |
236 }; | 243 }; |
237 | 244 |
238 } // namespace cricket | 245 } // namespace cricket |
239 | 246 |
240 #endif // WEBRTC_P2P_BASE_FAKEICETRANSPORT_H_ | 247 #endif // WEBRTC_P2P_BASE_FAKEICETRANSPORT_H_ |
OLD | NEW |