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 |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 SendPacketInternal(packet); | 79 SendPacketInternal(packet); |
80 } | 80 } |
81 SentPacket sent_packet(options.packet_id, TimeMillis()); | 81 SentPacket sent_packet(options.packet_id, TimeMillis()); |
82 SignalSentPacket(this, sent_packet); | 82 SignalSentPacket(this, sent_packet); |
83 return static_cast<int>(len); | 83 return static_cast<int>(len); |
84 } | 84 } |
85 int SetOption(Socket::Option opt, int value) override { return true; } | 85 int SetOption(Socket::Option opt, int value) override { return true; } |
86 bool GetOption(Socket::Option opt, int* value) override { return true; } | 86 bool GetOption(Socket::Option opt, int* value) override { return true; } |
87 int GetError() override { return 0; } | 87 int GetError() override { return 0; } |
88 | 88 |
89 const CopyOnWriteBuffer* last_sent_packet() { return &last_sent_packet_; } | |
90 | |
91 private: | 89 private: |
92 void set_writable(bool writable) { | 90 void set_writable(bool writable) { |
93 if (writable_ == writable) { | 91 if (writable_ == writable) { |
94 return; | 92 return; |
95 } | 93 } |
96 writable_ = writable; | 94 writable_ = writable; |
97 if (writable_) { | 95 if (writable_) { |
98 SignalReadyToSend(this); | 96 SignalReadyToSend(this); |
99 } | 97 } |
100 SignalWritableState(this); | 98 SignalWritableState(this); |
101 } | 99 } |
102 | 100 |
103 void set_receiving(bool receiving) { | 101 void set_receiving(bool receiving) { |
104 if (receiving_ == receiving) { | 102 if (receiving_ == receiving) { |
105 return; | 103 return; |
106 } | 104 } |
107 receiving_ = receiving; | 105 receiving_ = receiving; |
108 SignalReceivingState(this); | 106 SignalReceivingState(this); |
109 } | 107 } |
110 | 108 |
111 void SendPacketInternal(const CopyOnWriteBuffer& packet) { | 109 void SendPacketInternal(const CopyOnWriteBuffer& packet) { |
112 last_sent_packet_ = packet; | |
113 if (dest_) { | 110 if (dest_) { |
114 dest_->SignalReadPacket(dest_, packet.data<char>(), packet.size(), | 111 dest_->SignalReadPacket(dest_, packet.data<char>(), packet.size(), |
115 CreatePacketTime(0), 0); | 112 CreatePacketTime(0), 0); |
116 } | 113 } |
117 } | 114 } |
118 | 115 |
119 CopyOnWriteBuffer last_sent_packet_; | |
120 AsyncInvoker invoker_; | 116 AsyncInvoker invoker_; |
121 std::string debug_name_; | 117 std::string debug_name_; |
122 FakePacketTransport* dest_ = nullptr; | 118 FakePacketTransport* dest_ = nullptr; |
123 bool async_ = false; | 119 bool async_ = false; |
124 int async_delay_ms_ = 0; | 120 int async_delay_ms_ = 0; |
125 bool writable_ = false; | 121 bool writable_ = false; |
126 bool receiving_ = false; | 122 bool receiving_ = false; |
127 }; | 123 }; |
128 | 124 |
129 } // namespace rtc | 125 } // namespace rtc |
130 | 126 |
131 #endif // WEBRTC_P2P_BASE_FAKEPACKETTRANSPORT_H_ | 127 #endif // WEBRTC_P2P_BASE_FAKEPACKETTRANSPORT_H_ |
OLD | NEW |