StreamDataCounters::last_packet_received_timestamp_ms added.

This a standard stat:
https://w3c.github.io/webrtc-stats/#dom-rtcinboundrtpstreamstats-lastpacketreceivedtimestamp

This is collected by StreamStatisticianImpl. A follow-up CL with plumb
it to the RTCStatsCollector.

Bug: webrtc:10449
Change-Id: I44e7f4735f9df78704ce21198f52e66d11e63740
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/130479
Reviewed-by: Åsa Persson <asapersson@webrtc.org>
Commit-Queue: Henrik Boström <hbos@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#27416}
This commit is contained in:
Henrik Boström
2019-04-02 15:11:48 +02:00
committed by Commit Bot
parent cf2df2fb97
commit cb755b001c
3 changed files with 18 additions and 0 deletions

View File

@ -448,6 +448,10 @@ struct StreamDataCounters {
}
int64_t first_packet_time_ms; // Time when first packet is sent/received.
// The timestamp at which the last packet was received, i.e. the time of the
// local clock when it was received - not the RTP timestamp of that packet.
// https://w3c.github.io/webrtc-stats/#dom-rtcinboundrtpstreamstats-lastpacketreceivedtimestamp
absl::optional<int64_t> last_packet_received_timestamp_ms;
RtpPacketCounter transmitted; // Number of transmitted packets/bytes.
RtpPacketCounter retransmitted; // Number of retransmitted packets/bytes.
RtpPacketCounter fec; // Number of redundancy packets/bytes.

View File

@ -108,6 +108,7 @@ StreamDataCounters StreamStatisticianImpl::UpdateCounters(
int64_t now_ms = clock_->TimeInMilliseconds();
incoming_bitrate_.Update(packet.size(), now_ms);
receive_counters_.last_packet_received_timestamp_ms = now_ms;
receive_counters_.transmitted.AddPacket(packet);
int64_t sequence_number =

View File

@ -605,6 +605,19 @@ TEST_F(ReceiveStatisticsTest, RtpCallbacks) {
callback.Matches(5, kSsrc1, expected);
}
TEST_F(ReceiveStatisticsTest, LastPacketReceivedTimestamp) {
RtpTestCallback callback;
receive_statistics_ = ReceiveStatistics::Create(&clock_, nullptr, &callback);
clock_.AdvanceTimeMilliseconds(42);
receive_statistics_->OnRtpPacket(packet1_);
EXPECT_EQ(42, callback.stats_.last_packet_received_timestamp_ms);
clock_.AdvanceTimeMilliseconds(3);
receive_statistics_->OnRtpPacket(packet1_);
EXPECT_EQ(45, callback.stats_.last_packet_received_timestamp_ms);
}
TEST_F(ReceiveStatisticsTest, RtpCallbacksFecFirst) {
RtpTestCallback callback;
receive_statistics_ = ReceiveStatistics::Create(&clock_, nullptr, &callback);