OLD | NEW |
---|---|
(Empty) | |
1 /* | |
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. | |
3 * | |
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 | |
6 * tree. An additional intellectual property rights grant can be found | |
7 * in the file PATENTS. All contributing project authors may | |
8 * be found in the AUTHORS file in the root of the source tree. | |
9 */ | |
10 | |
11 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/pli.h" | |
12 | |
13 #include "testing/gtest/include/gtest/gtest.h" | |
14 #include "webrtc/modules/rtp_rtcp/source/rtcp_utility.h" | |
15 | |
16 using webrtc::rtcp::Pli; | |
17 using webrtc::rtcp::RawPacket; | |
18 using webrtc::RTCPUtility::RtcpCommonHeader; | |
19 using webrtc::RTCPUtility::RtcpParseCommonHeader; | |
20 | |
21 namespace webrtc { | |
22 namespace { | |
23 | |
24 const uint32_t kSenderSsrc = 0x12345678; | |
25 const uint32_t kRemoteSsrc = 0x23456789; | |
26 // Manually created Pli packet matching constants above. | |
27 const uint8_t kPacket[] = {0x81, 206, 0x00, 0x02, | |
28 0x12, 0x34, 0x56, 0x78, | |
29 0x23, 0x45, 0x67, 0x89}; | |
30 const size_t kPacketLength = sizeof(kPacket); | |
31 | |
32 TEST(RtcpPacketPliTest, Parse) { | |
33 RtcpCommonHeader header; | |
34 EXPECT_TRUE(RtcpParseCommonHeader(kPacket, kPacketLength, &header)); | |
35 Pli mutable_parsed; | |
36 EXPECT_TRUE(mutable_parsed.Parse( | |
37 header, kPacket + RtcpCommonHeader::kHeaderSizeBytes)); | |
38 const Pli& parsed = mutable_parsed; // Read values from constant object. | |
39 | |
40 EXPECT_EQ(kSenderSsrc, parsed.sender_ssrc()); | |
41 EXPECT_EQ(kRemoteSsrc, parsed.media_ssrc()); | |
42 } | |
43 | |
44 TEST(RtcpPacketPliTest, Create) { | |
45 Pli pli; | |
46 pli.From(kSenderSsrc); | |
47 pli.To(kRemoteSsrc); | |
48 | |
49 rtc::scoped_ptr<RawPacket> packet(pli.Build()); | |
50 | |
51 ASSERT_EQ(kPacketLength, packet->Length()); | |
52 EXPECT_EQ(0, memcmp(kPacket, packet->Buffer(), kPacketLength)); | |
53 } | |
54 | |
55 TEST(RtcpPacketPliTest, ParseFailesOnTooSmallPacket) { | |
åsapersson
2015/11/26 08:24:36
Failes->Fails
danilchap
2015/11/26 23:05:46
Done.
| |
56 RtcpCommonHeader header; | |
57 EXPECT_TRUE(RtcpParseCommonHeader(kPacket, kPacketLength, &header)); | |
58 header.payload_size_bytes--; | |
59 | |
60 Pli parsed; | |
61 EXPECT_FALSE( | |
62 parsed.Parse(header, kPacket + RtcpCommonHeader::kHeaderSizeBytes)); | |
63 } | |
64 | |
65 } // namespace | |
66 } // namespace webrtc | |
OLD | NEW |