Skip to content
This repository was archived by the owner on Oct 25, 2024. It is now read-only.

Commit 6556ed2

Browse files
perkjCommit Bot
authored andcommitted
Add experimental extension RtpVideoLayersAllocation
The extension is suggested to be used for signaling per target bitrate, resolution and frame rate to a SFU to allow a SFU to know what video layers a client is currently targeting. It is hoped to replace the current Target bitrate RTCP XR message currently used only for screen share. Bug: webrtc:12000 Change-Id: Id7b55e7ddaf6304e31839fd0482b096e1dbe8925 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/185980 Reviewed-by: Henrik Lundin <[email protected]> Reviewed-by: Danil Chapovalov <[email protected]> Commit-Queue: Per Kjellander <[email protected]> Cr-Commit-Position: refs/heads/master@{#32313}
1 parent 3c65a2b commit 6556ed2

12 files changed

+529
-1
lines changed

api/video/BUILD.gn

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ rtc_library("video_rtp_headers") {
2121
"hdr_metadata.h",
2222
"video_content_type.cc",
2323
"video_content_type.h",
24+
"video_layers_allocation.h",
2425
"video_rotation.h",
2526
"video_timing.cc",
2627
"video_timing.h",
@@ -30,8 +31,12 @@ rtc_library("video_rtp_headers") {
3031
"..:array_view",
3132
"../../rtc_base:rtc_base_approved",
3233
"../../rtc_base/system:rtc_export",
34+
"../units:data_rate",
35+
]
36+
absl_deps = [
37+
"//third_party/abseil-cpp/absl/container:inlined_vector",
38+
"//third_party/abseil-cpp/absl/types:optional",
3339
]
34-
absl_deps = [ "//third_party/abseil-cpp/absl/types:optional" ]
3540
}
3641

3742
rtc_library("video_frame") {

api/video/video_layers_allocation.h

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
/*
2+
* Copyright (c) 2020 The WebRTC project authors. All Rights Reserved.
3+
*
4+
* Use of this source code is governed by a BSD-style license
5+
* that can be found in the LICENSE file in the root of the source
6+
* tree. An additional intellectual property rights grant can be found
7+
* in the file PATENTS. All contributing project authors may
8+
* be found in the AUTHORS file in the root of the source tree.
9+
*/
10+
11+
#ifndef API_VIDEO_VIDEO_LAYERS_ALLOCATION_H_
12+
#define API_VIDEO_VIDEO_LAYERS_ALLOCATION_H_
13+
14+
#include <cstdint>
15+
16+
#include "absl/container/inlined_vector.h"
17+
#include "api/units/data_rate.h"
18+
19+
namespace webrtc {
20+
21+
// This struct contains additional stream-level information needed by a
22+
// Selective Forwarding Middlebox to make relay decisions of RTP streams.
23+
struct VideoLayersAllocation {
24+
static constexpr int kMaxSpatialIds = 4;
25+
static constexpr int kMaxTemporalIds = 4;
26+
27+
friend bool operator==(const VideoLayersAllocation& lhs,
28+
const VideoLayersAllocation& rhs) {
29+
return lhs.rtp_stream_index == rhs.rtp_stream_index &&
30+
lhs.resolution_and_frame_rate_is_valid ==
31+
rhs.resolution_and_frame_rate_is_valid &&
32+
lhs.active_spatial_layers == rhs.active_spatial_layers;
33+
}
34+
35+
friend bool operator!=(const VideoLayersAllocation& lhs,
36+
const VideoLayersAllocation& rhs) {
37+
return !(lhs == rhs);
38+
}
39+
40+
struct SpatialLayer {
41+
friend bool operator==(const SpatialLayer& lhs, const SpatialLayer& rhs) {
42+
return lhs.rtp_stream_index == rhs.rtp_stream_index &&
43+
lhs.spatial_id == rhs.spatial_id &&
44+
lhs.target_bitrate_per_temporal_layer ==
45+
rhs.target_bitrate_per_temporal_layer &&
46+
lhs.width == rhs.width && lhs.height == rhs.height &&
47+
lhs.frame_rate_fps == rhs.frame_rate_fps;
48+
}
49+
50+
friend bool operator!=(const SpatialLayer& lhs, const SpatialLayer& rhs) {
51+
return !(lhs == rhs);
52+
}
53+
int rtp_stream_index = 0;
54+
// Index of the spatial layer per `rtp_stream_index`.
55+
int spatial_id = 0;
56+
// Target bitrate per decode target.
57+
absl::InlinedVector<DataRate, kMaxTemporalIds>
58+
target_bitrate_per_temporal_layer;
59+
60+
// These fields are only valid if `resolution_and_frame_rate_is_valid` is
61+
// true
62+
uint16_t width = 0;
63+
uint16_t height = 0;
64+
// Max frame rate used in any temporal layer of this spatial layer.
65+
uint8_t frame_rate_fps = 0;
66+
};
67+
68+
// Index of the rtp stream this allocation is sent on. Used for mapping
69+
// a SpatialLayer to a rtp stream.
70+
int rtp_stream_index = 0;
71+
bool resolution_and_frame_rate_is_valid = false;
72+
absl::InlinedVector<SpatialLayer, kMaxSpatialIds> active_spatial_layers;
73+
};
74+
75+
} // namespace webrtc
76+
77+
#endif // API_VIDEO_VIDEO_LAYERS_ALLOCATION_H_

modules/rtp_rtcp/BUILD.gn

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ rtc_library("rtp_rtcp_format") {
5252
"source/rtp_packet.h",
5353
"source/rtp_packet_received.h",
5454
"source/rtp_packet_to_send.h",
55+
"source/rtp_video_layers_allocation_extension.h",
5556
]
5657
sources = [
5758
"include/report_block_data.cc",
@@ -95,6 +96,7 @@ rtc_library("rtp_rtcp_format") {
9596
"source/rtp_packet.cc",
9697
"source/rtp_packet_received.cc",
9798
"source/rtp_packet_to_send.cc",
99+
"source/rtp_video_layers_allocation_extension.cc",
98100
]
99101

100102
deps = [
@@ -500,6 +502,7 @@ if (rtc_include_tests) {
500502
"source/rtp_sender_video_unittest.cc",
501503
"source/rtp_sequence_number_map_unittest.cc",
502504
"source/rtp_utility_unittest.cc",
505+
"source/rtp_video_layers_allocation_extension_unittest.cc",
503506
"source/source_tracker_unittest.cc",
504507
"source/time_util_unittest.cc",
505508
"source/ulpfec_generator_unittest.cc",

modules/rtp_rtcp/include/rtp_rtcp_defines.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ enum RTPExtensionType : int {
6565
kRtpExtensionTransportSequenceNumber02,
6666
kRtpExtensionPlayoutDelay,
6767
kRtpExtensionVideoContentType,
68+
kRtpExtensionVideoLayersAllocation,
6869
kRtpExtensionVideoTiming,
6970
kRtpExtensionRtpStreamId,
7071
kRtpExtensionRepairedRtpStreamId,

modules/rtp_rtcp/source/rtp_header_extension_map.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include "modules/rtp_rtcp/source/rtp_dependency_descriptor_extension.h"
1414
#include "modules/rtp_rtcp/source/rtp_generic_frame_descriptor_extension.h"
1515
#include "modules/rtp_rtcp/source/rtp_header_extensions.h"
16+
#include "modules/rtp_rtcp/source/rtp_video_layers_allocation_extension.h"
1617
#include "rtc_base/arraysize.h"
1718
#include "rtc_base/checks.h"
1819
#include "rtc_base/logging.h"
@@ -40,6 +41,7 @@ constexpr ExtensionInfo kExtensions[] = {
4041
CreateExtensionInfo<TransportSequenceNumberV2>(),
4142
CreateExtensionInfo<PlayoutDelayLimits>(),
4243
CreateExtensionInfo<VideoContentTypeExtension>(),
44+
CreateExtensionInfo<RtpVideoLayersAllocationExtension>(),
4345
CreateExtensionInfo<VideoTimingExtension>(),
4446
CreateExtensionInfo<RtpStreamId>(),
4547
CreateExtensionInfo<RepairedRtpStreamId>(),

modules/rtp_rtcp/source/rtp_packet.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ void RtpPacket::ZeroMutableExtensions() {
196196
case RTPExtensionType::kRtpExtensionRepairedRtpStreamId:
197197
case RTPExtensionType::kRtpExtensionRtpStreamId:
198198
case RTPExtensionType::kRtpExtensionVideoContentType:
199+
case RTPExtensionType::kRtpExtensionVideoLayersAllocation:
199200
case RTPExtensionType::kRtpExtensionVideoRotation:
200201
case RTPExtensionType::kRtpExtensionInbandComfortNoise: {
201202
// Non-mutable extension. Don't change it.

modules/rtp_rtcp/source/rtp_sender.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ bool IsNonVolatile(RTPExtensionType type) {
118118
case kRtpExtensionVideoRotation:
119119
case kRtpExtensionPlayoutDelay:
120120
case kRtpExtensionVideoContentType:
121+
case kRtpExtensionVideoLayersAllocation:
121122
case kRtpExtensionVideoTiming:
122123
case kRtpExtensionRepairedRtpStreamId:
123124
case kRtpExtensionColorSpace:

modules/rtp_rtcp/source/rtp_utility.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -492,6 +492,10 @@ void RtpHeaderParser::ParseOneByteExtensionHeader(
492492
&header->extension.video_timing);
493493
break;
494494
}
495+
case kRtpExtensionVideoLayersAllocation:
496+
RTC_LOG(WARNING) << "VideoLayersAllocation extension unsupported by "
497+
"rtp header parser.";
498+
break;
495499
case kRtpExtensionRtpStreamId: {
496500
std::string name(reinterpret_cast<const char*>(ptr), len + 1);
497501
if (IsLegalRsidName(name)) {

0 commit comments

Comments
 (0)