Propagate sequence number to cloned encoded audio frames
Bug: chromium:1520859
Change-Id: I6ce0304c850158ebfea1cb88bbcc74b09904fac2
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/336061
Auto-Submit: Tony Herre <herre@google.com>
Reviewed-by: Stefan Holmer <stefan@webrtc.org>
Commit-Queue: Stefan Holmer <stefan@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#41629}
diff --git a/api/frame_transformer_interface.h b/api/frame_transformer_interface.h
index 5bbcffe..102ac33 100644
--- a/api/frame_transformer_interface.h
+++ b/api/frame_transformer_interface.h
@@ -73,11 +73,7 @@
virtual rtc::ArrayView<const uint32_t> GetContributingSources() const = 0;
- // TODO(crbug.com/1453226): Change this to pure virtual after it
- // is implemented everywhere.
- virtual const absl::optional<uint16_t> SequenceNumber() const {
- return absl::nullopt;
- }
+ virtual const absl::optional<uint16_t> SequenceNumber() const = 0;
virtual absl::optional<uint64_t> AbsoluteCaptureTimestamp() const = 0;
diff --git a/audio/channel_send_frame_transformer_delegate.cc b/audio/channel_send_frame_transformer_delegate.cc
index ac32410..6d3c011 100644
--- a/audio/channel_send_frame_transformer_delegate.cc
+++ b/audio/channel_send_frame_transformer_delegate.cc
@@ -58,7 +58,8 @@
absl::optional<uint64_t> absolute_capture_timestamp_ms,
uint32_t ssrc,
std::vector<uint32_t> csrcs,
- const std::string& codec_mime_type)
+ const std::string& codec_mime_type,
+ absl::optional<uint16_t> sequence_number)
: frame_type_(frame_type),
payload_type_(payload_type),
rtp_timestamp_with_offset_(rtp_timestamp_with_offset),
@@ -66,7 +67,8 @@
absolute_capture_timestamp_ms_(absolute_capture_timestamp_ms),
ssrc_(ssrc),
csrcs_(std::move(csrcs)),
- codec_mime_type_(codec_mime_type) {}
+ codec_mime_type_(codec_mime_type),
+ sequence_number_(sequence_number) {}
~TransformableOutgoingAudioFrame() override = default;
rtc::ArrayView<const uint8_t> GetData() const override { return payload_; }
void SetData(rtc::ArrayView<const uint8_t> data) override {
@@ -88,7 +90,7 @@
}
const absl::optional<uint16_t> SequenceNumber() const override {
- return absl::nullopt;
+ return sequence_number_;
}
void SetRTPTimestamp(uint32_t rtp_timestamp_with_offset) override {
@@ -108,6 +110,7 @@
uint32_t ssrc_;
std::vector<uint32_t> csrcs_;
std::string codec_mime_type_;
+ absl::optional<uint16_t> sequence_number_;
};
} // namespace
@@ -155,7 +158,8 @@
std::make_unique<TransformableOutgoingAudioFrame>(
frame_type, payload_type, rtp_timestamp, payload_data, payload_size,
absolute_capture_timestamp_ms, ssrc,
- /*csrcs=*/std::vector<uint32_t>(), codec_mimetype));
+ /*csrcs=*/std::vector<uint32_t>(), codec_mimetype,
+ /*sequence_number=*/absl::nullopt));
}
void ChannelSendFrameTransformerDelegate::OnTransformedFrame(
@@ -203,7 +207,7 @@
original->GetPayloadType(), original->GetTimestamp(),
original->GetData().data(), original->GetData().size(),
original->AbsoluteCaptureTimestamp(), original->GetSsrc(),
- std::move(csrcs), original->GetMimeType());
+ std::move(csrcs), original->GetMimeType(), original->SequenceNumber());
}
} // namespace webrtc
diff --git a/audio/channel_send_frame_transformer_delegate_unittest.cc b/audio/channel_send_frame_transformer_delegate_unittest.cc
index 5295e26..428235e 100644
--- a/audio/channel_send_frame_transformer_delegate_unittest.cc
+++ b/audio/channel_send_frame_transformer_delegate_unittest.cc
@@ -68,6 +68,7 @@
ON_CALL(*mock_frame, GetDirection)
.WillByDefault(Return(TransformableFrameInterface::Direction::kReceiver));
ON_CALL(*mock_frame, GetContributingSources).WillByDefault(Return(csrcs));
+ ON_CALL(*mock_frame, SequenceNumber).WillByDefault(Return(987654321));
return mock_frame;
}
@@ -252,6 +253,7 @@
ASSERT_NE(frame->GetContributingSources().size(), 0u);
EXPECT_THAT(cloned_frame->GetContributingSources(),
ElementsAreArray(frame->GetContributingSources()));
+ EXPECT_EQ(cloned_frame->SequenceNumber(), frame->SequenceNumber());
}
} // namespace