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

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

Issue 1696203002: [rtp_rtcp] rtc::scoped_ptr<rtcp::RawPacket> replaced with rtc::Buffer (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 10 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
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2016 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 "webrtc/modules/rtp_rtcp/source/rtcp_packet/remb.h" 11 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/remb.h"
12 12
13 #include "testing/gmock/include/gmock/gmock.h" 13 #include "testing/gmock/include/gmock/gmock.h"
14 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
15 15
16 using testing::ElementsAreArray; 16 using testing::ElementsAreArray;
17 using testing::IsEmpty; 17 using testing::IsEmpty;
18 using testing::make_tuple; 18 using testing::make_tuple;
19 using webrtc::rtcp::RawPacket;
20 using webrtc::rtcp::Remb; 19 using webrtc::rtcp::Remb;
21 using webrtc::RTCPUtility::RtcpCommonHeader; 20 using webrtc::RTCPUtility::RtcpCommonHeader;
22 using webrtc::RTCPUtility::RtcpParseCommonHeader; 21 using webrtc::RTCPUtility::RtcpParseCommonHeader;
23 22
24 namespace webrtc { 23 namespace webrtc {
25 namespace { 24 namespace {
26 25
27 const uint32_t kSenderSsrc = 0x12345678; 26 const uint32_t kSenderSsrc = 0x12345678;
28 const uint32_t kRemoteSsrcs[] = {0x23456789, 0x2345678a, 0x2345678b}; 27 const uint32_t kRemoteSsrcs[] = {0x23456789, 0x2345678a, 0x2345678b};
29 const uint32_t kBitrateBps = 0x3fb93 * 2; // 522022; 28 const uint32_t kBitrateBps = 0x3fb93 * 2; // 522022;
(...skipping 11 matching lines...) Expand all
41 } 40 }
42 41
43 TEST(RtcpPacketRembTest, Create) { 42 TEST(RtcpPacketRembTest, Create) {
44 Remb remb; 43 Remb remb;
45 remb.From(kSenderSsrc); 44 remb.From(kSenderSsrc);
46 remb.AppliesTo(kRemoteSsrcs[0]); 45 remb.AppliesTo(kRemoteSsrcs[0]);
47 remb.AppliesTo(kRemoteSsrcs[1]); 46 remb.AppliesTo(kRemoteSsrcs[1]);
48 remb.AppliesTo(kRemoteSsrcs[2]); 47 remb.AppliesTo(kRemoteSsrcs[2]);
49 remb.WithBitrateBps(kBitrateBps); 48 remb.WithBitrateBps(kBitrateBps);
50 49
51 rtc::scoped_ptr<RawPacket> packet(remb.Build()); 50 rtc::Buffer packet = remb.Build();
52 51
53 EXPECT_THAT(make_tuple(packet->Buffer(), packet->Length()), 52 EXPECT_THAT(make_tuple(packet.data(), packet.size()),
54 ElementsAreArray(kPacket)); 53 ElementsAreArray(kPacket));
55 } 54 }
56 55
57 TEST(RtcpPacketRembTest, Parse) { 56 TEST(RtcpPacketRembTest, Parse) {
58 Remb remb; 57 Remb remb;
59 EXPECT_TRUE(ParseRemb(kPacket, kPacketLength, &remb)); 58 EXPECT_TRUE(ParseRemb(kPacket, kPacketLength, &remb));
60 const Remb& parsed = remb; 59 const Remb& parsed = remb;
61 60
62 EXPECT_EQ(kSenderSsrc, parsed.sender_ssrc()); 61 EXPECT_EQ(kSenderSsrc, parsed.sender_ssrc());
63 EXPECT_EQ(kBitrateBps, parsed.bitrate_bps()); 62 EXPECT_EQ(kBitrateBps, parsed.bitrate_bps());
64 EXPECT_THAT(parsed.ssrcs(), ElementsAreArray(kRemoteSsrcs)); 63 EXPECT_THAT(parsed.ssrcs(), ElementsAreArray(kRemoteSsrcs));
65 } 64 }
66 65
67 TEST(RtcpPacketRembTest, CreateAndParseWithoutSsrcs) { 66 TEST(RtcpPacketRembTest, CreateAndParseWithoutSsrcs) {
68 Remb remb; 67 Remb remb;
69 remb.From(kSenderSsrc); 68 remb.From(kSenderSsrc);
70 remb.WithBitrateBps(kBitrateBps); 69 remb.WithBitrateBps(kBitrateBps);
71 rtc::scoped_ptr<RawPacket> packet(remb.Build()); 70 rtc::Buffer packet = remb.Build();
72 71
73 Remb parsed; 72 Remb parsed;
74 EXPECT_TRUE(ParseRemb(packet->Buffer(), packet->Length(), &parsed)); 73 EXPECT_TRUE(ParseRemb(packet.data(), packet.size(), &parsed));
75 EXPECT_EQ(kSenderSsrc, parsed.sender_ssrc()); 74 EXPECT_EQ(kSenderSsrc, parsed.sender_ssrc());
76 EXPECT_EQ(kBitrateBps, parsed.bitrate_bps()); 75 EXPECT_EQ(kBitrateBps, parsed.bitrate_bps());
77 EXPECT_THAT(parsed.ssrcs(), IsEmpty()); 76 EXPECT_THAT(parsed.ssrcs(), IsEmpty());
78 } 77 }
79 78
80 TEST(RtcpPacketRembTest, ParseFailsOnTooSmallPacketToBeRemb) { 79 TEST(RtcpPacketRembTest, ParseFailsOnTooSmallPacketToBeRemb) {
81 uint8_t packet[kPacketLength]; 80 uint8_t packet[kPacketLength];
82 memcpy(packet, kPacket, kPacketLength); 81 memcpy(packet, kPacket, kPacketLength);
83 packet[3] = 3; // Make it too small. 82 packet[3] = 3; // Make it too small.
84 83
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 EXPECT_TRUE(remb.AppliesToMany(kAllButOneSsrc)); 121 EXPECT_TRUE(remb.AppliesToMany(kAllButOneSsrc));
123 // Should be no place for 2 more. 122 // Should be no place for 2 more.
124 EXPECT_FALSE(remb.AppliesToMany(kTwoSsrcs)); 123 EXPECT_FALSE(remb.AppliesToMany(kTwoSsrcs));
125 // But enough place for 1 more. 124 // But enough place for 1 more.
126 EXPECT_TRUE(remb.AppliesTo(kRemoteSsrc)); 125 EXPECT_TRUE(remb.AppliesTo(kRemoteSsrc));
127 // But not for another one. 126 // But not for another one.
128 EXPECT_FALSE(remb.AppliesTo(kRemoteSsrc)); 127 EXPECT_FALSE(remb.AppliesTo(kRemoteSsrc));
129 } 128 }
130 } // namespace 129 } // namespace
131 } // namespace webrtc 130 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698