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

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

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