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 30 matching lines...) Expand all Loading... |
41 private: | 41 private: |
42 DISALLOW_COPY_AND_ASSIGN(DemuxerHostImpl); | 42 DISALLOW_COPY_AND_ASSIGN(DemuxerHostImpl); |
43 }; | 43 }; |
44 | 44 |
45 void QuitLoopWithStatus(base::MessageLoop* message_loop, | 45 void QuitLoopWithStatus(base::MessageLoop* message_loop, |
46 media::PipelineStatus status) { | 46 media::PipelineStatus status) { |
47 CHECK_EQ(status, media::PIPELINE_OK); | 47 CHECK_EQ(status, media::PIPELINE_OK); |
48 message_loop->PostTask(FROM_HERE, base::MessageLoop::QuitWhenIdleClosure()); | 48 message_loop->PostTask(FROM_HERE, base::MessageLoop::QuitWhenIdleClosure()); |
49 } | 49 } |
50 | 50 |
51 static void NeedKey(const std::string& type, scoped_ptr<uint8[]> init_data, | 51 static void NeedKey(const std::string& type, |
52 int init_data_size) { | 52 const std::vector<uint8>& init_data) { |
53 LOG(INFO) << "File is encrypted."; | 53 LOG(INFO) << "File is encrypted."; |
54 } | 54 } |
55 | 55 |
56 typedef std::vector<media::DemuxerStream* > Streams; | 56 typedef std::vector<media::DemuxerStream* > Streams; |
57 | 57 |
58 // Simulates playback reading requirements by reading from each stream | 58 // Simulates playback reading requirements by reading from each stream |
59 // present in |demuxer| in as-close-to-monotonically-increasing timestamp order. | 59 // present in |demuxer| in as-close-to-monotonically-increasing timestamp order. |
60 class StreamReader { | 60 class StreamReader { |
61 public: | 61 public: |
62 StreamReader(media::Demuxer* demuxer, bool enable_bitstream_converter); | 62 StreamReader(media::Demuxer* demuxer, bool enable_bitstream_converter); |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 } | 187 } |
188 | 188 |
189 base::MessageLoop message_loop; | 189 base::MessageLoop message_loop; |
190 DemuxerHostImpl demuxer_host; | 190 DemuxerHostImpl demuxer_host; |
191 base::FilePath file_path(cmd_line->GetArgs()[0]); | 191 base::FilePath file_path(cmd_line->GetArgs()[0]); |
192 | 192 |
193 // Setup. | 193 // Setup. |
194 media::FileDataSource data_source; | 194 media::FileDataSource data_source; |
195 CHECK(data_source.Initialize(file_path)); | 195 CHECK(data_source.Initialize(file_path)); |
196 | 196 |
197 media::FFmpegNeedKeyCB need_key_cb = base::Bind(&NeedKey); | 197 media::Demuxer::NeedKeyCB need_key_cb = base::Bind(&NeedKey); |
198 media::FFmpegDemuxer demuxer(message_loop.message_loop_proxy(), | 198 media::FFmpegDemuxer demuxer(message_loop.message_loop_proxy(), |
199 &data_source, | 199 &data_source, |
200 need_key_cb, | 200 need_key_cb, |
201 new media::MediaLog()); | 201 new media::MediaLog()); |
202 | 202 |
203 demuxer.Initialize(&demuxer_host, base::Bind( | 203 demuxer.Initialize(&demuxer_host, base::Bind( |
204 &QuitLoopWithStatus, &message_loop)); | 204 &QuitLoopWithStatus, &message_loop)); |
205 message_loop.Run(); | 205 message_loop.Run(); |
206 | 206 |
207 StreamReader stream_reader( | 207 StreamReader stream_reader( |
(...skipping 23 matching lines...) Expand all Loading... |
231 std::cout << ", " << stream_reader.counts()[i] << " packets" << std::endl; | 231 std::cout << ", " << stream_reader.counts()[i] << " packets" << std::endl; |
232 } | 232 } |
233 | 233 |
234 // Teardown. | 234 // Teardown. |
235 demuxer.Stop(base::Bind( | 235 demuxer.Stop(base::Bind( |
236 &QuitLoopWithStatus, &message_loop, media::PIPELINE_OK)); | 236 &QuitLoopWithStatus, &message_loop, media::PIPELINE_OK)); |
237 message_loop.Run(); | 237 message_loop.Run(); |
238 | 238 |
239 return 0; | 239 return 0; |
240 } | 240 } |
OLD | NEW |