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

Side by Side Diff: media/formats/mp2t/es_parser_test_base.cc

Issue 2158923004: Convert media constants to constexpr. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "media/formats/mp2t/es_parser_test_base.h" 5 #include "media/formats/mp2t/es_parser_test_base.h"
6 6
7 #include "base/files/memory_mapped_file.h" 7 #include "base/files/memory_mapped_file.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "base/strings/stringprintf.h" 10 #include "base/strings/stringprintf.h"
11 #include "media/base/stream_parser_buffer.h" 11 #include "media/base/stream_parser_buffer.h"
12 #include "media/base/test_data_util.h" 12 #include "media/base/test_data_util.h"
13 #include "media/base/timestamp_constants.h" 13 #include "media/base/timestamp_constants.h"
14 #include "media/formats/mp2t/es_parser.h" 14 #include "media/formats/mp2t/es_parser.h"
15 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
16 16
17 namespace media { 17 namespace media {
18 namespace mp2t { 18 namespace mp2t {
19 19
20 EsParserTestBase::Packet::Packet() 20 EsParserTestBase::Packet::Packet() : offset(0u), size(0u), pts(kNoTimestamp) {}
21 : offset(0u),
22 size(0u),
23 pts(kNoTimestamp()) {
24 }
25 21
26 EsParserTestBase::EsParserTestBase() 22 EsParserTestBase::EsParserTestBase()
27 : config_count_(0u), 23 : config_count_(0u),
28 buffer_count_(0u) { 24 buffer_count_(0u) {
29 } 25 }
30 26
31 EsParserTestBase::~EsParserTestBase() { 27 EsParserTestBase::~EsParserTestBase() {
32 } 28 }
33 29
34 void EsParserTestBase::LoadStream(const char* filename) { 30 void EsParserTestBase::LoadStream(const char* filename) {
(...skipping 14 matching lines...) Expand all
49 for (size_t i = 0; i < file_count; ++i) { 45 for (size_t i = 0; i < file_count; ++i) {
50 base::FilePath file_path = 46 base::FilePath file_path =
51 GetTestDataFilePath(base::StringPrintf(filename_template, i)); 47 GetTestDataFilePath(base::StringPrintf(filename_template, i));
52 base::MemoryMappedFile stream; 48 base::MemoryMappedFile stream;
53 EXPECT_TRUE(stream.Initialize(file_path)) << "Couldn't open stream file: " 49 EXPECT_TRUE(stream.Initialize(file_path)) << "Couldn't open stream file: "
54 << file_path.MaybeAsASCII(); 50 << file_path.MaybeAsASCII();
55 51
56 Packet packet; 52 Packet packet;
57 packet.offset = stream_.size(); 53 packet.offset = stream_.size();
58 packet.size = stream.length(); 54 packet.size = stream.length();
59 packet.pts = kNoTimestamp(); 55 packet.pts = kNoTimestamp;
60 56
61 stream_.insert(stream_.end(), stream.data(), 57 stream_.insert(stream_.end(), stream.data(),
62 stream.data() + stream.length()); 58 stream.data() + stream.length());
63 packets.push_back(packet); 59 packets.push_back(packet);
64 } 60 }
65 61
66 return packets; 62 return packets;
67 } 63 }
68 64
69 void EsParserTestBase::NewAudioConfig(const AudioDecoderConfig& config) { 65 void EsParserTestBase::NewAudioConfig(const AudioDecoderConfig& config) {
(...skipping 18 matching lines...) Expand all
88 DCHECK(es_parser); 84 DCHECK(es_parser);
89 85
90 buffer_count_ = 0; 86 buffer_count_ = 0;
91 config_count_ = 0; 87 config_count_ = 0;
92 buffer_timestamps_stream_.str(std::string()); 88 buffer_timestamps_stream_.str(std::string());
93 89
94 for (size_t k = 0; k < pes_packets.size(); k++) { 90 for (size_t k = 0; k < pes_packets.size(); k++) {
95 size_t cur_pes_offset = pes_packets[k].offset; 91 size_t cur_pes_offset = pes_packets[k].offset;
96 size_t cur_pes_size = pes_packets[k].size; 92 size_t cur_pes_size = pes_packets[k].size;
97 93
98 base::TimeDelta pts = kNoTimestamp(); 94 base::TimeDelta pts = kNoTimestamp;
99 DecodeTimestamp dts = kNoDecodeTimestamp(); 95 DecodeTimestamp dts = kNoDecodeTimestamp();
100 if (pes_packets[k].pts >= base::TimeDelta() || force_timing) 96 if (pes_packets[k].pts >= base::TimeDelta() || force_timing)
101 pts = pes_packets[k].pts; 97 pts = pes_packets[k].pts;
102 98
103 DCHECK_LT(cur_pes_offset, stream_.size()); 99 DCHECK_LT(cur_pes_offset, stream_.size());
104 if (!es_parser->Parse(&stream_[cur_pes_offset], cur_pes_size, pts, dts)) 100 if (!es_parser->Parse(&stream_[cur_pes_offset], cur_pes_size, pts, dts))
105 return false; 101 return false;
106 } 102 }
107 es_parser->Flush(); 103 es_parser->Flush();
108 104
(...skipping 19 matching lines...) Expand all
128 cur->size = stream_.size() - cur->offset; 124 cur->size = stream_.size() - cur->offset;
129 } 125 }
130 126
131 std::vector<EsParserTestBase::Packet> 127 std::vector<EsParserTestBase::Packet>
132 EsParserTestBase::GenerateFixedSizePesPacket(size_t pes_size) { 128 EsParserTestBase::GenerateFixedSizePesPacket(size_t pes_size) {
133 DCHECK_GT(stream_.size(), 0u); 129 DCHECK_GT(stream_.size(), 0u);
134 std::vector<Packet> pes_packets; 130 std::vector<Packet> pes_packets;
135 131
136 Packet cur_pes_packet; 132 Packet cur_pes_packet;
137 cur_pes_packet.offset = 0; 133 cur_pes_packet.offset = 0;
138 cur_pes_packet.pts = kNoTimestamp(); 134 cur_pes_packet.pts = kNoTimestamp;
139 while (cur_pes_packet.offset < stream_.size()) { 135 while (cur_pes_packet.offset < stream_.size()) {
140 pes_packets.push_back(cur_pes_packet); 136 pes_packets.push_back(cur_pes_packet);
141 cur_pes_packet.offset += pes_size; 137 cur_pes_packet.offset += pes_size;
142 } 138 }
143 ComputePacketSize(&pes_packets); 139 ComputePacketSize(&pes_packets);
144 140
145 return pes_packets; 141 return pes_packets;
146 } 142 }
147 143
148 } // namespace mp2t 144 } // namespace mp2t
149 } // namespace media 145 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698