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

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

Issue 1335353005: Remove channel ids from various interfaces. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: LoopBackTransport SSRC demuxing. Created 5 years, 3 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 <algorithm> 11 #include <algorithm>
12 #include <iterator> 12 #include <iterator>
13 #include <list> 13 #include <list>
14 #include <set> 14 #include <set>
15 15
16 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
17 #include "webrtc/base/scoped_ptr.h" 17 #include "webrtc/base/scoped_ptr.h"
18 #include "webrtc/common_types.h" 18 #include "webrtc/common_types.h"
19 #include "webrtc/modules/rtp_rtcp/interface/receive_statistics.h" 19 #include "webrtc/modules/rtp_rtcp/interface/receive_statistics.h"
20 #include "webrtc/modules/rtp_rtcp/interface/rtp_header_parser.h" 20 #include "webrtc/modules/rtp_rtcp/interface/rtp_header_parser.h"
21 #include "webrtc/modules/rtp_rtcp/interface/rtp_payload_registry.h" 21 #include "webrtc/modules/rtp_rtcp/interface/rtp_payload_registry.h"
22 #include "webrtc/modules/rtp_rtcp/interface/rtp_receiver.h" 22 #include "webrtc/modules/rtp_rtcp/interface/rtp_receiver.h"
23 #include "webrtc/modules/rtp_rtcp/interface/rtp_rtcp.h" 23 #include "webrtc/modules/rtp_rtcp/interface/rtp_rtcp.h"
24 #include "webrtc/modules/rtp_rtcp/interface/rtp_rtcp_defines.h" 24 #include "webrtc/modules/rtp_rtcp/interface/rtp_rtcp_defines.h"
25 25
26 using namespace webrtc; 26 using namespace webrtc;
27 27
28 const int kVideoNackListSize = 30; 28 const int kVideoNackListSize = 30;
29 const int kTestId = 123;
30 const uint32_t kTestSsrc = 3456; 29 const uint32_t kTestSsrc = 3456;
31 const uint16_t kTestSequenceNumber = 2345; 30 const uint16_t kTestSequenceNumber = 2345;
32 const uint32_t kTestNumberOfPackets = 1350; 31 const uint32_t kTestNumberOfPackets = 1350;
33 const int kTestNumberOfRtxPackets = 149; 32 const int kTestNumberOfRtxPackets = 149;
34 const int kNumFrames = 30; 33 const int kNumFrames = 30;
35 const int kPayloadType = 123; 34 const int kPayloadType = 123;
36 const int kRtxPayloadType = 98; 35 const int kRtxPayloadType = 98;
37 36
38 class VerifyingRtxReceiver : public NullRtpData 37 class VerifyingRtxReceiver : public NullRtpData
39 { 38 {
(...skipping 10 matching lines...) Expand all
50 return 0; 49 return 0;
51 } 50 }
52 std::list<uint16_t> sequence_numbers_; 51 std::list<uint16_t> sequence_numbers_;
53 }; 52 };
54 53
55 class TestRtpFeedback : public NullRtpFeedback { 54 class TestRtpFeedback : public NullRtpFeedback {
56 public: 55 public:
57 TestRtpFeedback(RtpRtcp* rtp_rtcp) : rtp_rtcp_(rtp_rtcp) {} 56 TestRtpFeedback(RtpRtcp* rtp_rtcp) : rtp_rtcp_(rtp_rtcp) {}
58 virtual ~TestRtpFeedback() {} 57 virtual ~TestRtpFeedback() {}
59 58
60 void OnIncomingSSRCChanged(const int32_t id, const uint32_t ssrc) override { 59 void OnIncomingSSRCChanged(const uint32_t ssrc) override {
61 rtp_rtcp_->SetRemoteSSRC(ssrc); 60 rtp_rtcp_->SetRemoteSSRC(ssrc);
62 } 61 }
63 62
64 private: 63 private:
65 RtpRtcp* rtp_rtcp_; 64 RtpRtcp* rtp_rtcp_;
66 }; 65 };
67 66
68 class RtxLoopBackTransport : public webrtc::Transport { 67 class RtxLoopBackTransport : public webrtc::Transport {
69 public: 68 public:
70 explicit RtxLoopBackTransport(uint32_t rtx_ssrc) 69 explicit RtxLoopBackTransport(uint32_t rtx_ssrc)
(...skipping 18 matching lines...) Expand all
89 void DropEveryNthPacket(int n) { 88 void DropEveryNthPacket(int n) {
90 packet_loss_ = n; 89 packet_loss_ = n;
91 } 90 }
92 91
93 void DropConsecutivePackets(int start, int total) { 92 void DropConsecutivePackets(int start, int total) {
94 consecutive_drop_start_ = start; 93 consecutive_drop_start_ = start;
95 consecutive_drop_end_ = start + total; 94 consecutive_drop_end_ = start + total;
96 packet_loss_ = 0; 95 packet_loss_ = 0;
97 } 96 }
98 97
99 int SendPacket(int channel, const void* data, size_t len) override { 98 int SendPacket(const void* data, size_t len) override {
100 count_++; 99 count_++;
101 const unsigned char* ptr = static_cast<const unsigned char*>(data); 100 const unsigned char* ptr = static_cast<const unsigned char*>(data);
102 uint32_t ssrc = (ptr[8] << 24) + (ptr[9] << 16) + (ptr[10] << 8) + ptr[11]; 101 uint32_t ssrc = (ptr[8] << 24) + (ptr[9] << 16) + (ptr[10] << 8) + ptr[11];
103 if (ssrc == rtx_ssrc_) count_rtx_ssrc_++; 102 if (ssrc == rtx_ssrc_) count_rtx_ssrc_++;
104 uint16_t sequence_number = (ptr[2] << 8) + ptr[3]; 103 uint16_t sequence_number = (ptr[2] << 8) + ptr[3];
105 expected_sequence_numbers_.insert(expected_sequence_numbers_.end(), 104 expected_sequence_numbers_.insert(expected_sequence_numbers_.end(),
106 sequence_number); 105 sequence_number);
107 if (packet_loss_ > 0) { 106 if (packet_loss_ > 0) {
108 if ((count_ % packet_loss_) == 0) { 107 if ((count_ % packet_loss_) == 0) {
109 return static_cast<int>(len); 108 return static_cast<int>(len);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 return -1; 142 return -1;
144 } 143 }
145 if (!rtp_receiver_->IncomingRtpPacket(header, restored_packet_ptr, 144 if (!rtp_receiver_->IncomingRtpPacket(header, restored_packet_ptr,
146 packet_length, payload_specific, 145 packet_length, payload_specific,
147 true)) { 146 true)) {
148 return -1; 147 return -1;
149 } 148 }
150 return static_cast<int>(len); 149 return static_cast<int>(len);
151 } 150 }
152 151
153 int SendRTCPPacket(int channel, const void* data, size_t len) override { 152 int SendRTCPPacket(const void* data, size_t len) override {
154 if (module_->IncomingRtcpPacket((const uint8_t*)data, len) == 0) { 153 if (module_->IncomingRtcpPacket((const uint8_t*)data, len) == 0) {
155 return static_cast<int>(len); 154 return static_cast<int>(len);
156 } 155 }
157 return -1; 156 return -1;
158 } 157 }
159 int count_; 158 int count_;
160 int packet_loss_; 159 int packet_loss_;
161 int consecutive_drop_start_; 160 int consecutive_drop_start_;
162 int consecutive_drop_end_; 161 int consecutive_drop_end_;
163 uint32_t rtx_ssrc_; 162 uint32_t rtx_ssrc_;
(...skipping 10 matching lines...) Expand all
174 : rtp_payload_registry_(RTPPayloadStrategy::CreateStrategy(false)), 173 : rtp_payload_registry_(RTPPayloadStrategy::CreateStrategy(false)),
175 rtp_rtcp_module_(NULL), 174 rtp_rtcp_module_(NULL),
176 transport_(kTestSsrc + 1), 175 transport_(kTestSsrc + 1),
177 receiver_(), 176 receiver_(),
178 payload_data_length(sizeof(payload_data)), 177 payload_data_length(sizeof(payload_data)),
179 fake_clock(123456) {} 178 fake_clock(123456) {}
180 ~RtpRtcpRtxNackTest() {} 179 ~RtpRtcpRtxNackTest() {}
181 180
182 void SetUp() override { 181 void SetUp() override {
183 RtpRtcp::Configuration configuration; 182 RtpRtcp::Configuration configuration;
184 configuration.id = kTestId;
185 configuration.audio = false; 183 configuration.audio = false;
186 configuration.clock = &fake_clock; 184 configuration.clock = &fake_clock;
187 receive_statistics_.reset(ReceiveStatistics::Create(&fake_clock)); 185 receive_statistics_.reset(ReceiveStatistics::Create(&fake_clock));
188 configuration.receive_statistics = receive_statistics_.get(); 186 configuration.receive_statistics = receive_statistics_.get();
189 configuration.outgoing_transport = &transport_; 187 configuration.outgoing_transport = &transport_;
190 rtp_rtcp_module_ = RtpRtcp::CreateRtpRtcp(configuration); 188 rtp_rtcp_module_ = RtpRtcp::CreateRtpRtcp(configuration);
191 189
192 rtp_feedback_.reset(new TestRtpFeedback(rtp_rtcp_module_)); 190 rtp_feedback_.reset(new TestRtpFeedback(rtp_rtcp_module_));
193 191
194 rtp_receiver_.reset(RtpReceiver::CreateVideoReceiver( 192 rtp_receiver_.reset(RtpReceiver::CreateVideoReceiver(
195 kTestId, &fake_clock, &receiver_, rtp_feedback_.get(), 193 &fake_clock, &receiver_, rtp_feedback_.get(),
196 &rtp_payload_registry_)); 194 &rtp_payload_registry_));
197 195
198 rtp_rtcp_module_->SetSSRC(kTestSsrc); 196 rtp_rtcp_module_->SetSSRC(kTestSsrc);
199 rtp_rtcp_module_->SetRTCPStatus(kRtcpCompound); 197 rtp_rtcp_module_->SetRTCPStatus(kRtcpCompound);
200 rtp_receiver_->SetNACKStatus(kNackRtcp); 198 rtp_receiver_->SetNACKStatus(kNackRtcp);
201 rtp_rtcp_module_->SetStorePacketsStatus(true, 600); 199 rtp_rtcp_module_->SetStorePacketsStatus(true, 600);
202 EXPECT_EQ(0, rtp_rtcp_module_->SetSendingStatus(true)); 200 EXPECT_EQ(0, rtp_rtcp_module_->SetSendingStatus(true));
203 rtp_rtcp_module_->SetSequenceNumber(kTestSequenceNumber); 201 rtp_rtcp_module_->SetSequenceNumber(kTestSequenceNumber);
204 rtp_rtcp_module_->SetStartTimestamp(111111); 202 rtp_rtcp_module_->SetStartTimestamp(111111);
205 203
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 337
340 TEST_F(RtpRtcpRtxNackTest, RtxNack) { 338 TEST_F(RtpRtcpRtxNackTest, RtxNack) {
341 RunRtxTest(kRtxRetransmitted, 10); 339 RunRtxTest(kRtxRetransmitted, 10);
342 EXPECT_EQ(kTestSequenceNumber, *(receiver_.sequence_numbers_.begin())); 340 EXPECT_EQ(kTestSequenceNumber, *(receiver_.sequence_numbers_.begin()));
343 EXPECT_EQ(kTestSequenceNumber + kTestNumberOfPackets - 1, 341 EXPECT_EQ(kTestSequenceNumber + kTestNumberOfPackets - 1,
344 *(receiver_.sequence_numbers_.rbegin())); 342 *(receiver_.sequence_numbers_.rbegin()));
345 EXPECT_EQ(kTestNumberOfPackets, receiver_.sequence_numbers_.size()); 343 EXPECT_EQ(kTestNumberOfPackets, receiver_.sequence_numbers_.size());
346 EXPECT_EQ(kTestNumberOfRtxPackets, transport_.count_rtx_ssrc_); 344 EXPECT_EQ(kTestNumberOfRtxPackets, transport_.count_rtx_ssrc_);
347 EXPECT_TRUE(ExpectedPacketsReceived()); 345 EXPECT_TRUE(ExpectedPacketsReceived());
348 } 346 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698