mirror of
https://github.com/mollyim/webrtc.git
synced 2025-05-13 05:40:42 +01:00
Add a setter for RTPTimestamp on TransformableFrameInterface
Move the SetRTPTimestamp method from TransformableAudioFrameInterface to the base class, so that RTPTimestamps can also be modified on encoded video frames. Bug: webrtc:14709 Change-Id: I355be527c2be201c9201e04c431394c962237140 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/310781 Commit-Queue: Tony Herre <herre@google.com> Reviewed-by: Harald Alvestrand <hta@webrtc.org> Reviewed-by: Palak Agarwal <agpalak@google.com> Cr-Commit-Position: refs/heads/main@{#40378}
This commit is contained in:
parent
cabd77a5c7
commit
b4062e5611
6 changed files with 28 additions and 3 deletions
|
@ -36,6 +36,8 @@ class TransformableFrameInterface {
|
|||
virtual uint8_t GetPayloadType() const = 0;
|
||||
virtual uint32_t GetSsrc() const = 0;
|
||||
virtual uint32_t GetTimestamp() const = 0;
|
||||
virtual void SetRTPTimestamp(uint32_t timestamp) = 0;
|
||||
|
||||
// TODO(https://bugs.webrtc.org/14878): Change this to pure virtual after it
|
||||
// is implemented everywhere.
|
||||
virtual absl::optional<Timestamp> GetCaptureTimeIdentifier() const {
|
||||
|
@ -68,8 +70,6 @@ class TransformableAudioFrameInterface : public TransformableFrameInterface {
|
|||
public:
|
||||
virtual ~TransformableAudioFrameInterface() = default;
|
||||
|
||||
virtual void SetRTPTimestamp(uint32_t timestamp) = 0;
|
||||
|
||||
// TODO(crbug.com/1453226): Remove after a few weeks.
|
||||
[[deprecated("Use specific getters instead.")]] virtual const RTPHeader&
|
||||
GetHeader() const = 0;
|
||||
|
|
|
@ -24,6 +24,7 @@ class MockTransformableVideoFrame
|
|||
MOCK_METHOD(rtc::ArrayView<const uint8_t>, GetData, (), (const, override));
|
||||
MOCK_METHOD(void, SetData, (rtc::ArrayView<const uint8_t> data), (override));
|
||||
MOCK_METHOD(uint32_t, GetTimestamp, (), (const, override));
|
||||
MOCK_METHOD(void, SetRTPTimestamp, (uint32_t), (override));
|
||||
MOCK_METHOD(uint32_t, GetSsrc, (), (const, override));
|
||||
MOCK_METHOD(bool, IsKeyFrame, (), (const, override));
|
||||
MOCK_METHOD(void,
|
||||
|
|
|
@ -64,6 +64,8 @@ class TransformableVideoSenderFrame : public TransformableVideoFrameInterface {
|
|||
}
|
||||
|
||||
uint32_t GetTimestamp() const override { return timestamp_; }
|
||||
void SetRTPTimestamp(uint32_t timestamp) override { timestamp_ = timestamp; }
|
||||
|
||||
uint32_t GetSsrc() const override { return ssrc_; }
|
||||
|
||||
bool IsKeyFrame() const override {
|
||||
|
@ -104,7 +106,7 @@ class TransformableVideoSenderFrame : public TransformableVideoFrameInterface {
|
|||
const VideoFrameType frame_type_;
|
||||
const uint8_t payload_type_;
|
||||
const absl::optional<VideoCodecType> codec_type_ = absl::nullopt;
|
||||
const uint32_t timestamp_;
|
||||
uint32_t timestamp_;
|
||||
const int64_t capture_time_ms_;
|
||||
const absl::optional<Timestamp> capture_time_identifier_;
|
||||
const absl::optional<int64_t> expected_retransmission_time_ms_;
|
||||
|
|
|
@ -270,5 +270,23 @@ TEST_F(RtpSenderVideoFrameTransformerDelegateTest,
|
|||
event.Wait(TimeDelta::Seconds(1));
|
||||
}
|
||||
|
||||
TEST_F(RtpSenderVideoFrameTransformerDelegateTest, SettingRTPTimestamp) {
|
||||
auto delegate = rtc::make_ref_counted<RTPSenderVideoFrameTransformerDelegate>(
|
||||
&test_sender_, frame_transformer_,
|
||||
/*ssrc=*/1111, /*csrcs=*/std::vector<uint32_t>(),
|
||||
time_controller_.CreateTaskQueueFactory().get());
|
||||
|
||||
std::unique_ptr<TransformableFrameInterface> frame =
|
||||
GetTransformableFrame(delegate);
|
||||
ASSERT_TRUE(frame);
|
||||
auto& video_frame = static_cast<TransformableVideoFrameInterface&>(*frame);
|
||||
|
||||
uint32_t rtp_timestamp = 12345;
|
||||
ASSERT_FALSE(video_frame.GetTimestamp() == rtp_timestamp);
|
||||
|
||||
video_frame.SetRTPTimestamp(rtp_timestamp);
|
||||
EXPECT_EQ(video_frame.GetTimestamp(), rtp_timestamp);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace webrtc
|
||||
|
|
|
@ -48,6 +48,9 @@ class TransformableVideoReceiverFrame
|
|||
uint8_t GetPayloadType() const override { return frame_->PayloadType(); }
|
||||
uint32_t GetSsrc() const override { return metadata_.GetSsrc(); }
|
||||
uint32_t GetTimestamp() const override { return frame_->Timestamp(); }
|
||||
void SetRTPTimestamp(uint32_t timestamp) override {
|
||||
frame_->SetTimestamp(timestamp);
|
||||
}
|
||||
|
||||
bool IsKeyFrame() const override {
|
||||
return frame_->FrameType() == VideoFrameType::kVideoFrameKey;
|
||||
|
|
|
@ -23,6 +23,7 @@ class MockTransformableFrame : public TransformableFrameInterface {
|
|||
MOCK_METHOD(uint8_t, GetPayloadType, (), (const, override));
|
||||
MOCK_METHOD(uint32_t, GetSsrc, (), (const, override));
|
||||
MOCK_METHOD(uint32_t, GetTimestamp, (), (const, override));
|
||||
MOCK_METHOD(void, SetRTPTimestamp, (uint32_t), (override));
|
||||
};
|
||||
|
||||
} // namespace webrtc
|
||||
|
|
Loading…
Reference in a new issue