Index: chromecast/public/media/media_clock_device.h |
diff --git a/chromecast/media/cma/backend/media_clock_device.h b/chromecast/public/media/media_clock_device.h |
similarity index 57% |
rename from chromecast/media/cma/backend/media_clock_device.h |
rename to chromecast/public/media/media_clock_device.h |
index b625dd57f8289e097768c56d6b72f83dd9b2da45..9d0eaea794f96e56d31de0763c888837a33aa8d4 100644 |
--- a/chromecast/media/cma/backend/media_clock_device.h |
+++ b/chromecast/public/media/media_clock_device.h |
@@ -2,15 +2,12 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-#ifndef CHROMECAST_MEDIA_CMA_BACKEND_MEDIA_CLOCK_DEVICE_H_ |
-#define CHROMECAST_MEDIA_CMA_BACKEND_MEDIA_CLOCK_DEVICE_H_ |
+#ifndef CHROMECAST_PUBLIC_MEDIA_MEDIA_CLOCK_DEVICE_H_ |
+#define CHROMECAST_PUBLIC_MEDIA_MEDIA_CLOCK_DEVICE_H_ |
#include <string> |
-#include "base/basictypes.h" |
-#include "base/macros.h" |
-#include "base/threading/non_thread_safe.h" |
-#include "base/time/time.h" |
+#include "chromecast/public/time_delta.h" |
byungchul
2015/07/27 18:22:23
relative to chromecast/public
halliwell
2015/07/28 02:19:36
TimeDelta removed now anyway.
|
namespace chromecast { |
namespace media { |
@@ -30,8 +27,7 @@ namespace media { |
// |kUninitialized| state to the |kIdle| state. |
// - The initial value of the timeline can only be set in the kIdle state. |
// |
-class MediaClockDevice |
- : NON_EXPORTED_BASE(public base::NonThreadSafe) { |
+class MediaClockDevice { |
public: |
enum State { |
kStateUninitialized, |
@@ -42,13 +38,43 @@ class MediaClockDevice |
// Return true if transition from |state1| to |state2| is a valid state |
// transition. |
- static bool IsValidStateTransition(State state1, State state2); |
+ inline static bool IsValidStateTransition(State state1, State state2) { |
+ if (state2 == state1) |
+ return true; |
- // Returns string representation of state (for logging) |
- static std::string StateToString(const State& state); |
+ // All states can transition to |kStateError|. |
+ bool is_transition_valid = (state2 == kStateError); |
+ |
+ // All the other valid FSM transitions. |
+ is_transition_valid = |
+ is_transition_valid || |
+ (state1 == kStateUninitialized && (state2 == kStateIdle)) || |
+ (state1 == kStateIdle && |
+ (state2 == kStateRunning || state2 == kStateUninitialized)) || |
+ (state1 == kStateRunning && (state2 == kStateIdle)) || |
+ (state1 == kStateError && (state2 == kStateUninitialized)); |
- MediaClockDevice(); |
- virtual ~MediaClockDevice(); |
+ return is_transition_valid; |
+ } |
+ |
+ // Returns string representation of state (for logging) |
+ inline static std::string StateToString(const State& state) { |
+ switch (state) { |
+ case kStateUninitialized: |
+ return "Uninitialized"; |
+ case kStateIdle: |
+ return "Idle"; |
+ case kStateRunning: |
+ return "Running"; |
+ case kStateError: |
+ return "Error"; |
+ default: |
+ return ""; |
+ } |
+ } |
byungchul
2015/07/27 18:22:23
Why are these 2 files defined here inline? Is it a
halliwell
2015/07/28 02:19:36
Yes, it's allowed. And all vendors call these fun
byungchul
2015/07/28 18:05:43
I think
1) StateToString() is not necessary to be
halliwell
2015/07/28 23:26:06
StateToString now moved out into implementation co
|
+ |
+ MediaClockDevice() {} |
+ virtual ~MediaClockDevice() {} |
// Return the current state of the media clock. |
virtual State GetState() const = 0; |
@@ -60,7 +86,7 @@ class MediaClockDevice |
// Sets the initial value of the timeline. |
// Can only be invoked in state kStateIdle. |
// Returns true when successful. |
- virtual bool ResetTimeline(base::TimeDelta time) = 0; |
+ virtual bool ResetTimeline(TimeDelta time) = 0; |
// Sets the clock rate. |
// Setting it to 0 means the clock is not progressing and that the renderer |
@@ -70,10 +96,7 @@ class MediaClockDevice |
// Retrieves the media clock time. |
// Can only be invoked in states kStateIdle or kStateRunning. |
- virtual base::TimeDelta GetTime() = 0; |
- |
- private: |
- DISALLOW_COPY_AND_ASSIGN(MediaClockDevice); |
+ virtual TimeDelta GetTime() = 0; |
}; |
} // namespace media |