Repo created

This commit is contained in:
Fr4nz D13trich 2025-11-22 14:04:28 +01:00
parent 81b91f4139
commit f8c34fa5ee
22732 changed files with 4815320 additions and 2 deletions

View file

@ -0,0 +1,36 @@
# 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_library("sent_packet") {
sources = [
"sent_packet.cc",
"sent_packet.h",
]
deps = [ "../system:rtc_export" ]
absl_deps = [ "//third_party/abseil-cpp/absl/types:optional" ]
}
rtc_library("received_packet") {
visibility = [ "*" ]
sources = [
"received_packet.cc",
"received_packet.h",
]
deps = [
"..:socket_address",
"../../api:array_view",
"../../api/units:timestamp",
"../system:rtc_export",
]
absl_deps = [
"//third_party/abseil-cpp/absl/functional:any_invocable",
"//third_party/abseil-cpp/absl/types:optional",
]
}

View file

@ -0,0 +1,40 @@
/*
* Copyright 2023 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/received_packet.h"
#include <utility>
#include "absl/types/optional.h"
namespace rtc {
ReceivedPacket::ReceivedPacket(rtc::ArrayView<const uint8_t> payload,
const SocketAddress& source_address,
absl::optional<webrtc::Timestamp> arrival_time)
: payload_(payload),
arrival_time_(std::move(arrival_time)),
source_address_(source_address) {}
// static
ReceivedPacket ReceivedPacket::CreateFromLegacy(
const uint8_t* data,
size_t size,
int64_t packet_time_us,
const rtc::SocketAddress& source_address) {
RTC_DCHECK(packet_time_us == -1 || packet_time_us >= 0);
return ReceivedPacket(rtc::MakeArrayView(data, size), source_address,
(packet_time_us >= 0)
? absl::optional<webrtc::Timestamp>(
webrtc::Timestamp::Micros(packet_time_us))
: absl::nullopt);
}
} // namespace rtc

View file

@ -0,0 +1,68 @@
/*
* Copyright 2023 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_RECEIVED_PACKET_H_
#define RTC_BASE_NETWORK_RECEIVED_PACKET_H_
#include <cstdint>
#include "absl/types/optional.h"
#include "api/array_view.h"
#include "api/units/timestamp.h"
#include "rtc_base/socket_address.h"
#include "rtc_base/system/rtc_export.h"
namespace rtc {
// ReceivedPacket repressent a received IP packet.
// It contains a payload and metadata.
// ReceivedPacket itself does not put constraints on what payload contains. For
// example it may contains STUN, SCTP, SRTP, RTP, RTCP.... etc.
class RTC_EXPORT ReceivedPacket {
public:
// Caller must keep memory pointed to by payload and address valid for the
// lifetime of this ReceivedPacket.
ReceivedPacket(
rtc::ArrayView<const uint8_t> payload,
const SocketAddress& source_address,
absl::optional<webrtc::Timestamp> arrival_time = absl::nullopt);
// Address/port of the packet sender.
const SocketAddress& source_address() const { return source_address_; }
rtc::ArrayView<const uint8_t> payload() const { return payload_; }
// Timestamp when this packet was received. Not available on all socket
// implementations.
absl::optional<webrtc::Timestamp> arrival_time() const {
return arrival_time_;
}
static ReceivedPacket CreateFromLegacy(
const char* data,
size_t size,
int64_t packet_time_us,
const rtc::SocketAddress& addr = rtc::SocketAddress()) {
return CreateFromLegacy(reinterpret_cast<const uint8_t*>(data), size,
packet_time_us, addr);
}
static ReceivedPacket CreateFromLegacy(
const uint8_t* data,
size_t size,
int64_t packet_time_us,
const rtc::SocketAddress& = rtc::SocketAddress());
private:
rtc::ArrayView<const uint8_t> payload_;
absl::optional<webrtc::Timestamp> arrival_time_;
const SocketAddress& source_address_;
};
} // namespace rtc
#endif // RTC_BASE_NETWORK_RECEIVED_PACKET_H_

View file

@ -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

View file

@ -0,0 +1,69 @@
/*
* 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 <stddef.h>
#include <stdint.h>
#include "absl/types/optional.h"
#include "rtc_base/system/rtc_export.h"
namespace rtc {
enum class PacketType {
kUnknown,
kData,
kIceConnectivityCheck,
kIceConnectivityCheckResponse,
kStunMessage,
kTurnMessage,
};
enum class PacketInfoProtocolType {
kUnknown,
kUdp,
kTcp,
kSsltcp,
kTls,
};
struct RTC_EXPORT 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<uint16_t> network_id;
size_t packet_size_bytes = 0;
size_t turn_overhead_bytes = 0;
size_t ip_overhead_bytes = 0;
};
struct RTC_EXPORT 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_