OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // demuxer_bench is a standalone benchmarking tool for FFmpegDemuxer. It | 5 // demuxer_bench is a standalone benchmarking tool for FFmpegDemuxer. It |
6 // simulates the reading requirements for playback by reading from the stream | 6 // simulates the reading requirements for playback by reading from the stream |
7 // that has the earliest timestamp. | 7 // that has the earliest timestamp. |
8 | 8 |
9 #include <iostream> | 9 #include <iostream> |
10 | 10 |
(...skipping 19 matching lines...) Expand all Loading... |
30 | 30 |
31 // DataSourceHost implementation. | 31 // DataSourceHost implementation. |
32 virtual void SetTotalBytes(int64 total_bytes) OVERRIDE {} | 32 virtual void SetTotalBytes(int64 total_bytes) OVERRIDE {} |
33 virtual void AddBufferedByteRange(int64 start, int64 end) OVERRIDE {} | 33 virtual void AddBufferedByteRange(int64 start, int64 end) OVERRIDE {} |
34 virtual void AddBufferedTimeRange(base::TimeDelta start, | 34 virtual void AddBufferedTimeRange(base::TimeDelta start, |
35 base::TimeDelta end) OVERRIDE {} | 35 base::TimeDelta end) OVERRIDE {} |
36 | 36 |
37 // DemuxerHost implementation. | 37 // DemuxerHost implementation. |
38 virtual void SetDuration(base::TimeDelta duration) OVERRIDE {} | 38 virtual void SetDuration(base::TimeDelta duration) OVERRIDE {} |
39 virtual void OnDemuxerError(media::PipelineStatus error) OVERRIDE {} | 39 virtual void OnDemuxerError(media::PipelineStatus error) OVERRIDE {} |
| 40 virtual void AddTextStream(media::DemuxerStream* text_stream, |
| 41 const media::TextTrackConfig& config) OVERRIDE {} |
| 42 virtual void RemoveTextStream(media::DemuxerStream* text_stream) OVERRIDE {} |
40 | 43 |
41 private: | 44 private: |
42 DISALLOW_COPY_AND_ASSIGN(DemuxerHostImpl); | 45 DISALLOW_COPY_AND_ASSIGN(DemuxerHostImpl); |
43 }; | 46 }; |
44 | 47 |
45 void QuitLoopWithStatus(base::MessageLoop* message_loop, | 48 void QuitLoopWithStatus(base::MessageLoop* message_loop, |
46 media::PipelineStatus status) { | 49 media::PipelineStatus status) { |
47 CHECK_EQ(status, media::PIPELINE_OK); | 50 CHECK_EQ(status, media::PIPELINE_OK); |
48 message_loop->PostTask(FROM_HERE, base::MessageLoop::QuitWhenIdleClosure()); | 51 message_loop->PostTask(FROM_HERE, base::MessageLoop::QuitWhenIdleClosure()); |
49 } | 52 } |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 base::FilePath file_path(cmd_line->GetArgs()[0]); | 194 base::FilePath file_path(cmd_line->GetArgs()[0]); |
192 | 195 |
193 // Setup. | 196 // Setup. |
194 media::FileDataSource data_source; | 197 media::FileDataSource data_source; |
195 CHECK(data_source.Initialize(file_path)); | 198 CHECK(data_source.Initialize(file_path)); |
196 | 199 |
197 media::Demuxer::NeedKeyCB need_key_cb = base::Bind(&NeedKey); | 200 media::Demuxer::NeedKeyCB need_key_cb = base::Bind(&NeedKey); |
198 media::FFmpegDemuxer demuxer(message_loop.message_loop_proxy(), | 201 media::FFmpegDemuxer demuxer(message_loop.message_loop_proxy(), |
199 &data_source, | 202 &data_source, |
200 need_key_cb, | 203 need_key_cb, |
| 204 true, // enable inband text tracks |
201 new media::MediaLog()); | 205 new media::MediaLog()); |
202 | 206 |
203 demuxer.Initialize(&demuxer_host, base::Bind( | 207 demuxer.Initialize(&demuxer_host, base::Bind( |
204 &QuitLoopWithStatus, &message_loop)); | 208 &QuitLoopWithStatus, &message_loop)); |
205 message_loop.Run(); | 209 message_loop.Run(); |
206 | 210 |
207 StreamReader stream_reader( | 211 StreamReader stream_reader( |
208 &demuxer, cmd_line->HasSwitch(switches::kEnableBitstreamConverter)); | 212 &demuxer, cmd_line->HasSwitch(switches::kEnableBitstreamConverter)); |
209 | 213 |
210 // Benchmark. | 214 // Benchmark. |
211 base::TimeTicks start = base::TimeTicks::HighResNow(); | 215 base::TimeTicks start = base::TimeTicks::HighResNow(); |
212 while (!stream_reader.IsDone()) { | 216 while (!stream_reader.IsDone()) { |
213 stream_reader.Read(); | 217 stream_reader.Read(); |
214 } | 218 } |
215 base::TimeTicks end = base::TimeTicks::HighResNow(); | 219 base::TimeTicks end = base::TimeTicks::HighResNow(); |
216 | 220 |
217 // Results. | 221 // Results. |
218 std::cout << "Time: " << (end - start).InMillisecondsF() << " ms\n"; | 222 std::cout << "Time: " << (end - start).InMillisecondsF() << " ms\n"; |
219 for (int i = 0; i < stream_reader.number_of_streams(); ++i) { | 223 for (int i = 0; i < stream_reader.number_of_streams(); ++i) { |
220 media::DemuxerStream* stream = stream_reader.streams()[i]; | 224 media::DemuxerStream* stream = stream_reader.streams()[i]; |
221 std::cout << "Stream #" << i << ": "; | 225 std::cout << "Stream #" << i << ": "; |
222 | 226 |
223 if (stream->type() == media::DemuxerStream::AUDIO) { | 227 if (stream->type() == media::DemuxerStream::AUDIO) { |
224 std::cout << "audio"; | 228 std::cout << "audio"; |
225 } else if (stream->type() == media::DemuxerStream::VIDEO) { | 229 } else if (stream->type() == media::DemuxerStream::VIDEO) { |
226 std::cout << "video"; | 230 std::cout << "video"; |
| 231 } else if (stream->type() == media::DemuxerStream::TEXT) { |
| 232 std::cout << "text"; |
227 } else { | 233 } else { |
228 std::cout << "unknown"; | 234 std::cout << "unknown"; |
229 } | 235 } |
230 | 236 |
231 std::cout << ", " << stream_reader.counts()[i] << " packets" << std::endl; | 237 std::cout << ", " << stream_reader.counts()[i] << " packets" << std::endl; |
232 } | 238 } |
233 | 239 |
234 // Teardown. | 240 // Teardown. |
235 demuxer.Stop(base::Bind( | 241 demuxer.Stop(base::Bind( |
236 &QuitLoopWithStatus, &message_loop, media::PIPELINE_OK)); | 242 &QuitLoopWithStatus, &message_loop, media::PIPELINE_OK)); |
237 message_loop.Run(); | 243 message_loop.Run(); |
238 | 244 |
239 return 0; | 245 return 0; |
240 } | 246 } |
OLD | NEW |