diff options
author | scherkus@chromium.org <scherkus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-28 20:36:37 +0000 |
---|---|---|
committer | scherkus@chromium.org <scherkus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-28 20:36:37 +0000 |
commit | 46564213965397d01fb87975f3bddd597985fcbf (patch) | |
tree | 346f9cf4005fcb9865196622f13462065f52a83f /media/base/clock.h | |
parent | c2972193bd0d0c2354d0862444b7ce4662d52d77 (diff) | |
download | chromium_src-46564213965397d01fb87975f3bddd597985fcbf.zip chromium_src-46564213965397d01fb87975f3bddd597985fcbf.tar.gz chromium_src-46564213965397d01fb87975f3bddd597985fcbf.tar.bz2 |
Implemented a proper clock for audio/video synchronization.
More or less a change to pull out time management from PipelineImpl into a new class ClockImpl. Biggest difference is ClockImpl will use the system clock + linear interpolation to provide a more "precise" representation of the current playback position.
BUG=16508
TEST=a/v sync should remain the same, currentTime should report more precise values
Review URL: http://codereview.chromium.org/159517
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@21882 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media/base/clock.h')
-rw-r--r-- | media/base/clock.h | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/media/base/clock.h b/media/base/clock.h new file mode 100644 index 0000000..93af4a9 --- /dev/null +++ b/media/base/clock.h @@ -0,0 +1,47 @@ +// Copyright (c) 2009 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. +// +// A clock represent a single source of time to allow audio and video streams +// to synchronize with each other. Clocks essentially track the media time with +// respect to some other source of time, whether that may be the system clock, +// audio hardware or some other OS-level API. +// +// Clocks start off paused with a playback rate of 1.0f and a media time of 0. +// +// TODO(scherkus): Clocks will some day be responsible for executing callbacks +// given a media time. This will be used primarily by video renderers. For now +// we'll keep using a poll-and-sleep solution. + +#ifndef MEDIA_BASE_CLOCK_H_ +#define MEDIA_BASE_CLOCK_H_ + +#include "base/time.h" + +namespace media { + +class Clock { + public: + // Starts the clock and returns the current media time, which will increase + // with respect to the current playback rate. + virtual base::TimeDelta Play() = 0; + + // Stops the clock and returns the current media time, which will remain + // constant until Play() is called. + virtual base::TimeDelta Pause() = 0; + + // Sets a new playback rate. The rate at which the media time will increase + // will now change. + virtual void SetPlaybackRate(float playback_rate) = 0; + + // Forcefully sets the media time to the given time. This should only be used + // where a discontinuity in the media is found (i.e., seeking). + virtual void SetTime(const base::TimeDelta& time) = 0; + + // Returns the current elapsed media time. + virtual base::TimeDelta Elapsed() const = 0; +}; + +} // namespace media + +#endif // MEDIA_BASE_CLOCK_H_ |