ozone: evdev: Sync caps lock LED state to evdev
[chromium-blink-merge.git] / chromecast / media / cma / backend / media_clock_device.h
blobb625dd57f8289e097768c56d6b72f83dd9b2da45
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_MEDIA_CMA_BACKEND_MEDIA_CLOCK_DEVICE_H_
6 #define CHROMECAST_MEDIA_CMA_BACKEND_MEDIA_CLOCK_DEVICE_H_
8 #include <string>
10 #include "base/basictypes.h"
11 #include "base/macros.h"
12 #include "base/threading/non_thread_safe.h"
13 #include "base/time/time.h"
15 namespace chromecast {
16 namespace media {
18 // MediaClockDevice -
20 // State machine:
21 // -------------------
22 // | |
23 // v |
24 // kUninitialized --> kIdle --------- kRunning
26 // {any state} --> kError
28 // Notes:
29 // - Hardware resources are acquired when transitioning from the
30 // |kUninitialized| state to the |kIdle| state.
31 // - The initial value of the timeline can only be set in the kIdle state.
33 class MediaClockDevice
34 : NON_EXPORTED_BASE(public base::NonThreadSafe) {
35 public:
36 enum State {
37 kStateUninitialized,
38 kStateIdle,
39 kStateRunning,
40 kStateError,
43 // Return true if transition from |state1| to |state2| is a valid state
44 // transition.
45 static bool IsValidStateTransition(State state1, State state2);
47 // Returns string representation of state (for logging)
48 static std::string StateToString(const State& state);
50 MediaClockDevice();
51 virtual ~MediaClockDevice();
53 // Return the current state of the media clock.
54 virtual State GetState() const = 0;
56 // Changes the state and performs any necessary transitions.
57 // Returns true when successful.
58 virtual bool SetState(State new_state) = 0;
60 // Sets the initial value of the timeline.
61 // Can only be invoked in state kStateIdle.
62 // Returns true when successful.
63 virtual bool ResetTimeline(base::TimeDelta time) = 0;
65 // Sets the clock rate.
66 // Setting it to 0 means the clock is not progressing and that the renderer
67 // tied to this media clock should pause rendering.
68 // Can only be invoked in states kStateIdle or kStateRunning.
69 virtual bool SetRate(float rate) = 0;
71 // Retrieves the media clock time.
72 // Can only be invoked in states kStateIdle or kStateRunning.
73 virtual base::TimeDelta GetTime() = 0;
75 private:
76 DISALLOW_COPY_AND_ASSIGN(MediaClockDevice);
79 } // namespace media
80 } // namespace chromecast
82 #endif // CHROMECAST_MEDIA_CMA_BACKEND_MEDIA_CLOCK_DEVICE_H_