Skip to content

Commit

Permalink
Bug 1876843 - Vendor libwebrtc from 3df661f798
Browse files Browse the repository at this point in the history
Upstream commit: https://webrtc.googlesource.com/src/+/3df661f79828194d0acb51a1480833bafd9e5066
    [121] Allow RTP retransmission for cloned encoded Video Frames

    Fix the unintended disabling of RTP retransmissions for cloned encoded
    frames, caused by passing an infinite "expected_retransmission_time".
    Instead use a constant 10ms for now. For frames encoded locally, this is
    set from an estimate of the RTT, but we currently don't have access to
    that here (TODO added to pipe it through)

    If an integration is cloning and then sending frames it received, it's
    almost certainly resending received media to other peers on a local
    network, so 10ms is a fair upperbound.

    Tested locally with Chrome on Mac, configuring packet drops & observing
    on chrome://webrtc-internals that retransmission packets are now sent.

    (cherry picked from commit 3e801c32086be59e502e276ff5d6beea42069582)

    No-Try: True
    Bug: chromium:1512631
    Change-Id: I2483415dc7e0079f8a7b66f6607f4907698514c4
    Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/331900
    Reviewed-by: Harald Alvestrand <hta@webrtc.org>
    Commit-Queue: Tony Herre <herre@google.com>
    Cr-Original-Commit-Position: refs/heads/main@{#41405}
    Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/332261
    Reviewed-by: Stefan Holmer <stefan@webrtc.org>
    Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
    Reviewed-by: Henrik Boström <hbos@webrtc.org>
    Cr-Commit-Position: refs/branch-heads/6167@{#3}
    Cr-Branched-From: ece5cb83715dea85617114b6d4e981fdee2623ba-refs/heads/main@{#41315}
  • Loading branch information
jan-ivar committed Feb 11, 2024
1 parent 13e2434 commit 26cedef
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 28 deletions.
3 changes: 3 additions & 0 deletions third_party/libwebrtc/README.moz-ff-commit
Original file line number Diff line number Diff line change
Expand Up @@ -27678,3 +27678,6 @@ ece5cb8371
# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh
# base of lastest vendoring
9f1e1925f3
# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh
# base of lastest vendoring
3df661f798
2 changes: 2 additions & 0 deletions third_party/libwebrtc/README.mozilla
Original file line number Diff line number Diff line change
Expand Up @@ -18476,3 +18476,5 @@ libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc c
libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T23:02:30.081484.
# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc
libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T23:04:03.473809.
# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc
libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-11T17:10:57.292037.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@
namespace webrtc {
namespace {

// Using a reasonable default of 10ms for the retransmission delay for frames
// not coming from this sender's encoder. This is usually taken from an
// estimate of the RTT of the link,so 10ms should be a reasonable estimate for
// frames being re-transmitted to a peer, probably on the same network.
const TimeDelta kDefaultRetransmissionsTime = TimeDelta::Millis(10);

class TransformableVideoSenderFrame : public TransformableVideoFrameInterface {
public:
TransformableVideoSenderFrame(const EncodedImage& encoded_image,
Expand Down Expand Up @@ -217,15 +223,17 @@ void RTPSenderVideoFrameTransformerDelegate::SendVideo(
auto* transformed_video_frame =
static_cast<TransformableVideoFrameInterface*>(transformed_frame.get());
VideoFrameMetadata metadata = transformed_video_frame->Metadata();
sender_->SendVideo(
transformed_video_frame->GetPayloadType(), metadata.GetCodec(),
transformed_video_frame->GetTimestamp(),
/*capture_time=*/Timestamp::MinusInfinity(),
transformed_video_frame->GetData(),
transformed_video_frame->GetData().size(),
RTPVideoHeader::FromMetadata(metadata),
/*expected_retransmission_time=*/TimeDelta::PlusInfinity(),
metadata.GetCsrcs());
// TODO(bugs.webrtc.org/14708): Use an actual RTT estimate for the
// retransmission time instead of a const default, in the same way as a
// locally encoded frame.
sender_->SendVideo(transformed_video_frame->GetPayloadType(),
metadata.GetCodec(),
transformed_video_frame->GetTimestamp(),
/*capture_time=*/Timestamp::MinusInfinity(),
transformed_video_frame->GetData(),
transformed_video_frame->GetData().size(),
RTPVideoHeader::FromMetadata(metadata),
kDefaultRetransmissionsTime, metadata.GetCsrcs());
}
}

Expand Down Expand Up @@ -270,13 +278,14 @@ std::unique_ptr<TransformableVideoFrameInterface> CloneSenderVideoFrame(
? VideoFrameType::kVideoFrameKey
: VideoFrameType::kVideoFrameDelta;
// TODO(bugs.webrtc.org/14708): Fill in other EncodedImage parameters

// TODO(bugs.webrtc.org/14708): Use an actual RTT estimate for the
// retransmission time instead of a const default, in the same way as a
// locally encoded frame.
VideoFrameMetadata metadata = original->Metadata();
RTPVideoHeader new_header = RTPVideoHeader::FromMetadata(metadata);
return std::make_unique<TransformableVideoSenderFrame>(
encoded_image, new_header, original->GetPayloadType(), new_header.codec,
original->GetTimestamp(),
/*expected_retransmission_time=*/TimeDelta::PlusInfinity(),
original->GetTimestamp(), kDefaultRetransmissionsTime,
original->GetSsrc(), metadata.GetCsrcs(), original->GetRid());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class RtpSenderVideoFrameTransformerDelegateTest : public ::testing::Test {
delegate->TransformFrame(
/*payload_type=*/1, VideoCodecType::kVideoCodecVP8, /*rtp_timestamp=*/2,
encoded_image, RTPVideoHeader::FromMetadata(metadata),
/*expected_retransmission_time=*/TimeDelta::PlusInfinity());
/*expected_retransmission_time=*/TimeDelta::Millis(10));
return frame;
}

Expand Down Expand Up @@ -123,7 +123,7 @@ TEST_F(RtpSenderVideoFrameTransformerDelegateTest,
delegate->TransformFrame(
/*payload_type=*/1, VideoCodecType::kVideoCodecVP8, /*rtp_timestamp=*/2,
encoded_image, RTPVideoHeader(),
/*expected_retransmission_time=*/TimeDelta::PlusInfinity());
/*expected_retransmission_time=*/TimeDelta::Millis(10));
}

TEST_F(RtpSenderVideoFrameTransformerDelegateTest,
Expand Down Expand Up @@ -260,7 +260,7 @@ TEST_F(RtpSenderVideoFrameTransformerDelegateTest,
test_sender_,
SendVideo(payload_type, absl::make_optional(kVideoCodecVP8), timestamp,
/*capture_time=*/Timestamp::MinusInfinity(), buffer, _, _,
/*expected_retransmission_time=*/TimeDelta::PlusInfinity(),
/*expected_retransmission_time=*/TimeDelta::Millis(10),
frame_csrcs))
.WillOnce(WithoutArgs([&] {
event.Set();
Expand Down Expand Up @@ -310,7 +310,7 @@ TEST_F(RtpSenderVideoFrameTransformerDelegateTest,
delegate->TransformFrame(
/*payload_type=*/1, VideoCodecType::kVideoCodecVP8, /*rtp_timestamp=*/2,
encoded_image, RTPVideoHeader(),
/*expected_retransmission_time=*/TimeDelta::PlusInfinity());
/*expected_retransmission_time=*/TimeDelta::Millis(10));
}

} // namespace
Expand Down
20 changes: 10 additions & 10 deletions third_party/libwebrtc/moz-patch-stack/0087.patch
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ index ebca7aaa75..ede8fdc3d6 100644
: nullptr) {
if (frame_transformer_delegate_)
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 26152df0f0..561056e55b 100644
index 2bb71941f9..ff15840529 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
@@ -32,7 +32,8 @@ class TransformableVideoSenderFrame : public TransformableVideoFrameInterface {
@@ -38,7 +38,8 @@ class TransformableVideoSenderFrame : public TransformableVideoFrameInterface {
uint32_t rtp_timestamp,
TimeDelta expected_retransmission_time,
uint32_t ssrc,
Expand All @@ -70,7 +70,7 @@ index 26152df0f0..561056e55b 100644
: encoded_data_(encoded_image.GetEncodedData()),
pre_transform_payload_size_(encoded_image.size()),
header_(video_header),
@@ -44,7 +45,8 @@ class TransformableVideoSenderFrame : public TransformableVideoFrameInterface {
@@ -50,7 +51,8 @@ class TransformableVideoSenderFrame : public TransformableVideoFrameInterface {
capture_time_identifier_(encoded_image.CaptureTimeIdentifier()),
expected_retransmission_time_(expected_retransmission_time),
ssrc_(ssrc),
Expand All @@ -80,7 +80,7 @@ index 26152df0f0..561056e55b 100644
RTC_DCHECK_GE(payload_type_, 0);
RTC_DCHECK_LE(payload_type_, 127);
}
@@ -107,6 +109,8 @@ class TransformableVideoSenderFrame : public TransformableVideoFrameInterface {
@@ -113,6 +115,8 @@ class TransformableVideoSenderFrame : public TransformableVideoFrameInterface {
return mime_type + CodecTypeToPayloadString(*codec_type_);
}

Expand All @@ -89,15 +89,15 @@ index 26152df0f0..561056e55b 100644
private:
rtc::scoped_refptr<EncodedImageBufferInterface> encoded_data_;
const size_t pre_transform_payload_size_;
@@ -121,6 +125,7 @@ class TransformableVideoSenderFrame : public TransformableVideoFrameInterface {
@@ -127,6 +131,7 @@ class TransformableVideoSenderFrame : public TransformableVideoFrameInterface {

uint32_t ssrc_;
std::vector<uint32_t> csrcs_;
+ const std::string rid_;
};
} // namespace

@@ -128,10 +133,12 @@ RTPSenderVideoFrameTransformerDelegate::RTPSenderVideoFrameTransformerDelegate(
@@ -134,10 +139,12 @@ RTPSenderVideoFrameTransformerDelegate::RTPSenderVideoFrameTransformerDelegate(
RTPVideoFrameSenderInterface* sender,
rtc::scoped_refptr<FrameTransformerInterface> frame_transformer,
uint32_t ssrc,
Expand All @@ -110,7 +110,7 @@ index 26152df0f0..561056e55b 100644
transformation_queue_(task_queue_factory->CreateTaskQueue(
"video_frame_transformer",
TaskQueueFactory::Priority::NORMAL)) {}
@@ -162,7 +169,7 @@ bool RTPSenderVideoFrameTransformerDelegate::TransformFrame(
@@ -168,7 +175,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_,
Expand All @@ -119,10 +119,10 @@ index 26152df0f0..561056e55b 100644
return true;
}

@@ -261,7 +268,7 @@ std::unique_ptr<TransformableVideoFrameInterface> CloneSenderVideoFrame(
@@ -270,7 +277,7 @@ std::unique_ptr<TransformableVideoFrameInterface> CloneSenderVideoFrame(
return std::make_unique<TransformableVideoSenderFrame>(
encoded_image, new_header, original->GetPayloadType(), new_header.codec,
original->GetTimestamp(),
/*expected_retransmission_time=*/TimeDelta::PlusInfinity(),
original->GetTimestamp(), kDefaultRetransmissionsTime,
- original->GetSsrc(), metadata.GetCsrcs());
+ original->GetSsrc(), metadata.GetCsrcs(), original->GetRid());
}
Expand Down
4 changes: 2 additions & 2 deletions third_party/libwebrtc/moz-patch-stack/0088.patch
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/91d9e8b6a5c430a73
1 file changed, 9 insertions(+)

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 561056e55b..8512b21776 100644
index ff15840529..ae9eb6b4bd 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
@@ -18,6 +18,7 @@
Expand All @@ -21,7 +21,7 @@ index 561056e55b..8512b21776 100644
#include "rtc_base/logging.h"

namespace webrtc {
@@ -249,6 +250,14 @@ void RTPSenderVideoFrameTransformerDelegate::Reset() {
@@ -257,6 +258,14 @@ void RTPSenderVideoFrameTransformerDelegate::Reset() {
MutexLock lock(&sender_lock_);
sender_ = nullptr;
}
Expand Down

0 comments on commit 26cedef

Please sign in to comment.