Remove uses of TransformableVideoFrame::GetMetadata and deprecate it

Chromium uses have been migrated to Metadata(), so we should be clear.
Other projects can easily migrate similarly.

Bug: chromium:1420245
Change-Id: I150654812676dabd5c957cff00d40d4c95eaf5d6
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/295481
Commit-Queue: Tony Herre <herre@google.com>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#39455}
This commit is contained in:
Tony Herre 2023-03-02 12:00:05 +00:00 committed by WebRTC LUCI CQ
parent 2d71807fe0
commit 2311f93909
6 changed files with 11 additions and 35 deletions

View File

@ -60,7 +60,9 @@ class TransformableVideoFrameInterface : public TransformableFrameInterface {
// The returned const ref may become invalid due to later SetMetadata calls,
// or other modifications. Use Metadata() instead.
virtual const VideoFrameMetadata& GetMetadata() const = 0;
[[deprecated("Use Metadata() instead")]] virtual const VideoFrameMetadata&
GetMetadata() const = 0;
virtual VideoFrameMetadata Metadata() const = 0;
// TODO(https://crbug.com/webrtc/14709): Make pure virtual when Chromium MOCK

View File

@ -30,7 +30,6 @@ namespace {
using testing::NiceMock;
using testing::Return;
using testing::ReturnRef;
TEST(FrameTransformerFactory, CloneVideoFrame) {
NiceMock<MockTransformableVideoFrame> original_frame;
@ -43,13 +42,12 @@ TEST(FrameTransformerFactory, CloneVideoFrame) {
// Copy csrcs rather than moving so we can compare in an EXPECT_EQ later.
metadata.SetCsrcs(csrcs);
EXPECT_CALL(original_frame, GetMetadata())
.WillRepeatedly(ReturnRef(metadata));
EXPECT_CALL(original_frame, Metadata()).WillRepeatedly(Return(metadata));
auto cloned_frame = CloneVideoFrame(&original_frame);
EXPECT_EQ(cloned_frame->GetData().size(), 10u);
EXPECT_THAT(cloned_frame->GetData(), testing::Each(5u));
EXPECT_EQ(cloned_frame->GetMetadata().GetCsrcs(), csrcs);
EXPECT_EQ(cloned_frame->Metadata().GetCsrcs(), csrcs);
}
} // namespace

View File

@ -216,14 +216,14 @@ std::unique_ptr<TransformableVideoFrameInterface> CloneSenderVideoFrame(
original->GetData().data(), original->GetData().size());
EncodedImage encoded_image;
encoded_image.SetEncodedData(encoded_image_buffer);
RTPVideoHeader new_header =
RTPVideoHeader::FromMetadata(original->GetMetadata());
VideoFrameMetadata metadata = original->Metadata();
RTPVideoHeader new_header = RTPVideoHeader::FromMetadata(metadata);
// TODO(bugs.webrtc.org/14708): Fill in other EncodedImage parameters
return std::make_unique<TransformableVideoSenderFrame>(
encoded_image, new_header, original->GetPayloadType(), new_header.codec,
original->GetTimestamp(),
absl::nullopt, // expected_retransmission_time_ms
original->GetSsrc(), original->GetMetadata().GetCsrcs());
original->GetSsrc(), metadata.GetCsrcs());
}
} // namespace webrtc

View File

@ -163,31 +163,7 @@ TEST_F(RtpSenderVideoFrameTransformerDelegateTest, CloneSenderVideoFrame) {
EXPECT_EQ(video_frame->GetPayloadType(), clone->GetPayloadType());
EXPECT_EQ(video_frame->GetSsrc(), clone->GetSsrc());
EXPECT_EQ(video_frame->GetTimestamp(), clone->GetTimestamp());
EXPECT_EQ(video_frame->GetMetadata(), clone->GetMetadata());
}
TEST_F(RtpSenderVideoFrameTransformerDelegateTest, MetadataEqualsGetMetadata) {
auto delegate = rtc::make_ref_counted<RTPSenderVideoFrameTransformerDelegate>(
&test_sender_, frame_transformer_,
/*ssrc=*/1111, /*csrcs=*/std::vector<uint32_t>({1, 2, 3}),
time_controller_.CreateTaskQueueFactory().get());
std::unique_ptr<TransformableFrameInterface> frame =
GetTransformableFrame(delegate);
ASSERT_TRUE(frame);
TransformableVideoFrameInterface* video_frame =
static_cast<TransformableVideoFrameInterface*>(frame.get());
const VideoFrameMetadata& metadata_ref = video_frame->GetMetadata();
VideoFrameMetadata metadata_copy = video_frame->Metadata();
// TODO(bugs.webrtc.org/14708): Just EXPECT_EQ the whole Metadata once the
// equality operator lands.
EXPECT_EQ(metadata_ref.GetFrameType(), metadata_copy.GetFrameType());
EXPECT_EQ(metadata_ref.GetFrameId(), metadata_copy.GetFrameId());
EXPECT_EQ(metadata_ref.GetCodec(), metadata_copy.GetCodec());
EXPECT_EQ(metadata_ref.GetSsrc(), metadata_copy.GetSsrc());
EXPECT_EQ(metadata_ref.GetCsrcs(), metadata_copy.GetCsrcs());
EXPECT_EQ(video_frame->Metadata(), clone->Metadata());
}
TEST_F(RtpSenderVideoFrameTransformerDelegateTest, MetadataAfterSetMetadata) {

View File

@ -1638,7 +1638,7 @@ TEST_F(RtpSenderVideoWithFrameTransformerTest,
absl::WrapUnique(static_cast<TransformableVideoFrameInterface*>(
transformable_frame.release()));
ASSERT_TRUE(frame);
auto metadata = frame->GetMetadata();
auto metadata = frame->Metadata();
EXPECT_EQ(metadata.GetWidth(), 1280u);
EXPECT_EQ(metadata.GetHeight(), 720u);
EXPECT_EQ(metadata.GetFrameId(), 10);

View File

@ -160,7 +160,7 @@ TEST(RtpVideoStreamReceiverFrameTransformerDelegateTest,
absl::WrapUnique(static_cast<TransformableVideoFrameInterface*>(
transformable_frame.release()));
ASSERT_TRUE(frame);
auto metadata = frame->GetMetadata();
auto metadata = frame->Metadata();
EXPECT_EQ(metadata.GetWidth(), 1280u);
EXPECT_EQ(metadata.GetHeight(), 720u);
EXPECT_EQ(metadata.GetFrameId(), 10);