Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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. | |
| 4 | |
| 5 #ifndef CHROMECAST_MEDIA_CMA_BACKEND_MEDIA_CLOCK_DEVICE_H_ | |
| 6 #define CHROMECAST_MEDIA_CMA_BACKEND_MEDIA_CLOCK_DEVICE_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 | |
| 10 #include "base/basictypes.h" | |
| 11 #include "base/macros.h" | |
| 12 #include "base/memory/ref_counted.h" | |
|
damienv1
2014/10/03 22:19:41
Not needed.
gunsch
2014/10/03 23:08:44
Done.
| |
| 13 #include "base/threading/non_thread_safe.h" | |
| 14 #include "base/time/time.h" | |
| 15 | |
| 16 namespace chromecast { | |
| 17 namespace media { | |
| 18 | |
| 19 // MediaClockDevice - | |
| 20 // | |
| 21 // State machine: | |
| 22 // ------------------- | |
| 23 // | | | |
| 24 // v | | |
| 25 // kUninitialized --> kIdle --------- kRunning | |
| 26 // | |
| 27 // {any state} --> kError | |
| 28 // | |
| 29 // Notes: | |
| 30 // - Hardware resources are acquired when transitioning from the | |
| 31 // |kUninitialized| state to the |kIdle| state. | |
| 32 // - The initial value of the timeline can only be set in the kIdle state. | |
| 33 // | |
| 34 class MediaClockDevice | |
| 35 : NON_EXPORTED_BASE(public base::NonThreadSafe) { | |
| 36 public: | |
| 37 enum State { | |
| 38 kStateUninitialized, | |
| 39 kStateIdle, | |
| 40 kStateRunning, | |
| 41 kStateError, | |
| 42 }; | |
| 43 | |
| 44 // Return true if transition from |state1| to |state2| is a valid state | |
| 45 // transition. | |
| 46 static bool IsValidStateTransition(State state1, State state2); | |
| 47 | |
| 48 // Returns string representation of state (for logging) | |
| 49 static std::string StateToString(const State& state); | |
| 50 | |
| 51 MediaClockDevice(); | |
| 52 virtual ~MediaClockDevice(); | |
| 53 | |
| 54 // Return the current state of the media clock. | |
| 55 virtual State GetState() const = 0; | |
| 56 | |
| 57 // Changes the state and performs any necessary transitions. | |
| 58 // Returns true when successful. | |
| 59 virtual bool SetState(State new_state) = 0; | |
| 60 | |
| 61 // Sets the initial value of the timeline. | |
| 62 // Can only be invoked in state kStateIdle. | |
| 63 // Returns true when successful. | |
| 64 virtual bool ResetTimeline(base::TimeDelta time) = 0; | |
| 65 | |
| 66 // Sets the clock rate. | |
| 67 // Setting it to 0 means the clock is not progressing and that the renderer | |
| 68 // tied to this media clock should pause rendering. | |
| 69 // Can only be invoked in states kStateIdle or kStateRunning. | |
| 70 virtual bool SetRate(float rate) = 0; | |
| 71 | |
| 72 // Retrieves the media clock time. | |
| 73 // Can only be invoked in states kStateIdle or kStateRunning. | |
| 74 virtual base::TimeDelta GetTime() = 0; | |
| 75 | |
| 76 private: | |
| 77 DISALLOW_COPY_AND_ASSIGN(MediaClockDevice); | |
| 78 }; | |
| 79 | |
| 80 } // namespace media | |
| 81 } // namespace chromecast | |
| 82 | |
| 83 #endif // CHROMECAST_MEDIA_CMA_BACKEND_MEDIA_CLOCK_DEVICE_H_ | |
| 84 | |
|
damienv1
2014/10/03 22:19:42
Last line.
gunsch
2014/10/03 23:08:44
Done.
| |
| OLD | NEW |