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

Side by Side Diff: webrtc/modules/rtp_rtcp/source/rtcp_packet/pli_unittest.cc

Issue 1446513002: rtcp::Pli moved into own file and got a Parse function (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: 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
OLDNEW
(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 <limits>
14
15 #include "testing/gtest/include/gtest/gtest.h"
16 #include "webrtc/modules/rtp_rtcp/source/rtcp_utility.h"
17
18 using webrtc::rtcp::Pli;
19 using webrtc::rtcp::RawPacket;
20 using webrtc::RTCPUtility::RtcpCommonHeader;
21 using webrtc::RTCPUtility::RtcpParseCommonHeader;
22
23 namespace webrtc {
24 namespace {
25
26 const uint32_t kSenderSsrc = 0x12345678;
27 const uint32_t kRemoteSsrc = 0x23456789;
28 // Manually created Pli packet matching constants above.
29 const uint8_t kPacket[] = {0x81, 206, 0x00, 0x02,
30 0x12, 0x34, 0x56, 0x78,
31 0x23, 0x45, 0x67, 0x89};
32 const size_t kPacketLength = sizeof(kPacket);
33
34 TEST(RtcpPacketPliTest, Parse) {
35 RtcpCommonHeader header;
36 EXPECT_TRUE(RtcpParseCommonHeader(kPacket, kPacketLength, &header));
37 Pli mutable_parsed;
38 EXPECT_TRUE(mutable_parsed.Parse(
39 header, kPacket + RtcpCommonHeader::kHeaderSizeBytes));
40 const Pli& parsed = mutable_parsed; // Read values from constant object.
sprang_webrtc 2015/11/16 10:01:34 Why not use mutable_parsed directly?
danilchap 2015/11/16 11:03:59 It is a check that accessors are const (this kind
41
42 EXPECT_EQ(kSenderSsrc, parsed.sender_ssrc());
43 EXPECT_EQ(kRemoteSsrc, parsed.media_ssrc());
44 }
45
46 TEST(RtcpPacketPliTest, Create) {
47 Pli pli;
48 pli.From(kSenderSsrc);
49 pli.To(kRemoteSsrc);
50
51 rtc::scoped_ptr<RawPacket> packet(pli.Build());
52
53 ASSERT_EQ(kPacketLength, packet->Length());
54 EXPECT_EQ(0, memcmp(kPacket, packet->Buffer(), kPacketLength));
55 }
56
57 TEST(RtcpPacketPliTest, ParseFailesOnSmallPacket) {
åsapersson 2015/11/25 16:14:48 maybe ParseFailsOnTooSmallPacket
danilchap 2015/11/25 16:49:17 Done.
58 Pli pli;
59 pli.From(kSenderSsrc);
60 pli.To(kRemoteSsrc);
61
62 rtc::scoped_ptr<RawPacket> packet(pli.Build());
63
64 RtcpCommonHeader header;
65 EXPECT_TRUE(
åsapersson 2015/11/25 16:14:48 maybe use kPacket (if create already tested)
danilchap 2015/11/25 16:49:17 Done.
66 RtcpParseCommonHeader(packet->Buffer(), packet->Length(), &header));
67 header.payload_size_bytes--;
68
69 Pli parsed;
70 EXPECT_FALSE(parsed.Parse(
71 header, packet->Buffer() + RtcpCommonHeader::kHeaderSizeBytes));
72 }
73
74 } // namespace
75 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698