Reland "Second reland of "Optimize execution time of RTPSender::UpdateDelayStatistics""

This reverts commit 8b7bc5d7010c84ac57459518fe18309ef5fee1dd.

Reason for revert: Slow RTC_DCHECK has been removed.

Original change's description:
> Revert "Second reland of "Optimize execution time of RTPSender::UpdateDelayStatistics""
>
> This reverts commit 9def3b45ef06de9e068e8f4d1644e9d508baa913.
>
> Reason for revert: webrtc_perf_tests fails on Mac-10.12.
>
> Original change's description:
> > Second reland of "Optimize execution time of RTPSender::UpdateDelayStatistics"
> >
> > The reland has a lot of additional DCHECKS for easier debugging,
> > so in debug builds it will actually be a ~2x slowdown compared to the old code.
> > The excessive DCHECKS should be removed in a followup CL.
> >
> > Bug: webrtc:9439
> > Change-Id: I8389cd84f1ca12c29cc6993f0d2cf7e6d7dd8379
> > Reviewed-on: https://webrtc-review.googlesource.com/101761
> > Reviewed-by: Åsa Persson <asapersson@webrtc.org>
> > Reviewed-by: Björn Terelius <terelius@webrtc.org>
> > Commit-Queue: Johannes Kron <kron@webrtc.org>
> > Cr-Commit-Position: refs/heads/master@{#24821}
>
> TBR=terelius@webrtc.org,asapersson@webrtc.org,kron@webrtc.org
>
> Change-Id: I98c4c96d552858d0299d49993e9b9be6a6204dfe
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: webrtc:9439
> Reviewed-on: https://webrtc-review.googlesource.com/101860
> Reviewed-by: Johannes Kron <kron@webrtc.org>
> Commit-Queue: Johannes Kron <kron@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#24825}

TBR=terelius@webrtc.org,asapersson@webrtc.org,kron@webrtc.org

Change-Id: I260c56932710d26f9d7201c07279fef8d2150bd9
Bug: webrtc:9439
Reviewed-on: https://webrtc-review.googlesource.com/102000
Reviewed-by: Björn Terelius <terelius@webrtc.org>
Reviewed-by: Åsa Persson <asapersson@webrtc.org>
Reviewed-by: Johannes Kron <kron@webrtc.org>
Commit-Queue: Johannes Kron <kron@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#24843}
This commit is contained in:
Johannes Kron
2018-09-26 09:57:48 +02:00
committed by Commit Bot
parent b8bccd530a
commit 4a8a5e7db1
3 changed files with 138 additions and 17 deletions

View File

@ -140,6 +140,11 @@ class MockTransportSequenceNumberAllocator
MOCK_METHOD0(AllocateSequenceNumber, uint16_t());
};
class MockSendSideDelayObserver : public SendSideDelayObserver {
public:
MOCK_METHOD3(SendSideDelayUpdated, void(int, int, uint32_t));
};
class MockSendPacketObserver : public SendPacketObserver {
public:
MOCK_METHOD3(OnSendPacket, void(uint16_t, int64_t, uint32_t));
@ -492,6 +497,71 @@ TEST_P(RtpSenderTestWithoutPacer, NoAllocationIfNotRegistered) {
SendGenericPayload();
}
TEST_P(RtpSenderTestWithoutPacer, OnSendSideDelayUpdated) {
testing::StrictMock<MockSendSideDelayObserver> send_side_delay_observer_;
rtp_sender_.reset(
new RTPSender(false, &fake_clock_, &transport_, nullptr, nullptr, nullptr,
nullptr, nullptr, nullptr, &send_side_delay_observer_,
&mock_rtc_event_log_, nullptr, nullptr, nullptr, false));
rtp_sender_->SetSSRC(kSsrc);
const uint8_t kPayloadType = 127;
const uint32_t kCaptureTimeMsToRtpTimestamp = 90; // 90 kHz clock
char payload_name[RTP_PAYLOAD_NAME_SIZE] = "GENERIC";
RTPVideoHeader video_header;
EXPECT_EQ(0, rtp_sender_->RegisterPayload(payload_name, kPayloadType,
1000 * kCaptureTimeMsToRtpTimestamp,
0, 1500));
// Send packet with 10 ms send-side delay. The average and max should be 10
// ms.
EXPECT_CALL(send_side_delay_observer_, SendSideDelayUpdated(10, 10, kSsrc))
.Times(1);
int64_t capture_time_ms = fake_clock_.TimeInMilliseconds();
fake_clock_.AdvanceTimeMilliseconds(10);
EXPECT_TRUE(rtp_sender_->SendOutgoingData(
kVideoFrameKey, kPayloadType,
capture_time_ms * kCaptureTimeMsToRtpTimestamp, capture_time_ms,
kPayloadData, sizeof(kPayloadData), nullptr, &video_header, nullptr,
kDefaultExpectedRetransmissionTimeMs));
// Send another packet with 20 ms delay. The average
// and max should be 15 and 20 ms respectively.
EXPECT_CALL(send_side_delay_observer_, SendSideDelayUpdated(15, 20, kSsrc))
.Times(1);
fake_clock_.AdvanceTimeMilliseconds(10);
EXPECT_TRUE(rtp_sender_->SendOutgoingData(
kVideoFrameKey, kPayloadType,
capture_time_ms * kCaptureTimeMsToRtpTimestamp, capture_time_ms,
kPayloadData, sizeof(kPayloadData), nullptr, &video_header, nullptr,
kDefaultExpectedRetransmissionTimeMs));
// Send another packet at the same time, which replaces the last packet.
// Since this packet has 0 ms delay, the average is now 5 ms and max is 10 ms.
// TODO(terelius): Is is not clear that this is the right behavior.
EXPECT_CALL(send_side_delay_observer_, SendSideDelayUpdated(5, 10, kSsrc))
.Times(1);
capture_time_ms = fake_clock_.TimeInMilliseconds();
EXPECT_TRUE(rtp_sender_->SendOutgoingData(
kVideoFrameKey, kPayloadType,
capture_time_ms * kCaptureTimeMsToRtpTimestamp, capture_time_ms,
kPayloadData, sizeof(kPayloadData), nullptr, &video_header, nullptr,
kDefaultExpectedRetransmissionTimeMs));
// Send a packet 1 second later. The earlier packets should have timed
// out, so both max and average should be the delay of this packet.
fake_clock_.AdvanceTimeMilliseconds(1000);
capture_time_ms = fake_clock_.TimeInMilliseconds();
fake_clock_.AdvanceTimeMilliseconds(1);
EXPECT_CALL(send_side_delay_observer_, SendSideDelayUpdated(1, 1, kSsrc))
.Times(1);
EXPECT_TRUE(rtp_sender_->SendOutgoingData(
kVideoFrameKey, kPayloadType,
capture_time_ms * kCaptureTimeMsToRtpTimestamp, capture_time_ms,
kPayloadData, sizeof(kPayloadData), nullptr, &video_header, nullptr,
kDefaultExpectedRetransmissionTimeMs));
}
TEST_P(RtpSenderTestWithoutPacer, OnSendPacketUpdated) {
EXPECT_EQ(0, rtp_sender_->RegisterRtpHeaderExtension(
kRtpExtensionTransportSequenceNumber,