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

Side by Side Diff: webrtc/modules/rtp_rtcp/source/rtp_rtcp_impl_unittest.cc

Issue 2061423003: Refactor NACK bitrate allocation (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Fixed nit Created 4 years, 5 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
OLDNEW
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
11 #include <map> 11 #include <map>
12 #include <memory> 12 #include <memory>
13 #include <set> 13 #include <set>
14 14
15 #include "testing/gmock/include/gmock/gmock.h" 15 #include "testing/gmock/include/gmock/gmock.h"
16 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
17 17
18 #include "webrtc/base/rate_limiter.h"
18 #include "webrtc/common_types.h" 19 #include "webrtc/common_types.h"
19 #include "webrtc/modules/rtp_rtcp/include/rtp_header_parser.h" 20 #include "webrtc/modules/rtp_rtcp/include/rtp_header_parser.h"
20 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" 21 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h"
21 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet.h" 22 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet.h"
22 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/nack.h" 23 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/nack.h"
23 #include "webrtc/modules/rtp_rtcp/source/rtp_rtcp_impl.h" 24 #include "webrtc/modules/rtp_rtcp/source/rtp_rtcp_impl.h"
24 #include "webrtc/test/rtcp_packet_parser.h" 25 #include "webrtc/test/rtcp_packet_parser.h"
25 26
26 using ::testing::_; 27 using ::testing::_;
27 using ::testing::ElementsAre; 28 using ::testing::ElementsAre;
28 using ::testing::NiceMock; 29 using ::testing::NiceMock;
29 using ::testing::Return; 30 using ::testing::Return;
30 using ::testing::SaveArg; 31 using ::testing::SaveArg;
31 32
32 namespace webrtc { 33 namespace webrtc {
33 namespace { 34 namespace {
34 const uint32_t kSenderSsrc = 0x12345; 35 const uint32_t kSenderSsrc = 0x12345;
35 const uint32_t kReceiverSsrc = 0x23456; 36 const uint32_t kReceiverSsrc = 0x23456;
36 const int64_t kOneWayNetworkDelayMs = 100; 37 const int64_t kOneWayNetworkDelayMs = 100;
37 const uint8_t kBaseLayerTid = 0; 38 const uint8_t kBaseLayerTid = 0;
38 const uint8_t kHigherLayerTid = 1; 39 const uint8_t kHigherLayerTid = 1;
39 const uint16_t kSequenceNumber = 100; 40 const uint16_t kSequenceNumber = 100;
41 const int64_t kMaxRttMs = 1000;
40 42
41 class RtcpRttStatsTestImpl : public RtcpRttStats { 43 class RtcpRttStatsTestImpl : public RtcpRttStats {
42 public: 44 public:
43 RtcpRttStatsTestImpl() : rtt_ms_(0) {} 45 RtcpRttStatsTestImpl() : rtt_ms_(0) {}
44 virtual ~RtcpRttStatsTestImpl() {} 46 virtual ~RtcpRttStatsTestImpl() {}
45 47
46 void OnRttUpdate(int64_t rtt_ms) override { rtt_ms_ = rtt_ms; } 48 void OnRttUpdate(int64_t rtt_ms) override { rtt_ms_ = rtt_ms; }
47 int64_t LastProcessedRtt() const override { return rtt_ms_; } 49 int64_t LastProcessedRtt() const override { return rtt_ms_; }
48 int64_t rtt_ms_; 50 int64_t rtt_ms_;
49 }; 51 };
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 SimulatedClock* clock_; 94 SimulatedClock* clock_;
93 int64_t delay_ms_; 95 int64_t delay_ms_;
94 int rtp_packets_sent_; 96 int rtp_packets_sent_;
95 RTPHeader last_rtp_header_; 97 RTPHeader last_rtp_header_;
96 std::vector<uint16_t> last_nack_list_; 98 std::vector<uint16_t> last_nack_list_;
97 }; 99 };
98 100
99 class RtpRtcpModule : public RtcpPacketTypeCounterObserver { 101 class RtpRtcpModule : public RtcpPacketTypeCounterObserver {
100 public: 102 public:
101 explicit RtpRtcpModule(SimulatedClock* clock) 103 explicit RtpRtcpModule(SimulatedClock* clock)
102 : receive_statistics_(ReceiveStatistics::Create(clock)) { 104 : receive_statistics_(ReceiveStatistics::Create(clock)),
105 remote_ssrc_(0),
106 retransmission_rate_limiter_(clock, kMaxRttMs) {
103 RtpRtcp::Configuration config; 107 RtpRtcp::Configuration config;
104 config.audio = false; 108 config.audio = false;
105 config.clock = clock; 109 config.clock = clock;
106 config.outgoing_transport = &transport_; 110 config.outgoing_transport = &transport_;
107 config.receive_statistics = receive_statistics_.get(); 111 config.receive_statistics = receive_statistics_.get();
108 config.rtcp_packet_type_counter_observer = this; 112 config.rtcp_packet_type_counter_observer = this;
109 config.rtt_stats = &rtt_stats_; 113 config.rtt_stats = &rtt_stats_;
114 config.retransmission_rate_limiter = &retransmission_rate_limiter_;
110 115
111 impl_.reset(new ModuleRtpRtcpImpl(config)); 116 impl_.reset(new ModuleRtpRtcpImpl(config));
112 impl_->SetRTCPStatus(RtcpMode::kCompound); 117 impl_->SetRTCPStatus(RtcpMode::kCompound);
113 118
114 transport_.SimulateNetworkDelay(kOneWayNetworkDelayMs, clock); 119 transport_.SimulateNetworkDelay(kOneWayNetworkDelayMs, clock);
115 } 120 }
116 121
117 RtcpPacketTypeCounter packets_sent_; 122 RtcpPacketTypeCounter packets_sent_;
118 RtcpPacketTypeCounter packets_received_; 123 RtcpPacketTypeCounter packets_received_;
119 std::unique_ptr<ReceiveStatistics> receive_statistics_; 124 std::unique_ptr<ReceiveStatistics> receive_statistics_;
120 SendTransport transport_; 125 SendTransport transport_;
121 RtcpRttStatsTestImpl rtt_stats_; 126 RtcpRttStatsTestImpl rtt_stats_;
122 std::unique_ptr<ModuleRtpRtcpImpl> impl_; 127 std::unique_ptr<ModuleRtpRtcpImpl> impl_;
123 uint32_t remote_ssrc_; 128 uint32_t remote_ssrc_;
129 RateLimiter retransmission_rate_limiter_;
124 130
125 void SetRemoteSsrc(uint32_t ssrc) { 131 void SetRemoteSsrc(uint32_t ssrc) {
126 remote_ssrc_ = ssrc; 132 remote_ssrc_ = ssrc;
127 impl_->SetRemoteSSRC(ssrc); 133 impl_->SetRemoteSSRC(ssrc);
128 } 134 }
129 135
130 void RtcpPacketTypesCounterUpdated( 136 void RtcpPacketTypesCounterUpdated(
131 uint32_t ssrc, 137 uint32_t ssrc,
132 const RtcpPacketTypeCounter& packet_counter) override { 138 const RtcpPacketTypeCounter& packet_counter) override {
133 counter_map_[ssrc] = packet_counter; 139 counter_map_[ssrc] = packet_counter;
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after
539 EXPECT_EQ(6U, receiver_.RtcpSent().unique_nack_requests); 545 EXPECT_EQ(6U, receiver_.RtcpSent().unique_nack_requests);
540 EXPECT_THAT(receiver_.LastNackListSent(), ElementsAre(11, 18, 20, 21)); 546 EXPECT_THAT(receiver_.LastNackListSent(), ElementsAre(11, 18, 20, 21));
541 547
542 // Send module receives the request. 548 // Send module receives the request.
543 EXPECT_EQ(2U, sender_.RtcpReceived().nack_packets); 549 EXPECT_EQ(2U, sender_.RtcpReceived().nack_packets);
544 EXPECT_EQ(8U, sender_.RtcpReceived().nack_requests); 550 EXPECT_EQ(8U, sender_.RtcpReceived().nack_requests);
545 EXPECT_EQ(6U, sender_.RtcpReceived().unique_nack_requests); 551 EXPECT_EQ(6U, sender_.RtcpReceived().unique_nack_requests);
546 EXPECT_EQ(75, sender_.RtcpReceived().UniqueNackRequestsInPercent()); 552 EXPECT_EQ(75, sender_.RtcpReceived().UniqueNackRequestsInPercent());
547 } 553 }
548 } // namespace webrtc 554 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/rtp_rtcp/source/rtp_rtcp_impl.cc ('k') | webrtc/modules/rtp_rtcp/source/rtp_sender.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698