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 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 media::DemuxerStream::Status status, | 46 media::DemuxerStream::Status status, |
47 const scoped_refptr<media::DecoderBuffer>& buffer) { | 47 const scoped_refptr<media::DecoderBuffer>& buffer) { |
48 CHECK_EQ(status, media::DemuxerStream::kOk); | 48 CHECK_EQ(status, media::DemuxerStream::kOk); |
49 if (buffer->GetTimestamp() == media::kNoTimestamp()) | 49 if (buffer->GetTimestamp() == media::kNoTimestamp()) |
50 *timestamp_ms = -1; | 50 *timestamp_ms = -1; |
51 else | 51 else |
52 *timestamp_ms = buffer->GetTimestamp().InMillisecondsF(); | 52 *timestamp_ms = buffer->GetTimestamp().InMillisecondsF(); |
53 loop->PostTask(FROM_HERE, MessageLoop::QuitClosure()); | 53 loop->PostTask(FROM_HERE, MessageLoop::QuitClosure()); |
54 } | 54 } |
55 | 55 |
| 56 static void NeedKey(const std::string& type, scoped_array<uint8> init_data, |
| 57 int init_data_size) { |
| 58 LOG(INFO) << "File is encrypted."; |
| 59 } |
| 60 |
56 int main(int argc, char** argv) { | 61 int main(int argc, char** argv) { |
57 base::AtExitManager at_exit; | 62 base::AtExitManager at_exit; |
58 media::InitializeMediaLibraryForTesting(); | 63 media::InitializeMediaLibraryForTesting(); |
59 | 64 |
60 CHECK_EQ(argc, 3) << "\nUsage: " << argv[0] << " <file> <seekTimeInMs>"; | 65 CHECK_EQ(argc, 3) << "\nUsage: " << argv[0] << " <file> <seekTimeInMs>"; |
61 uint64 seek_target_ms; | 66 uint64 seek_target_ms; |
62 CHECK(base::StringToUint64(argv[2], &seek_target_ms)); | 67 CHECK(base::StringToUint64(argv[2], &seek_target_ms)); |
63 scoped_refptr<media::FileDataSource> file_data_source( | 68 scoped_refptr<media::FileDataSource> file_data_source( |
64 new media::FileDataSource()); | 69 new media::FileDataSource()); |
65 CHECK(file_data_source->Initialize(base::FilePath::FromUTF8Unsafe(argv[1]))); | 70 CHECK(file_data_source->Initialize(base::FilePath::FromUTF8Unsafe(argv[1]))); |
66 | 71 |
67 DemuxerHostImpl host; | 72 DemuxerHostImpl host; |
68 MessageLoop loop; | 73 MessageLoop loop; |
69 media::PipelineStatusCB quitter = base::Bind(&QuitMessageLoop, &loop); | 74 media::PipelineStatusCB quitter = base::Bind(&QuitMessageLoop, &loop); |
| 75 media::FFmpegNeedKeyCB need_key_cb = base::Bind(&NeedKey); |
70 scoped_refptr<media::FFmpegDemuxer> demuxer( | 76 scoped_refptr<media::FFmpegDemuxer> demuxer( |
71 new media::FFmpegDemuxer(loop.message_loop_proxy(), file_data_source)); | 77 new media::FFmpegDemuxer(loop.message_loop_proxy(), file_data_source, |
| 78 need_key_cb)); |
72 demuxer->Initialize(&host, quitter); | 79 demuxer->Initialize(&host, quitter); |
73 loop.Run(); | 80 loop.Run(); |
74 | 81 |
75 demuxer->Seek(base::TimeDelta::FromMilliseconds(seek_target_ms), quitter); | 82 demuxer->Seek(base::TimeDelta::FromMilliseconds(seek_target_ms), quitter); |
76 loop.Run(); | 83 loop.Run(); |
77 | 84 |
78 uint64 audio_seeked_to_ms; | 85 uint64 audio_seeked_to_ms; |
79 uint64 video_seeked_to_ms; | 86 uint64 video_seeked_to_ms; |
80 scoped_refptr<media::DemuxerStream> audio_stream( | 87 scoped_refptr<media::DemuxerStream> audio_stream( |
81 demuxer->GetStream(media::DemuxerStream::AUDIO)); | 88 demuxer->GetStream(media::DemuxerStream::AUDIO)); |
(...skipping 11 matching lines...) Expand all Loading... |
93 base::Bind(&TimestampExtractor, &video_seeked_to_ms, &loop)); | 100 base::Bind(&TimestampExtractor, &video_seeked_to_ms, &loop)); |
94 loop.Run(); | 101 loop.Run(); |
95 LOG(INFO) << " video seeked to: " << video_seeked_to_ms << "ms"; | 102 LOG(INFO) << " video seeked to: " << video_seeked_to_ms << "ms"; |
96 } | 103 } |
97 | 104 |
98 demuxer->Stop(base::Bind(&MessageLoop::Quit, base::Unretained(&loop))); | 105 demuxer->Stop(base::Bind(&MessageLoop::Quit, base::Unretained(&loop))); |
99 loop.Run(); | 106 loop.Run(); |
100 | 107 |
101 return 0; | 108 return 0; |
102 } | 109 } |
OLD | NEW |