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

Side by Side Diff: talk/media/base/rtpdump_unittest.cc

Issue 1362503003: Use suffixed {uint,int}{8,16,32,64}_t types. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: rebase + revert basictypes.h (to be landed separately just in case of a revert due to unexpected us… Created 5 years, 2 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 | « talk/media/base/rtpdump.cc ('k') | talk/media/base/rtputils.h » ('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 * libjingle 2 * libjingle
3 * Copyright 2004 Google Inc. 3 * Copyright 2004 Google Inc.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met: 6 * modification, are permitted provided that the following conditions are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright notice, 8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer. 9 * this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright notice, 10 * 2. Redistributions in binary form must reproduce the above copyright notice,
(...skipping 18 matching lines...) Expand all
29 29
30 #include "talk/media/base/rtpdump.h" 30 #include "talk/media/base/rtpdump.h"
31 #include "talk/media/base/rtputils.h" 31 #include "talk/media/base/rtputils.h"
32 #include "talk/media/base/testutils.h" 32 #include "talk/media/base/testutils.h"
33 #include "webrtc/base/bytebuffer.h" 33 #include "webrtc/base/bytebuffer.h"
34 #include "webrtc/base/gunit.h" 34 #include "webrtc/base/gunit.h"
35 #include "webrtc/base/thread.h" 35 #include "webrtc/base/thread.h"
36 36
37 namespace cricket { 37 namespace cricket {
38 38
39 static const uint32 kTestSsrc = 1; 39 static const uint32_t kTestSsrc = 1;
40 40
41 // Test that we read the correct header fields from the RTP/RTCP packet. 41 // Test that we read the correct header fields from the RTP/RTCP packet.
42 TEST(RtpDumpTest, ReadRtpDumpPacket) { 42 TEST(RtpDumpTest, ReadRtpDumpPacket) {
43 rtc::ByteBuffer rtp_buf; 43 rtc::ByteBuffer rtp_buf;
44 RtpTestUtility::kTestRawRtpPackets[0].WriteToByteBuffer(kTestSsrc, &rtp_buf); 44 RtpTestUtility::kTestRawRtpPackets[0].WriteToByteBuffer(kTestSsrc, &rtp_buf);
45 RtpDumpPacket rtp_packet(rtp_buf.Data(), rtp_buf.Length(), 0, false); 45 RtpDumpPacket rtp_packet(rtp_buf.Data(), rtp_buf.Length(), 0, false);
46 46
47 int payload_type; 47 int payload_type;
48 int seq_num; 48 int seq_num;
49 uint32 ts; 49 uint32_t ts;
50 uint32 ssrc; 50 uint32_t ssrc;
51 int rtcp_type; 51 int rtcp_type;
52 EXPECT_FALSE(rtp_packet.is_rtcp()); 52 EXPECT_FALSE(rtp_packet.is_rtcp());
53 EXPECT_TRUE(rtp_packet.IsValidRtpPacket()); 53 EXPECT_TRUE(rtp_packet.IsValidRtpPacket());
54 EXPECT_FALSE(rtp_packet.IsValidRtcpPacket()); 54 EXPECT_FALSE(rtp_packet.IsValidRtcpPacket());
55 EXPECT_TRUE(rtp_packet.GetRtpPayloadType(&payload_type)); 55 EXPECT_TRUE(rtp_packet.GetRtpPayloadType(&payload_type));
56 EXPECT_EQ(0, payload_type); 56 EXPECT_EQ(0, payload_type);
57 EXPECT_TRUE(rtp_packet.GetRtpSeqNum(&seq_num)); 57 EXPECT_TRUE(rtp_packet.GetRtpSeqNum(&seq_num));
58 EXPECT_EQ(0, seq_num); 58 EXPECT_EQ(0, seq_num);
59 EXPECT_TRUE(rtp_packet.GetRtpTimestamp(&ts)); 59 EXPECT_TRUE(rtp_packet.GetRtpTimestamp(&ts));
60 EXPECT_EQ(0U, ts); 60 EXPECT_EQ(0U, ts);
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 ASSERT_TRUE(RtpTestUtility::WriteTestPackets( 122 ASSERT_TRUE(RtpTestUtility::WriteTestPackets(
123 RtpTestUtility::GetTestPacketCount(), false, kTestSsrc, &writer)); 123 RtpTestUtility::GetTestPacketCount(), false, kTestSsrc, &writer));
124 EXPECT_TRUE(RtpTestUtility::VerifyTestPacketsFromStream( 124 EXPECT_TRUE(RtpTestUtility::VerifyTestPacketsFromStream(
125 RtpTestUtility::GetTestPacketCount(), &stream, kTestSsrc)); 125 RtpTestUtility::GetTestPacketCount(), &stream, kTestSsrc));
126 126
127 // Check stream has only RtpTestUtility::GetTestPacketCount() packets. 127 // Check stream has only RtpTestUtility::GetTestPacketCount() packets.
128 RtpDumpPacket packet; 128 RtpDumpPacket packet;
129 RtpDumpReader reader(&stream); 129 RtpDumpReader reader(&stream);
130 for (size_t i = 0; i < RtpTestUtility::GetTestPacketCount(); ++i) { 130 for (size_t i = 0; i < RtpTestUtility::GetTestPacketCount(); ++i) {
131 EXPECT_EQ(rtc::SR_SUCCESS, reader.ReadPacket(&packet)); 131 EXPECT_EQ(rtc::SR_SUCCESS, reader.ReadPacket(&packet));
132 uint32 ssrc; 132 uint32_t ssrc;
133 EXPECT_TRUE(GetRtpSsrc(&packet.data[0], packet.data.size(), &ssrc)); 133 EXPECT_TRUE(GetRtpSsrc(&packet.data[0], packet.data.size(), &ssrc));
134 EXPECT_EQ(kTestSsrc, ssrc); 134 EXPECT_EQ(kTestSsrc, ssrc);
135 } 135 }
136 // No more packets to read. 136 // No more packets to read.
137 EXPECT_EQ(rtc::SR_EOS, reader.ReadPacket(&packet)); 137 EXPECT_EQ(rtc::SR_EOS, reader.ReadPacket(&packet));
138 138
139 // Rewind the stream and read again with a specified ssrc. 139 // Rewind the stream and read again with a specified ssrc.
140 stream.Rewind(); 140 stream.Rewind();
141 RtpDumpReader reader_w_ssrc(&stream); 141 RtpDumpReader reader_w_ssrc(&stream);
142 const uint32 send_ssrc = kTestSsrc + 1; 142 const uint32_t send_ssrc = kTestSsrc + 1;
143 reader_w_ssrc.SetSsrc(send_ssrc); 143 reader_w_ssrc.SetSsrc(send_ssrc);
144 for (size_t i = 0; i < RtpTestUtility::GetTestPacketCount(); ++i) { 144 for (size_t i = 0; i < RtpTestUtility::GetTestPacketCount(); ++i) {
145 EXPECT_EQ(rtc::SR_SUCCESS, reader_w_ssrc.ReadPacket(&packet)); 145 EXPECT_EQ(rtc::SR_SUCCESS, reader_w_ssrc.ReadPacket(&packet));
146 EXPECT_FALSE(packet.is_rtcp()); 146 EXPECT_FALSE(packet.is_rtcp());
147 EXPECT_EQ(packet.original_data_len, packet.data.size()); 147 EXPECT_EQ(packet.original_data_len, packet.data.size());
148 uint32 ssrc; 148 uint32_t ssrc;
149 EXPECT_TRUE(GetRtpSsrc(&packet.data[0], packet.data.size(), &ssrc)); 149 EXPECT_TRUE(GetRtpSsrc(&packet.data[0], packet.data.size(), &ssrc));
150 EXPECT_EQ(send_ssrc, ssrc); 150 EXPECT_EQ(send_ssrc, ssrc);
151 } 151 }
152 // No more packets to read. 152 // No more packets to read.
153 EXPECT_EQ(rtc::SR_EOS, reader_w_ssrc.ReadPacket(&packet)); 153 EXPECT_EQ(rtc::SR_EOS, reader_w_ssrc.ReadPacket(&packet));
154 } 154 }
155 155
156 // Test that we read the same RTCP packets that rtp dump writes. 156 // Test that we read the same RTCP packets that rtp dump writes.
157 TEST(RtpDumpTest, WriteReadSameRtcp) { 157 TEST(RtpDumpTest, WriteReadSameRtcp) {
158 rtc::MemoryStream stream; 158 rtc::MemoryStream stream;
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 289
290 // The loop reader reads three packets from the input stream. 290 // The loop reader reads three packets from the input stream.
291 stream.Rewind(); 291 stream.Rewind();
292 RtpDumpLoopReader loop_reader(&stream); 292 RtpDumpLoopReader loop_reader(&stream);
293 EXPECT_EQ(rtc::SR_SUCCESS, loop_reader.ReadPacket(&packet)); 293 EXPECT_EQ(rtc::SR_SUCCESS, loop_reader.ReadPacket(&packet));
294 EXPECT_EQ(rtc::SR_SUCCESS, loop_reader.ReadPacket(&packet)); 294 EXPECT_EQ(rtc::SR_SUCCESS, loop_reader.ReadPacket(&packet));
295 EXPECT_EQ(rtc::SR_SUCCESS, loop_reader.ReadPacket(&packet)); 295 EXPECT_EQ(rtc::SR_SUCCESS, loop_reader.ReadPacket(&packet));
296 } 296 }
297 297
298 } // namespace cricket 298 } // namespace cricket
OLDNEW
« no previous file with comments | « talk/media/base/rtpdump.cc ('k') | talk/media/base/rtputils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698