Source code

Revision control

Copy as Markdown

Other Tools

From: Michael Froman <mjfroman@mac.com>
Date: Thu, 27 Jul 2023 12:42:44 -0500
Subject: Bug 1838080: Store the rid in TransformableVideoSenderFrame.
r=ng,webrtc-reviewers
This is necessary to reliably detect what rid a given keyframe is for, for the
purposes of resolving promises from RTCRtpScriptTransformer.generateKeyFrame.
---
api/frame_transformer_interface.h | 1 +
modules/rtp_rtcp/source/rtp_sender.h | 4 ++++
modules/rtp_rtcp/source/rtp_sender_video.cc | 1 +
...rtp_sender_video_frame_transformer_delegate.cc | 15 +++++++++++----
.../rtp_sender_video_frame_transformer_delegate.h | 2 ++
..._stream_receiver_frame_transformer_delegate.cc | 5 +++++
6 files changed, 24 insertions(+), 4 deletions(-)
diff --git a/api/frame_transformer_interface.h b/api/frame_transformer_interface.h
index b1f5426dd3..2fd002c0eb 100644
--- a/api/frame_transformer_interface.h
+++ b/api/frame_transformer_interface.h
@@ -77,6 +77,7 @@ class TransformableVideoFrameInterface : public TransformableFrameInterface {
RTC_EXPORT explicit TransformableVideoFrameInterface(Passkey passkey);
virtual ~TransformableVideoFrameInterface() = default;
virtual bool IsKeyFrame() const = 0;
+ virtual const std::string& GetRid() const = 0;
virtual VideoFrameMetadata Metadata() const = 0;
diff --git a/modules/rtp_rtcp/source/rtp_sender.h b/modules/rtp_rtcp/source/rtp_sender.h
index 61a1a5fbfe..027fbde220 100644
--- a/modules/rtp_rtcp/source/rtp_sender.h
+++ b/modules/rtp_rtcp/source/rtp_sender.h
@@ -140,6 +140,10 @@ class RTPSender {
uint32_t SSRC() const RTC_LOCKS_EXCLUDED(send_mutex_) { return ssrc_; }
+ const std::string& Rid() const RTC_LOCKS_EXCLUDED(send_mutex_) {
+ return rid_;
+ }
+
absl::optional<uint32_t> FlexfecSsrc() const RTC_LOCKS_EXCLUDED(send_mutex_) {
return flexfec_ssrc_;
}
diff --git a/modules/rtp_rtcp/source/rtp_sender_video.cc b/modules/rtp_rtcp/source/rtp_sender_video.cc
index fc39225d7e..15208c62fd 100644
--- a/modules/rtp_rtcp/source/rtp_sender_video.cc
+++ b/modules/rtp_rtcp/source/rtp_sender_video.cc
@@ -156,6 +156,7 @@ RTPSenderVideo::RTPSenderVideo(const Config& config)
this,
config.frame_transformer,
rtp_sender_->SSRC(),
+ rtp_sender_->Rid(),
config.task_queue_factory)
: nullptr),
enable_av1_even_split_(
diff --git a/modules/rtp_rtcp/source/rtp_sender_video_frame_transformer_delegate.cc b/modules/rtp_rtcp/source/rtp_sender_video_frame_transformer_delegate.cc
index 8c24160f38..b49a6fead5 100644
--- a/modules/rtp_rtcp/source/rtp_sender_video_frame_transformer_delegate.cc
+++ b/modules/rtp_rtcp/source/rtp_sender_video_frame_transformer_delegate.cc
@@ -55,7 +55,8 @@ class TransformableVideoSenderFrame : public TransformableVideoFrameInterface {
uint32_t rtp_timestamp,
TimeDelta expected_retransmission_time,
uint32_t ssrc,
- std::vector<uint32_t> csrcs)
+ std::vector<uint32_t> csrcs,
+ const std::string& rid)
: TransformableVideoFrameInterface(Passkey()),
encoded_data_(encoded_image.GetEncodedData()),
pre_transform_payload_size_(encoded_image.size()),
@@ -68,7 +69,8 @@ class TransformableVideoSenderFrame : public TransformableVideoFrameInterface {
capture_time_identifier_(encoded_image.CaptureTimeIdentifier()),
expected_retransmission_time_(expected_retransmission_time),
ssrc_(ssrc),
- csrcs_(csrcs) {
+ csrcs_(csrcs),
+ rid_(rid) {
RTC_DCHECK_GE(payload_type_, 0);
RTC_DCHECK_LE(payload_type_, 127);
}
@@ -131,6 +133,8 @@ class TransformableVideoSenderFrame : public TransformableVideoFrameInterface {
return mime_type + CodecTypeToPayloadString(*codec_type_);
}
+ const std::string& GetRid() const override { return rid_; }
+
private:
rtc::scoped_refptr<EncodedImageBufferInterface> encoded_data_;
const size_t pre_transform_payload_size_;
@@ -145,16 +149,19 @@ class TransformableVideoSenderFrame : public TransformableVideoFrameInterface {
uint32_t ssrc_;
std::vector<uint32_t> csrcs_;
+ const std::string rid_;
};
RTPSenderVideoFrameTransformerDelegate::RTPSenderVideoFrameTransformerDelegate(
RTPVideoFrameSenderInterface* sender,
rtc::scoped_refptr<FrameTransformerInterface> frame_transformer,
uint32_t ssrc,
+ const std::string& rid,
TaskQueueFactory* task_queue_factory)
: sender_(sender),
frame_transformer_(std::move(frame_transformer)),
ssrc_(ssrc),
+ rid_(rid),
transformation_queue_(task_queue_factory->CreateTaskQueue(
"video_frame_transformer",
TaskQueueFactory::Priority::NORMAL)) {}
@@ -185,7 +192,7 @@ bool RTPSenderVideoFrameTransformerDelegate::TransformFrame(
frame_transformer_->Transform(std::make_unique<TransformableVideoSenderFrame>(
encoded_image, video_header, payload_type, codec_type, rtp_timestamp,
expected_retransmission_time, ssrc_,
- /*csrcs=*/std::vector<uint32_t>()));
+ /*csrcs=*/std::vector<uint32_t>(), rid_));
return true;
}
@@ -287,7 +294,7 @@ std::unique_ptr<TransformableVideoFrameInterface> CloneSenderVideoFrame(
return std::make_unique<TransformableVideoSenderFrame>(
encoded_image, new_header, original->GetPayloadType(), new_header.codec,
original->GetTimestamp(), kDefaultRetransmissionsTime,
- original->GetSsrc(), metadata.GetCsrcs());
+ original->GetSsrc(), metadata.GetCsrcs(), original->GetRid());
}
} // namespace webrtc
diff --git a/modules/rtp_rtcp/source/rtp_sender_video_frame_transformer_delegate.h b/modules/rtp_rtcp/source/rtp_sender_video_frame_transformer_delegate.h
index a32c7084ea..ef6f128899 100644
--- a/modules/rtp_rtcp/source/rtp_sender_video_frame_transformer_delegate.h
+++ b/modules/rtp_rtcp/source/rtp_sender_video_frame_transformer_delegate.h
@@ -60,6 +60,7 @@ class RTPSenderVideoFrameTransformerDelegate : public TransformedFrameCallback {
RTPVideoFrameSenderInterface* sender,
rtc::scoped_refptr<FrameTransformerInterface> frame_transformer,
uint32_t ssrc,
+ const std::string& rid,
TaskQueueFactory* send_transport_queue);
void Init();
@@ -108,6 +109,7 @@ class RTPSenderVideoFrameTransformerDelegate : public TransformedFrameCallback {
RTPVideoFrameSenderInterface* sender_ RTC_GUARDED_BY(sender_lock_);
rtc::scoped_refptr<FrameTransformerInterface> frame_transformer_;
const uint32_t ssrc_;
+ const std::string rid_;
// Used when the encoded frames arrives without a current task queue. This can
// happen if a hardware encoder was used.
std::unique_ptr<TaskQueueBase, TaskQueueDeleter> transformation_queue_;
diff --git a/modules/rtp_rtcp/source/rtp_video_stream_receiver_frame_transformer_delegate.cc b/modules/rtp_rtcp/source/rtp_video_stream_receiver_frame_transformer_delegate.cc
index de74684a1f..7e0754284a 100644
--- a/modules/rtp_rtcp/source/rtp_video_stream_receiver_frame_transformer_delegate.cc
+++ b/modules/rtp_rtcp/source/rtp_video_stream_receiver_frame_transformer_delegate.cc
@@ -59,6 +59,11 @@ class TransformableVideoReceiverFrame
return frame_->FrameType() == VideoFrameType::kVideoFrameKey;
}
+ const std::string& GetRid() const override {
+ static const std::string empty;
+ return empty;
+ }
+
VideoFrameMetadata Metadata() const override { return metadata_; }
void SetMetadata(const VideoFrameMetadata& metadata) override {