OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 <algorithm> | 5 #include <algorithm> |
6 #include <string> | 6 #include <string> |
7 | 7 |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/bind_helpers.h" | 9 #include "base/bind_helpers.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
12 #include "base/time/time.h" | 12 #include "base/time/time.h" |
13 #include "media/base/audio_decoder_config.h" | 13 #include "media/base/audio_decoder_config.h" |
14 #include "media/base/decoder_buffer.h" | 14 #include "media/base/decoder_buffer.h" |
15 #include "media/base/stream_parser_buffer.h" | 15 #include "media/base/stream_parser_buffer.h" |
16 #include "media/base/test_data_util.h" | 16 #include "media/base/test_data_util.h" |
| 17 #include "media/base/text_track_config.h" |
17 #include "media/base/video_decoder_config.h" | 18 #include "media/base/video_decoder_config.h" |
18 #include "media/mp2t/mp2t_stream_parser.h" | 19 #include "media/mp2t/mp2t_stream_parser.h" |
19 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
20 | 21 |
21 namespace media { | 22 namespace media { |
22 namespace mp2t { | 23 namespace mp2t { |
23 | 24 |
24 class Mp2tStreamParserTest : public testing::Test { | 25 class Mp2tStreamParserTest : public testing::Test { |
25 public: | 26 public: |
26 Mp2tStreamParserTest() | 27 Mp2tStreamParserTest() |
(...skipping 26 matching lines...) Expand all Loading... |
53 start += append_size; | 54 start += append_size; |
54 } | 55 } |
55 return true; | 56 return true; |
56 } | 57 } |
57 | 58 |
58 void OnInit(bool init_ok, base::TimeDelta duration) { | 59 void OnInit(bool init_ok, base::TimeDelta duration) { |
59 DVLOG(1) << "OnInit: ok=" << init_ok | 60 DVLOG(1) << "OnInit: ok=" << init_ok |
60 << ", dur=" << duration.InMilliseconds(); | 61 << ", dur=" << duration.InMilliseconds(); |
61 } | 62 } |
62 | 63 |
63 bool OnNewConfig(const AudioDecoderConfig& ac, const VideoDecoderConfig& vc) { | 64 bool OnNewConfig(const AudioDecoderConfig& ac, |
| 65 const VideoDecoderConfig& vc, |
| 66 const StreamParser::TextTrackConfigMap& tc) { |
64 DVLOG(1) << "OnNewConfig: audio=" << ac.IsValidConfig() | 67 DVLOG(1) << "OnNewConfig: audio=" << ac.IsValidConfig() |
65 << ", video=" << vc.IsValidConfig(); | 68 << ", video=" << vc.IsValidConfig(); |
66 return true; | 69 return true; |
67 } | 70 } |
68 | 71 |
69 | 72 |
70 void DumpBuffers(const std::string& label, | 73 void DumpBuffers(const std::string& label, |
71 const StreamParser::BufferQueue& buffers) { | 74 const StreamParser::BufferQueue& buffers) { |
72 DVLOG(2) << "DumpBuffers: " << label << " size " << buffers.size(); | 75 DVLOG(2) << "DumpBuffers: " << label << " size " << buffers.size(); |
73 for (StreamParser::BufferQueue::const_iterator buf = buffers.begin(); | 76 for (StreamParser::BufferQueue::const_iterator buf = buffers.begin(); |
(...skipping 20 matching lines...) Expand all Loading... |
94 StreamParser::BufferQueue::const_iterator it2 = ++it1; | 97 StreamParser::BufferQueue::const_iterator it2 = ++it1; |
95 for ( ; it2 != video_buffers.end(); ++it1, ++it2) { | 98 for ( ; it2 != video_buffers.end(); ++it1, ++it2) { |
96 if ((*it2)->GetDecodeTimestamp() < (*it1)->GetDecodeTimestamp()) | 99 if ((*it2)->GetDecodeTimestamp() < (*it1)->GetDecodeTimestamp()) |
97 return false; | 100 return false; |
98 } | 101 } |
99 } | 102 } |
100 | 103 |
101 return true; | 104 return true; |
102 } | 105 } |
103 | 106 |
104 bool OnNewTextBuffers(TextTrack* text_track, | |
105 const StreamParser::BufferQueue& buffers) { | |
106 return true; | |
107 } | |
108 | |
109 void OnKeyNeeded(const std::string& type, | 107 void OnKeyNeeded(const std::string& type, |
110 const std::vector<uint8>& init_data) { | 108 const std::vector<uint8>& init_data) { |
111 DVLOG(1) << "OnKeyNeeded: " << init_data.size(); | 109 DVLOG(1) << "OnKeyNeeded: " << init_data.size(); |
112 } | 110 } |
113 | 111 |
114 scoped_ptr<TextTrack> OnAddTextTrack( | |
115 TextKind kind, | |
116 const std::string& label, | |
117 const std::string& language) { | |
118 return scoped_ptr<TextTrack>(); | |
119 } | |
120 | |
121 void OnNewSegment() { | 112 void OnNewSegment() { |
122 DVLOG(1) << "OnNewSegment"; | 113 DVLOG(1) << "OnNewSegment"; |
123 } | 114 } |
124 | 115 |
125 void OnEndOfSegment() { | 116 void OnEndOfSegment() { |
126 DVLOG(1) << "OnEndOfSegment()"; | 117 DVLOG(1) << "OnEndOfSegment()"; |
127 } | 118 } |
128 | 119 |
129 void InitializeParser() { | 120 void InitializeParser() { |
130 parser_->Init( | 121 parser_->Init( |
131 base::Bind(&Mp2tStreamParserTest::OnInit, | 122 base::Bind(&Mp2tStreamParserTest::OnInit, |
132 base::Unretained(this)), | 123 base::Unretained(this)), |
133 base::Bind(&Mp2tStreamParserTest::OnNewConfig, | 124 base::Bind(&Mp2tStreamParserTest::OnNewConfig, |
134 base::Unretained(this)), | 125 base::Unretained(this)), |
135 base::Bind(&Mp2tStreamParserTest::OnNewBuffers, | 126 base::Bind(&Mp2tStreamParserTest::OnNewBuffers, |
136 base::Unretained(this)), | 127 base::Unretained(this)), |
137 base::Bind(&Mp2tStreamParserTest::OnNewTextBuffers, | 128 StreamParser::NewTextBuffersCB(), |
138 base::Unretained(this)), | |
139 base::Bind(&Mp2tStreamParserTest::OnKeyNeeded, | 129 base::Bind(&Mp2tStreamParserTest::OnKeyNeeded, |
140 base::Unretained(this)), | 130 base::Unretained(this)), |
141 base::Bind(&Mp2tStreamParserTest::OnAddTextTrack, | |
142 base::Unretained(this)), | |
143 base::Bind(&Mp2tStreamParserTest::OnNewSegment, | 131 base::Bind(&Mp2tStreamParserTest::OnNewSegment, |
144 base::Unretained(this)), | 132 base::Unretained(this)), |
145 base::Bind(&Mp2tStreamParserTest::OnEndOfSegment, | 133 base::Bind(&Mp2tStreamParserTest::OnEndOfSegment, |
146 base::Unretained(this)), | 134 base::Unretained(this)), |
147 LogCB()); | 135 LogCB()); |
148 } | 136 } |
149 | 137 |
150 bool ParseMpeg2TsFile(const std::string& filename, int append_bytes) { | 138 bool ParseMpeg2TsFile(const std::string& filename, int append_bytes) { |
151 InitializeParser(); | 139 InitializeParser(); |
152 | 140 |
(...skipping 27 matching lines...) Expand all Loading... |
180 // (close to 2^33 / 90000) which results in timestamps wrap around | 168 // (close to 2^33 / 90000) which results in timestamps wrap around |
181 // in the Mpeg2 TS stream. | 169 // in the Mpeg2 TS stream. |
182 ParseMpeg2TsFile("bear-1280x720_ptswraparound.ts", 512); | 170 ParseMpeg2TsFile("bear-1280x720_ptswraparound.ts", 512); |
183 EXPECT_EQ(video_frame_count_, 81); | 171 EXPECT_EQ(video_frame_count_, 81); |
184 EXPECT_GE(video_min_dts_, base::TimeDelta::FromSeconds(95443 - 10)); | 172 EXPECT_GE(video_min_dts_, base::TimeDelta::FromSeconds(95443 - 10)); |
185 EXPECT_LE(video_max_dts_, base::TimeDelta::FromSeconds(95443 + 10)); | 173 EXPECT_LE(video_max_dts_, base::TimeDelta::FromSeconds(95443 + 10)); |
186 } | 174 } |
187 | 175 |
188 } // namespace mp2t | 176 } // namespace mp2t |
189 } // namespace media | 177 } // namespace media |
OLD | NEW |