summaryrefslogtreecommitdiffstats
path: root/media/tools
diff options
context:
space:
mode:
authorfischman@chromium.org <fischman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-08 00:10:45 +0000
committerfischman@chromium.org <fischman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-08 00:10:45 +0000
commit11883849004bdead3af9e2e51ea3f40d5f985169 (patch)
tree93ca605b7bbff45208a2b6925a3ea83c65277867 /media/tools
parent53351ee74a811c40542b34981a19802244572449 (diff)
downloadchromium_src-11883849004bdead3af9e2e51ea3f40d5f985169.zip
chromium_src-11883849004bdead3af9e2e51ea3f40d5f985169.tar.gz
chromium_src-11883849004bdead3af9e2e51ea3f40d5f985169.tar.bz2
seek_tester is born: a standalone binary for exploring seek behavior.
I got tired of hacking logging into chrome every time I want to answer this question. BUG=none TEST=none Review URL: http://codereview.chromium.org/9355001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@120870 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media/tools')
-rw-r--r--media/tools/seek_tester/seek_tester.cc85
1 files changed, 85 insertions, 0 deletions
diff --git a/media/tools/seek_tester/seek_tester.cc b/media/tools/seek_tester/seek_tester.cc
new file mode 100644
index 0000000..17b03ea
--- /dev/null
+++ b/media/tools/seek_tester/seek_tester.cc
@@ -0,0 +1,85 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+//
+// This standalone binary is a helper for diagnosing seek behavior of the
+// demuxer setup in media/ code. It answers the question: "if I ask the demuxer
+// to Seek to X ms, where will it actually seek to? (necessitating
+// frame-dropping until the original seek target is reached)". Sample run:
+//
+// $ ./out/Debug/seek_tester .../LayoutTests/media/content/test.ogv 6300
+// [0207/130327:INFO:seek_tester.cc(63)] Requested: 6123ms
+// [0207/130327:INFO:seek_tester.cc(68)] audio seeked to: 5526ms
+// [0207/130327:INFO:seek_tester.cc(74)] video seeked to: 5577ms
+
+
+#include "base/at_exit.h"
+#include "base/bind.h"
+#include "base/logging.h"
+#include "base/message_loop.h"
+#include "base/string_number_conversions.h"
+#include "media/base/media.h"
+#include "media/filters/ffmpeg_demuxer.h"
+#include "media/filters/file_data_source.h"
+
+void QuitMessageLoop(MessageLoop* loop, media::PipelineStatus status) {
+ CHECK_EQ(status, media::PIPELINE_OK);
+ loop->PostTask(FROM_HERE, MessageLoop::QuitClosure());
+}
+
+void TimestampExtractor(uint64* timestamp_ms,
+ MessageLoop* loop,
+ const scoped_refptr<media::Buffer>& buffer) {
+ if (buffer->GetTimestamp() == media::kNoTimestamp())
+ *timestamp_ms = -1;
+ else
+ *timestamp_ms = buffer->GetTimestamp().InMillisecondsF();
+ loop->PostTask(FROM_HERE, MessageLoop::QuitClosure());
+}
+
+int main(int argc, char** argv) {
+ base::AtExitManager at_exit;
+ media::InitializeMediaLibraryForTesting();
+
+ CHECK_EQ(argc, 3) << "\nUsage: " << argv[0] << " <file> <seekTimeInMs>";
+ uint64 seek_target_ms;
+ CHECK(base::StringToUint64(argv[2], &seek_target_ms));
+ scoped_refptr<media::FileDataSource> file_data_source(
+ new media::FileDataSource());
+ CHECK_EQ(file_data_source->Initialize(argv[1]), media::PIPELINE_OK);
+
+ MessageLoop loop;
+ media::PipelineStatusCB quitter = base::Bind(&QuitMessageLoop, &loop);
+ scoped_refptr<media::FFmpegDemuxer> demuxer(
+ new media::FFmpegDemuxer(&loop, true));
+ demuxer->Initialize(file_data_source, quitter);
+ loop.Run();
+
+ demuxer->Seek(base::TimeDelta::FromMilliseconds(seek_target_ms), quitter);
+ loop.Run();
+
+ uint64 audio_seeked_to_ms;
+ uint64 video_seeked_to_ms;
+ scoped_refptr<media::DemuxerStream> audio_stream(
+ demuxer->GetStream(media::DemuxerStream::AUDIO));
+ scoped_refptr<media::DemuxerStream> video_stream(
+ demuxer->GetStream(media::DemuxerStream::VIDEO));
+ LOG(INFO) << "Requested: " << seek_target_ms << "ms";
+ if (audio_stream) {
+ audio_stream->Read(base::Bind(
+ &TimestampExtractor, &audio_seeked_to_ms, &loop));
+ loop.Run();
+ LOG(INFO) << " audio seeked to: " << audio_seeked_to_ms << "ms";
+ }
+ if (video_stream) {
+ video_stream->Read(
+ base::Bind(&TimestampExtractor, &video_seeked_to_ms, &loop));
+ loop.Run();
+ LOG(INFO) << " video seeked to: " << video_seeked_to_ms << "ms";
+ }
+
+ demuxer->Stop(base::Bind(&MessageLoop::Quit, base::Unretained(&loop)));
+ loop.Run();
+
+ return 0;
+}