Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(554)

Unified Diff: webrtc/p2p/base/fakeicetransport.h

Issue 2970883005: Handle case where UDP packet contains multiple DTLS records. (Closed)
Patch Set: Feedback from Taylor. Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webrtc/p2p/base/dtlstransportchannel_unittest.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/p2p/base/fakeicetransport.h
diff --git a/webrtc/p2p/base/fakeicetransport.h b/webrtc/p2p/base/fakeicetransport.h
index 2b0662f8561cde3f69fd713f8ae0ea44f26debec..bc003a32e3a099fcdd298dab62db79d123d9a21b 100644
--- a/webrtc/p2p/base/fakeicetransport.h
+++ b/webrtc/p2p/base/fakeicetransport.h
@@ -161,6 +161,11 @@ class FakeIceTransport : public IceTransportInternal {
// Fake PacketTransportInternal implementation.
bool writable() const override { return writable_; }
bool receiving() const override { return receiving_; }
+ // If combine is enabled, every two consecutive packets to be sent with
+ // "SendPacket" will be combined into one outgoing packet.
+ void combine_outgoing_packets(bool combine) {
+ combine_outgoing_packets_ = combine;
+ }
int SendPacket(const char* data,
size_t len,
const rtc::PacketOptions& options,
@@ -168,14 +173,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_outgoing_packets_ || 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 +242,8 @@ class FakeIceTransport : public IceTransportInternal {
bool had_connection_ = false;
bool writable_ = false;
bool receiving_ = false;
+ bool combine_outgoing_packets_ = false;
+ rtc::CopyOnWriteBuffer send_packet_;
};
} // namespace cricket
« no previous file with comments | « webrtc/p2p/base/dtlstransportchannel_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698