Passing the estimated capture clock offset to SendVideo.
Bug: webrtc:10739
Change-Id: I491db1910fad9101c7c9087e880862e755dfc69d
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/182184
Reviewed-by: Chen Xing <chxg@google.com>
Reviewed-by: Stefan Holmer <stefan@webrtc.org>
Commit-Queue: Minyue Li <minyue@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#31983}
diff --git a/modules/rtp_rtcp/source/rtp_sender_video.cc b/modules/rtp_rtcp/source/rtp_sender_video.cc
index ea920ec..31002aa 100644
--- a/modules/rtp_rtcp/source/rtp_sender_video.cc
+++ b/modules/rtp_rtcp/source/rtp_sender_video.cc
@@ -399,7 +399,8 @@
int64_t capture_time_ms,
rtc::ArrayView<const uint8_t> payload,
RTPVideoHeader video_header,
- absl::optional<int64_t> expected_retransmission_time_ms) {
+ absl::optional<int64_t> expected_retransmission_time_ms,
+ absl::optional<int64_t> estimated_capture_clock_offset_ms) {
#if RTC_TRACE_EVENTS_ENABLED
TRACE_EVENT_ASYNC_STEP1("webrtc", "Video", capture_time_ms, "Send", "type",
FrameTypeToString(video_header.frame_type));
@@ -452,7 +453,7 @@
single_packet->Timestamp(), kVideoPayloadTypeFrequency,
Int64MsToUQ32x32(single_packet->capture_time_ms() + NtpOffsetMs()),
/*estimated_capture_clock_offset=*/
- include_capture_clock_offset_ ? absl::make_optional(0)
+ include_capture_clock_offset_ ? estimated_capture_clock_offset_ms
: absl::nullopt);
auto first_packet = std::make_unique<RtpPacketToSend>(*single_packet);
diff --git a/modules/rtp_rtcp/source/rtp_sender_video.h b/modules/rtp_rtcp/source/rtp_sender_video.h
index e82496c..4addb09 100644
--- a/modules/rtp_rtcp/source/rtp_sender_video.h
+++ b/modules/rtp_rtcp/source/rtp_sender_video.h
@@ -91,13 +91,19 @@
// expected_retransmission_time_ms.has_value() -> retransmission allowed.
// Calls to this method is assumed to be externally serialized.
+ // |estimated_capture_clock_offset_ms| is an estimated clock offset between
+ // this sender and the original capturer, for this video packet. See
+ // http://www.webrtc.org/experiments/rtp-hdrext/abs-capture-time for more
+ // details. If the sender and the capture has the same clock, it is supposed
+ // to be zero valued, which is given as the default.
bool SendVideo(int payload_type,
absl::optional<VideoCodecType> codec_type,
uint32_t rtp_timestamp,
int64_t capture_time_ms,
rtc::ArrayView<const uint8_t> payload,
RTPVideoHeader video_header,
- absl::optional<int64_t> expected_retransmission_time_ms);
+ absl::optional<int64_t> expected_retransmission_time_ms,
+ absl::optional<int64_t> estimated_capture_clock_offset_ms = 0);
bool SendEncodedImage(
int payload_type,
diff --git a/modules/rtp_rtcp/source/rtp_sender_video_unittest.cc b/modules/rtp_rtcp/source/rtp_sender_video_unittest.cc
index bbd8caa..b114cd27 100644
--- a/modules/rtp_rtcp/source/rtp_sender_video_unittest.cc
+++ b/modules/rtp_rtcp/source/rtp_sender_video_unittest.cc
@@ -867,10 +867,12 @@
kAbsoluteCaptureTimeExtensionId);
RTPVideoHeader hdr;
+ const absl::optional<int64_t> kExpectedCaptureClockOffset =
+ absl::make_optional(1234);
hdr.frame_type = VideoFrameType::kVideoFrameKey;
- rtp_sender_video_->SendVideo(kPayload, kType, kTimestamp,
- kAbsoluteCaptureTimestampMs, kFrame, hdr,
- kDefaultExpectedRetransmissionTimeMs);
+ rtp_sender_video_->SendVideo(
+ kPayload, kType, kTimestamp, kAbsoluteCaptureTimestampMs, kFrame, hdr,
+ kDefaultExpectedRetransmissionTimeMs, kExpectedCaptureClockOffset);
// It is expected that one and only one of the packets sent on this video
// frame has absolute capture time header extension. And it includes capture
@@ -883,9 +885,8 @@
++packets_with_abs_capture_time;
EXPECT_EQ(absolute_capture_time->absolute_capture_timestamp,
Int64MsToUQ32x32(kAbsoluteCaptureTimestampMs + NtpOffsetMs()));
- EXPECT_TRUE(
- absolute_capture_time->estimated_capture_clock_offset.has_value());
- EXPECT_EQ(0, *absolute_capture_time->estimated_capture_clock_offset);
+ EXPECT_EQ(kExpectedCaptureClockOffset,
+ absolute_capture_time->estimated_capture_clock_offset);
}
}
EXPECT_EQ(packets_with_abs_capture_time, 1);