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

Side by Side Diff: webrtc/modules/rtp_rtcp/source/rtp_format_vp9_unittest.cc

Issue 1924443002: Revert of Replace the remaining scoped_ptr with unique_ptr in webrtc/modules/ (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 7 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) 2015 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2015 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>
12 #include <vector> 11 #include <vector>
13 12
14 #include "testing/gmock/include/gmock/gmock.h" 13 #include "testing/gmock/include/gmock/gmock.h"
15 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
16 #include "webrtc/modules/rtp_rtcp/source/rtp_format_vp9.h" 15 #include "webrtc/modules/rtp_rtcp/source/rtp_format_vp9.h"
17 #include "webrtc/typedefs.h" 16 #include "webrtc/typedefs.h"
18 17
19 namespace webrtc { 18 namespace webrtc {
20 namespace { 19 namespace {
21 void VerifyHeader(const RTPVideoHeaderVP9& expected, 20 void VerifyHeader(const RTPVideoHeaderVP9& expected,
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 EXPECT_EQ(payload_length, parsed.payload_length); 69 EXPECT_EQ(payload_length, parsed.payload_length);
71 EXPECT_THAT(std::vector<uint8_t>(parsed.payload, 70 EXPECT_THAT(std::vector<uint8_t>(parsed.payload,
72 parsed.payload + parsed.payload_length), 71 parsed.payload + parsed.payload_length),
73 ::testing::ElementsAreArray(payload, payload_length)); 72 ::testing::ElementsAreArray(payload, payload_length));
74 } 73 }
75 74
76 void ParseAndCheckPacket(const uint8_t* packet, 75 void ParseAndCheckPacket(const uint8_t* packet,
77 const RTPVideoHeaderVP9& expected, 76 const RTPVideoHeaderVP9& expected,
78 size_t expected_hdr_length, 77 size_t expected_hdr_length,
79 size_t expected_length) { 78 size_t expected_length) {
80 std::unique_ptr<RtpDepacketizer> depacketizer(new RtpDepacketizerVp9()); 79 rtc::scoped_ptr<RtpDepacketizer> depacketizer(new RtpDepacketizerVp9());
81 RtpDepacketizer::ParsedPayload parsed; 80 RtpDepacketizer::ParsedPayload parsed;
82 ASSERT_TRUE(depacketizer->Parse(&parsed, packet, expected_length)); 81 ASSERT_TRUE(depacketizer->Parse(&parsed, packet, expected_length));
83 EXPECT_EQ(kRtpVideoVp9, parsed.type.Video.codec); 82 EXPECT_EQ(kRtpVideoVp9, parsed.type.Video.codec);
84 VerifyHeader(expected, parsed.type.Video.codecHeader.VP9); 83 VerifyHeader(expected, parsed.type.Video.codecHeader.VP9);
85 const size_t kExpectedPayloadLength = expected_length - expected_hdr_length; 84 const size_t kExpectedPayloadLength = expected_length - expected_hdr_length;
86 VerifyPayload(parsed, packet + expected_hdr_length, kExpectedPayloadLength); 85 VerifyPayload(parsed, packet + expected_hdr_length, kExpectedPayloadLength);
87 } 86 }
88 } // namespace 87 } // namespace
89 88
90 // Payload descriptor for flexible mode 89 // Payload descriptor for flexible mode
(...skipping 30 matching lines...) Expand all
121 // | .. | 120 // | .. |
122 // +-+-+-+-+-+-+-+-+ 121 // +-+-+-+-+-+-+-+-+
123 122
124 class RtpPacketizerVp9Test : public ::testing::Test { 123 class RtpPacketizerVp9Test : public ::testing::Test {
125 protected: 124 protected:
126 RtpPacketizerVp9Test() {} 125 RtpPacketizerVp9Test() {}
127 virtual void SetUp() { 126 virtual void SetUp() {
128 expected_.InitRTPVideoHeaderVP9(); 127 expected_.InitRTPVideoHeaderVP9();
129 } 128 }
130 129
131 std::unique_ptr<uint8_t[]> packet_; 130 rtc::scoped_ptr<uint8_t[]> packet_;
132 std::unique_ptr<uint8_t[]> payload_; 131 rtc::scoped_ptr<uint8_t[]> payload_;
133 size_t payload_size_; 132 size_t payload_size_;
134 size_t payload_pos_; 133 size_t payload_pos_;
135 RTPVideoHeaderVP9 expected_; 134 RTPVideoHeaderVP9 expected_;
136 std::unique_ptr<RtpPacketizerVp9> packetizer_; 135 rtc::scoped_ptr<RtpPacketizerVp9> packetizer_;
137 136
138 void Init(size_t payload_size, size_t packet_size) { 137 void Init(size_t payload_size, size_t packet_size) {
139 payload_.reset(new uint8_t[payload_size]); 138 payload_.reset(new uint8_t[payload_size]);
140 memset(payload_.get(), 7, payload_size); 139 memset(payload_.get(), 7, payload_size);
141 payload_size_ = payload_size; 140 payload_size_ = payload_size;
142 payload_pos_ = 0; 141 payload_pos_ = 0;
143 packetizer_.reset(new RtpPacketizerVp9(expected_, packet_size)); 142 packetizer_.reset(new RtpPacketizerVp9(expected_, packet_size));
144 packetizer_->SetPayloadData(payload_.get(), payload_size_, NULL); 143 packetizer_->SetPayloadData(payload_.get(), payload_size_, NULL);
145 144
146 const int kMaxPayloadDescriptorLength = 100; 145 const int kMaxPayloadDescriptorLength = 100;
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
463 class RtpDepacketizerVp9Test : public ::testing::Test { 462 class RtpDepacketizerVp9Test : public ::testing::Test {
464 protected: 463 protected:
465 RtpDepacketizerVp9Test() 464 RtpDepacketizerVp9Test()
466 : depacketizer_(new RtpDepacketizerVp9()) {} 465 : depacketizer_(new RtpDepacketizerVp9()) {}
467 466
468 virtual void SetUp() { 467 virtual void SetUp() {
469 expected_.InitRTPVideoHeaderVP9(); 468 expected_.InitRTPVideoHeaderVP9();
470 } 469 }
471 470
472 RTPVideoHeaderVP9 expected_; 471 RTPVideoHeaderVP9 expected_;
473 std::unique_ptr<RtpDepacketizer> depacketizer_; 472 rtc::scoped_ptr<RtpDepacketizer> depacketizer_;
474 }; 473 };
475 474
476 TEST_F(RtpDepacketizerVp9Test, ParseBasicHeader) { 475 TEST_F(RtpDepacketizerVp9Test, ParseBasicHeader) {
477 const uint8_t kHeaderLength = 1; 476 const uint8_t kHeaderLength = 1;
478 uint8_t packet[4] = {0}; 477 uint8_t packet[4] = {0};
479 packet[0] = 0x0C; // I:0 P:0 L:0 F:0 B:1 E:1 V:0 R:0 478 packet[0] = 0x0C; // I:0 P:0 L:0 F:0 B:1 E:1 V:0 R:0
480 expected_.beginning_of_frame = true; 479 expected_.beginning_of_frame = true;
481 expected_.end_of_frame = true; 480 expected_.end_of_frame = true;
482 ParseAndCheckPacket(packet, expected_, kHeaderLength, sizeof(packet)); 481 ParseAndCheckPacket(packet, expected_, kHeaderLength, sizeof(packet));
483 } 482 }
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
682 } 681 }
683 682
684 TEST_F(RtpDepacketizerVp9Test, ParseFailsForTooShortBufferToFitPayload) { 683 TEST_F(RtpDepacketizerVp9Test, ParseFailsForTooShortBufferToFitPayload) {
685 const uint8_t kHeaderLength = 1; 684 const uint8_t kHeaderLength = 1;
686 uint8_t packet[kHeaderLength] = {0}; 685 uint8_t packet[kHeaderLength] = {0};
687 RtpDepacketizer::ParsedPayload parsed; 686 RtpDepacketizer::ParsedPayload parsed;
688 EXPECT_FALSE(depacketizer_->Parse(&parsed, packet, sizeof(packet))); 687 EXPECT_FALSE(depacketizer_->Parse(&parsed, packet, sizeof(packet)));
689 } 688 }
690 689
691 } // namespace webrtc 690 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698