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