| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 receive_statistics_->IncomingPacket(header2_, kPacketSize2, false); | 48 receive_statistics_->IncomingPacket(header2_, kPacketSize2, false); |
| 49 ++header2_.sequenceNumber; | 49 ++header2_.sequenceNumber; |
| 50 clock_.AdvanceTimeMilliseconds(100); | 50 clock_.AdvanceTimeMilliseconds(100); |
| 51 receive_statistics_->IncomingPacket(header1_, kPacketSize1, false); | 51 receive_statistics_->IncomingPacket(header1_, kPacketSize1, false); |
| 52 ++header1_.sequenceNumber; | 52 ++header1_.sequenceNumber; |
| 53 receive_statistics_->IncomingPacket(header2_, kPacketSize2, false); | 53 receive_statistics_->IncomingPacket(header2_, kPacketSize2, false); |
| 54 ++header2_.sequenceNumber; | 54 ++header2_.sequenceNumber; |
| 55 | 55 |
| 56 StreamStatistician* statistician = | 56 StreamStatistician* statistician = |
| 57 receive_statistics_->GetStatistician(kSsrc1); | 57 receive_statistics_->GetStatistician(kSsrc1); |
| 58 ASSERT_TRUE(statistician != NULL); | 58 ASSERT_TRUE(statistician != nullptr); |
| 59 EXPECT_GT(statistician->BitrateReceived(), 0u); | 59 EXPECT_GT(statistician->BitrateReceived(), 0u); |
| 60 size_t bytes_received = 0; | 60 size_t bytes_received = 0; |
| 61 uint32_t packets_received = 0; | 61 uint32_t packets_received = 0; |
| 62 statistician->GetDataCounters(&bytes_received, &packets_received); | 62 statistician->GetDataCounters(&bytes_received, &packets_received); |
| 63 EXPECT_EQ(200u, bytes_received); | 63 EXPECT_EQ(200u, bytes_received); |
| 64 EXPECT_EQ(2u, packets_received); | 64 EXPECT_EQ(2u, packets_received); |
| 65 | 65 |
| 66 statistician = | 66 statistician = |
| 67 receive_statistics_->GetStatistician(kSsrc2); | 67 receive_statistics_->GetStatistician(kSsrc2); |
| 68 ASSERT_TRUE(statistician != NULL); | 68 ASSERT_TRUE(statistician != nullptr); |
| 69 EXPECT_GT(statistician->BitrateReceived(), 0u); | 69 EXPECT_GT(statistician->BitrateReceived(), 0u); |
| 70 statistician->GetDataCounters(&bytes_received, &packets_received); | 70 statistician->GetDataCounters(&bytes_received, &packets_received); |
| 71 EXPECT_EQ(600u, bytes_received); | 71 EXPECT_EQ(600u, bytes_received); |
| 72 EXPECT_EQ(2u, packets_received); | 72 EXPECT_EQ(2u, packets_received); |
| 73 | 73 |
| 74 StatisticianMap statisticians = receive_statistics_->GetActiveStatisticians(); | 74 StatisticianMap statisticians = receive_statistics_->GetActiveStatisticians(); |
| 75 EXPECT_EQ(2u, statisticians.size()); | 75 EXPECT_EQ(2u, statisticians.size()); |
| 76 // Add more incoming packets and verify that they are registered in both | 76 // Add more incoming packets and verify that they are registered in both |
| 77 // access methods. | 77 // access methods. |
| 78 receive_statistics_->IncomingPacket(header1_, kPacketSize1, false); | 78 receive_statistics_->IncomingPacket(header1_, kPacketSize1, false); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 statisticians = receive_statistics_->GetActiveStatisticians(); | 118 statisticians = receive_statistics_->GetActiveStatisticians(); |
| 119 EXPECT_EQ(0u, statisticians.size()); | 119 EXPECT_EQ(0u, statisticians.size()); |
| 120 | 120 |
| 121 receive_statistics_->IncomingPacket(header1_, kPacketSize1, false); | 121 receive_statistics_->IncomingPacket(header1_, kPacketSize1, false); |
| 122 ++header1_.sequenceNumber; | 122 ++header1_.sequenceNumber; |
| 123 // kSsrc1 should be active again and the data counters should have survived. | 123 // kSsrc1 should be active again and the data counters should have survived. |
| 124 statisticians = receive_statistics_->GetActiveStatisticians(); | 124 statisticians = receive_statistics_->GetActiveStatisticians(); |
| 125 EXPECT_EQ(1u, statisticians.size()); | 125 EXPECT_EQ(1u, statisticians.size()); |
| 126 StreamStatistician* statistician = | 126 StreamStatistician* statistician = |
| 127 receive_statistics_->GetStatistician(kSsrc1); | 127 receive_statistics_->GetStatistician(kSsrc1); |
| 128 ASSERT_TRUE(statistician != NULL); | 128 ASSERT_TRUE(statistician != nullptr); |
| 129 size_t bytes_received = 0; | 129 size_t bytes_received = 0; |
| 130 uint32_t packets_received = 0; | 130 uint32_t packets_received = 0; |
| 131 statistician->GetDataCounters(&bytes_received, &packets_received); | 131 statistician->GetDataCounters(&bytes_received, &packets_received); |
| 132 EXPECT_EQ(200u, bytes_received); | 132 EXPECT_EQ(200u, bytes_received); |
| 133 EXPECT_EQ(2u, packets_received); | 133 EXPECT_EQ(2u, packets_received); |
| 134 } | 134 } |
| 135 | 135 |
| 136 TEST_F(ReceiveStatisticsTest, GetReceiveStreamDataCounters) { | 136 TEST_F(ReceiveStatisticsTest, GetReceiveStreamDataCounters) { |
| 137 receive_statistics_->IncomingPacket(header1_, kPacketSize1, false); | 137 receive_statistics_->IncomingPacket(header1_, kPacketSize1, false); |
| 138 StreamStatistician* statistician = | 138 StreamStatistician* statistician = |
| 139 receive_statistics_->GetStatistician(kSsrc1); | 139 receive_statistics_->GetStatistician(kSsrc1); |
| 140 ASSERT_TRUE(statistician != NULL); | 140 ASSERT_TRUE(statistician != nullptr); |
| 141 | 141 |
| 142 StreamDataCounters counters; | 142 StreamDataCounters counters; |
| 143 statistician->GetReceiveStreamDataCounters(&counters); | 143 statistician->GetReceiveStreamDataCounters(&counters); |
| 144 EXPECT_GT(counters.first_packet_time_ms, -1); | 144 EXPECT_GT(counters.first_packet_time_ms, -1); |
| 145 EXPECT_EQ(1u, counters.transmitted.packets); | 145 EXPECT_EQ(1u, counters.transmitted.packets); |
| 146 | 146 |
| 147 receive_statistics_->IncomingPacket(header1_, kPacketSize1, false); | 147 receive_statistics_->IncomingPacket(header1_, kPacketSize1, false); |
| 148 statistician->GetReceiveStreamDataCounters(&counters); | 148 statistician->GetReceiveStreamDataCounters(&counters); |
| 149 EXPECT_GT(counters.first_packet_time_ms, -1); | 149 EXPECT_GT(counters.first_packet_time_ms, -1); |
| 150 EXPECT_EQ(2u, counters.transmitted.packets); | 150 EXPECT_EQ(2u, counters.transmitted.packets); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 EXPECT_EQ(statistics.cumulative_lost, callback.stats_.cumulative_lost); | 204 EXPECT_EQ(statistics.cumulative_lost, callback.stats_.cumulative_lost); |
| 205 EXPECT_EQ(statistics.extended_max_sequence_number, | 205 EXPECT_EQ(statistics.extended_max_sequence_number, |
| 206 callback.stats_.extended_max_sequence_number); | 206 callback.stats_.extended_max_sequence_number); |
| 207 EXPECT_EQ(statistics.fraction_lost, callback.stats_.fraction_lost); | 207 EXPECT_EQ(statistics.fraction_lost, callback.stats_.fraction_lost); |
| 208 EXPECT_EQ(statistics.jitter, callback.stats_.jitter); | 208 EXPECT_EQ(statistics.jitter, callback.stats_.jitter); |
| 209 EXPECT_EQ(51, statistics.fraction_lost); | 209 EXPECT_EQ(51, statistics.fraction_lost); |
| 210 EXPECT_EQ(1u, statistics.cumulative_lost); | 210 EXPECT_EQ(1u, statistics.cumulative_lost); |
| 211 EXPECT_EQ(5u, statistics.extended_max_sequence_number); | 211 EXPECT_EQ(5u, statistics.extended_max_sequence_number); |
| 212 EXPECT_EQ(4u, statistics.jitter); | 212 EXPECT_EQ(4u, statistics.jitter); |
| 213 | 213 |
| 214 receive_statistics_->RegisterRtcpStatisticsCallback(NULL); | 214 receive_statistics_->RegisterRtcpStatisticsCallback(nullptr); |
| 215 | 215 |
| 216 // Add some more data. | 216 // Add some more data. |
| 217 header1_.sequenceNumber = 1; | 217 header1_.sequenceNumber = 1; |
| 218 clock_.AdvanceTimeMilliseconds(7); | 218 clock_.AdvanceTimeMilliseconds(7); |
| 219 header1_.timestamp += 3; | 219 header1_.timestamp += 3; |
| 220 receive_statistics_->IncomingPacket(header1_, kPacketSize1, false); | 220 receive_statistics_->IncomingPacket(header1_, kPacketSize1, false); |
| 221 header1_.sequenceNumber += 2; | 221 header1_.sequenceNumber += 2; |
| 222 clock_.AdvanceTimeMilliseconds(9); | 222 clock_.AdvanceTimeMilliseconds(9); |
| 223 header1_.timestamp += 9; | 223 header1_.timestamp += 9; |
| 224 receive_statistics_->IncomingPacket(header1_, kPacketSize1, false); | 224 receive_statistics_->IncomingPacket(header1_, kPacketSize1, false); |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 333 receive_statistics_->FecPacketReceived(header1_, | 333 receive_statistics_->FecPacketReceived(header1_, |
| 334 kPacketSize1 + kHeaderLength); | 334 kPacketSize1 + kHeaderLength); |
| 335 expected.transmitted.payload_bytes = kPacketSize1 * 4; | 335 expected.transmitted.payload_bytes = kPacketSize1 * 4; |
| 336 expected.transmitted.header_bytes = kHeaderLength * 4; | 336 expected.transmitted.header_bytes = kHeaderLength * 4; |
| 337 expected.transmitted.packets = 4; | 337 expected.transmitted.packets = 4; |
| 338 expected.fec.payload_bytes = kPacketSize1; | 338 expected.fec.payload_bytes = kPacketSize1; |
| 339 expected.fec.header_bytes = kHeaderLength; | 339 expected.fec.header_bytes = kHeaderLength; |
| 340 expected.fec.packets = 1; | 340 expected.fec.packets = 1; |
| 341 callback.Matches(5, kSsrc1, expected); | 341 callback.Matches(5, kSsrc1, expected); |
| 342 | 342 |
| 343 receive_statistics_->RegisterRtpStatisticsCallback(NULL); | 343 receive_statistics_->RegisterRtpStatisticsCallback(nullptr); |
| 344 | 344 |
| 345 // New stats, but callback should not be called. | 345 // New stats, but callback should not be called. |
| 346 ++header1_.sequenceNumber; | 346 ++header1_.sequenceNumber; |
| 347 clock_.AdvanceTimeMilliseconds(5); | 347 clock_.AdvanceTimeMilliseconds(5); |
| 348 receive_statistics_->IncomingPacket( | 348 receive_statistics_->IncomingPacket( |
| 349 header1_, kPacketSize1 + kHeaderLength, true); | 349 header1_, kPacketSize1 + kHeaderLength, true); |
| 350 callback.Matches(5, kSsrc1, expected); | 350 callback.Matches(5, kSsrc1, expected); |
| 351 } | 351 } |
| 352 | 352 |
| 353 TEST_F(ReceiveStatisticsTest, RtpCallbacksFecFirst) { | 353 TEST_F(ReceiveStatisticsTest, RtpCallbacksFecFirst) { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 373 callback.Matches(1, kSsrc1, expected); | 373 callback.Matches(1, kSsrc1, expected); |
| 374 | 374 |
| 375 receive_statistics_->FecPacketReceived(header1_, | 375 receive_statistics_->FecPacketReceived(header1_, |
| 376 kPacketSize1 + kHeaderLength); | 376 kPacketSize1 + kHeaderLength); |
| 377 expected.fec.payload_bytes = kPacketSize1; | 377 expected.fec.payload_bytes = kPacketSize1; |
| 378 expected.fec.header_bytes = kHeaderLength; | 378 expected.fec.header_bytes = kHeaderLength; |
| 379 expected.fec.packets = 1; | 379 expected.fec.packets = 1; |
| 380 callback.Matches(2, kSsrc1, expected); | 380 callback.Matches(2, kSsrc1, expected); |
| 381 } | 381 } |
| 382 } // namespace webrtc | 382 } // namespace webrtc |
| OLD | NEW |