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

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

Issue 1411573007: Removed vie_defines.h (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Rebase Created 5 years, 1 month 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 | « no previous file | webrtc/test/channel_transport/channel_transport.cc » ('j') | 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) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 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 * This file includes unit tests for the RTPPacketHistory. 10 * This file includes unit tests for the RTPPacketHistory.
11 */ 11 */
12 12
13 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
14 14
15 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" 15 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h"
16 #include "webrtc/modules/rtp_rtcp/source/rtp_packet_history.h" 16 #include "webrtc/modules/rtp_rtcp/source/rtp_packet_history.h"
17 #include "webrtc/system_wrappers/include/clock.h" 17 #include "webrtc/system_wrappers/include/clock.h"
18 #include "webrtc/video_engine/vie_defines.h"
19 #include "webrtc/typedefs.h" 18 #include "webrtc/typedefs.h"
20 19
21 namespace webrtc { 20 namespace webrtc {
22 21
23 class RtpPacketHistoryTest : public ::testing::Test { 22 class RtpPacketHistoryTest : public ::testing::Test {
24 protected: 23 protected:
25 RtpPacketHistoryTest() 24 RtpPacketHistoryTest()
26 : fake_clock_(123456), 25 : fake_clock_(123456),
27 hist_(new RTPPacketHistory(&fake_clock_)) { 26 hist_(new RTPPacketHistory(&fake_clock_)) {
28 } 27 }
29 ~RtpPacketHistoryTest() { 28 ~RtpPacketHistoryTest() {
30 delete hist_; 29 delete hist_;
31 } 30 }
32 31
33 SimulatedClock fake_clock_; 32 SimulatedClock fake_clock_;
34 RTPPacketHistory* hist_; 33 RTPPacketHistory* hist_;
35 enum {kPayload = 127}; 34 enum {kPayload = 127};
36 enum {kSsrc = 12345678}; 35 enum {kSsrc = 12345678};
37 enum {kSeqNum = 88}; 36 enum {kSeqNum = 88};
38 enum {kTimestamp = 127}; 37 enum {kTimestamp = 127};
39 enum {kMaxPacketLength = 1500}; 38 enum {kMaxPacketLength = 1500};
40 uint8_t packet_[kMaxPacketLength]; 39 uint8_t packet_[kMaxPacketLength];
41 uint8_t packet_out_[kMaxPacketLength]; 40 uint8_t packet_out_[kMaxPacketLength];
42 41
43 void CreateRtpPacket(uint16_t seq_num, uint32_t ssrc, uint8_t payload, 42 void CreateRtpPacket(uint16_t seq_num, uint32_t ssrc, uint8_t payload,
44 uint32_t timestamp, uint8_t* array, size_t* cur_pos) { 43 uint32_t timestamp, uint8_t* array, size_t* cur_pos) {
45 array[(*cur_pos)++] = 0x80; 44 array[(*cur_pos)++] = 0x80;
46 array[(*cur_pos)++] = payload; 45 array[(*cur_pos)++] = payload;
47 array[(*cur_pos)++] = seq_num >> 8; 46 array[(*cur_pos)++] = seq_num >> 8;
48 array[(*cur_pos)++] = seq_num; 47 array[(*cur_pos)++] = seq_num;
49 array[(*cur_pos)++] = timestamp >> 24; 48 array[(*cur_pos)++] = timestamp >> 24;
50 array[(*cur_pos)++] = timestamp >> 16; 49 array[(*cur_pos)++] = timestamp >> 16;
51 array[(*cur_pos)++] = timestamp >> 8; 50 array[(*cur_pos)++] = timestamp >> 8;
52 array[(*cur_pos)++] = timestamp; 51 array[(*cur_pos)++] = timestamp;
53 array[(*cur_pos)++] = ssrc >> 24; 52 array[(*cur_pos)++] = ssrc >> 24;
54 array[(*cur_pos)++] = ssrc >> 16; 53 array[(*cur_pos)++] = ssrc >> 16;
55 array[(*cur_pos)++] = ssrc >> 8; 54 array[(*cur_pos)++] = ssrc >> 8;
56 array[(*cur_pos)++] = ssrc; 55 array[(*cur_pos)++] = ssrc;
57 } 56 }
58 }; 57 };
59 58
60 TEST_F(RtpPacketHistoryTest, SetStoreStatus) { 59 TEST_F(RtpPacketHistoryTest, SetStoreStatus) {
61 EXPECT_FALSE(hist_->StorePackets()); 60 EXPECT_FALSE(hist_->StorePackets());
62 hist_->SetStorePacketsStatus(true, 10); 61 hist_->SetStorePacketsStatus(true, 10);
63 EXPECT_TRUE(hist_->StorePackets()); 62 EXPECT_TRUE(hist_->StorePackets());
64 hist_->SetStorePacketsStatus(false, 0); 63 hist_->SetStorePacketsStatus(false, 0);
65 EXPECT_FALSE(hist_->StorePackets()); 64 EXPECT_FALSE(hist_->StorePackets());
66 } 65 }
67 66
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 260
262 // Retransmit last 16 packets. 261 // Retransmit last 16 packets.
263 for (int i = 4; i < 20; ++i) { 262 for (int i = 4; i < 20; ++i) {
264 len = kMaxPacketLength; 263 len = kMaxPacketLength;
265 EXPECT_TRUE(hist_->GetPacketAndSetSendTime(kSeqNum + i, 100, false, packet_, 264 EXPECT_TRUE(hist_->GetPacketAndSetSendTime(kSeqNum + i, 100, false, packet_,
266 &len, &time)); 265 &len, &time));
267 } 266 }
268 } 267 }
269 268
270 TEST_F(RtpPacketHistoryTest, FullExpansion) { 269 TEST_F(RtpPacketHistoryTest, FullExpansion) {
270 static const int kSendSidePacketHistorySize = 600;
271 hist_->SetStorePacketsStatus(true, kSendSidePacketHistorySize); 271 hist_->SetStorePacketsStatus(true, kSendSidePacketHistorySize);
272 size_t len; 272 size_t len;
273 int64_t capture_time_ms = fake_clock_.TimeInMilliseconds(); 273 int64_t capture_time_ms = fake_clock_.TimeInMilliseconds();
274 int64_t time; 274 int64_t time;
275 for (size_t i = 0; i < kMaxHistoryCapacity + 1; ++i) { 275 for (size_t i = 0; i < kMaxHistoryCapacity + 1; ++i) {
276 len = 0; 276 len = 0;
277 CreateRtpPacket(kSeqNum + i, kSsrc, kPayload, kTimestamp, packet_, &len); 277 CreateRtpPacket(kSeqNum + i, kSsrc, kPayload, kTimestamp, packet_, &len);
278 EXPECT_EQ(0, hist_->PutRTPPacket(packet_, len, capture_time_ms, 278 EXPECT_EQ(0, hist_->PutRTPPacket(packet_, len, capture_time_ms,
279 kAllowRetransmission)); 279 kAllowRetransmission));
280 } 280 }
281 281
282 fake_clock_.AdvanceTimeMilliseconds(100); 282 fake_clock_.AdvanceTimeMilliseconds(100);
283 283
284 // Retransmit all packets currently in buffer. 284 // Retransmit all packets currently in buffer.
285 for (size_t i = 1; i < kMaxHistoryCapacity + 1; ++i) { 285 for (size_t i = 1; i < kMaxHistoryCapacity + 1; ++i) {
286 len = kMaxPacketLength; 286 len = kMaxPacketLength;
287 EXPECT_TRUE(hist_->GetPacketAndSetSendTime(kSeqNum + i, 100, false, packet_, 287 EXPECT_TRUE(hist_->GetPacketAndSetSendTime(kSeqNum + i, 100, false, packet_,
288 &len, &time)); 288 &len, &time));
289 } 289 }
290 } 290 }
291 291
292 } // namespace webrtc 292 } // namespace webrtc
OLDNEW
« no previous file with comments | « no previous file | webrtc/test/channel_transport/channel_transport.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698