Remove FrameTransformerInterface functions using EncodedFrame.

Replaced by the function versions using TransformableFrameInterface
downstream.

Bug: webrtc:11380
Change-Id: Ia4aef84dd76b542ba33287aff6c9151448ed5be6
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/171864
Commit-Queue: Marina Ciocea <marinaciocea@webrtc.org>
Reviewed-by: Danil Chapovalov <danilchap@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Reviewed-by: Magnus Flodman <mflodman@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#31170}
This commit is contained in:
Marina Ciocea
2020-05-05 16:03:54 +02:00
committed by Commit Bot
parent a0ff50c031
commit 81be4217b8
12 changed files with 24 additions and 256 deletions

View File

@ -64,14 +64,8 @@ class TransformableAudioFrameInterface : public TransformableFrameInterface {
// Objects implement this interface to be notified with the transformed frame.
class TransformedFrameCallback : public rtc::RefCountInterface {
public:
// TODO(bugs.webrtc.org/11380) remove after updating downstream dependencies
// to use new OnTransformedFrame signature.
virtual void OnTransformedFrame(
std::unique_ptr<video_coding::EncodedFrame> transformed_frame) {}
// TODO(bugs.webrtc.org/11380) make pure virtual after updating usage
// downstream.
virtual void OnTransformedFrame(
std::unique_ptr<TransformableFrameInterface> transformed_frame) {}
std::unique_ptr<TransformableFrameInterface> frame) = 0;
protected:
~TransformedFrameCallback() override = default;
@ -82,23 +76,8 @@ class TransformedFrameCallback : public rtc::RefCountInterface {
class FrameTransformerInterface : public rtc::RefCountInterface {
public:
// Transforms |frame| using the implementing class' processing logic.
// |additional_data| holds data that is needed in the frame transformation
// logic, but is not included in |frame|; for example, when the transform
// function is used for encrypting/decrypting the frame, the additional data
// holds the serialized generic frame descriptor extension calculated in
// webrtc::RtpDescriptorAuthentication, needed in the encryption/decryption
// algorithms.
// TODO(bugs.webrtc.org/11380) remove after updating downstream dependencies
// to use new OnTransformedFrame() signature.
virtual void TransformFrame(std::unique_ptr<video_coding::EncodedFrame> frame,
std::vector<uint8_t> additional_data,
uint32_t ssrc) {}
// Transforms |frame| using the implementing class' processing logic.
// TODO(bugs.webrtc.org/11380) make pure virtual after updating usage
// downstream.
virtual void Transform(
std::unique_ptr<TransformableFrameInterface> transformable_frame) {}
std::unique_ptr<TransformableFrameInterface> transformable_frame) = 0;
virtual void RegisterTransformedFrameCallback(
rtc::scoped_refptr<TransformedFrameCallback>) {}

View File

@ -206,8 +206,6 @@ rtc_library("rtp_rtcp") {
"source/time_util.h",
"source/tmmbr_help.cc",
"source/tmmbr_help.h",
"source/transformable_encoded_frame.cc",
"source/transformable_encoded_frame.h",
"source/ulpfec_generator.cc",
"source/ulpfec_generator.h",
"source/ulpfec_header_reader_writer.cc",

View File

@ -35,7 +35,6 @@
#include "modules/rtp_rtcp/source/rtp_header_extensions.h"
#include "modules/rtp_rtcp/source/rtp_packet_to_send.h"
#include "modules/rtp_rtcp/source/time_util.h"
#include "modules/rtp_rtcp/source/transformable_encoded_frame.h"
#include "rtc_base/checks.h"
#include "rtc_base/logging.h"
#include "rtc_base/trace_event.h"

View File

@ -16,7 +16,6 @@
#include "absl/memory/memory.h"
#include "modules/rtp_rtcp/source/rtp_descriptor_authentication.h"
#include "modules/rtp_rtcp/source/rtp_sender_video.h"
#include "modules/rtp_rtcp/source/transformable_encoded_frame.h"
#include "rtc_base/task_utils/to_queued_task.h"
namespace webrtc {
@ -126,35 +125,12 @@ bool RTPSenderVideoFrameTransformerDelegate::TransformFrame(
absl::optional<int64_t> expected_retransmission_time_ms) {
if (!encoder_queue_)
encoder_queue_ = TaskQueueBase::Current();
// TODO(bugs.webrtc.org/11380) remove once this version of TransformFrame() is
// deprecated.
frame_transformer_->TransformFrame(
std::make_unique<TransformableEncodedFrame>(
encoded_image.GetEncodedData(), video_header, payload_type,
codec_type, rtp_timestamp, encoded_image.capture_time_ms_,
fragmentation, expected_retransmission_time_ms),
RtpDescriptorAuthentication(video_header), ssrc_);
frame_transformer_->Transform(std::make_unique<TransformableVideoSenderFrame>(
encoded_image, video_header, payload_type, codec_type, rtp_timestamp,
fragmentation, expected_retransmission_time_ms, ssrc_));
return true;
}
void RTPSenderVideoFrameTransformerDelegate::OnTransformedFrame(
std::unique_ptr<video_coding::EncodedFrame> frame) {
rtc::CritScope lock(&sender_lock_);
// The encoder queue gets destroyed after the sender; as long as the sender is
// alive, it's safe to post.
if (!sender_)
return;
rtc::scoped_refptr<RTPSenderVideoFrameTransformerDelegate> delegate = this;
encoder_queue_->PostTask(ToQueuedTask(
[delegate = std::move(delegate), frame = std::move(frame)]() mutable {
delegate->SendVideo(std::move(frame));
}));
}
void RTPSenderVideoFrameTransformerDelegate::OnTransformedFrame(
std::unique_ptr<TransformableFrameInterface> frame) {
rtc::CritScope lock(&sender_lock_);
@ -170,23 +146,6 @@ void RTPSenderVideoFrameTransformerDelegate::OnTransformedFrame(
}));
}
void RTPSenderVideoFrameTransformerDelegate::SendVideo(
std::unique_ptr<video_coding::EncodedFrame> frame) const {
RTC_CHECK(encoder_queue_->IsCurrent());
rtc::CritScope lock(&sender_lock_);
if (!sender_)
return;
auto* transformed_frame =
static_cast<TransformableEncodedFrame*>(frame.get());
sender_->SendVideo(
transformed_frame->PayloadType(), transformed_frame->codec_type(),
transformed_frame->Timestamp(), transformed_frame->capture_time_ms(),
transformed_frame->EncodedImage(),
transformed_frame->fragmentation_header(),
transformed_frame->video_header(),
transformed_frame->expected_retransmission_time_ms());
}
void RTPSenderVideoFrameTransformerDelegate::SendVideo(
std::unique_ptr<TransformableFrameInterface> transformed_frame) const {
RTC_CHECK(encoder_queue_->IsCurrent());

View File

@ -16,7 +16,6 @@
#include "api/frame_transformer_interface.h"
#include "api/scoped_refptr.h"
#include "api/task_queue/task_queue_base.h"
#include "modules/rtp_rtcp/source/transformable_encoded_frame.h"
#include "rtc_base/critical_section.h"
namespace webrtc {
@ -46,13 +45,10 @@ class RTPSenderVideoFrameTransformerDelegate : public TransformedFrameCallback {
// Implements TransformedFrameCallback. Can be called on any thread. Posts
// the transformed frame to be sent on the |encoder_queue_|.
void OnTransformedFrame(
std::unique_ptr<video_coding::EncodedFrame> frame) override;
void OnTransformedFrame(
std::unique_ptr<TransformableFrameInterface> frame) override;
// Delegates the call to RTPSendVideo::SendVideo on the |encoder_queue_|.
void SendVideo(std::unique_ptr<video_coding::EncodedFrame> frame) const;
void SendVideo(std::unique_ptr<TransformableFrameInterface> frame) const;
// Delegates the call to RTPSendVideo::SendVideo under |sender_lock_|.

View File

@ -1,55 +0,0 @@
/*
* 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 "modules/rtp_rtcp/source/transformable_encoded_frame.h"
namespace webrtc {
TransformableEncodedFrame::TransformableEncodedFrame(
rtc::scoped_refptr<EncodedImageBufferInterface> encoded_data,
const RTPVideoHeader& video_header,
int payload_type,
absl::optional<VideoCodecType> codec_type,
uint32_t rtp_timestamp,
int64_t capture_time_ms,
const RTPFragmentationHeader* fragmentation,
absl::optional<int64_t> expected_retransmission_time_ms)
: video_header_(video_header),
codec_type_(codec_type),
expected_retransmission_time_ms_(expected_retransmission_time_ms) {
SetEncodedData(encoded_data);
_payloadType = payload_type;
SetTimestamp(rtp_timestamp);
capture_time_ms_ = capture_time_ms;
if (fragmentation) {
fragmentation_header_ = std::make_unique<RTPFragmentationHeader>();
fragmentation_header_->CopyFrom(*fragmentation);
}
}
TransformableEncodedFrame::~TransformableEncodedFrame() = default;
const RTPVideoHeader& TransformableEncodedFrame::video_header() const {
return video_header_;
}
absl::optional<VideoCodecType> TransformableEncodedFrame::codec_type() const {
return codec_type_;
}
int64_t TransformableEncodedFrame::ReceivedTime() const {
return 0;
}
int64_t TransformableEncodedFrame::RenderTime() const {
return _renderTimeMs;
}
} // namespace webrtc

View File

@ -1,59 +0,0 @@
/*
* 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 MODULES_RTP_RTCP_SOURCE_TRANSFORMABLE_ENCODED_FRAME_H_
#define MODULES_RTP_RTCP_SOURCE_TRANSFORMABLE_ENCODED_FRAME_H_
#include <memory>
#include "absl/types/optional.h"
#include "api/video/encoded_frame.h"
#include "modules/include/module_common_types.h"
#include "modules/rtp_rtcp/source/rtp_video_header.h"
namespace webrtc {
class TransformableEncodedFrame : public video_coding::EncodedFrame {
public:
TransformableEncodedFrame(
rtc::scoped_refptr<EncodedImageBufferInterface> encoded_data,
const RTPVideoHeader& video_header,
int payload_type,
absl::optional<VideoCodecType> codec_type,
uint32_t rtp_timestamp,
int64_t capture_time_ms,
const RTPFragmentationHeader* fragmentation,
absl::optional<int64_t> expected_retransmission_time_ms);
~TransformableEncodedFrame() override;
const RTPVideoHeader& video_header() const;
absl::optional<VideoCodecType> codec_type() const;
int64_t capture_time_ms() const { return capture_time_ms_; }
RTPFragmentationHeader* fragmentation_header() const {
return fragmentation_header_.get();
}
const absl::optional<int64_t>& expected_retransmission_time_ms() const {
return expected_retransmission_time_ms_;
}
// Implements EncodedFrame.
int64_t ReceivedTime() const override;
int64_t RenderTime() const override;
private:
RTPVideoHeader video_header_;
absl::optional<VideoCodecType> codec_type_ = absl::nullopt;
std::unique_ptr<RTPFragmentationHeader> fragmentation_header_;
absl::optional<int64_t> expected_retransmission_time_ms_ = absl::nullopt;
};
} // namespace webrtc
#endif // MODULES_RTP_RTCP_SOURCE_TRANSFORMABLE_ENCODED_FRAME_H_

View File

@ -21,12 +21,6 @@ namespace webrtc {
class MockFrameTransformer : public FrameTransformerInterface {
public:
MOCK_METHOD(void,
TransformFrame,
(std::unique_ptr<video_coding::EncodedFrame>,
std::vector<uint8_t>,
uint32_t),
(override));
MOCK_METHOD(void,
Transform,
(std::unique_ptr<TransformableFrameInterface>),

View File

@ -89,30 +89,11 @@ void RtpVideoStreamReceiverFrameTransformerDelegate::Reset() {
void RtpVideoStreamReceiverFrameTransformerDelegate::TransformFrame(
std::unique_ptr<video_coding::RtpFrameObject> frame) {
RTC_DCHECK_RUN_ON(&network_sequence_checker_);
// TODO(bugs.webrtc.org/11380) remove once this version of TransformFrame is
// deprecated.
auto additional_data =
RtpDescriptorAuthentication(frame->GetRtpVideoHeader());
auto frame_copy =
std::make_unique<video_coding::RtpFrameObject>(*frame.get());
frame_transformer_->TransformFrame(std::move(frame_copy),
std::move(additional_data), ssrc_);
frame_transformer_->Transform(
std::make_unique<TransformableVideoReceiverFrame>(std::move(frame),
ssrc_));
}
void RtpVideoStreamReceiverFrameTransformerDelegate::OnTransformedFrame(
std::unique_ptr<video_coding::EncodedFrame> frame) {
rtc::scoped_refptr<RtpVideoStreamReceiverFrameTransformerDelegate> delegate =
this;
network_thread_->PostTask(ToQueuedTask(
[delegate = std::move(delegate), frame = std::move(frame)]() mutable {
delegate->ManageFrame(std::move(frame));
}));
}
void RtpVideoStreamReceiverFrameTransformerDelegate::OnTransformedFrame(
std::unique_ptr<TransformableFrameInterface> frame) {
rtc::scoped_refptr<RtpVideoStreamReceiverFrameTransformerDelegate> delegate =
@ -123,16 +104,6 @@ void RtpVideoStreamReceiverFrameTransformerDelegate::OnTransformedFrame(
}));
}
void RtpVideoStreamReceiverFrameTransformerDelegate::ManageFrame(
std::unique_ptr<video_coding::EncodedFrame> frame) {
RTC_DCHECK_RUN_ON(&network_sequence_checker_);
if (!receiver_)
return;
auto transformed_frame = absl::WrapUnique(
static_cast<video_coding::RtpFrameObject*>(frame.release()));
receiver_->ManageFrame(std::move(transformed_frame));
}
void RtpVideoStreamReceiverFrameTransformerDelegate::ManageFrame(
std::unique_ptr<TransformableFrameInterface> frame) {
RTC_DCHECK_RUN_ON(&network_sequence_checker_);

View File

@ -41,14 +41,11 @@ class RtpVideoStreamReceiverFrameTransformerDelegate
// Implements TransformedFrameCallback. Can be called on any thread. Posts
// the transformed frame to be managed on the |network_thread_|.
void OnTransformedFrame(
std::unique_ptr<video_coding::EncodedFrame> frame) override;
void OnTransformedFrame(
std::unique_ptr<TransformableFrameInterface> frame) override;
// Delegates the call to RtpVideoReceiver::ManageFrame on the
// |network_thread_|.
void ManageFrame(std::unique_ptr<video_coding::EncodedFrame> frame);
void ManageFrame(std::unique_ptr<TransformableFrameInterface> frame);
protected:

View File

@ -30,6 +30,8 @@ namespace webrtc {
namespace {
using ::testing::_;
using ::testing::NiceMock;
using ::testing::SaveArg;
std::unique_ptr<video_coding::RtpFrameObject> CreateRtpFrameObject() {
return std::make_unique<video_coding::RtpFrameObject>(
@ -145,45 +147,34 @@ TEST(RtpVideoStreamReceiverFrameTransformerDelegateTest, TransformFrame) {
&receiver, frame_transformer, rtc::Thread::Current(),
/*remote_ssrc*/ 1111));
auto frame = CreateRtpFrameObject();
EXPECT_CALL(*frame_transformer,
TransformFrame(_, RtpDescriptorAuthentication(RTPVideoHeader()),
/*remote_ssrc*/ 1111));
EXPECT_CALL(*frame_transformer, Transform);
delegate->TransformFrame(std::move(frame));
}
TEST(RtpVideoStreamReceiverFrameTransformerDelegateTest,
ManageFrameOnTransformedFrame) {
auto main_thread = rtc::Thread::Create();
main_thread->Start();
auto network_thread = rtc::Thread::Create();
network_thread->Start();
TestRtpVideoStreamReceiver receiver;
rtc::scoped_refptr<MockFrameTransformer> frame_transformer(
new rtc::RefCountedObject<MockFrameTransformer>());
auto delegate = network_thread->Invoke<
rtc::scoped_refptr<RtpVideoStreamReceiverFrameTransformerDelegate>>(
RTC_FROM_HERE, [&]() mutable {
return new rtc::RefCountedObject<
RtpVideoStreamReceiverFrameTransformerDelegate>(
&receiver, frame_transformer, network_thread.get(),
rtc::scoped_refptr<MockFrameTransformer> mock_frame_transformer(
new rtc::RefCountedObject<NiceMock<MockFrameTransformer>>());
rtc::scoped_refptr<RtpVideoStreamReceiverFrameTransformerDelegate> delegate =
new rtc::RefCountedObject<RtpVideoStreamReceiverFrameTransformerDelegate>(
&receiver, mock_frame_transformer, rtc::Thread::Current(),
/*remote_ssrc*/ 1111);
});
auto frame = CreateRtpFrameObject();
rtc::scoped_refptr<TransformedFrameCallback> callback;
EXPECT_CALL(*mock_frame_transformer, RegisterTransformedFrameSinkCallback)
.WillOnce(SaveArg<0>(&callback));
delegate->Init();
ASSERT_TRUE(callback);
EXPECT_CALL(receiver, ManageFrame)
.WillOnce([&network_thread](
std::unique_ptr<video_coding::RtpFrameObject> frame) {
EXPECT_TRUE(network_thread->IsCurrent());
});
main_thread->Invoke<void>(RTC_FROM_HERE, [&]() mutable {
delegate->OnTransformedFrame(std::move(frame));
EXPECT_CALL(receiver, ManageFrame);
ON_CALL(*mock_frame_transformer, Transform)
.WillByDefault(
[&callback](std::unique_ptr<TransformableFrameInterface> frame) {
callback->OnTransformedFrame(std::move(frame));
});
delegate->TransformFrame(CreateRtpFrameObject());
rtc::ThreadManager::ProcessAllMessageQueuesForTesting();
main_thread->Stop();
network_thread->Stop();
}
} // namespace

View File

@ -1137,9 +1137,7 @@ TEST_F(RtpVideoStreamReceiverTest, TransformFrame) {
GetGenericVideoHeader(VideoFrameType::kVideoFrameKey);
mock_on_complete_frame_callback_.AppendExpectedBitstream(data.data(),
data.size());
EXPECT_CALL(*mock_frame_transformer,
TransformFrame(_, RtpDescriptorAuthentication(video_header),
config_.rtp.remote_ssrc));
EXPECT_CALL(*mock_frame_transformer, Transform(_));
receiver->OnReceivedPayloadData(data, rtp_packet, video_header);
EXPECT_CALL(*mock_frame_transformer,