diff --git a/api/transport/rtp/BUILD.gn b/api/transport/rtp/BUILD.gn index 777ff22639..b0849502c8 100644 --- a/api/transport/rtp/BUILD.gn +++ b/api/transport/rtp/BUILD.gn @@ -10,12 +10,19 @@ import("../../../webrtc.gni") rtc_source_set("rtp_source") { visibility = [ "*" ] - sources = [ - "rtp_source.h", - ] + sources = [ "rtp_source.h" ] deps = [ "../../../api:rtp_headers", "../../../rtc_base:checks", "//third_party/abseil-cpp/absl/types:optional", ] } + +rtc_source_set("dependency_descriptor") { + visibility = [ "*" ] + sources = [ "dependency_descriptor.h" ] + deps = [ + "//third_party/abseil-cpp/absl/container:inlined_vector", + "//third_party/abseil-cpp/absl/types:optional", + ] +} diff --git a/api/transport/rtp/dependency_descriptor.h b/api/transport/rtp/dependency_descriptor.h new file mode 100644 index 0000000000..a488f56dfd --- /dev/null +++ b/api/transport/rtp/dependency_descriptor.h @@ -0,0 +1,104 @@ +/* + * 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 + +#include +#include + +#include "absl/container/inlined_vector.h" +#include "absl/types/optional.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 +class RenderResolution { + public: + constexpr RenderResolution() = default; + constexpr RenderResolution(int width, int height) + : width_(width), height_(height) {} + RenderResolution(const RenderResolution&) = default; + RenderResolution& operator=(const RenderResolution&) = default; + + friend bool operator==(const RenderResolution& lhs, + const RenderResolution& rhs) { + return lhs.width_ == rhs.width_ && lhs.height_ == rhs.height_; + } + + constexpr int Width() const { return width_; } + constexpr int Height() const { return height_; } + + private: + int width_ = 0; + int height_ = 0; +}; + +// 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 { + 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 decode_target_indications; + absl::InlinedVector frame_diffs; + absl::InlinedVector 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 or |num_chains| value if decode target is + // not protected by a chain. + absl::InlinedVector decode_target_protected_by_chain; + absl::InlinedVector resolutions; + std::vector templates; +}; + +struct DependencyDescriptor { + bool first_packet_in_frame = true; + bool last_packet_in_frame = true; + int frame_number = 0; + FrameDependencyTemplate frame_dependencies; + absl::optional resolution; + absl::optional active_decode_targets_bitmask; + std::unique_ptr attached_structure; +}; + +} // namespace webrtc + +#endif // API_TRANSPORT_RTP_DEPENDENCY_DESCRIPTOR_H_ diff --git a/common_video/generic_frame_descriptor/BUILD.gn b/common_video/generic_frame_descriptor/BUILD.gn index 9ea0912118..05a4e2396c 100644 --- a/common_video/generic_frame_descriptor/BUILD.gn +++ b/common_video/generic_frame_descriptor/BUILD.gn @@ -16,6 +16,7 @@ rtc_library("generic_frame_descriptor") { deps = [ "../../api:array_view", + "../../api/transport/rtp:dependency_descriptor", "../../api/video:video_codec_constants", "../../rtc_base:checks", "//third_party/abseil-cpp/absl/container:inlined_vector", diff --git a/common_video/generic_frame_descriptor/generic_frame_info.h b/common_video/generic_frame_descriptor/generic_frame_info.h index 2aff0e3fd5..ce3ee6c4b3 100644 --- a/common_video/generic_frame_descriptor/generic_frame_info.h +++ b/common_video/generic_frame_descriptor/generic_frame_info.h @@ -12,94 +12,13 @@ #define COMMON_VIDEO_GENERIC_FRAME_DESCRIPTOR_GENERIC_FRAME_INFO_H_ #include -#include -#include #include "absl/container/inlined_vector.h" #include "absl/strings/string_view.h" -#include "absl/types/optional.h" -#include "api/array_view.h" +#include "api/transport/rtp/dependency_descriptor.h" #include "api/video/video_codec_constants.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 -class RenderResolution { - public: - constexpr RenderResolution() = default; - constexpr RenderResolution(int width, int height) - : width_(width), height_(height) {} - RenderResolution(const RenderResolution&) = default; - RenderResolution& operator=(const RenderResolution&) = default; - - friend bool operator==(const RenderResolution& lhs, - const RenderResolution& rhs) { - return lhs.width_ == rhs.width_ && lhs.height_ == rhs.height_; - } - - constexpr int Width() const { return width_; } - constexpr int Height() const { return height_; } - - private: - int width_ = 0; - int height_ = 0; -}; - -// 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 { - 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 decode_target_indications; - absl::InlinedVector frame_diffs; - absl::InlinedVector 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 or |num_chains| value if decode target is - // not protected by a chain. - absl::InlinedVector decode_target_protected_by_chain; - absl::InlinedVector resolutions; - std::vector templates; -}; - -struct DependencyDescriptor { - bool first_packet_in_frame = true; - bool last_packet_in_frame = true; - int frame_number = 0; - FrameDependencyTemplate frame_dependencies; - absl::optional resolution; - absl::optional active_decode_targets_bitmask; - std::unique_ptr attached_structure; -}; // Describes how a certain encoder buffer was used when encoding a frame. struct CodecBufferUsage { diff --git a/modules/rtp_rtcp/BUILD.gn b/modules/rtp_rtcp/BUILD.gn index fcf013d244..daaac94d68 100644 --- a/modules/rtp_rtcp/BUILD.gn +++ b/modules/rtp_rtcp/BUILD.gn @@ -106,11 +106,11 @@ rtc_library("rtp_rtcp_format") { "../../api:rtp_parameters", "../../api/audio_codecs:audio_codecs_api", "../../api/transport:network_control", + "../../api/transport/rtp:dependency_descriptor", "../../api/units:time_delta", "../../api/video:video_frame", "../../api/video:video_rtp_headers", "../../common_video", - "../../common_video/generic_frame_descriptor", "../../rtc_base:checks", "../../rtc_base:deprecation", "../../rtc_base:divide_round", diff --git a/modules/rtp_rtcp/source/rtp_dependency_descriptor_extension.cc b/modules/rtp_rtcp/source/rtp_dependency_descriptor_extension.cc index 7d24f7c3a0..30dedb192f 100644 --- a/modules/rtp_rtcp/source/rtp_dependency_descriptor_extension.cc +++ b/modules/rtp_rtcp/source/rtp_dependency_descriptor_extension.cc @@ -13,7 +13,7 @@ #include #include "api/array_view.h" -#include "common_video/generic_frame_descriptor/generic_frame_info.h" +#include "api/transport/rtp/dependency_descriptor.h" #include "modules/rtp_rtcp/include/rtp_rtcp_defines.h" #include "modules/rtp_rtcp/source/rtp_dependency_descriptor_reader.h" #include "modules/rtp_rtcp/source/rtp_dependency_descriptor_writer.h" diff --git a/modules/rtp_rtcp/source/rtp_dependency_descriptor_extension.h b/modules/rtp_rtcp/source/rtp_dependency_descriptor_extension.h index 58757822f4..d6e080402d 100644 --- a/modules/rtp_rtcp/source/rtp_dependency_descriptor_extension.h +++ b/modules/rtp_rtcp/source/rtp_dependency_descriptor_extension.h @@ -13,7 +13,7 @@ #include #include "api/array_view.h" -#include "common_video/generic_frame_descriptor/generic_frame_info.h" +#include "api/transport/rtp/dependency_descriptor.h" #include "modules/rtp_rtcp/include/rtp_rtcp_defines.h" namespace webrtc { diff --git a/modules/rtp_rtcp/source/rtp_dependency_descriptor_reader.cc b/modules/rtp_rtcp/source/rtp_dependency_descriptor_reader.cc index cf816c27bc..07b6a3b3c3 100644 --- a/modules/rtp_rtcp/source/rtp_dependency_descriptor_reader.cc +++ b/modules/rtp_rtcp/source/rtp_dependency_descriptor_reader.cc @@ -13,6 +13,7 @@ #include #include +#include "api/transport/rtp/dependency_descriptor.h" #include "rtc_base/bit_buffer.h" #include "rtc_base/checks.h" diff --git a/modules/rtp_rtcp/source/rtp_dependency_descriptor_reader.h b/modules/rtp_rtcp/source/rtp_dependency_descriptor_reader.h index 11df2f49a0..abef3716ab 100644 --- a/modules/rtp_rtcp/source/rtp_dependency_descriptor_reader.h +++ b/modules/rtp_rtcp/source/rtp_dependency_descriptor_reader.h @@ -15,7 +15,7 @@ #include #include "api/array_view.h" -#include "common_video/generic_frame_descriptor/generic_frame_info.h" +#include "api/transport/rtp/dependency_descriptor.h" #include "rtc_base/bit_buffer.h" namespace webrtc { diff --git a/modules/rtp_rtcp/source/rtp_dependency_descriptor_writer.cc b/modules/rtp_rtcp/source/rtp_dependency_descriptor_writer.cc index 28f4444e9c..9e1a425666 100644 --- a/modules/rtp_rtcp/source/rtp_dependency_descriptor_writer.cc +++ b/modules/rtp_rtcp/source/rtp_dependency_descriptor_writer.cc @@ -16,7 +16,7 @@ #include "absl/algorithm/container.h" #include "api/array_view.h" -#include "common_video/generic_frame_descriptor/generic_frame_info.h" +#include "api/transport/rtp/dependency_descriptor.h" #include "rtc_base/bit_buffer.h" #include "rtc_base/checks.h" diff --git a/modules/rtp_rtcp/source/rtp_dependency_descriptor_writer.h b/modules/rtp_rtcp/source/rtp_dependency_descriptor_writer.h index 5274f2da95..5a823b6e86 100644 --- a/modules/rtp_rtcp/source/rtp_dependency_descriptor_writer.h +++ b/modules/rtp_rtcp/source/rtp_dependency_descriptor_writer.h @@ -15,7 +15,7 @@ #include #include "api/array_view.h" -#include "common_video/generic_frame_descriptor/generic_frame_info.h" +#include "api/transport/rtp/dependency_descriptor.h" #include "rtc_base/bit_buffer.h" namespace webrtc {