Upstream version 11.40.271.0
[platform/framework/web/crosswalk.git] / src / chromecast / media / cma / backend / media_clock_device.cc
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 #include "chromecast/media/cma/backend/media_clock_device.h"
6
7 #include "base/logging.h"
8
9 namespace chromecast {
10 namespace media {
11
12 MediaClockDevice::MediaClockDevice() {
13 }
14
15 MediaClockDevice::~MediaClockDevice() {
16 }
17
18 // static
19 bool MediaClockDevice::IsValidStateTransition(State state1, State state2) {
20   if (state2 == state1)
21     return true;
22
23   // All states can transition to |kStateError|.
24   bool is_transition_valid = (state2 == kStateError);
25
26   // All the other valid FSM transitions.
27   is_transition_valid = is_transition_valid ||
28       (state1 == kStateUninitialized && (state2 == kStateIdle)) ||
29       (state1 == kStateIdle && (state2 == kStateRunning ||
30                                 state2 == kStateUninitialized)) ||
31       (state1 == kStateRunning && (state2 == kStateIdle)) ||
32       (state1 == kStateError && (state2 == kStateUninitialized));
33
34   return is_transition_valid;
35 }
36
37 // static
38 std::string MediaClockDevice::StateToString(const State& state) {
39   switch (state) {
40     case kStateUninitialized:
41       return "Uninitialized";
42     case kStateIdle:
43       return "Idle";
44     case kStateRunning:
45       return "Running";
46     case kStateError:
47       return "Error";
48     default:
49       NOTREACHED() << "Unknown MediaClockDevice::State: " << state;
50       return "";
51   }
52 }
53
54 }  // namespace media
55 }  // namespace chromecast