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"
12 MediaComponentDevice::Client::Client() {
15 MediaComponentDevice::Client::~Client() {
18 MediaComponentDevice::MediaComponentDevice() {
21 MediaComponentDevice::~MediaComponentDevice() {
25 bool MediaComponentDevice::IsValidStateTransition(State state1
, State state2
) {
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
;
48 std::string
MediaComponentDevice::StateToString(const State
& state
) {
50 case kStateUninitialized
:
51 return "Uninitialized";
61 NOTREACHED() << "Unknown MediaComponentDevice::State: " << state
;
67 } // namespace chromecast