OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2004 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2004 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 <memory> | 11 #include <memory> |
12 #include <string> | 12 #include <string> |
13 | 13 |
14 #include "webrtc/base/bytebuffer.h" | 14 #include "webrtc/base/bytebuffer.h" |
15 #include "webrtc/base/gunit.h" | 15 #include "webrtc/base/gunit.h" |
16 #include "webrtc/base/thread.h" | 16 #include "webrtc/base/thread.h" |
17 #include "webrtc/media/base/rtpdump.h" | 17 #include "webrtc/media/base/rtpdump.h" |
18 #include "webrtc/media/base/rtputils.h" | 18 #include "webrtc/media/base/rtputils.h" |
19 #include "webrtc/media/base/testutils.h" | 19 #include "webrtc/media/base/testutils.h" |
20 | 20 |
21 namespace cricket { | 21 namespace cricket { |
22 | 22 |
23 static const uint32_t kTestSsrc = 1; | 23 static const uint32_t kTestSsrc = 1; |
24 | 24 |
25 // Test that we read the correct header fields from the RTP/RTCP packet. | 25 // Test that we read the correct header fields from the RTP/RTCP packet. |
26 TEST(RtpDumpTest, ReadRtpDumpPacket) { | 26 TEST(RtpDumpTest, ReadRtpDumpPacket) { |
27 rtc::ByteBuffer rtp_buf; | 27 rtc::ByteBufferWriter rtp_buf; |
28 RtpTestUtility::kTestRawRtpPackets[0].WriteToByteBuffer(kTestSsrc, &rtp_buf); | 28 RtpTestUtility::kTestRawRtpPackets[0].WriteToByteBuffer(kTestSsrc, &rtp_buf); |
29 RtpDumpPacket rtp_packet(rtp_buf.Data(), rtp_buf.Length(), 0, false); | 29 RtpDumpPacket rtp_packet(rtp_buf.Data(), rtp_buf.Length(), 0, false); |
30 | 30 |
31 int payload_type; | 31 int payload_type; |
32 int seq_num; | 32 int seq_num; |
33 uint32_t ts; | 33 uint32_t ts; |
34 uint32_t ssrc; | 34 uint32_t ssrc; |
35 int rtcp_type; | 35 int rtcp_type; |
36 EXPECT_FALSE(rtp_packet.is_rtcp()); | 36 EXPECT_FALSE(rtp_packet.is_rtcp()); |
37 EXPECT_TRUE(rtp_packet.IsValidRtpPacket()); | 37 EXPECT_TRUE(rtp_packet.IsValidRtpPacket()); |
38 EXPECT_FALSE(rtp_packet.IsValidRtcpPacket()); | 38 EXPECT_FALSE(rtp_packet.IsValidRtcpPacket()); |
39 EXPECT_TRUE(rtp_packet.GetRtpPayloadType(&payload_type)); | 39 EXPECT_TRUE(rtp_packet.GetRtpPayloadType(&payload_type)); |
40 EXPECT_EQ(0, payload_type); | 40 EXPECT_EQ(0, payload_type); |
41 EXPECT_TRUE(rtp_packet.GetRtpSeqNum(&seq_num)); | 41 EXPECT_TRUE(rtp_packet.GetRtpSeqNum(&seq_num)); |
42 EXPECT_EQ(0, seq_num); | 42 EXPECT_EQ(0, seq_num); |
43 EXPECT_TRUE(rtp_packet.GetRtpTimestamp(&ts)); | 43 EXPECT_TRUE(rtp_packet.GetRtpTimestamp(&ts)); |
44 EXPECT_EQ(0U, ts); | 44 EXPECT_EQ(0U, ts); |
45 EXPECT_TRUE(rtp_packet.GetRtpSsrc(&ssrc)); | 45 EXPECT_TRUE(rtp_packet.GetRtpSsrc(&ssrc)); |
46 EXPECT_EQ(kTestSsrc, ssrc); | 46 EXPECT_EQ(kTestSsrc, ssrc); |
47 EXPECT_FALSE(rtp_packet.GetRtcpType(&rtcp_type)); | 47 EXPECT_FALSE(rtp_packet.GetRtcpType(&rtcp_type)); |
48 | 48 |
49 rtc::ByteBuffer rtcp_buf; | 49 rtc::ByteBufferWriter rtcp_buf; |
50 RtpTestUtility::kTestRawRtcpPackets[0].WriteToByteBuffer(&rtcp_buf); | 50 RtpTestUtility::kTestRawRtcpPackets[0].WriteToByteBuffer(&rtcp_buf); |
51 RtpDumpPacket rtcp_packet(rtcp_buf.Data(), rtcp_buf.Length(), 0, true); | 51 RtpDumpPacket rtcp_packet(rtcp_buf.Data(), rtcp_buf.Length(), 0, true); |
52 | 52 |
53 EXPECT_TRUE(rtcp_packet.is_rtcp()); | 53 EXPECT_TRUE(rtcp_packet.is_rtcp()); |
54 EXPECT_FALSE(rtcp_packet.IsValidRtpPacket()); | 54 EXPECT_FALSE(rtcp_packet.IsValidRtpPacket()); |
55 EXPECT_TRUE(rtcp_packet.IsValidRtcpPacket()); | 55 EXPECT_TRUE(rtcp_packet.IsValidRtcpPacket()); |
56 EXPECT_TRUE(rtcp_packet.GetRtcpType(&rtcp_type)); | 56 EXPECT_TRUE(rtcp_packet.GetRtcpType(&rtcp_type)); |
57 EXPECT_EQ(0, rtcp_type); | 57 EXPECT_EQ(0, rtcp_type); |
58 } | 58 } |
59 | 59 |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 | 273 |
274 // The loop reader reads three packets from the input stream. | 274 // The loop reader reads three packets from the input stream. |
275 stream.Rewind(); | 275 stream.Rewind(); |
276 RtpDumpLoopReader loop_reader(&stream); | 276 RtpDumpLoopReader loop_reader(&stream); |
277 EXPECT_EQ(rtc::SR_SUCCESS, loop_reader.ReadPacket(&packet)); | 277 EXPECT_EQ(rtc::SR_SUCCESS, loop_reader.ReadPacket(&packet)); |
278 EXPECT_EQ(rtc::SR_SUCCESS, loop_reader.ReadPacket(&packet)); | 278 EXPECT_EQ(rtc::SR_SUCCESS, loop_reader.ReadPacket(&packet)); |
279 EXPECT_EQ(rtc::SR_SUCCESS, loop_reader.ReadPacket(&packet)); | 279 EXPECT_EQ(rtc::SR_SUCCESS, loop_reader.ReadPacket(&packet)); |
280 } | 280 } |
281 | 281 |
282 } // namespace cricket | 282 } // namespace cricket |
OLD | NEW |