blob: f586b635ecdee8d18e68867499c90e2348c0d9fc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
// 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;
protected:
virtual ~Clock() {}
};
} // namespace media
#endif // MEDIA_BASE_CLOCK_H_
|