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

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

Issue 2063443002: Return parsed sample frequency of ADTS header (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: SBR Created 4 years, 6 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 "media/base/stream_parser_buffer.h" 11 #include "media/base/stream_parser_buffer.h"
11 #include "media/base/test_data_util.h" 12 #include "media/base/test_data_util.h"
12 #include "media/base/timestamp_constants.h" 13 #include "media/base/timestamp_constants.h"
13 #include "media/formats/mp2t/es_parser.h" 14 #include "media/formats/mp2t/es_parser.h"
14 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
15 16
16 namespace media { 17 namespace media {
17 namespace mp2t { 18 namespace mp2t {
18 19
19 EsParserTestBase::Packet::Packet() 20 EsParserTestBase::Packet::Packet()
(...skipping 14 matching lines...) Expand all
34 base::FilePath file_path = GetTestDataFilePath(filename); 35 base::FilePath file_path = GetTestDataFilePath(filename);
35 36
36 base::MemoryMappedFile stream; 37 base::MemoryMappedFile stream;
37 ASSERT_TRUE(stream.Initialize(file_path)) 38 ASSERT_TRUE(stream.Initialize(file_path))
38 << "Couldn't open stream file: " << file_path.MaybeAsASCII(); 39 << "Couldn't open stream file: " << file_path.MaybeAsASCII();
39 40
40 stream_.resize(stream.length()); 41 stream_.resize(stream.length());
41 memcpy(&stream_[0], stream.data(), stream_.size()); 42 memcpy(&stream_[0], stream.data(), stream_.size());
42 } 43 }
43 44
45 std::vector<EsParserTestBase::Packet> EsParserTestBase::LoadPacketsFromFiles(
46 const char* filename_template,
47 size_t file_count) {
48 std::vector<Packet> packets;
49 for (size_t i = 0; i < file_count; ++i) {
50 base::FilePath file_path =
51 GetTestDataFilePath(base::StringPrintf(filename_template, i));
52 base::MemoryMappedFile stream;
53 EXPECT_TRUE(stream.Initialize(file_path)) << "Couldn't open stream file: "
54 << file_path.MaybeAsASCII();
55
56 Packet packet;
57 packet.offset = stream_.size();
58 packet.size = stream.length();
59 packet.pts = kNoTimestamp();
60
61 stream_.insert(stream_.end(), stream.data(),
62 stream.data() + stream.length());
63 packets.push_back(packet);
64 }
65
66 return packets;
67 }
68
44 void EsParserTestBase::NewAudioConfig(const AudioDecoderConfig& config) { 69 void EsParserTestBase::NewAudioConfig(const AudioDecoderConfig& config) {
45 config_count_++; 70 config_count_++;
46 } 71 }
47 72
48 void EsParserTestBase::NewVideoConfig(const VideoDecoderConfig& config) { 73 void EsParserTestBase::NewVideoConfig(const VideoDecoderConfig& config) {
49 config_count_++; 74 config_count_++;
50 } 75 }
51 76
52 void EsParserTestBase::EmitBuffer(scoped_refptr<StreamParserBuffer> buffer) { 77 void EsParserTestBase::EmitBuffer(scoped_refptr<StreamParserBuffer> buffer) {
53 buffer_timestamps_stream_ << "(" 78 buffer_timestamps_stream_ << "("
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 pes_packets.push_back(cur_pes_packet); 140 pes_packets.push_back(cur_pes_packet);
116 cur_pes_packet.offset += pes_size; 141 cur_pes_packet.offset += pes_size;
117 } 142 }
118 ComputePacketSize(&pes_packets); 143 ComputePacketSize(&pes_packets);
119 144
120 return pes_packets; 145 return pes_packets;
121 } 146 }
122 147
123 } // namespace mp2t 148 } // namespace mp2t
124 } // namespace media 149 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698