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 <stddef.h> | 5 #include <stddef.h> |
6 #include <stdint.h> | 6 #include <stdint.h> |
7 | 7 |
8 #include "base/at_exit.h" | 8 #include "base/at_exit.h" |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "base/message_loop/message_loop.h" | 11 #include "base/message_loop/message_loop.h" |
12 #include "base/strings/string_number_conversions.h" | 12 #include "base/strings/string_number_conversions.h" |
13 #include "base/time/time.h" | 13 #include "base/time/time.h" |
14 #include "build/build_config.h" | 14 #include "build/build_config.h" |
15 #include "media/base/media.h" | 15 #include "media/base/media.h" |
16 #include "media/base/media_log.h" | 16 #include "media/base/media_log.h" |
| 17 #include "media/base/media_tracks.h" |
17 #include "media/base/test_data_util.h" | 18 #include "media/base/test_data_util.h" |
18 #include "media/base/timestamp_constants.h" | 19 #include "media/base/timestamp_constants.h" |
19 #include "media/filters/ffmpeg_demuxer.h" | 20 #include "media/filters/ffmpeg_demuxer.h" |
20 #include "media/filters/file_data_source.h" | 21 #include "media/filters/file_data_source.h" |
21 #include "testing/gtest/include/gtest/gtest.h" | 22 #include "testing/gtest/include/gtest/gtest.h" |
22 #include "testing/perf/perf_test.h" | 23 #include "testing/perf/perf_test.h" |
23 | 24 |
24 namespace media { | 25 namespace media { |
25 | 26 |
26 static const int kBenchmarkIterations = 100; | 27 static const int kBenchmarkIterations = 100; |
(...skipping 20 matching lines...) Expand all Loading... |
47 media::PipelineStatus status) { | 48 media::PipelineStatus status) { |
48 CHECK_EQ(status, media::PIPELINE_OK); | 49 CHECK_EQ(status, media::PIPELINE_OK); |
49 message_loop->PostTask(FROM_HERE, base::MessageLoop::QuitWhenIdleClosure()); | 50 message_loop->PostTask(FROM_HERE, base::MessageLoop::QuitWhenIdleClosure()); |
50 } | 51 } |
51 | 52 |
52 static void OnEncryptedMediaInitData(EmeInitDataType init_data_type, | 53 static void OnEncryptedMediaInitData(EmeInitDataType init_data_type, |
53 const std::vector<uint8_t>& init_data) { | 54 const std::vector<uint8_t>& init_data) { |
54 VLOG(0) << "File is encrypted."; | 55 VLOG(0) << "File is encrypted."; |
55 } | 56 } |
56 | 57 |
| 58 static void OnMediaTracksUpdated(scoped_ptr<MediaTracks> tracks) { |
| 59 VLOG(0) << "Got media tracks info, tracks = " << tracks->tracks().size(); |
| 60 } |
| 61 |
57 typedef std::vector<media::DemuxerStream* > Streams; | 62 typedef std::vector<media::DemuxerStream* > Streams; |
58 | 63 |
59 // Simulates playback reading requirements by reading from each stream | 64 // Simulates playback reading requirements by reading from each stream |
60 // present in |demuxer| in as-close-to-monotonically-increasing timestamp order. | 65 // present in |demuxer| in as-close-to-monotonically-increasing timestamp order. |
61 class StreamReader { | 66 class StreamReader { |
62 public: | 67 public: |
63 StreamReader(media::Demuxer* demuxer, bool enable_bitstream_converter); | 68 StreamReader(media::Demuxer* demuxer, bool enable_bitstream_converter); |
64 ~StreamReader(); | 69 ~StreamReader(); |
65 | 70 |
66 // Performs a single step read. | 71 // Performs a single step read. |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 double total_time = 0.0; | 181 double total_time = 0.0; |
177 for (int i = 0; i < kBenchmarkIterations; ++i) { | 182 for (int i = 0; i < kBenchmarkIterations; ++i) { |
178 // Setup. | 183 // Setup. |
179 base::MessageLoop message_loop; | 184 base::MessageLoop message_loop; |
180 DemuxerHostImpl demuxer_host; | 185 DemuxerHostImpl demuxer_host; |
181 FileDataSource data_source; | 186 FileDataSource data_source; |
182 ASSERT_TRUE(data_source.Initialize(file_path)); | 187 ASSERT_TRUE(data_source.Initialize(file_path)); |
183 | 188 |
184 Demuxer::EncryptedMediaInitDataCB encrypted_media_init_data_cb = | 189 Demuxer::EncryptedMediaInitDataCB encrypted_media_init_data_cb = |
185 base::Bind(&OnEncryptedMediaInitData); | 190 base::Bind(&OnEncryptedMediaInitData); |
| 191 Demuxer::MediaTracksUpdatedCB tracks_updated_cb = |
| 192 base::Bind(&OnMediaTracksUpdated); |
186 FFmpegDemuxer demuxer(message_loop.task_runner(), &data_source, | 193 FFmpegDemuxer demuxer(message_loop.task_runner(), &data_source, |
187 encrypted_media_init_data_cb, new MediaLog()); | 194 encrypted_media_init_data_cb, tracks_updated_cb, |
| 195 new MediaLog()); |
188 | 196 |
189 demuxer.Initialize(&demuxer_host, | 197 demuxer.Initialize(&demuxer_host, |
190 base::Bind(&QuitLoopWithStatus, &message_loop), | 198 base::Bind(&QuitLoopWithStatus, &message_loop), |
191 false); | 199 false); |
192 message_loop.Run(); | 200 message_loop.Run(); |
193 StreamReader stream_reader(&demuxer, false); | 201 StreamReader stream_reader(&demuxer, false); |
194 | 202 |
195 // Benchmark. | 203 // Benchmark. |
196 base::TimeTicks start = base::TimeTicks::Now(); | 204 base::TimeTicks start = base::TimeTicks::Now(); |
197 while (!stream_reader.IsDone()) { | 205 while (!stream_reader.IsDone()) { |
(...skipping 30 matching lines...) Expand all Loading... |
228 #endif | 236 #endif |
229 #if defined(OS_CHROMEOS) | 237 #if defined(OS_CHROMEOS) |
230 RunDemuxerBenchmark("bear.flac"); | 238 RunDemuxerBenchmark("bear.flac"); |
231 #endif | 239 #endif |
232 #if defined(USE_PROPRIETARY_CODECS) && defined(OS_CHROMEOS) | 240 #if defined(USE_PROPRIETARY_CODECS) && defined(OS_CHROMEOS) |
233 RunDemuxerBenchmark("bear.avi"); | 241 RunDemuxerBenchmark("bear.avi"); |
234 #endif | 242 #endif |
235 } | 243 } |
236 | 244 |
237 } // namespace media | 245 } // namespace media |
OLD | NEW |