in RtpSenderVideo propagate chain_diffs into dependency descriptor
Bug: webrtc:10342
Change-Id: I14644c38792616a2002d1420770640d9b6f5099a
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/175085
Reviewed-by: Philip Eliasson <philipel@webrtc.org>
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#31263}
diff --git a/common_video/generic_frame_descriptor/generic_frame_info.cc b/common_video/generic_frame_descriptor/generic_frame_info.cc
index ca61072..ef78fac 100644
--- a/common_video/generic_frame_descriptor/generic_frame_info.cc
+++ b/common_video/generic_frame_descriptor/generic_frame_info.cc
@@ -71,8 +71,13 @@
GenericFrameInfo::Builder& GenericFrameInfo::Builder::Fdiffs(
std::initializer_list<int> frame_diffs) {
- info_.frame_diffs.insert(info_.frame_diffs.end(), frame_diffs.begin(),
- frame_diffs.end());
+ info_.frame_diffs.assign(frame_diffs.begin(), frame_diffs.end());
+ return *this;
+}
+
+GenericFrameInfo::Builder& GenericFrameInfo::Builder::ChainDiffs(
+ std::initializer_list<int> chain_diffs) {
+ info_.chain_diffs.assign(chain_diffs.begin(), chain_diffs.end());
return *this;
}
diff --git a/common_video/generic_frame_descriptor/generic_frame_info.h b/common_video/generic_frame_descriptor/generic_frame_info.h
index b602ee0..ba3265b 100644
--- a/common_video/generic_frame_descriptor/generic_frame_info.h
+++ b/common_video/generic_frame_descriptor/generic_frame_info.h
@@ -54,6 +54,7 @@
Builder& S(int spatial_id);
Builder& Dtis(absl::string_view indication_symbols);
Builder& Fdiffs(std::initializer_list<int> frame_diffs);
+ Builder& ChainDiffs(std::initializer_list<int> chain_diffs);
private:
GenericFrameInfo info_;
diff --git a/modules/rtp_rtcp/source/rtp_sender_video.cc b/modules/rtp_rtcp/source/rtp_sender_video.cc
index b903b9f..8dbcc90 100644
--- a/modules/rtp_rtcp/source/rtp_sender_video.cc
+++ b/modules/rtp_rtcp/source/rtp_sender_video.cc
@@ -251,8 +251,6 @@
video_structure_ =
std::make_unique<FrameDependencyStructure>(*video_structure);
video_structure_->structure_id = structure_id;
- // TODO(bugs.webrtc.org/10342): Support chains.
- video_structure_->num_chains = 0;
}
void RTPSenderVideo::AddRtpHeaderExtensions(
@@ -336,6 +334,8 @@
descriptor.frame_dependencies.frame_diffs.push_back(
video_header.generic->frame_id - dep);
}
+ descriptor.frame_dependencies.chain_diffs =
+ video_header.generic->chain_diffs;
descriptor.frame_dependencies.decode_target_indications =
video_header.generic->decode_target_indications;
RTC_DCHECK_EQ(
diff --git a/modules/rtp_rtcp/source/rtp_sender_video_unittest.cc b/modules/rtp_rtcp/source/rtp_sender_video_unittest.cc
index 21c4da0..75fa6c8 100644
--- a/modules/rtp_rtcp/source/rtp_sender_video_unittest.cc
+++ b/modules/rtp_rtcp/source/rtp_sender_video_unittest.cc
@@ -45,6 +45,7 @@
namespace {
using ::testing::_;
+using ::testing::ContainerEq;
using ::testing::ElementsAre;
using ::testing::ElementsAreArray;
using ::testing::IsEmpty;
@@ -606,6 +607,40 @@
ElementsAre(1, 501));
}
+TEST_P(RtpSenderVideoTest, PropagatesChainDiffsIntoDependencyDescriptor) {
+ const int64_t kFrameId = 100000;
+ uint8_t kFrame[100];
+ rtp_module_->RegisterRtpHeaderExtension(
+ RtpDependencyDescriptorExtension::kUri, kDependencyDescriptorId);
+ FrameDependencyStructure video_structure;
+ video_structure.num_decode_targets = 2;
+ video_structure.num_chains = 1;
+ // First decode target is protected by the only chain, second one - is not.
+ video_structure.decode_target_protected_by_chain = {0, 1};
+ video_structure.templates = {
+ GenericFrameInfo::Builder().S(0).T(0).Dtis("SS").ChainDiffs({1}).Build(),
+ };
+ rtp_sender_video_.SetVideoStructure(&video_structure);
+
+ RTPVideoHeader hdr;
+ RTPVideoHeader::GenericDescriptorInfo& generic = hdr.generic.emplace();
+ generic.frame_id = kFrameId;
+ generic.decode_target_indications = {DecodeTargetIndication::kSwitch,
+ DecodeTargetIndication::kSwitch};
+ generic.chain_diffs = {2};
+ hdr.frame_type = VideoFrameType::kVideoFrameKey;
+ rtp_sender_video_.SendVideo(kPayload, kType, kTimestamp, 0, kFrame, nullptr,
+ hdr, kDefaultExpectedRetransmissionTimeMs);
+
+ ASSERT_EQ(transport_.packets_sent(), 1);
+ DependencyDescriptor descriptor_key;
+ ASSERT_TRUE(transport_.last_sent_packet()
+ .GetExtension<RtpDependencyDescriptorExtension>(
+ nullptr, &descriptor_key));
+ EXPECT_THAT(descriptor_key.frame_dependencies.chain_diffs,
+ ContainerEq(generic.chain_diffs));
+}
+
TEST_P(RtpSenderVideoTest,
SetDiffentVideoStructureAvoidsCollisionWithThePreviousStructure) {
const int64_t kFrameId = 100000;
diff --git a/modules/rtp_rtcp/source/rtp_video_header.h b/modules/rtp_rtcp/source/rtp_video_header.h
index 7071463..5785ea9 100644
--- a/modules/rtp_rtcp/source/rtp_video_header.h
+++ b/modules/rtp_rtcp/source/rtp_video_header.h
@@ -23,7 +23,7 @@
#include "api/video/video_frame_type.h"
#include "api/video/video_rotation.h"
#include "api/video/video_timing.h"
-#include "common_types.h" // NOLINT(build/include)
+#include "common_types.h" // NOLINT(build/include_directory)
#include "modules/video_coding/codecs/h264/include/h264_globals.h"
#include "modules/video_coding/codecs/vp8/include/vp8_globals.h"
#include "modules/video_coding/codecs/vp9/include/vp9_globals.h"
@@ -53,6 +53,7 @@
int temporal_index = 0;
absl::InlinedVector<DecodeTargetIndication, 10> decode_target_indications;
absl::InlinedVector<int64_t, 5> dependencies;
+ absl::InlinedVector<int, 4> chain_diffs;
};
RTPVideoHeader();