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 // This standalone binary is a helper for diagnosing seek behavior of the | 5 // This standalone binary is a helper for diagnosing seek behavior of the |
6 // demuxer setup in media/ code. It answers the question: "if I ask the demuxer | 6 // demuxer setup in media/ code. It answers the question: "if I ask the demuxer |
7 // to Seek to X ms, where will it actually seek to? (necessitating | 7 // to Seek to X ms, where will it actually seek to? (necessitating |
8 // frame-dropping until the original seek target is reached)". Sample run: | 8 // frame-dropping until the original seek target is reached)". Sample run: |
9 // | 9 // |
10 // $ ./out/Debug/seek_tester .../LayoutTests/media/content/test.ogv 6300 | 10 // $ ./out/Debug/seek_tester .../LayoutTests/media/content/test.ogv 6300 |
11 // [0207/130327:INFO:seek_tester.cc(63)] Requested: 6123ms | 11 // [0207/130327:INFO:seek_tester.cc(63)] Requested: 6123ms |
12 // [0207/130327:INFO:seek_tester.cc(68)] audio seeked to: 5526ms | 12 // [0207/130327:INFO:seek_tester.cc(68)] audio seeked to: 5526ms |
13 // [0207/130327:INFO:seek_tester.cc(74)] video seeked to: 5577ms | 13 // [0207/130327:INFO:seek_tester.cc(74)] video seeked to: 5577ms |
14 | 14 |
15 | 15 |
16 #include "base/at_exit.h" | 16 #include "base/at_exit.h" |
17 #include "base/bind.h" | 17 #include "base/bind.h" |
18 #include "base/logging.h" | 18 #include "base/logging.h" |
19 #include "base/message_loop.h" | 19 #include "base/message_loop.h" |
20 #include "base/string_number_conversions.h" | 20 #include "base/string_number_conversions.h" |
21 #include "media/base/media.h" | 21 #include "media/base/media.h" |
22 #include "media/filters/ffmpeg_demuxer.h" | 22 #include "media/filters/ffmpeg_demuxer.h" |
23 #include "media/filters/file_data_source.h" | 23 #include "media/filters/file_data_source.h" |
24 | 24 |
25 class DemuxerHostImpl : public media::DemuxerHost { | 25 class DemuxerHostImpl : public media::DemuxerHost { |
26 public: | 26 public: |
27 // DataSourceHost implementation. | 27 // DataSourceHost implementation. |
28 virtual void SetTotalBytes(int64 total_bytes) OVERRIDE {} | 28 virtual void SetTotalBytes(int64 total_bytes) OVERRIDE {} |
29 virtual void SetBufferedBytes(int64 buffered_bytes) OVERRIDE {} | 29 virtual void AddBufferedByteRange(int64 start, int64 end) OVERRIDE {} |
30 virtual void SetNetworkActivity(bool is_downloading_data) OVERRIDE {} | 30 virtual void SetNetworkActivity(bool is_downloading_data) OVERRIDE {} |
31 | 31 |
32 // DemuxerHost implementation. | 32 // DemuxerHost implementation. |
33 virtual void SetDuration(base::TimeDelta duration) OVERRIDE {} | 33 virtual void SetDuration(base::TimeDelta duration) OVERRIDE {} |
34 virtual void SetCurrentReadPosition(int64 offset) OVERRIDE {} | |
35 virtual void OnDemuxerError(media::PipelineStatus error) OVERRIDE {} | 34 virtual void OnDemuxerError(media::PipelineStatus error) OVERRIDE {} |
36 }; | 35 }; |
37 | 36 |
38 void QuitMessageLoop(MessageLoop* loop, media::PipelineStatus status) { | 37 void QuitMessageLoop(MessageLoop* loop, media::PipelineStatus status) { |
39 CHECK_EQ(status, media::PIPELINE_OK); | 38 CHECK_EQ(status, media::PIPELINE_OK); |
40 loop->PostTask(FROM_HERE, MessageLoop::QuitClosure()); | 39 loop->PostTask(FROM_HERE, MessageLoop::QuitClosure()); |
41 } | 40 } |
42 | 41 |
43 void TimestampExtractor(uint64* timestamp_ms, | 42 void TimestampExtractor(uint64* timestamp_ms, |
44 MessageLoop* loop, | 43 MessageLoop* loop, |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 base::Bind(&TimestampExtractor, &video_seeked_to_ms, &loop)); | 89 base::Bind(&TimestampExtractor, &video_seeked_to_ms, &loop)); |
91 loop.Run(); | 90 loop.Run(); |
92 LOG(INFO) << " video seeked to: " << video_seeked_to_ms << "ms"; | 91 LOG(INFO) << " video seeked to: " << video_seeked_to_ms << "ms"; |
93 } | 92 } |
94 | 93 |
95 demuxer->Stop(base::Bind(&MessageLoop::Quit, base::Unretained(&loop))); | 94 demuxer->Stop(base::Bind(&MessageLoop::Quit, base::Unretained(&loop))); |
96 loop.Run(); | 95 loop.Run(); |
97 | 96 |
98 return 0; | 97 return 0; |
99 } | 98 } |
OLD | NEW |