| 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 "base/at_exit.h" | 5 #include "base/at_exit.h" |
| 6 #include "base/bind.h" | 6 #include "base/bind.h" |
| 7 #include "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
| 8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
| 9 #include "base/time/time.h" | 9 #include "base/time/time.h" |
| 10 #include "media/base/media.h" | 10 #include "media/base/media.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 private: | 36 private: |
| 37 DISALLOW_COPY_AND_ASSIGN(DemuxerHostImpl); | 37 DISALLOW_COPY_AND_ASSIGN(DemuxerHostImpl); |
| 38 }; | 38 }; |
| 39 | 39 |
| 40 static void QuitLoopWithStatus(base::MessageLoop* message_loop, | 40 static void QuitLoopWithStatus(base::MessageLoop* message_loop, |
| 41 media::PipelineStatus status) { | 41 media::PipelineStatus status) { |
| 42 CHECK_EQ(status, media::PIPELINE_OK); | 42 CHECK_EQ(status, media::PIPELINE_OK); |
| 43 message_loop->PostTask(FROM_HERE, base::MessageLoop::QuitWhenIdleClosure()); | 43 message_loop->PostTask(FROM_HERE, base::MessageLoop::QuitWhenIdleClosure()); |
| 44 } | 44 } |
| 45 | 45 |
| 46 static void NeedKey(const std::string& type, | 46 static void OnEncryptedMediaInitData(const std::string& init_data_type, |
| 47 const std::vector<uint8>& init_data) { | 47 const std::vector<uint8>& init_data) { |
| 48 VLOG(0) << "File is encrypted."; | 48 VLOG(0) << "File is encrypted."; |
| 49 } | 49 } |
| 50 | 50 |
| 51 typedef std::vector<media::DemuxerStream* > Streams; | 51 typedef std::vector<media::DemuxerStream* > Streams; |
| 52 | 52 |
| 53 // Simulates playback reading requirements by reading from each stream | 53 // Simulates playback reading requirements by reading from each stream |
| 54 // present in |demuxer| in as-close-to-monotonically-increasing timestamp order. | 54 // present in |demuxer| in as-close-to-monotonically-increasing timestamp order. |
| 55 class StreamReader { | 55 class StreamReader { |
| 56 public: | 56 public: |
| 57 StreamReader(media::Demuxer* demuxer, bool enable_bitstream_converter); | 57 StreamReader(media::Demuxer* demuxer, bool enable_bitstream_converter); |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 static void RunDemuxerBenchmark(const std::string& filename) { | 168 static void RunDemuxerBenchmark(const std::string& filename) { |
| 169 base::FilePath file_path(GetTestDataFilePath(filename)); | 169 base::FilePath file_path(GetTestDataFilePath(filename)); |
| 170 double total_time = 0.0; | 170 double total_time = 0.0; |
| 171 for (int i = 0; i < kBenchmarkIterations; ++i) { | 171 for (int i = 0; i < kBenchmarkIterations; ++i) { |
| 172 // Setup. | 172 // Setup. |
| 173 base::MessageLoop message_loop; | 173 base::MessageLoop message_loop; |
| 174 DemuxerHostImpl demuxer_host; | 174 DemuxerHostImpl demuxer_host; |
| 175 FileDataSource data_source; | 175 FileDataSource data_source; |
| 176 ASSERT_TRUE(data_source.Initialize(file_path)); | 176 ASSERT_TRUE(data_source.Initialize(file_path)); |
| 177 | 177 |
| 178 Demuxer::NeedKeyCB need_key_cb = base::Bind(&NeedKey); | 178 Demuxer::EncryptedMediaInitDataCB encrypted_media_init_data_cb = |
| 179 FFmpegDemuxer demuxer(message_loop.message_loop_proxy(), | 179 base::Bind(&OnEncryptedMediaInitData); |
| 180 &data_source, | 180 FFmpegDemuxer demuxer(message_loop.message_loop_proxy(), &data_source, |
| 181 need_key_cb, | 181 encrypted_media_init_data_cb, new MediaLog()); |
| 182 new MediaLog()); | |
| 183 | 182 |
| 184 demuxer.Initialize(&demuxer_host, | 183 demuxer.Initialize(&demuxer_host, |
| 185 base::Bind(&QuitLoopWithStatus, &message_loop), | 184 base::Bind(&QuitLoopWithStatus, &message_loop), |
| 186 false); | 185 false); |
| 187 message_loop.Run(); | 186 message_loop.Run(); |
| 188 StreamReader stream_reader(&demuxer, false); | 187 StreamReader stream_reader(&demuxer, false); |
| 189 | 188 |
| 190 // Benchmark. | 189 // Benchmark. |
| 191 base::TimeTicks start = base::TimeTicks::HighResNow(); | 190 base::TimeTicks start = base::TimeTicks::HighResNow(); |
| 192 while (!stream_reader.IsDone()) { | 191 while (!stream_reader.IsDone()) { |
| (...skipping 30 matching lines...) Expand all Loading... |
| 223 #endif | 222 #endif |
| 224 #if defined(OS_CHROMEOS) | 223 #if defined(OS_CHROMEOS) |
| 225 RunDemuxerBenchmark("bear.flac"); | 224 RunDemuxerBenchmark("bear.flac"); |
| 226 #endif | 225 #endif |
| 227 #if defined(USE_PROPRIETARY_CODECS) && defined(OS_CHROMEOS) | 226 #if defined(USE_PROPRIETARY_CODECS) && defined(OS_CHROMEOS) |
| 228 RunDemuxerBenchmark("bear.avi"); | 227 RunDemuxerBenchmark("bear.avi"); |
| 229 #endif | 228 #endif |
| 230 } | 229 } |
| 231 | 230 |
| 232 } // namespace media | 231 } // namespace media |
| OLD | NEW |