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,38 @@
# Copyright (c) 2019 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("rtp_source") {
visibility = [ "*" ]
sources = [ "rtp_source.h" ]
deps = [
"../../../api:rtp_headers",
"../../../api/units:time_delta",
"../../../api/units:timestamp",
"../../../rtc_base:checks",
]
absl_deps = [ "//third_party/abseil-cpp/absl/types:optional" ]
}
rtc_source_set("dependency_descriptor") {
visibility = [ "*" ]
sources = [
"dependency_descriptor.cc",
"dependency_descriptor.h",
]
deps = [
"../../../rtc_base:checks",
"../../video:render_resolution",
]
absl_deps = [
"//third_party/abseil-cpp/absl/container:inlined_vector",
"//third_party/abseil-cpp/absl/strings",
"//third_party/abseil-cpp/absl/types:optional",
]
}

View file

@ -0,0 +1,54 @@
/*
* Copyright (c) 2020 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 "api/transport/rtp/dependency_descriptor.h"
#include "absl/container/inlined_vector.h"
#include "absl/strings/string_view.h"
#include "rtc_base/checks.h"
namespace webrtc {
constexpr int DependencyDescriptor::kMaxSpatialIds;
constexpr int DependencyDescriptor::kMaxTemporalIds;
constexpr int DependencyDescriptor::kMaxTemplates;
constexpr int DependencyDescriptor::kMaxDecodeTargets;
namespace webrtc_impl {
absl::InlinedVector<DecodeTargetIndication, 10> StringToDecodeTargetIndications(
absl::string_view symbols) {
absl::InlinedVector<DecodeTargetIndication, 10> dtis;
dtis.reserve(symbols.size());
for (char symbol : symbols) {
DecodeTargetIndication indication;
switch (symbol) {
case '-':
indication = DecodeTargetIndication::kNotPresent;
break;
case 'D':
indication = DecodeTargetIndication::kDiscardable;
break;
case 'R':
indication = DecodeTargetIndication::kRequired;
break;
case 'S':
indication = DecodeTargetIndication::kSwitch;
break;
default:
RTC_DCHECK_NOTREACHED();
}
dtis.push_back(indication);
}
return dtis;
}
} // namespace webrtc_impl
} // namespace webrtc

View file

@ -0,0 +1,150 @@
/*
* Copyright (c) 2020 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 API_TRANSPORT_RTP_DEPENDENCY_DESCRIPTOR_H_
#define API_TRANSPORT_RTP_DEPENDENCY_DESCRIPTOR_H_
#include <stdint.h>
#include <initializer_list>
#include <memory>
#include <vector>
#include "absl/container/inlined_vector.h"
#include "absl/strings/string_view.h"
#include "absl/types/optional.h"
#include "api/video/render_resolution.h"
namespace webrtc {
// Structures to build and parse dependency descriptor as described in
// https://aomediacodec.github.io/av1-rtp-spec/#dependency-descriptor-rtp-header-extension
// Relationship of a frame to a Decode target.
enum class DecodeTargetIndication {
kNotPresent = 0, // DecodeTargetInfo symbol '-'
kDiscardable = 1, // DecodeTargetInfo symbol 'D'
kSwitch = 2, // DecodeTargetInfo symbol 'S'
kRequired = 3 // DecodeTargetInfo symbol 'R'
};
struct FrameDependencyTemplate {
// Setters are named briefly to chain them when building the template.
FrameDependencyTemplate& S(int spatial_layer);
FrameDependencyTemplate& T(int temporal_layer);
FrameDependencyTemplate& Dtis(absl::string_view dtis);
FrameDependencyTemplate& FrameDiffs(std::initializer_list<int> diffs);
FrameDependencyTemplate& ChainDiffs(std::initializer_list<int> diffs);
friend bool operator==(const FrameDependencyTemplate& lhs,
const FrameDependencyTemplate& rhs) {
return lhs.spatial_id == rhs.spatial_id &&
lhs.temporal_id == rhs.temporal_id &&
lhs.decode_target_indications == rhs.decode_target_indications &&
lhs.frame_diffs == rhs.frame_diffs &&
lhs.chain_diffs == rhs.chain_diffs;
}
int spatial_id = 0;
int temporal_id = 0;
absl::InlinedVector<DecodeTargetIndication, 10> decode_target_indications;
absl::InlinedVector<int, 4> frame_diffs;
absl::InlinedVector<int, 4> chain_diffs;
};
struct FrameDependencyStructure {
friend bool operator==(const FrameDependencyStructure& lhs,
const FrameDependencyStructure& rhs) {
return lhs.num_decode_targets == rhs.num_decode_targets &&
lhs.num_chains == rhs.num_chains &&
lhs.decode_target_protected_by_chain ==
rhs.decode_target_protected_by_chain &&
lhs.resolutions == rhs.resolutions && lhs.templates == rhs.templates;
}
int structure_id = 0;
int num_decode_targets = 0;
int num_chains = 0;
// If chains are used (num_chains > 0), maps decode target index into index of
// the chain protecting that target.
absl::InlinedVector<int, 10> decode_target_protected_by_chain;
absl::InlinedVector<RenderResolution, 4> resolutions;
std::vector<FrameDependencyTemplate> templates;
};
class DependencyDescriptorMandatory {
public:
void set_frame_number(int frame_number) { frame_number_ = frame_number; }
int frame_number() const { return frame_number_; }
void set_template_id(int template_id) { template_id_ = template_id; }
int template_id() const { return template_id_; }
void set_first_packet_in_frame(bool first) { first_packet_in_frame_ = first; }
bool first_packet_in_frame() const { return first_packet_in_frame_; }
void set_last_packet_in_frame(bool last) { last_packet_in_frame_ = last; }
bool last_packet_in_frame() const { return last_packet_in_frame_; }
private:
int frame_number_;
int template_id_;
bool first_packet_in_frame_;
bool last_packet_in_frame_;
};
struct DependencyDescriptor {
static constexpr int kMaxSpatialIds = 4;
static constexpr int kMaxTemporalIds = 8;
static constexpr int kMaxDecodeTargets = 32;
static constexpr int kMaxTemplates = 64;
bool first_packet_in_frame = true;
bool last_packet_in_frame = true;
int frame_number = 0;
FrameDependencyTemplate frame_dependencies;
absl::optional<RenderResolution> resolution;
absl::optional<uint32_t> active_decode_targets_bitmask;
std::unique_ptr<FrameDependencyStructure> attached_structure;
};
// Below are implementation details.
namespace webrtc_impl {
absl::InlinedVector<DecodeTargetIndication, 10> StringToDecodeTargetIndications(
absl::string_view indication_symbols);
} // namespace webrtc_impl
inline FrameDependencyTemplate& FrameDependencyTemplate::S(int spatial_layer) {
this->spatial_id = spatial_layer;
return *this;
}
inline FrameDependencyTemplate& FrameDependencyTemplate::T(int temporal_layer) {
this->temporal_id = temporal_layer;
return *this;
}
inline FrameDependencyTemplate& FrameDependencyTemplate::Dtis(
absl::string_view dtis) {
this->decode_target_indications =
webrtc_impl::StringToDecodeTargetIndications(dtis);
return *this;
}
inline FrameDependencyTemplate& FrameDependencyTemplate::FrameDiffs(
std::initializer_list<int> diffs) {
this->frame_diffs.assign(diffs.begin(), diffs.end());
return *this;
}
inline FrameDependencyTemplate& FrameDependencyTemplate::ChainDiffs(
std::initializer_list<int> diffs) {
this->chain_diffs.assign(diffs.begin(), diffs.end());
return *this;
}
} // namespace webrtc
#endif // API_TRANSPORT_RTP_DEPENDENCY_DESCRIPTOR_H_

View file

@ -0,0 +1,108 @@
/*
* Copyright 2019 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 API_TRANSPORT_RTP_RTP_SOURCE_H_
#define API_TRANSPORT_RTP_RTP_SOURCE_H_
#include <stdint.h>
#include "absl/types/optional.h"
#include "api/rtp_headers.h"
#include "api/units/time_delta.h"
#include "api/units/timestamp.h"
#include "rtc_base/checks.h"
namespace webrtc {
enum class RtpSourceType {
SSRC,
CSRC,
};
class RtpSource {
public:
struct Extensions {
absl::optional<uint8_t> audio_level;
// Fields from the Absolute Capture Time header extension:
// http://www.webrtc.org/experiments/rtp-hdrext/abs-capture-time
absl::optional<AbsoluteCaptureTime> absolute_capture_time;
// Clock offset between the local clock and the capturer's clock.
// Do not confuse with `AbsoluteCaptureTime::estimated_capture_clock_offset`
// which instead represents the clock offset between a remote sender and the
// capturer. The following holds:
// Capture's NTP Clock = Local NTP Clock + Local-Capture Clock Offset
absl::optional<TimeDelta> local_capture_clock_offset;
};
RtpSource() = delete;
RtpSource(Timestamp timestamp,
uint32_t source_id,
RtpSourceType source_type,
uint32_t rtp_timestamp,
const RtpSource::Extensions& extensions)
: timestamp_(timestamp),
source_id_(source_id),
source_type_(source_type),
extensions_(extensions),
rtp_timestamp_(rtp_timestamp) {}
RtpSource(const RtpSource&) = default;
RtpSource& operator=(const RtpSource&) = default;
~RtpSource() = default;
Timestamp timestamp() const { return timestamp_; }
// The identifier of the source can be the CSRC or the SSRC.
uint32_t source_id() const { return source_id_; }
// The source can be either a contributing source or a synchronization source.
RtpSourceType source_type() const { return source_type_; }
absl::optional<uint8_t> audio_level() const {
return extensions_.audio_level;
}
void set_audio_level(const absl::optional<uint8_t>& level) {
extensions_.audio_level = level;
}
uint32_t rtp_timestamp() const { return rtp_timestamp_; }
absl::optional<AbsoluteCaptureTime> absolute_capture_time() const {
return extensions_.absolute_capture_time;
}
absl::optional<TimeDelta> local_capture_clock_offset() const {
return extensions_.local_capture_clock_offset;
}
bool operator==(const RtpSource& o) const {
return timestamp_ == o.timestamp() && source_id_ == o.source_id() &&
source_type_ == o.source_type() &&
extensions_.audio_level == o.extensions_.audio_level &&
extensions_.absolute_capture_time ==
o.extensions_.absolute_capture_time &&
rtp_timestamp_ == o.rtp_timestamp();
}
private:
Timestamp timestamp_;
uint32_t source_id_;
RtpSourceType source_type_;
RtpSource::Extensions extensions_;
uint32_t rtp_timestamp_;
};
} // namespace webrtc
#endif // API_TRANSPORT_RTP_RTP_SOURCE_H_