Index: webrtc/p2p/base/fakeicetransport.h |
diff --git a/webrtc/p2p/base/fakeicetransport.h b/webrtc/p2p/base/fakeicetransport.h |
index 2b0662f8561cde3f69fd713f8ae0ea44f26debec..357668f44f8ec224c0e4d9076f44ed58ce15f623 100644 |
--- a/webrtc/p2p/base/fakeicetransport.h |
+++ b/webrtc/p2p/base/fakeicetransport.h |
@@ -161,6 +161,9 @@ class FakeIceTransport : public IceTransportInternal { |
// Fake PacketTransportInternal implementation. |
bool writable() const override { return writable_; } |
bool receiving() const override { return receiving_; } |
+ // If combine is enabled, two incoming packets will be combined into one |
Taylor Brandstetter
2017/07/06 22:06:11
This comment is a little misleading, since all the
joachim
2017/07/07 16:13:00
Changed.
|
+ // outgoing packet. |
+ void set_combine(bool combine) { combine_ = combine; } |
Taylor Brandstetter
2017/07/06 22:06:11
nit: Making this name more descriptive, like "comb
joachim
2017/07/07 16:13:00
Done.
|
int SendPacket(const char* data, |
size_t len, |
const rtc::PacketOptions& options, |
@@ -168,14 +171,18 @@ class FakeIceTransport : public IceTransportInternal { |
if (!dest_) { |
return -1; |
} |
- rtc::CopyOnWriteBuffer packet(data, len); |
- if (async_) { |
- invoker_.AsyncInvokeDelayed<void>( |
- RTC_FROM_HERE, rtc::Thread::Current(), |
- rtc::Bind(&FakeIceTransport::SendPacketInternal, this, packet), |
- async_delay_ms_); |
- } else { |
- SendPacketInternal(packet); |
+ |
+ send_packet_.AppendData(data, len); |
+ if (!combine_ || send_packet_.size() > len) { |
+ rtc::CopyOnWriteBuffer packet(std::move(send_packet_)); |
+ if (async_) { |
+ invoker_.AsyncInvokeDelayed<void>( |
+ RTC_FROM_HERE, rtc::Thread::Current(), |
+ rtc::Bind(&FakeIceTransport::SendPacketInternal, this, packet), |
+ async_delay_ms_); |
+ } else { |
+ SendPacketInternal(packet); |
+ } |
} |
rtc::SentPacket sent_packet(options.packet_id, rtc::TimeMillis()); |
SignalSentPacket(this, sent_packet); |
@@ -233,6 +240,8 @@ class FakeIceTransport : public IceTransportInternal { |
bool had_connection_ = false; |
bool writable_ = false; |
bool receiving_ = false; |
+ bool combine_ = false; |
+ rtc::CopyOnWriteBuffer send_packet_; |
}; |
} // namespace cricket |