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_
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
{
21 // -------------------
24 // kUninitialized --> kIdle --------- kRunning
26 // {any state} --> kError
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
) {
43 // Return true if transition from |state1| to |state2| is a valid state
45 static bool IsValidStateTransition(State state1
, State state2
);
47 // Returns string representation of state (for logging)
48 static std::string
StateToString(const State
& state
);
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;
76 DISALLOW_COPY_AND_ASSIGN(MediaClockDevice
);
80 } // namespace chromecast
82 #endif // CHROMECAST_MEDIA_CMA_BACKEND_MEDIA_CLOCK_DEVICE_H_