1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CHROMECAST_PUBLIC_MEDIA_MEDIA_CLOCK_DEVICE_H_
6 #define CHROMECAST_PUBLIC_MEDIA_MEDIA_CLOCK_DEVICE_H_
10 namespace chromecast
{
13 // Interface for platform-specific pipeline clock.
14 // Pipeline clocks follow this state machine:
15 // -------------------
18 // kUninitialized --> kIdle --------- kRunning
20 // {any state} --> kError
23 // - Hardware resources should be acquired when transitioning from the
24 // |kUninitialized| state to the |kIdle| state.
25 // - The initial value of the timeline will only be set in the kIdle state.
26 class MediaClockDevice
{
35 virtual ~MediaClockDevice() {}
37 // Returns the current state of the media clock.
38 virtual State
GetState() const = 0;
40 // Changes the state and performs any necessary transitions.
41 // Returns true when successful.
42 virtual bool SetState(State new_state
) = 0;
44 // Sets the initial value of the timeline in microseconds.
45 // Will only be invoked in state kStateIdle.
46 // Returns true when successful.
47 virtual bool ResetTimeline(int64_t time_microseconds
) = 0;
49 // Sets the clock rate.
50 // |rate| == 0 means the clock is not progressing and that the renderer
51 // tied to this media clock should pause rendering.
52 // Will only be invoked in states kStateIdle or kStateRunning.
53 virtual bool SetRate(float rate
) = 0;
55 // Retrieves the media clock time in microseconds.
56 // Will only be invoked in states kStateIdle or kStateRunning.
57 virtual int64_t GetTimeMicroseconds() = 0;
61 } // namespace chromecast
63 #endif // CHROMECAST_MEDIA_CMA_BACKEND_MEDIA_CLOCK_DEVICE_H_