1 /* 2 * Copyright (c) 2021-2021 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef HISTREAMER_HIRECORDER_PAUSE_STATE_H 17 #define HISTREAMER_HIRECORDER_PAUSE_STATE_H 18 19 #include "pipeline/core/error_code.h" 20 #include "recorder_executor.h" 21 #include "state.h" 22 23 namespace OHOS { 24 namespace Media { 25 namespace Record { 26 class PauseState : public State { 27 public: PauseState(StateId stateId,RecorderExecutor & executor)28 explicit PauseState(StateId stateId, RecorderExecutor& executor) : State(stateId, "PauseState", executor) 29 { 30 } 31 32 ~PauseState() override = default; 33 Enter(Intent)34 std::tuple<ErrorCode, Action> Enter(Intent) override 35 { 36 MEDIA_LOG_D("Pause state entered."); 37 auto ret = executor_.DoPause(); 38 return {ret, Action::ACTION_BUTT}; 39 } 40 Start()41 std::tuple<ErrorCode, Action> Start() override 42 { 43 MEDIA_LOG_D("Start in pause state."); 44 return {ErrorCode::SUCCESS, Action::TRANS_TO_RECORDING}; 45 } 46 Pause()47 std::tuple<ErrorCode, Action> Pause() override 48 { 49 MEDIA_LOG_D("Pause in pause state."); 50 return {ErrorCode::SUCCESS, Action::ACTION_BUTT}; 51 } 52 Resume()53 std::tuple<ErrorCode, Action> Resume() override 54 { 55 MEDIA_LOG_D("Resume in pause state."); 56 return {ErrorCode::SUCCESS, Action::TRANS_TO_RECORDING}; 57 } 58 Stop(const Plugin::Any & param)59 std::tuple<ErrorCode, Action> Stop(const Plugin::Any& param) override 60 { 61 MEDIA_LOG_D("Stop called in pause state."); 62 auto ret = executor_.DoStop(param); 63 Action action = (ret == ErrorCode::SUCCESS) ? Action::TRANS_TO_INIT : Action::TRANS_TO_ERROR; 64 return {ret, action}; 65 } 66 }; 67 } // namespace Record 68 } // namespace Media 69 } // namespace OHOS 70 #endif // HISTREAMER_HIRECORDER_PAUSE_STATE_H 71