From e07864ea6ec179562bf3915aaac6f5b55f700c0e Mon Sep 17 00:00:00 2001 From: Sebastian Jansson Date: Mon, 15 Oct 2018 09:28:15 +0200 Subject: [PATCH] Moves rtc::SentPacket to separate target. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This means that users of the struct no longer has to include socket.h. Bug: webrtc:9586 Change-Id: I09d77d0b4c3a359d2ae4587a48dfc7540a8969e4 Reviewed-on: https://webrtc-review.googlesource.com/c/105105 Reviewed-by: Karl Wiberg Reviewed-by: Björn Terelius Commit-Queue: Sebastian Jansson Cr-Commit-Position: refs/heads/master@{#25168} --- rtc_base/BUILD.gn | 1 + rtc_base/network/BUILD.gn | 19 ++++++++++ rtc_base/network/sent_packet.cc | 27 +++++++++++++ rtc_base/network/sent_packet.h | 67 +++++++++++++++++++++++++++++++++ rtc_base/socket.cc | 12 ------ rtc_base/socket.h | 47 +---------------------- 6 files changed, 115 insertions(+), 58 deletions(-) create mode 100644 rtc_base/network/BUILD.gn create mode 100644 rtc_base/network/sent_packet.cc create mode 100644 rtc_base/network/sent_packet.h diff --git a/rtc_base/BUILD.gn b/rtc_base/BUILD.gn index faec269696..a4c2205fd8 100644 --- a/rtc_base/BUILD.gn +++ b/rtc_base/BUILD.gn @@ -697,6 +697,7 @@ rtc_static_library("rtc_base") { ":stringutils", "..:webrtc_common", "../api:array_view", + "network:sent_packet", "third_party/base64", "third_party/sigslot", "//third_party/abseil-cpp/absl/memory", diff --git a/rtc_base/network/BUILD.gn b/rtc_base/network/BUILD.gn new file mode 100644 index 0000000000..0fbdbb1edb --- /dev/null +++ b/rtc_base/network/BUILD.gn @@ -0,0 +1,19 @@ +# Copyright (c) 2018 The WebRTC project authors. All Rights Reserved. +# +# Use of this source code is governed by a BSD-style license +# that can be found in the LICENSE file in the root of the source +# tree. An additional intellectual property rights grant can be found +# in the file PATENTS. All contributing project authors may +# be found in the AUTHORS file in the root of the source tree. + +import("../../webrtc.gni") + +rtc_source_set("sent_packet") { + sources = [ + "sent_packet.cc", + "sent_packet.h", + ] + deps = [ + "//third_party/abseil-cpp/absl/types:optional", + ] +} diff --git a/rtc_base/network/sent_packet.cc b/rtc_base/network/sent_packet.cc new file mode 100644 index 0000000000..8cc49737ef --- /dev/null +++ b/rtc_base/network/sent_packet.cc @@ -0,0 +1,27 @@ +/* + * Copyright 2018 The WebRTC Project Authors. All rights reserved. + * + * Use of this source code is governed by a BSD-style license + * that can be found in the LICENSE file in the root of the source + * tree. An additional intellectual property rights grant can be found + * in the file PATENTS. All contributing project authors may + * be found in the AUTHORS file in the root of the source tree. + */ + +#include "rtc_base/network/sent_packet.h" + +namespace rtc { + +PacketInfo::PacketInfo() = default; +PacketInfo::PacketInfo(const PacketInfo& info) = default; +PacketInfo::~PacketInfo() = default; + +SentPacket::SentPacket() = default; +SentPacket::SentPacket(int64_t packet_id, int64_t send_time_ms) + : packet_id(packet_id), send_time_ms(send_time_ms) {} +SentPacket::SentPacket(int64_t packet_id, + int64_t send_time_ms, + const rtc::PacketInfo& info) + : packet_id(packet_id), send_time_ms(send_time_ms), info(info) {} + +} // namespace rtc diff --git a/rtc_base/network/sent_packet.h b/rtc_base/network/sent_packet.h new file mode 100644 index 0000000000..ec80982751 --- /dev/null +++ b/rtc_base/network/sent_packet.h @@ -0,0 +1,67 @@ +/* + * Copyright 2018 The WebRTC Project Authors. All rights reserved. + * + * Use of this source code is governed by a BSD-style license + * that can be found in the LICENSE file in the root of the source + * tree. An additional intellectual property rights grant can be found + * in the file PATENTS. All contributing project authors may + * be found in the AUTHORS file in the root of the source tree. + */ + +#ifndef RTC_BASE_NETWORK_SENT_PACKET_H_ +#define RTC_BASE_NETWORK_SENT_PACKET_H_ + +#include + +#include "absl/types/optional.h" + +namespace rtc { + +enum class PacketType { + kUnknown, + kData, + kIceConnectivityCheck, + kIceConnectivityCheckResponse, + kStunMessage, + kTurnMessage, +}; + +enum class PacketInfoProtocolType { + kUnknown, + kUdp, + kTcp, + kSsltcp, + kTls, +}; + +struct PacketInfo { + PacketInfo(); + PacketInfo(const PacketInfo& info); + ~PacketInfo(); + + bool included_in_feedback = false; + bool included_in_allocation = false; + PacketType packet_type = PacketType::kUnknown; + PacketInfoProtocolType protocol = PacketInfoProtocolType::kUnknown; + // A unique id assigned by the network manager, and absl::nullopt if not set. + absl::optional network_id; + size_t packet_size_bytes = 0; + size_t turn_overhead_bytes = 0; + size_t ip_overhead_bytes = 0; +}; + +struct SentPacket { + SentPacket(); + SentPacket(int64_t packet_id, int64_t send_time_ms); + SentPacket(int64_t packet_id, + int64_t send_time_ms, + const rtc::PacketInfo& info); + + int64_t packet_id = -1; + int64_t send_time_ms = -1; + rtc::PacketInfo info; +}; + +} // namespace rtc + +#endif // RTC_BASE_NETWORK_SENT_PACKET_H_ diff --git a/rtc_base/socket.cc b/rtc_base/socket.cc index a9749a473e..f19b34412f 100644 --- a/rtc_base/socket.cc +++ b/rtc_base/socket.cc @@ -12,16 +12,4 @@ namespace rtc { -PacketInfo::PacketInfo() = default; -PacketInfo::PacketInfo(const PacketInfo& info) = default; -PacketInfo::~PacketInfo() = default; - -SentPacket::SentPacket() = default; -SentPacket::SentPacket(int64_t packet_id, int64_t send_time_ms) - : packet_id(packet_id), send_time_ms(send_time_ms) {} -SentPacket::SentPacket(int64_t packet_id, - int64_t send_time_ms, - const rtc::PacketInfo& info) - : packet_id(packet_id), send_time_ms(send_time_ms), info(info) {} - } // namespace rtc diff --git a/rtc_base/socket.h b/rtc_base/socket.h index 1cf086149a..e7e82108cd 100644 --- a/rtc_base/socket.h +++ b/rtc_base/socket.h @@ -25,8 +25,8 @@ #include "rtc_base/win32.h" #endif -#include "absl/types/optional.h" #include "rtc_base/constructormagic.h" +#include "rtc_base/network/sent_packet.h" #include "rtc_base/socketaddress.h" // Rather than converting errors into a private namespace, @@ -123,51 +123,6 @@ inline bool IsBlockingError(int e) { return (e == EWOULDBLOCK) || (e == EAGAIN) || (e == EINPROGRESS); } -enum class PacketType { - kUnknown, - kData, - kIceConnectivityCheck, - kIceConnectivityCheckResponse, - kStunMessage, - kTurnMessage, -}; - -enum class PacketInfoProtocolType { - kUnknown, - kUdp, - kTcp, - kSsltcp, - kTls, -}; - -struct PacketInfo { - PacketInfo(); - PacketInfo(const PacketInfo& info); - ~PacketInfo(); - - bool included_in_feedback = false; - bool included_in_allocation = false; - PacketType packet_type = PacketType::kUnknown; - PacketInfoProtocolType protocol = PacketInfoProtocolType::kUnknown; - // A unique id assigned by the network manager, and absl::nullopt if not set. - absl::optional network_id; - size_t packet_size_bytes = 0; - size_t turn_overhead_bytes = 0; - size_t ip_overhead_bytes = 0; -}; - -struct SentPacket { - SentPacket(); - SentPacket(int64_t packet_id, int64_t send_time_ms); - SentPacket(int64_t packet_id, - int64_t send_time_ms, - const rtc::PacketInfo& info); - - int64_t packet_id = -1; - int64_t send_time_ms = -1; - rtc::PacketInfo info; -}; - // General interface for the socket implementations of various networks. The // methods match those of normal UNIX sockets very closely. class Socket {