Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(255)

Side by Side Diff: webrtc/voice_engine/transport_feedback_packet_loss_tracker_unittest.cc

Issue 2754373002: TransportFeedbackPacketLossTracker to receive std::vector<PacketFeedback> in place of the entire fe… (Closed)
Patch Set: . Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/voice_engine/transport_feedback_packet_loss_tracker.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2017 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
11 #include <limits> 11 #include <limits>
12 #include <memory> 12 #include <memory>
13 #include <numeric> 13 #include <numeric>
14 #include <vector> 14 #include <vector>
15 15
16 #include "webrtc/base/checks.h" 16 #include "webrtc/base/checks.h"
17 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h"
17 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/transport_feedback.h" 18 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/transport_feedback.h"
18 #include "webrtc/test/gmock.h" 19 #include "webrtc/test/gmock.h"
19 #include "webrtc/test/gtest.h" 20 #include "webrtc/test/gtest.h"
20 #include "webrtc/voice_engine/transport_feedback_packet_loss_tracker.h" 21 #include "webrtc/voice_engine/transport_feedback_packet_loss_tracker.h"
21 22
22 namespace webrtc { 23 namespace webrtc {
23 24
24 namespace { 25 namespace {
25 26
26 constexpr int64_t kDefaultSendIntervalMs = 10; 27 constexpr int64_t kDefaultSendIntervalMs = 10;
27 constexpr int64_t kDefaultMaxWindowSizeMs = 500 * kDefaultSendIntervalMs; 28 constexpr int64_t kDefaultMaxWindowSizeMs = 500 * kDefaultSendIntervalMs;
28 29
29 class TransportFeedbackPacketLossTrackerTest 30 class TransportFeedbackPacketLossTrackerTest
30 : public ::testing::TestWithParam<uint16_t> { 31 : public ::testing::TestWithParam<uint16_t> {
31 using TransportFeedback = webrtc::rtcp::TransportFeedback;
32
33 public: 32 public:
34 TransportFeedbackPacketLossTrackerTest() = default; 33 TransportFeedbackPacketLossTrackerTest() = default;
35 virtual ~TransportFeedbackPacketLossTrackerTest() = default; 34 virtual ~TransportFeedbackPacketLossTrackerTest() = default;
36 35
37 protected: 36 protected:
38 void SendPackets(TransportFeedbackPacketLossTracker* tracker, 37 void SendPackets(TransportFeedbackPacketLossTracker* tracker,
39 const std::vector<uint16_t>& sequence_numbers, 38 const std::vector<uint16_t>& sequence_numbers,
40 int64_t send_time_interval_ms, 39 int64_t send_time_interval_ms,
41 bool validate_all = true) { 40 bool validate_all = true) {
42 RTC_CHECK_GE(send_time_interval_ms, 0); 41 RTC_CHECK_GE(send_time_interval_ms, 0);
(...skipping 25 matching lines...) Expand all
68 67
69 void AdvanceClock(int64_t time_delta_ms) { 68 void AdvanceClock(int64_t time_delta_ms) {
70 RTC_CHECK_GT(time_delta_ms, 0); 69 RTC_CHECK_GT(time_delta_ms, 0);
71 time_ms_ += time_delta_ms; 70 time_ms_ += time_delta_ms;
72 } 71 }
73 72
74 void AddTransportFeedbackAndValidate( 73 void AddTransportFeedbackAndValidate(
75 TransportFeedbackPacketLossTracker* tracker, 74 TransportFeedbackPacketLossTracker* tracker,
76 uint16_t base_sequence_num, 75 uint16_t base_sequence_num,
77 const std::vector<bool>& reception_status_vec) { 76 const std::vector<bool>& reception_status_vec) {
78 const int64_t kBaseTimeUs = 1234; // Irrelevant to this test. 77 // Any positive integer signals reception. kNotReceived signals loss.
79 TransportFeedback test_feedback; 78 // Other values are just illegal.
80 test_feedback.SetBase(base_sequence_num, kBaseTimeUs); 79 constexpr int64_t kArrivalTimeMs = 1234;
81 uint16_t sequence_num = base_sequence_num; 80
82 for (bool status : reception_status_vec) { 81 std::vector<PacketFeedback> packet_feedback_vector;
83 if (status) 82 uint16_t seq_num = base_sequence_num;
84 test_feedback.AddReceivedPacket(sequence_num, kBaseTimeUs); 83 for (bool received : reception_status_vec) {
85 ++sequence_num; 84 packet_feedback_vector.emplace_back(PacketFeedback(
85 received ? kArrivalTimeMs : PacketFeedback::kNotReceived, seq_num));
86 ++seq_num;
86 } 87 }
87 88
88 // TransportFeedback imposes some limitations on what constitutes a legal 89 tracker->OnNewTransportFeedbackVector(packet_feedback_vector);
89 // status vector. For instance, the vector cannot terminate in a lost
90 // packet. Make sure all limitations are abided by.
91 RTC_CHECK_EQ(base_sequence_num, test_feedback.GetBaseSequence());
92 const auto& vec = test_feedback.GetStatusVector();
93 RTC_CHECK_EQ(reception_status_vec.size(), vec.size());
94 for (size_t i = 0; i < reception_status_vec.size(); i++) {
95 RTC_CHECK_EQ(reception_status_vec[i],
96 vec[i] != TransportFeedback::StatusSymbol::kNotReceived);
97 }
98
99 tracker->OnReceivedTransportFeedback(test_feedback);
100 tracker->Validate(); 90 tracker->Validate();
101 } 91 }
102 92
103 // Checks that validty is as expected. If valid, checks also that 93 // Checks that validty is as expected. If valid, checks also that
104 // value is as expected. 94 // value is as expected.
105 void ValidatePacketLossStatistics( 95 void ValidatePacketLossStatistics(
106 const TransportFeedbackPacketLossTracker& tracker, 96 const TransportFeedbackPacketLossTracker& tracker,
107 rtc::Optional<float> expected_plr, 97 rtc::Optional<float> expected_plr,
108 rtc::Optional<float> expected_rplr) { 98 rtc::Optional<float> expected_rplr) {
109 // TODO(elad.alon): Comparing the rtc::Optional<float> directly would have 99 // TODO(elad.alon): Comparing the rtc::Optional<float> directly would have
(...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after
601 591
602 // All tests are run multiple times with various baseline sequence number, 592 // All tests are run multiple times with various baseline sequence number,
603 // to weed out potential bugs with wrap-around handling. 593 // to weed out potential bugs with wrap-around handling.
604 constexpr uint16_t kBases[] = {0x0000, 0x3456, 0xc032, 0xfffe}; 594 constexpr uint16_t kBases[] = {0x0000, 0x3456, 0xc032, 0xfffe};
605 595
606 INSTANTIATE_TEST_CASE_P(_, 596 INSTANTIATE_TEST_CASE_P(_,
607 TransportFeedbackPacketLossTrackerTest, 597 TransportFeedbackPacketLossTrackerTest,
608 testing::ValuesIn(kBases)); 598 testing::ValuesIn(kBases));
609 599
610 } // namespace webrtc 600 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/voice_engine/transport_feedback_packet_loss_tracker.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698