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 |
89 private: | 91 private: |
90 void set_writable(bool writable) { | 92 void set_writable(bool writable) { |
91 if (writable_ == writable) { | 93 if (writable_ == writable) { |
92 return; | 94 return; |
93 } | 95 } |
94 writable_ = writable; | 96 writable_ = writable; |
95 if (writable_) { | 97 if (writable_) { |
96 SignalReadyToSend(this); | 98 SignalReadyToSend(this); |
97 } | 99 } |
98 SignalWritableState(this); | 100 SignalWritableState(this); |
99 } | 101 } |
100 | 102 |
101 void set_receiving(bool receiving) { | 103 void set_receiving(bool receiving) { |
102 if (receiving_ == receiving) { | 104 if (receiving_ == receiving) { |
103 return; | 105 return; |
104 } | 106 } |
105 receiving_ = receiving; | 107 receiving_ = receiving; |
106 SignalReceivingState(this); | 108 SignalReceivingState(this); |
107 } | 109 } |
108 | 110 |
109 void SendPacketInternal(const CopyOnWriteBuffer& packet) { | 111 void SendPacketInternal(const CopyOnWriteBuffer& packet) { |
| 112 last_sent_packet_ = packet; |
110 if (dest_) { | 113 if (dest_) { |
111 dest_->SignalReadPacket(dest_, packet.data<char>(), packet.size(), | 114 dest_->SignalReadPacket(dest_, packet.data<char>(), packet.size(), |
112 CreatePacketTime(0), 0); | 115 CreatePacketTime(0), 0); |
113 } | 116 } |
114 } | 117 } |
115 | 118 |
| 119 CopyOnWriteBuffer last_sent_packet_; |
116 AsyncInvoker invoker_; | 120 AsyncInvoker invoker_; |
117 std::string debug_name_; | 121 std::string debug_name_; |
118 FakePacketTransport* dest_ = nullptr; | 122 FakePacketTransport* dest_ = nullptr; |
119 bool async_ = false; | 123 bool async_ = false; |
120 int async_delay_ms_ = 0; | 124 int async_delay_ms_ = 0; |
121 bool writable_ = false; | 125 bool writable_ = false; |
122 bool receiving_ = false; | 126 bool receiving_ = false; |
123 }; | 127 }; |
124 | 128 |
125 } // namespace rtc | 129 } // namespace rtc |
126 | 130 |
127 #endif // WEBRTC_P2P_BASE_FAKEPACKETTRANSPORT_H_ | 131 #endif // WEBRTC_P2P_BASE_FAKEPACKETTRANSPORT_H_ |
OLD | NEW |