Upstreaming browser/ui/uikit_ui_util from iOS.
[chromium-blink-merge.git] / chromecast / media / cma / backend / media_component_device.cc
blob7331946f47c7d78bc515686e65a9134dcf0d81b7
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 #include "chromecast/media/cma/backend/media_component_device.h"
7 #include "base/logging.h"
9 namespace chromecast {
10 namespace media {
12 MediaComponentDevice::Client::Client() {
15 MediaComponentDevice::Client::~Client() {
18 MediaComponentDevice::MediaComponentDevice() {
21 MediaComponentDevice::~MediaComponentDevice() {
24 // static
25 bool MediaComponentDevice::IsValidStateTransition(State state1, State state2) {
26 if (state2 == state1)
27 return true;
29 // All states can transition to |kStateError|.
30 bool is_transition_valid = (state2 == kStateError);
32 // All the other valid FSM transitions.
33 is_transition_valid = is_transition_valid ||
34 (state1 == kStateUninitialized && (state2 == kStateIdle)) ||
35 (state1 == kStateIdle && (state2 == kStateRunning ||
36 state2 == kStatePaused ||
37 state2 == kStateUninitialized)) ||
38 (state1 == kStatePaused && (state2 == kStateIdle ||
39 state2 == kStateRunning)) ||
40 (state1 == kStateRunning && (state2 == kStateIdle ||
41 state2 == kStatePaused)) ||
42 (state1 == kStateError && (state2 == kStateUninitialized));
44 return is_transition_valid;
47 // static
48 std::string MediaComponentDevice::StateToString(const State& state) {
49 switch (state) {
50 case kStateUninitialized:
51 return "Uninitialized";
52 case kStateIdle:
53 return "Idle";
54 case kStateRunning:
55 return "Running";
56 case kStatePaused:
57 return "Paused";
58 case kStateError:
59 return "Error";
60 default:
61 NOTREACHED() << "Unknown MediaComponentDevice::State: " << state;
62 return "";
66 } // namespace media
67 } // namespace chromecast