Chromium Code Reviews| 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 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/at_exit.h" | 9 #include "base/at_exit.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/message_loop/message_loop.h" | 12 #include "base/message_loop/message_loop.h" |
| 13 #include "base/run_loop.h" | 13 #include "base/run_loop.h" |
| 14 #include "base/strings/string_number_conversions.h" | 14 #include "base/strings/string_number_conversions.h" |
| 15 #include "base/test/scoped_task_scheduler.h" | |
| 15 #include "base/threading/thread_task_runner_handle.h" | 16 #include "base/threading/thread_task_runner_handle.h" |
| 16 #include "base/time/time.h" | 17 #include "base/time/time.h" |
| 17 #include "build/build_config.h" | 18 #include "build/build_config.h" |
| 18 #include "media/base/media.h" | 19 #include "media/base/media.h" |
| 19 #include "media/base/media_log.h" | 20 #include "media/base/media_log.h" |
| 20 #include "media/base/media_tracks.h" | 21 #include "media/base/media_tracks.h" |
| 21 #include "media/base/test_data_util.h" | 22 #include "media/base/test_data_util.h" |
| 22 #include "media/base/timestamp_constants.h" | 23 #include "media/base/timestamp_constants.h" |
| 23 #include "media/filters/ffmpeg_demuxer.h" | 24 #include "media/filters/ffmpeg_demuxer.h" |
| 24 #include "media/filters/file_data_source.h" | 25 #include "media/filters/file_data_source.h" |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 178 static void RunDemuxerBenchmark(const std::string& filename) { | 179 static void RunDemuxerBenchmark(const std::string& filename) { |
| 179 base::FilePath file_path(GetTestDataFilePath(filename)); | 180 base::FilePath file_path(GetTestDataFilePath(filename)); |
| 180 double total_time = 0.0; | 181 double total_time = 0.0; |
| 181 for (int i = 0; i < kBenchmarkIterations; ++i) { | 182 for (int i = 0; i < kBenchmarkIterations; ++i) { |
| 182 // Setup. | 183 // Setup. |
| 183 base::MessageLoop message_loop; | 184 base::MessageLoop message_loop; |
| 184 DemuxerHostImpl demuxer_host; | 185 DemuxerHostImpl demuxer_host; |
| 185 FileDataSource data_source; | 186 FileDataSource data_source; |
| 186 ASSERT_TRUE(data_source.Initialize(file_path)); | 187 ASSERT_TRUE(data_source.Initialize(file_path)); |
| 187 | 188 |
| 189 base::test::ScopedTaskScheduler scoped_task_scheduler(&message_loop); | |
| 188 Demuxer::EncryptedMediaInitDataCB encrypted_media_init_data_cb = | 190 Demuxer::EncryptedMediaInitDataCB encrypted_media_init_data_cb = |
| 189 base::Bind(&OnEncryptedMediaInitData); | 191 base::Bind(&OnEncryptedMediaInitData); |
| 190 Demuxer::MediaTracksUpdatedCB tracks_updated_cb = | 192 Demuxer::MediaTracksUpdatedCB tracks_updated_cb = |
| 191 base::Bind(&OnMediaTracksUpdated); | 193 base::Bind(&OnMediaTracksUpdated); |
| 192 FFmpegDemuxer demuxer(message_loop.task_runner(), &data_source, | 194 FFmpegDemuxer demuxer(message_loop.task_runner(), &data_source, |
| 193 encrypted_media_init_data_cb, tracks_updated_cb, | 195 encrypted_media_init_data_cb, tracks_updated_cb, |
| 194 new MediaLog()); | 196 new MediaLog()); |
| 195 | 197 |
| 196 demuxer.Initialize(&demuxer_host, | 198 demuxer.Initialize(&demuxer_host, |
| 197 base::Bind(&QuitLoopWithStatus, &message_loop), | 199 base::Bind(&QuitLoopWithStatus, &message_loop), |
|
gab
2017/02/24 01:09:05
Use RunLoop::QuitClosure() (from the RunLoop on 21
DaleCurtis
2017/02/24 23:40:29
Done.
| |
| 198 false); | 200 false); |
| 199 base::RunLoop().Run(); | 201 base::RunLoop().Run(); |
| 200 StreamReader stream_reader(&demuxer, false); | 202 StreamReader stream_reader(&demuxer, false); |
| 201 | 203 |
| 202 // Benchmark. | 204 // Benchmark. |
| 203 base::TimeTicks start = base::TimeTicks::Now(); | 205 base::TimeTicks start = base::TimeTicks::Now(); |
| 204 while (!stream_reader.IsDone()) { | 206 while (!stream_reader.IsDone()) { |
| 205 stream_reader.Read(); | 207 stream_reader.Read(); |
| 206 } | 208 } |
| 207 base::TimeTicks end = base::TimeTicks::Now(); | 209 base::TimeTicks end = base::TimeTicks::Now(); |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 233 #if BUILDFLAG(USE_PROPRIETARY_CODECS) | 235 #if BUILDFLAG(USE_PROPRIETARY_CODECS) |
| 234 RunDemuxerBenchmark("bear-1280x720.mp4"); | 236 RunDemuxerBenchmark("bear-1280x720.mp4"); |
| 235 RunDemuxerBenchmark("sfx.mp3"); | 237 RunDemuxerBenchmark("sfx.mp3"); |
| 236 #endif | 238 #endif |
| 237 #if BUILDFLAG(USE_PROPRIETARY_CODECS) && defined(OS_CHROMEOS) | 239 #if BUILDFLAG(USE_PROPRIETARY_CODECS) && defined(OS_CHROMEOS) |
| 238 RunDemuxerBenchmark("bear.avi"); | 240 RunDemuxerBenchmark("bear.avi"); |
| 239 #endif | 241 #endif |
| 240 } | 242 } |
| 241 | 243 |
| 242 } // namespace media | 244 } // namespace media |
| OLD | NEW |