webrtc_m130/modules/rtp_rtcp/source/rtp_rtcp_impl_unittest.cc

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

717 lines
27 KiB
C++
Raw Normal View History

/*
* Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#include "modules/rtp_rtcp/source/rtp_rtcp_impl.h"
#include <cstddef>
#include <cstdint>
#include <map>
#include <memory>
#include <optional>
#include <vector>
#include "api/array_view.h"
#include "api/call/transport.h"
#include "api/environment/environment.h"
#include "api/environment/environment_factory.h"
#include "api/rtp_headers.h"
#include "api/units/time_delta.h"
#include "api/video/video_codec_type.h"
#include "api/video/video_content_type.h"
#include "api/video/video_frame_type.h"
#include "api/video/video_rotation.h"
#include "modules/rtp_rtcp/include/receive_statistics.h"
#include "modules/rtp_rtcp/include/rtcp_statistics.h"
#include "modules/rtp_rtcp/include/rtp_rtcp_defines.h"
#include "modules/rtp_rtcp/source/rtcp_packet/nack.h"
#include "modules/rtp_rtcp/source/rtcp_packet/sender_report.h"
#include "modules/rtp_rtcp/source/rtp_packet_received.h"
#include "modules/rtp_rtcp/source/rtp_rtcp_interface.h"
#include "modules/rtp_rtcp/source/rtp_sender_video.h"
#include "modules/rtp_rtcp/source/rtp_sequence_number_map.h"
#include "modules/video_coding/codecs/interface/common_constants.h"
#include "modules/video_coding/codecs/vp8/include/vp8_globals.h"
#include "system_wrappers/include/clock.h"
#include "system_wrappers/include/ntp_time.h"
#include "test/explicit_key_value_config.h"
#include "test/gmock.h"
#include "test/gtest.h"
#include "test/rtcp_packet_parser.h"
using ::testing::ElementsAre;
using ::testing::Eq;
using ::testing::Field;
using ::testing::Gt;
using ::testing::Not;
using ::testing::Optional;
namespace webrtc {
namespace {
const uint32_t kSenderSsrc = 0x12345;
const uint32_t kReceiverSsrc = 0x23456;
constexpr TimeDelta kOneWayNetworkDelay = TimeDelta::Millis(100);
const uint8_t kBaseLayerTid = 0;
const uint8_t kHigherLayerTid = 1;
const uint16_t kSequenceNumber = 100;
const uint8_t kPayloadType = 100;
const int kWidth = 320;
const int kHeight = 100;
MATCHER_P2(Near, value, margin, "") {
return value - margin <= arg && arg <= value + margin;
}
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
class RtcpRttStatsTestImpl : public RtcpRttStats {
public:
RtcpRttStatsTestImpl() : rtt_ms_(0) {}
Reland "Enable and fix chromium clang warnings in rtp_rtcp test targets" This reverts commit 01aa210fad68f1006528d32d388b307c22990734. Reason for revert: downstream project adjusted Original change's description: > Revert "Enable and fix chromium clang warnings in rtp_rtcp test targets" > > This reverts commit 9486b117daac09c9f7ac8450ccda835938cf3150. > > Reason for revert: Breaks downstream project > > Original change's description: > > Enable and fix chromium clang warnings in rtp_rtcp test targets > > > > Bug: webrtc:163 > > Change-Id: I4ed3e63296d8bf06536a83196d597c7a906ba11c > > Reviewed-on: https://webrtc-review.googlesource.com/60802 > > Reviewed-by: Björn Terelius <terelius@webrtc.org> > > Reviewed-by: Patrik Höglund <phoglund@webrtc.org> > > Commit-Queue: Danil Chapovalov <danilchap@webrtc.org> > > Cr-Commit-Position: refs/heads/master@{#22357} > > TBR=danilchap@webrtc.org,phoglund@webrtc.org,terelius@webrtc.org > > Change-Id: I2c3777ea9f26813bdb395e7fd68f6b49443586ea > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: webrtc:163 > Reviewed-on: https://webrtc-review.googlesource.com/61060 > Reviewed-by: Oleh Prypin <oprypin@webrtc.org> > Commit-Queue: Oleh Prypin <oprypin@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#22365} TBR=danilchap@webrtc.org,phoglund@webrtc.org,oprypin@webrtc.org,terelius@webrtc.org Change-Id: I0b4cb6d05b37caeb52cca9abf95417ad3ad6f76b No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: webrtc:163 Reviewed-on: https://webrtc-review.googlesource.com/61080 Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> Commit-Queue: Danil Chapovalov <danilchap@webrtc.org> Cr-Commit-Position: refs/heads/master@{#22368}
2018-03-09 15:37:03 +00:00
~RtcpRttStatsTestImpl() override = default;
void OnRttUpdate(int64_t rtt_ms) override { rtt_ms_ = rtt_ms; }
int64_t LastProcessedRtt() const override { return rtt_ms_; }
int64_t rtt_ms_;
};
class SendTransport : public Transport {
public:
SendTransport()
: receiver_(nullptr),
clock_(nullptr),
delay_ms_(0),
rtp_packets_sent_(0),
rtcp_packets_sent_(0) {}
void SetRtpRtcpModule(ModuleRtpRtcpImpl* receiver) { receiver_ = receiver; }
void SimulateNetworkDelay(int64_t delay_ms, SimulatedClock* clock) {
clock_ = clock;
delay_ms_ = delay_ms;
}
bool SendRtp(rtc::ArrayView<const uint8_t> data,
const PacketOptions& options) override {
RtpPacket packet;
EXPECT_TRUE(packet.Parse(data));
++rtp_packets_sent_;
last_rtp_sequence_number_ = packet.SequenceNumber();
return true;
}
bool SendRtcp(rtc::ArrayView<const uint8_t> data) override {
test::RtcpPacketParser parser;
parser.Parse(data);
last_nack_list_ = parser.nack()->packet_ids();
if (clock_) {
clock_->AdvanceTimeMilliseconds(delay_ms_);
}
EXPECT_TRUE(receiver_);
receiver_->IncomingRtcpPacket(data);
++rtcp_packets_sent_;
return true;
}
size_t NumRtcpSent() { return rtcp_packets_sent_; }
ModuleRtpRtcpImpl* receiver_;
SimulatedClock* clock_;
int64_t delay_ms_;
int rtp_packets_sent_;
size_t rtcp_packets_sent_;
uint16_t last_rtp_sequence_number_;
std::vector<uint16_t> last_nack_list_;
};
class RtpRtcpModule : public RtcpPacketTypeCounterObserver {
public:
RtpRtcpModule(SimulatedClock* clock, bool is_sender)
: env_(CreateEnvironment(clock)),
is_sender_(is_sender),
receive_statistics_(ReceiveStatistics::Create(clock)) {
CreateModuleImpl();
transport_.SimulateNetworkDelay(kOneWayNetworkDelay.ms(), clock);
}
const Environment env_;
const bool is_sender_;
RtcpPacketTypeCounter packets_sent_;
RtcpPacketTypeCounter packets_received_;
std::unique_ptr<ReceiveStatistics> receive_statistics_;
SendTransport transport_;
RtcpRttStatsTestImpl rtt_stats_;
std::unique_ptr<ModuleRtpRtcpImpl> impl_;
int rtcp_report_interval_ms_ = 0;
void RtcpPacketTypesCounterUpdated(
uint32_t ssrc,
const RtcpPacketTypeCounter& packet_counter) override {
counter_map_[ssrc] = packet_counter;
}
RtcpPacketTypeCounter RtcpSent() {
// RTCP counters for remote SSRC.
return counter_map_[is_sender_ ? kReceiverSsrc : kSenderSsrc];
}
RtcpPacketTypeCounter RtcpReceived() {
// Received RTCP stats for (own) local SSRC.
return counter_map_[impl_->SSRC()];
}
int RtpSent() { return transport_.rtp_packets_sent_; }
uint16_t LastRtpSequenceNumber() {
return transport_.last_rtp_sequence_number_;
}
std::vector<uint16_t> LastNackListSent() {
return transport_.last_nack_list_;
}
void SetRtcpReportIntervalAndReset(int rtcp_report_interval_ms) {
rtcp_report_interval_ms_ = rtcp_report_interval_ms;
CreateModuleImpl();
}
private:
void CreateModuleImpl() {
RtpRtcpInterface::Configuration config;
config.audio = false;
config.outgoing_transport = &transport_;
config.receive_statistics = receive_statistics_.get();
config.rtcp_packet_type_counter_observer = this;
config.rtt_stats = &rtt_stats_;
config.rtcp_report_interval_ms = rtcp_report_interval_ms_;
config.local_media_ssrc = is_sender_ ? kSenderSsrc : kReceiverSsrc;
config.need_rtp_packet_infos = true;
config.non_sender_rtt_measurement = true;
impl_.reset(new ModuleRtpRtcpImpl(env_, config));
impl_->SetRemoteSSRC(is_sender_ ? kReceiverSsrc : kSenderSsrc);
impl_->SetRTCPStatus(RtcpMode::kCompound);
}
std::map<uint32_t, RtcpPacketTypeCounter> counter_map_;
};
} // namespace
class RtpRtcpImplTest : public ::testing::Test {
protected:
RtpRtcpImplTest()
: clock_(133590000000000),
sender_(&clock_, /*is_sender=*/true),
receiver_(&clock_, /*is_sender=*/false) {}
void SetUp() override {
// Send module.
EXPECT_EQ(0, sender_.impl_->SetSendingStatus(true));
sender_.impl_->SetSendingMediaStatus(true);
sender_.impl_->SetSequenceNumber(kSequenceNumber);
sender_.impl_->SetStorePacketsStatus(true, 100);
test::ExplicitKeyValueConfig field_trials("");
RTPSenderVideo::Config video_config;
video_config.clock = &clock_;
video_config.rtp_sender = sender_.impl_->RtpSender();
video_config.field_trials = &field_trials;
sender_video_ = std::make_unique<RTPSenderVideo>(video_config);
// Receive module.
EXPECT_EQ(0, receiver_.impl_->SetSendingStatus(false));
receiver_.impl_->SetSendingMediaStatus(false);
// Transport settings.
sender_.transport_.SetRtpRtcpModule(receiver_.impl_.get());
receiver_.transport_.SetRtpRtcpModule(sender_.impl_.get());
}
SimulatedClock clock_;
RtpRtcpModule sender_;
std::unique_ptr<RTPSenderVideo> sender_video_;
RtpRtcpModule receiver_;
void SendFrame(const RtpRtcpModule* module,
RTPSenderVideo* sender,
uint8_t tid) {
RTPVideoHeaderVP8 vp8_header = {};
vp8_header.temporalIdx = tid;
Reland of Rename RTPVideoHeader.isFirstPacket to .is_first_packet_in_frame. Add RTC_DEPRACATed anonymous unions to not break downstream projects. Orignal issue's description: > commit 0ad21111fcc57a7e978edba3c4263f0062d7f9ff > Author: danilchap <danilchap@webrtc.org> > Date: Mon Dec 19 09:36:33 2016 -0800 > > Revert of Rename RTPVideoHeader.isFirstPacket to > .is_first_packet_in_frame. (patchset #1 id:1 of > https://codereview.webrtc.org/2574943003/ ) > > Reason for revert: > breaks downstream project. > > Can you make this change in a compatible way using anonymous > union: > union { > bool is_first_packet_in_frame; > RTC_DEPRECATED bool isFirstPacket; > }; > (unfortunetly this this treak breaks braced initialization in > rtp_rtcp_impl_unittest.cc, > so that should be rewritting in a more classic way) > > Original issue's description: > > Rename RTPVideoHeader.isFirstPacket to > > .is_first_packet_in_frame. > > > > Name should represent the actual meaning. > > > > BUG=None > > > > Review-Url: https://codereview.webrtc.org/2574943003 > > Cr-Commit-Position: refs/heads/master@{#15684} > > Committed: > > https://chromium.googlesource.com/external/webrtc/+/efde90838055f44ca05863ba020ca02c88b6d14c > > TBR=stefan@webrtc.org,sprang@webrtc.org,johan@webrtc.org > # Skipping CQ checks because original CL landed less than 1 days > ago. > NOPRESUBMIT=true > NOTREECHECKS=true > NOTRY=true > BUG=None > > Review-Url: https://codereview.webrtc.org/2589783003 > Cr-Commit-Position: refs/heads/master@{#15686} > BUG=None Review-Url: https://codereview.webrtc.org/2614503002 Cr-Commit-Position: refs/heads/master@{#15987}
2017-01-10 04:21:35 -08:00
RTPVideoHeader rtp_video_header;
rtp_video_header.frame_type = VideoFrameType::kVideoFrameKey;
rtp_video_header.width = kWidth;
rtp_video_header.height = kHeight;
Reland of Rename RTPVideoHeader.isFirstPacket to .is_first_packet_in_frame. Add RTC_DEPRACATed anonymous unions to not break downstream projects. Orignal issue's description: > commit 0ad21111fcc57a7e978edba3c4263f0062d7f9ff > Author: danilchap <danilchap@webrtc.org> > Date: Mon Dec 19 09:36:33 2016 -0800 > > Revert of Rename RTPVideoHeader.isFirstPacket to > .is_first_packet_in_frame. (patchset #1 id:1 of > https://codereview.webrtc.org/2574943003/ ) > > Reason for revert: > breaks downstream project. > > Can you make this change in a compatible way using anonymous > union: > union { > bool is_first_packet_in_frame; > RTC_DEPRECATED bool isFirstPacket; > }; > (unfortunetly this this treak breaks braced initialization in > rtp_rtcp_impl_unittest.cc, > so that should be rewritting in a more classic way) > > Original issue's description: > > Rename RTPVideoHeader.isFirstPacket to > > .is_first_packet_in_frame. > > > > Name should represent the actual meaning. > > > > BUG=None > > > > Review-Url: https://codereview.webrtc.org/2574943003 > > Cr-Commit-Position: refs/heads/master@{#15684} > > Committed: > > https://chromium.googlesource.com/external/webrtc/+/efde90838055f44ca05863ba020ca02c88b6d14c > > TBR=stefan@webrtc.org,sprang@webrtc.org,johan@webrtc.org > # Skipping CQ checks because original CL landed less than 1 days > ago. > NOPRESUBMIT=true > NOTREECHECKS=true > NOTRY=true > BUG=None > > Review-Url: https://codereview.webrtc.org/2589783003 > Cr-Commit-Position: refs/heads/master@{#15686} > BUG=None Review-Url: https://codereview.webrtc.org/2614503002 Cr-Commit-Position: refs/heads/master@{#15987}
2017-01-10 04:21:35 -08:00
rtp_video_header.rotation = kVideoRotation_0;
rtp_video_header.content_type = VideoContentType::UNSPECIFIED;
Reland of Rename RTPVideoHeader.isFirstPacket to .is_first_packet_in_frame. Add RTC_DEPRACATed anonymous unions to not break downstream projects. Orignal issue's description: > commit 0ad21111fcc57a7e978edba3c4263f0062d7f9ff > Author: danilchap <danilchap@webrtc.org> > Date: Mon Dec 19 09:36:33 2016 -0800 > > Revert of Rename RTPVideoHeader.isFirstPacket to > .is_first_packet_in_frame. (patchset #1 id:1 of > https://codereview.webrtc.org/2574943003/ ) > > Reason for revert: > breaks downstream project. > > Can you make this change in a compatible way using anonymous > union: > union { > bool is_first_packet_in_frame; > RTC_DEPRECATED bool isFirstPacket; > }; > (unfortunetly this this treak breaks braced initialization in > rtp_rtcp_impl_unittest.cc, > so that should be rewritting in a more classic way) > > Original issue's description: > > Rename RTPVideoHeader.isFirstPacket to > > .is_first_packet_in_frame. > > > > Name should represent the actual meaning. > > > > BUG=None > > > > Review-Url: https://codereview.webrtc.org/2574943003 > > Cr-Commit-Position: refs/heads/master@{#15684} > > Committed: > > https://chromium.googlesource.com/external/webrtc/+/efde90838055f44ca05863ba020ca02c88b6d14c > > TBR=stefan@webrtc.org,sprang@webrtc.org,johan@webrtc.org > # Skipping CQ checks because original CL landed less than 1 days > ago. > NOPRESUBMIT=true > NOTREECHECKS=true > NOTRY=true > BUG=None > > Review-Url: https://codereview.webrtc.org/2589783003 > Cr-Commit-Position: refs/heads/master@{#15686} > BUG=None Review-Url: https://codereview.webrtc.org/2614503002 Cr-Commit-Position: refs/heads/master@{#15987}
2017-01-10 04:21:35 -08:00
rtp_video_header.is_first_packet_in_frame = true;
rtp_video_header.simulcastIdx = 0;
rtp_video_header.codec = kVideoCodecVP8;
Reland "Remove RTPVideoHeader::vp8() accessors." This reverts commit 1811c04f22a26da3ed2832373a5c92a9786420c3. Reason for revert: Downstream projects fixed. Original change's description: > Revert "Remove RTPVideoHeader::vp8() accessors." > > This reverts commit af7afc66427b0e9109e7d492f2805d63d239b914. > > Reason for revert: Break downstream projects. > > Original change's description: > > Remove RTPVideoHeader::vp8() accessors. > > > > Bug: none > > Change-Id: Ia7d65148fb36a8f26647bee8a876ce7217ff8a68 > > Reviewed-on: https://webrtc-review.googlesource.com/93321 > > Reviewed-by: Niels Moller <nisse@webrtc.org> > > Reviewed-by: Stefan Holmer <stefan@webrtc.org> > > Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> > > Commit-Queue: Philip Eliasson <philipel@webrtc.org> > > Cr-Commit-Position: refs/heads/master@{#24626} > > TBR=danilchap@webrtc.org,nisse@webrtc.org,sprang@webrtc.org,stefan@webrtc.org,philipel@webrtc.org,holmer@google.com > > Change-Id: I3f7f19c0ea810c0fd988c59e6556bbea9b756b33 > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: none > Reviewed-on: https://webrtc-review.googlesource.com/98864 > Reviewed-by: Philip Eliasson <philipel@webrtc.org> > Commit-Queue: Philip Eliasson <philipel@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#24628} TBR=danilchap@webrtc.org,nisse@webrtc.org,sprang@webrtc.org,stefan@webrtc.org,philipel@webrtc.org,holmer@google.com Change-Id: I9246f36e638108ae4fc46c1ae4559c8205d50fc1 No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: none Reviewed-on: https://webrtc-review.googlesource.com/98841 Reviewed-by: Philip Eliasson <philipel@webrtc.org> Commit-Queue: Philip Eliasson <philipel@webrtc.org> Cr-Commit-Position: refs/heads/master@{#24629}
2018-09-07 13:03:55 +00:00
rtp_video_header.video_type_header = vp8_header;
rtp_video_header.video_timing = {0u, 0u, 0u, 0u, 0u, 0u, false};
const uint8_t payload[100] = {0};
EXPECT_TRUE(module->impl_->OnSendingRtpFrame(0, 0, kPayloadType, true));
EXPECT_TRUE(sender->SendVideo(
kPayloadType, VideoCodecType::kVideoCodecVP8, 0, clock_.CurrentTime(),
payload, sizeof(payload), rtp_video_header, TimeDelta::Zero(), {}));
}
void IncomingRtcpNack(const RtpRtcpModule* module, uint16_t sequence_number) {
bool sender = module->impl_->SSRC() == kSenderSsrc;
rtcp::Nack nack;
uint16_t list[1];
list[0] = sequence_number;
const uint16_t kListLength = sizeof(list) / sizeof(list[0]);
2016-09-27 09:27:47 -07:00
nack.SetSenderSsrc(sender ? kReceiverSsrc : kSenderSsrc);
nack.SetMediaSsrc(sender ? kSenderSsrc : kReceiverSsrc);
nack.SetPacketIds(list, kListLength);
module->impl_->IncomingRtcpPacket(nack.Build());
}
};
TEST_F(RtpRtcpImplTest, RetransmitsAllLayers) {
// Send frames.
EXPECT_EQ(0, sender_.RtpSent());
SendFrame(&sender_, sender_video_.get(), kBaseLayerTid); // kSequenceNumber
SendFrame(&sender_, sender_video_.get(),
kHigherLayerTid); // kSequenceNumber + 1
SendFrame(&sender_, sender_video_.get(),
kNoTemporalIdx); // kSequenceNumber + 2
EXPECT_EQ(3, sender_.RtpSent());
EXPECT_EQ(kSequenceNumber + 2, sender_.LastRtpSequenceNumber());
// Min required delay until retransmit = 5 + RTT ms (RTT = 0).
clock_.AdvanceTimeMilliseconds(5);
// Frame with kBaseLayerTid re-sent.
IncomingRtcpNack(&sender_, kSequenceNumber);
EXPECT_EQ(4, sender_.RtpSent());
EXPECT_EQ(kSequenceNumber, sender_.LastRtpSequenceNumber());
// Frame with kHigherLayerTid re-sent.
IncomingRtcpNack(&sender_, kSequenceNumber + 1);
EXPECT_EQ(5, sender_.RtpSent());
EXPECT_EQ(kSequenceNumber + 1, sender_.LastRtpSequenceNumber());
// Frame with kNoTemporalIdx re-sent.
IncomingRtcpNack(&sender_, kSequenceNumber + 2);
EXPECT_EQ(6, sender_.RtpSent());
EXPECT_EQ(kSequenceNumber + 2, sender_.LastRtpSequenceNumber());
}
TEST_F(RtpRtcpImplTest, Rtt) {
RtpPacketReceived packet;
packet.SetTimestamp(1);
packet.SetSequenceNumber(123);
packet.SetSsrc(kSenderSsrc);
packet.AllocatePayload(100 - 12);
receiver_.receive_statistics_->OnRtpPacket(packet);
// Send Frame before sending an SR.
SendFrame(&sender_, sender_video_.get(), kBaseLayerTid);
// Sender module should send an SR.
EXPECT_EQ(0, sender_.impl_->SendRTCP(kRtcpReport));
// Receiver module should send a RR with a response to the last received SR.
clock_.AdvanceTimeMilliseconds(1000);
EXPECT_EQ(0, receiver_.impl_->SendRTCP(kRtcpReport));
// Verify RTT.
EXPECT_THAT(sender_.impl_->LastRtt(),
Near(2 * kOneWayNetworkDelay, TimeDelta::Millis(1)));
// Verify RTT from rtt_stats config.
EXPECT_EQ(0, sender_.rtt_stats_.LastProcessedRtt());
EXPECT_EQ(0, sender_.impl_->rtt_ms());
sender_.impl_->Process();
EXPECT_NEAR(2 * kOneWayNetworkDelay.ms(),
sender_.rtt_stats_.LastProcessedRtt(), 1);
EXPECT_NEAR(2 * kOneWayNetworkDelay.ms(), sender_.impl_->rtt_ms(), 1);
}
TEST_F(RtpRtcpImplTest, RttForReceiverOnly) {
// Receiver module should send a Receiver reference time report block (RRTR).
EXPECT_EQ(0, receiver_.impl_->SendRTCP(kRtcpReport));
// Sender module should send a response to the last received RRTR (DLRR).
clock_.AdvanceTimeMilliseconds(1000);
// Send Frame before sending a SR.
SendFrame(&sender_, sender_video_.get(), kBaseLayerTid);
EXPECT_EQ(0, sender_.impl_->SendRTCP(kRtcpReport));
// Verify RTT.
EXPECT_EQ(0, receiver_.rtt_stats_.LastProcessedRtt());
EXPECT_EQ(0, receiver_.impl_->rtt_ms());
receiver_.impl_->Process();
EXPECT_NEAR(2 * kOneWayNetworkDelay.ms(),
receiver_.rtt_stats_.LastProcessedRtt(), 1);
EXPECT_NEAR(2 * kOneWayNetworkDelay.ms(), receiver_.impl_->rtt_ms(), 1);
}
TEST_F(RtpRtcpImplTest, NoSrBeforeMedia) {
// Ignore fake transport delays in this test.
sender_.transport_.SimulateNetworkDelay(0, &clock_);
receiver_.transport_.SimulateNetworkDelay(0, &clock_);
sender_.impl_->Process();
EXPECT_EQ(sender_.transport_.NumRtcpSent(), 0u);
// Verify no SR is sent before media has been sent, RR should still be sent
// from the receiving module though.
clock_.AdvanceTimeMilliseconds(2000);
sender_.impl_->Process();
receiver_.impl_->Process();
EXPECT_EQ(sender_.transport_.NumRtcpSent(), 0u);
EXPECT_EQ(receiver_.transport_.NumRtcpSent(), 1u);
SendFrame(&sender_, sender_video_.get(), kBaseLayerTid);
EXPECT_EQ(sender_.transport_.NumRtcpSent(), 1u);
}
TEST_F(RtpRtcpImplTest, RtcpPacketTypeCounter_Nack) {
EXPECT_EQ(0U, sender_.RtcpReceived().nack_packets);
EXPECT_EQ(0U, receiver_.RtcpSent().nack_packets);
// Receive module sends a NACK.
const uint16_t kNackLength = 1;
uint16_t nack_list[kNackLength] = {123};
EXPECT_EQ(0, receiver_.impl_->SendNACK(nack_list, kNackLength));
EXPECT_EQ(1U, receiver_.RtcpSent().nack_packets);
// Send module receives the NACK.
EXPECT_EQ(1U, sender_.RtcpReceived().nack_packets);
}
TEST_F(RtpRtcpImplTest, AddStreamDataCounters) {
StreamDataCounters rtp;
rtp.transmitted.packets = 1;
rtp.transmitted.payload_bytes = 1;
rtp.transmitted.header_bytes = 2;
rtp.transmitted.padding_bytes = 3;
EXPECT_EQ(rtp.transmitted.TotalBytes(), rtp.transmitted.payload_bytes +
rtp.transmitted.header_bytes +
rtp.transmitted.padding_bytes);
StreamDataCounters rtp2;
rtp2.transmitted.packets = 10;
rtp2.transmitted.payload_bytes = 10;
rtp2.retransmitted.header_bytes = 4;
rtp2.retransmitted.payload_bytes = 5;
rtp2.retransmitted.padding_bytes = 6;
rtp2.retransmitted.packets = 7;
rtp2.fec.packets = 8;
StreamDataCounters sum = rtp;
sum.Add(rtp2);
EXPECT_EQ(11U, sum.transmitted.packets);
EXPECT_EQ(11U, sum.transmitted.payload_bytes);
EXPECT_EQ(2U, sum.transmitted.header_bytes);
EXPECT_EQ(3U, sum.transmitted.padding_bytes);
EXPECT_EQ(4U, sum.retransmitted.header_bytes);
EXPECT_EQ(5U, sum.retransmitted.payload_bytes);
EXPECT_EQ(6U, sum.retransmitted.padding_bytes);
EXPECT_EQ(7U, sum.retransmitted.packets);
EXPECT_EQ(8U, sum.fec.packets);
EXPECT_EQ(sum.transmitted.TotalBytes(),
rtp.transmitted.TotalBytes() + rtp2.transmitted.TotalBytes());
}
TEST_F(RtpRtcpImplTest, SendsInitialNackList) {
// Send module sends a NACK.
const uint16_t kNackLength = 1;
uint16_t nack_list[kNackLength] = {123};
EXPECT_EQ(0U, sender_.RtcpSent().nack_packets);
// Send Frame before sending a compound RTCP that starts with SR.
SendFrame(&sender_, sender_video_.get(), kBaseLayerTid);
EXPECT_EQ(0, sender_.impl_->SendNACK(nack_list, kNackLength));
EXPECT_EQ(1U, sender_.RtcpSent().nack_packets);
EXPECT_THAT(sender_.LastNackListSent(), ElementsAre(123));
}
TEST_F(RtpRtcpImplTest, SendsExtendedNackList) {
// Send module sends a NACK.
const uint16_t kNackLength = 1;
uint16_t nack_list[kNackLength] = {123};
EXPECT_EQ(0U, sender_.RtcpSent().nack_packets);
// Send Frame before sending a compound RTCP that starts with SR.
SendFrame(&sender_, sender_video_.get(), kBaseLayerTid);
EXPECT_EQ(0, sender_.impl_->SendNACK(nack_list, kNackLength));
EXPECT_EQ(1U, sender_.RtcpSent().nack_packets);
EXPECT_THAT(sender_.LastNackListSent(), ElementsAre(123));
// Same list not re-send.
EXPECT_EQ(0, sender_.impl_->SendNACK(nack_list, kNackLength));
EXPECT_EQ(1U, sender_.RtcpSent().nack_packets);
EXPECT_THAT(sender_.LastNackListSent(), ElementsAre(123));
// Only extended list sent.
const uint16_t kNackExtLength = 2;
uint16_t nack_list_ext[kNackExtLength] = {123, 124};
EXPECT_EQ(0, sender_.impl_->SendNACK(nack_list_ext, kNackExtLength));
EXPECT_EQ(2U, sender_.RtcpSent().nack_packets);
EXPECT_THAT(sender_.LastNackListSent(), ElementsAre(124));
}
TEST_F(RtpRtcpImplTest, ReSendsNackListAfterRttMs) {
sender_.transport_.SimulateNetworkDelay(0, &clock_);
// Send module sends a NACK.
const uint16_t kNackLength = 2;
uint16_t nack_list[kNackLength] = {123, 125};
EXPECT_EQ(0U, sender_.RtcpSent().nack_packets);
// Send Frame before sending a compound RTCP that starts with SR.
SendFrame(&sender_, sender_video_.get(), kBaseLayerTid);
EXPECT_EQ(0, sender_.impl_->SendNACK(nack_list, kNackLength));
EXPECT_EQ(1U, sender_.RtcpSent().nack_packets);
EXPECT_THAT(sender_.LastNackListSent(), ElementsAre(123, 125));
// Same list not re-send, rtt interval has not passed.
const int kStartupRttMs = 100;
clock_.AdvanceTimeMilliseconds(kStartupRttMs);
EXPECT_EQ(0, sender_.impl_->SendNACK(nack_list, kNackLength));
EXPECT_EQ(1U, sender_.RtcpSent().nack_packets);
// Rtt interval passed, full list sent.
clock_.AdvanceTimeMilliseconds(1);
EXPECT_EQ(0, sender_.impl_->SendNACK(nack_list, kNackLength));
EXPECT_EQ(2U, sender_.RtcpSent().nack_packets);
EXPECT_THAT(sender_.LastNackListSent(), ElementsAre(123, 125));
}
TEST_F(RtpRtcpImplTest, UniqueNackRequests) {
receiver_.transport_.SimulateNetworkDelay(0, &clock_);
EXPECT_EQ(0U, receiver_.RtcpSent().nack_packets);
EXPECT_EQ(0U, receiver_.RtcpSent().nack_requests);
EXPECT_EQ(0U, receiver_.RtcpSent().unique_nack_requests);
EXPECT_EQ(0, receiver_.RtcpSent().UniqueNackRequestsInPercent());
// Receive module sends NACK request.
const uint16_t kNackLength = 4;
uint16_t nack_list[kNackLength] = {10, 11, 13, 18};
EXPECT_EQ(0, receiver_.impl_->SendNACK(nack_list, kNackLength));
EXPECT_EQ(1U, receiver_.RtcpSent().nack_packets);
EXPECT_EQ(4U, receiver_.RtcpSent().nack_requests);
EXPECT_EQ(4U, receiver_.RtcpSent().unique_nack_requests);
EXPECT_THAT(receiver_.LastNackListSent(), ElementsAre(10, 11, 13, 18));
// Send module receives the request.
EXPECT_EQ(1U, sender_.RtcpReceived().nack_packets);
EXPECT_EQ(4U, sender_.RtcpReceived().nack_requests);
EXPECT_EQ(4U, sender_.RtcpReceived().unique_nack_requests);
EXPECT_EQ(100, sender_.RtcpReceived().UniqueNackRequestsInPercent());
// Receive module sends new request with duplicated packets.
const int kStartupRttMs = 100;
clock_.AdvanceTimeMilliseconds(kStartupRttMs + 1);
const uint16_t kNackLength2 = 4;
uint16_t nack_list2[kNackLength2] = {11, 18, 20, 21};
EXPECT_EQ(0, receiver_.impl_->SendNACK(nack_list2, kNackLength2));
EXPECT_EQ(2U, receiver_.RtcpSent().nack_packets);
EXPECT_EQ(8U, receiver_.RtcpSent().nack_requests);
EXPECT_EQ(6U, receiver_.RtcpSent().unique_nack_requests);
EXPECT_THAT(receiver_.LastNackListSent(), ElementsAre(11, 18, 20, 21));
// Send module receives the request.
EXPECT_EQ(2U, sender_.RtcpReceived().nack_packets);
EXPECT_EQ(8U, sender_.RtcpReceived().nack_requests);
EXPECT_EQ(6U, sender_.RtcpReceived().unique_nack_requests);
EXPECT_EQ(75, sender_.RtcpReceived().UniqueNackRequestsInPercent());
}
TEST_F(RtpRtcpImplTest, ConfigurableRtcpReportInterval) {
const int kVideoReportInterval = 3000;
// Recreate sender impl with new configuration, and redo setup.
sender_.SetRtcpReportIntervalAndReset(kVideoReportInterval);
SetUp();
SendFrame(&sender_, sender_video_.get(), kBaseLayerTid);
// Initial state
sender_.impl_->Process();
EXPECT_EQ(0u, sender_.transport_.NumRtcpSent());
// Move ahead to the last ms before a rtcp is expected, no action.
clock_.AdvanceTimeMilliseconds(kVideoReportInterval / 2 - 1);
sender_.impl_->Process();
EXPECT_EQ(sender_.transport_.NumRtcpSent(), 0u);
// Move ahead to the first rtcp. Send RTCP.
clock_.AdvanceTimeMilliseconds(1);
sender_.impl_->Process();
EXPECT_EQ(sender_.transport_.NumRtcpSent(), 1u);
SendFrame(&sender_, sender_video_.get(), kBaseLayerTid);
// Move ahead to the last possible second before second rtcp is expected.
clock_.AdvanceTimeMilliseconds(kVideoReportInterval * 1 / 2 - 1);
sender_.impl_->Process();
EXPECT_EQ(sender_.transport_.NumRtcpSent(), 1u);
// Move ahead into the range of second rtcp, the second rtcp may be sent.
clock_.AdvanceTimeMilliseconds(1);
sender_.impl_->Process();
EXPECT_GE(sender_.transport_.NumRtcpSent(), 1u);
clock_.AdvanceTimeMilliseconds(kVideoReportInterval / 2);
sender_.impl_->Process();
EXPECT_GE(sender_.transport_.NumRtcpSent(), 1u);
// Move out the range of second rtcp, the second rtcp must have been sent.
clock_.AdvanceTimeMilliseconds(kVideoReportInterval / 2);
sender_.impl_->Process();
EXPECT_EQ(sender_.transport_.NumRtcpSent(), 2u);
}
TEST_F(RtpRtcpImplTest, StoresPacketInfoForSentPackets) {
const uint32_t kStartTimestamp = 1u;
SetUp();
sender_.impl_->SetStartTimestamp(kStartTimestamp);
sender_.impl_->SetSequenceNumber(1);
PacedPacketInfo pacing_info;
RtpPacketToSend packet(nullptr);
packet.set_packet_type(RtpPacketToSend::Type::kVideo);
packet.SetSsrc(kSenderSsrc);
// Single-packet frame.
packet.SetTimestamp(1);
packet.set_first_packet_of_frame(true);
packet.SetMarker(true);
sender_.impl_->TrySendPacket(std::make_unique<RtpPacketToSend>(packet),
pacing_info);
std::vector<RtpSequenceNumberMap::Info> seqno_info =
sender_.impl_->GetSentRtpPacketInfos(std::vector<uint16_t>{1});
EXPECT_THAT(seqno_info, ElementsAre(RtpSequenceNumberMap::Info(
/*timestamp=*/1 - kStartTimestamp,
/*is_first=*/1,
/*is_last=*/1)));
// Three-packet frame.
packet.SetTimestamp(2);
packet.set_first_packet_of_frame(true);
packet.SetMarker(false);
sender_.impl_->TrySendPacket(std::make_unique<RtpPacketToSend>(packet),
pacing_info);
packet.set_first_packet_of_frame(false);
sender_.impl_->TrySendPacket(std::make_unique<RtpPacketToSend>(packet),
pacing_info);
packet.SetMarker(true);
sender_.impl_->TrySendPacket(std::make_unique<RtpPacketToSend>(packet),
pacing_info);
seqno_info =
sender_.impl_->GetSentRtpPacketInfos(std::vector<uint16_t>{2, 3, 4});
EXPECT_THAT(seqno_info, ElementsAre(RtpSequenceNumberMap::Info(
/*timestamp=*/2 - kStartTimestamp,
/*is_first=*/1,
/*is_last=*/0),
RtpSequenceNumberMap::Info(
/*timestamp=*/2 - kStartTimestamp,
/*is_first=*/0,
/*is_last=*/0),
RtpSequenceNumberMap::Info(
/*timestamp=*/2 - kStartTimestamp,
/*is_first=*/0,
/*is_last=*/1)));
}
Reland "Wire up non-sender RTT for audio, and implement related standardized stats." This reverts commit 2c41cbae37cac548a1133589b9d2c2e8614fa6cb. Reason for revert: The breaking test in Chromium has been temporarily disabled in https://chromium-review.googlesource.com/c/chromium/src/+/3139794/2. Original change's description: > Revert "Wire up non-sender RTT for audio, and implement related standardized stats." > > This reverts commit fb0dca6c055cbf9e43af665d3c437eba6f43372e. > > Reason for revert: Speculative revert due to failing stats test in chromium. Possibly because the chromium test expected the metrics to not be supported, and now they are. Reverting just to unblock the webrtc roll into chromium. > > Original change's description: > > Wire up non-sender RTT for audio, and implement related standardized stats. > > > > The implemented stats are: > > - https://www.w3.org/TR/webrtc-stats/#dom-rtcremoteoutboundrtpstreamstats-roundtriptime > > - https://www.w3.org/TR/webrtc-stats/#dom-rtcremoteoutboundrtpstreamstats-totalroundtriptime > > - https://www.w3.org/TR/webrtc-stats/#dom-rtcremoteoutboundrtpstreamstats-roundtriptimemeasurements > > > > Bug: webrtc:12951, webrtc:12714 > > Change-Id: Ia362d5c4b0456140e32da79d40edc06ab9ce2a2c > > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/226956 > > Commit-Queue: Ivo Creusen <ivoc@webrtc.org> > > Reviewed-by: Henrik Boström <hbos@webrtc.org> > > Reviewed-by: Harald Alvestrand <hta@webrtc.org> > > Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> > > Cr-Commit-Position: refs/heads/main@{#34861} > > # Not skipping CQ checks because original CL landed > 1 day ago. > > TBR=hta,hbos,minyue > > Bug: webrtc:12951, webrtc:12714 > Change-Id: If07ad63286eea9cdde88271e61cc28f4b268b290 > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/231001 > Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> > Reviewed-by: Ivo Creusen <ivoc@webrtc.org> > Reviewed-by: Olga Sharonova <olka@webrtc.org> > Commit-Queue: Björn Terelius <terelius@webrtc.org> > Cr-Commit-Position: refs/heads/main@{#34897} # Not skipping CQ checks because original CL landed > 1 day ago. Bug: webrtc:12951, webrtc:12714 Change-Id: I786b06933d85bdffc5e879bf52436bb3469b7f3a Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/231181 Reviewed-by: Henrik Boström <hbos@webrtc.org> Reviewed-by: Björn Terelius <terelius@webrtc.org> Reviewed-by: Harald Alvestrand <hta@webrtc.org> Commit-Queue: Ivo Creusen <ivoc@webrtc.org> Cr-Commit-Position: refs/heads/main@{#34930}
2021-09-03 14:51:22 +00:00
// Checks that the remote sender stats are not available if no RTCP SR was sent.
TEST_F(RtpRtcpImplTest, SenderReportStatsNotAvailable) {
EXPECT_THAT(receiver_.impl_->GetSenderReportStats(), Eq(std::nullopt));
}
Reland "Wire up non-sender RTT for audio, and implement related standardized stats." This reverts commit 2c41cbae37cac548a1133589b9d2c2e8614fa6cb. Reason for revert: The breaking test in Chromium has been temporarily disabled in https://chromium-review.googlesource.com/c/chromium/src/+/3139794/2. Original change's description: > Revert "Wire up non-sender RTT for audio, and implement related standardized stats." > > This reverts commit fb0dca6c055cbf9e43af665d3c437eba6f43372e. > > Reason for revert: Speculative revert due to failing stats test in chromium. Possibly because the chromium test expected the metrics to not be supported, and now they are. Reverting just to unblock the webrtc roll into chromium. > > Original change's description: > > Wire up non-sender RTT for audio, and implement related standardized stats. > > > > The implemented stats are: > > - https://www.w3.org/TR/webrtc-stats/#dom-rtcremoteoutboundrtpstreamstats-roundtriptime > > - https://www.w3.org/TR/webrtc-stats/#dom-rtcremoteoutboundrtpstreamstats-totalroundtriptime > > - https://www.w3.org/TR/webrtc-stats/#dom-rtcremoteoutboundrtpstreamstats-roundtriptimemeasurements > > > > Bug: webrtc:12951, webrtc:12714 > > Change-Id: Ia362d5c4b0456140e32da79d40edc06ab9ce2a2c > > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/226956 > > Commit-Queue: Ivo Creusen <ivoc@webrtc.org> > > Reviewed-by: Henrik Boström <hbos@webrtc.org> > > Reviewed-by: Harald Alvestrand <hta@webrtc.org> > > Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> > > Cr-Commit-Position: refs/heads/main@{#34861} > > # Not skipping CQ checks because original CL landed > 1 day ago. > > TBR=hta,hbos,minyue > > Bug: webrtc:12951, webrtc:12714 > Change-Id: If07ad63286eea9cdde88271e61cc28f4b268b290 > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/231001 > Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> > Reviewed-by: Ivo Creusen <ivoc@webrtc.org> > Reviewed-by: Olga Sharonova <olka@webrtc.org> > Commit-Queue: Björn Terelius <terelius@webrtc.org> > Cr-Commit-Position: refs/heads/main@{#34897} # Not skipping CQ checks because original CL landed > 1 day ago. Bug: webrtc:12951, webrtc:12714 Change-Id: I786b06933d85bdffc5e879bf52436bb3469b7f3a Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/231181 Reviewed-by: Henrik Boström <hbos@webrtc.org> Reviewed-by: Björn Terelius <terelius@webrtc.org> Reviewed-by: Harald Alvestrand <hta@webrtc.org> Commit-Queue: Ivo Creusen <ivoc@webrtc.org> Cr-Commit-Position: refs/heads/main@{#34930}
2021-09-03 14:51:22 +00:00
// Checks that the remote sender stats are available if an RTCP SR was sent.
TEST_F(RtpRtcpImplTest, SenderReportStatsAvailable) {
// Send a frame in order to send an SR.
SendFrame(&sender_, sender_video_.get(), kBaseLayerTid);
// Send an SR.
ASSERT_THAT(sender_.impl_->SendRTCP(kRtcpReport), Eq(0));
EXPECT_THAT(receiver_.impl_->GetSenderReportStats(), Not(Eq(std::nullopt)));
}
Reland "Wire up non-sender RTT for audio, and implement related standardized stats." This reverts commit 2c41cbae37cac548a1133589b9d2c2e8614fa6cb. Reason for revert: The breaking test in Chromium has been temporarily disabled in https://chromium-review.googlesource.com/c/chromium/src/+/3139794/2. Original change's description: > Revert "Wire up non-sender RTT for audio, and implement related standardized stats." > > This reverts commit fb0dca6c055cbf9e43af665d3c437eba6f43372e. > > Reason for revert: Speculative revert due to failing stats test in chromium. Possibly because the chromium test expected the metrics to not be supported, and now they are. Reverting just to unblock the webrtc roll into chromium. > > Original change's description: > > Wire up non-sender RTT for audio, and implement related standardized stats. > > > > The implemented stats are: > > - https://www.w3.org/TR/webrtc-stats/#dom-rtcremoteoutboundrtpstreamstats-roundtriptime > > - https://www.w3.org/TR/webrtc-stats/#dom-rtcremoteoutboundrtpstreamstats-totalroundtriptime > > - https://www.w3.org/TR/webrtc-stats/#dom-rtcremoteoutboundrtpstreamstats-roundtriptimemeasurements > > > > Bug: webrtc:12951, webrtc:12714 > > Change-Id: Ia362d5c4b0456140e32da79d40edc06ab9ce2a2c > > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/226956 > > Commit-Queue: Ivo Creusen <ivoc@webrtc.org> > > Reviewed-by: Henrik Boström <hbos@webrtc.org> > > Reviewed-by: Harald Alvestrand <hta@webrtc.org> > > Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> > > Cr-Commit-Position: refs/heads/main@{#34861} > > # Not skipping CQ checks because original CL landed > 1 day ago. > > TBR=hta,hbos,minyue > > Bug: webrtc:12951, webrtc:12714 > Change-Id: If07ad63286eea9cdde88271e61cc28f4b268b290 > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/231001 > Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> > Reviewed-by: Ivo Creusen <ivoc@webrtc.org> > Reviewed-by: Olga Sharonova <olka@webrtc.org> > Commit-Queue: Björn Terelius <terelius@webrtc.org> > Cr-Commit-Position: refs/heads/main@{#34897} # Not skipping CQ checks because original CL landed > 1 day ago. Bug: webrtc:12951, webrtc:12714 Change-Id: I786b06933d85bdffc5e879bf52436bb3469b7f3a Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/231181 Reviewed-by: Henrik Boström <hbos@webrtc.org> Reviewed-by: Björn Terelius <terelius@webrtc.org> Reviewed-by: Harald Alvestrand <hta@webrtc.org> Commit-Queue: Ivo Creusen <ivoc@webrtc.org> Cr-Commit-Position: refs/heads/main@{#34930}
2021-09-03 14:51:22 +00:00
// Checks that the remote sender stats are not available if an RTCP SR with an
// unexpected SSRC is received.
TEST_F(RtpRtcpImplTest, SenderReportStatsNotUpdatedWithUnexpectedSsrc) {
constexpr uint32_t kUnexpectedSenderSsrc = 0x87654321;
static_assert(kUnexpectedSenderSsrc != kSenderSsrc, "");
// Forge a sender report and pass it to the receiver as if an RTCP SR were
// sent by an unexpected sender.
rtcp::SenderReport sr;
sr.SetSenderSsrc(kUnexpectedSenderSsrc);
sr.SetNtp({/*seconds=*/1u, /*fractions=*/1u << 31});
sr.SetPacketCount(123u);
sr.SetOctetCount(456u);
receiver_.impl_->IncomingRtcpPacket(sr.Build());
EXPECT_THAT(receiver_.impl_->GetSenderReportStats(), Eq(std::nullopt));
}
// Checks the stats derived from the last received RTCP SR are set correctly.
TEST_F(RtpRtcpImplTest, SenderReportStatsCheckStatsFromLastReport) {
using SenderReportStats = RtpRtcpInterface::SenderReportStats;
const NtpTime ntp(/*seconds=*/1u, /*fractions=*/1u << 31);
constexpr uint32_t kPacketCount = 123u;
constexpr uint32_t kOctetCount = 456u;
// Forge a sender report and pass it to the receiver as if an RTCP SR were
// sent by the sender.
rtcp::SenderReport sr;
sr.SetSenderSsrc(kSenderSsrc);
sr.SetNtp(ntp);
sr.SetPacketCount(kPacketCount);
sr.SetOctetCount(kOctetCount);
receiver_.impl_->IncomingRtcpPacket(sr.Build());
EXPECT_THAT(
receiver_.impl_->GetSenderReportStats(),
Optional(AllOf(Field(&SenderReportStats::last_remote_timestamp, Eq(ntp)),
Field(&SenderReportStats::packets_sent, Eq(kPacketCount)),
Field(&SenderReportStats::bytes_sent, Eq(kOctetCount)))));
}
Reland "Wire up non-sender RTT for audio, and implement related standardized stats." This reverts commit 2c41cbae37cac548a1133589b9d2c2e8614fa6cb. Reason for revert: The breaking test in Chromium has been temporarily disabled in https://chromium-review.googlesource.com/c/chromium/src/+/3139794/2. Original change's description: > Revert "Wire up non-sender RTT for audio, and implement related standardized stats." > > This reverts commit fb0dca6c055cbf9e43af665d3c437eba6f43372e. > > Reason for revert: Speculative revert due to failing stats test in chromium. Possibly because the chromium test expected the metrics to not be supported, and now they are. Reverting just to unblock the webrtc roll into chromium. > > Original change's description: > > Wire up non-sender RTT for audio, and implement related standardized stats. > > > > The implemented stats are: > > - https://www.w3.org/TR/webrtc-stats/#dom-rtcremoteoutboundrtpstreamstats-roundtriptime > > - https://www.w3.org/TR/webrtc-stats/#dom-rtcremoteoutboundrtpstreamstats-totalroundtriptime > > - https://www.w3.org/TR/webrtc-stats/#dom-rtcremoteoutboundrtpstreamstats-roundtriptimemeasurements > > > > Bug: webrtc:12951, webrtc:12714 > > Change-Id: Ia362d5c4b0456140e32da79d40edc06ab9ce2a2c > > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/226956 > > Commit-Queue: Ivo Creusen <ivoc@webrtc.org> > > Reviewed-by: Henrik Boström <hbos@webrtc.org> > > Reviewed-by: Harald Alvestrand <hta@webrtc.org> > > Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> > > Cr-Commit-Position: refs/heads/main@{#34861} > > # Not skipping CQ checks because original CL landed > 1 day ago. > > TBR=hta,hbos,minyue > > Bug: webrtc:12951, webrtc:12714 > Change-Id: If07ad63286eea9cdde88271e61cc28f4b268b290 > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/231001 > Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> > Reviewed-by: Ivo Creusen <ivoc@webrtc.org> > Reviewed-by: Olga Sharonova <olka@webrtc.org> > Commit-Queue: Björn Terelius <terelius@webrtc.org> > Cr-Commit-Position: refs/heads/main@{#34897} # Not skipping CQ checks because original CL landed > 1 day ago. Bug: webrtc:12951, webrtc:12714 Change-Id: I786b06933d85bdffc5e879bf52436bb3469b7f3a Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/231181 Reviewed-by: Henrik Boström <hbos@webrtc.org> Reviewed-by: Björn Terelius <terelius@webrtc.org> Reviewed-by: Harald Alvestrand <hta@webrtc.org> Commit-Queue: Ivo Creusen <ivoc@webrtc.org> Cr-Commit-Position: refs/heads/main@{#34930}
2021-09-03 14:51:22 +00:00
// Checks that the remote sender stats count equals the number of sent RTCP SRs.
TEST_F(RtpRtcpImplTest, SenderReportStatsCount) {
using SenderReportStats = RtpRtcpInterface::SenderReportStats;
// Send a frame in order to send an SR.
SendFrame(&sender_, sender_video_.get(), kBaseLayerTid);
// Send the first SR.
ASSERT_THAT(sender_.impl_->SendRTCP(kRtcpReport), Eq(0));
EXPECT_THAT(receiver_.impl_->GetSenderReportStats(),
Optional(Field(&SenderReportStats::reports_count, Eq(1u))));
// Send the second SR.
ASSERT_THAT(sender_.impl_->SendRTCP(kRtcpReport), Eq(0));
EXPECT_THAT(receiver_.impl_->GetSenderReportStats(),
Optional(Field(&SenderReportStats::reports_count, Eq(2u))));
}
Reland "Wire up non-sender RTT for audio, and implement related standardized stats." This reverts commit 2c41cbae37cac548a1133589b9d2c2e8614fa6cb. Reason for revert: The breaking test in Chromium has been temporarily disabled in https://chromium-review.googlesource.com/c/chromium/src/+/3139794/2. Original change's description: > Revert "Wire up non-sender RTT for audio, and implement related standardized stats." > > This reverts commit fb0dca6c055cbf9e43af665d3c437eba6f43372e. > > Reason for revert: Speculative revert due to failing stats test in chromium. Possibly because the chromium test expected the metrics to not be supported, and now they are. Reverting just to unblock the webrtc roll into chromium. > > Original change's description: > > Wire up non-sender RTT for audio, and implement related standardized stats. > > > > The implemented stats are: > > - https://www.w3.org/TR/webrtc-stats/#dom-rtcremoteoutboundrtpstreamstats-roundtriptime > > - https://www.w3.org/TR/webrtc-stats/#dom-rtcremoteoutboundrtpstreamstats-totalroundtriptime > > - https://www.w3.org/TR/webrtc-stats/#dom-rtcremoteoutboundrtpstreamstats-roundtriptimemeasurements > > > > Bug: webrtc:12951, webrtc:12714 > > Change-Id: Ia362d5c4b0456140e32da79d40edc06ab9ce2a2c > > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/226956 > > Commit-Queue: Ivo Creusen <ivoc@webrtc.org> > > Reviewed-by: Henrik Boström <hbos@webrtc.org> > > Reviewed-by: Harald Alvestrand <hta@webrtc.org> > > Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> > > Cr-Commit-Position: refs/heads/main@{#34861} > > # Not skipping CQ checks because original CL landed > 1 day ago. > > TBR=hta,hbos,minyue > > Bug: webrtc:12951, webrtc:12714 > Change-Id: If07ad63286eea9cdde88271e61cc28f4b268b290 > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/231001 > Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> > Reviewed-by: Ivo Creusen <ivoc@webrtc.org> > Reviewed-by: Olga Sharonova <olka@webrtc.org> > Commit-Queue: Björn Terelius <terelius@webrtc.org> > Cr-Commit-Position: refs/heads/main@{#34897} # Not skipping CQ checks because original CL landed > 1 day ago. Bug: webrtc:12951, webrtc:12714 Change-Id: I786b06933d85bdffc5e879bf52436bb3469b7f3a Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/231181 Reviewed-by: Henrik Boström <hbos@webrtc.org> Reviewed-by: Björn Terelius <terelius@webrtc.org> Reviewed-by: Harald Alvestrand <hta@webrtc.org> Commit-Queue: Ivo Creusen <ivoc@webrtc.org> Cr-Commit-Position: refs/heads/main@{#34930}
2021-09-03 14:51:22 +00:00
// Checks that the remote sender stats include a valid arrival time if an RTCP
// SR was sent.
TEST_F(RtpRtcpImplTest, SenderReportStatsArrivalTimestampSet) {
// Send a frame in order to send an SR.
SendFrame(&sender_, sender_video_.get(), kBaseLayerTid);
// Send an SR.
ASSERT_THAT(sender_.impl_->SendRTCP(kRtcpReport), Eq(0));
auto stats = receiver_.impl_->GetSenderReportStats();
ASSERT_THAT(stats, Not(Eq(std::nullopt)));
EXPECT_TRUE(stats->last_arrival_timestamp.Valid());
}
// Checks that the packet and byte counters from an RTCP SR are not zero once
// a frame is sent.
TEST_F(RtpRtcpImplTest, SenderReportStatsPacketByteCounters) {
using SenderReportStats = RtpRtcpInterface::SenderReportStats;
// Send a frame in order to send an SR.
SendFrame(&sender_, sender_video_.get(), kBaseLayerTid);
ASSERT_THAT(sender_.transport_.rtp_packets_sent_, Gt(0));
// Advance time otherwise the RTCP SR report will not include any packets
// generated by `SendFrame()`.
clock_.AdvanceTimeMilliseconds(1);
// Send an SR.
ASSERT_THAT(sender_.impl_->SendRTCP(kRtcpReport), Eq(0));
EXPECT_THAT(receiver_.impl_->GetSenderReportStats(),
Optional(AllOf(Field(&SenderReportStats::packets_sent, Gt(0u)),
Field(&SenderReportStats::bytes_sent, Gt(0u)))));
}
#pragma clang diagnostic pop
} // namespace webrtc