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_INIT_STATE_H 17 #define HISTREAMER_HIRECORDER_INIT_STATE_H 18 19 #include "foundation/osal/thread/mutex.h" 20 #include "pipeline/core/error_code.h" 21 #include "recorder_executor.h" 22 #include "state.h" 23 24 namespace OHOS { 25 namespace Media { 26 namespace Record { 27 class InitState : public State { 28 public: InitState(StateId stateId,RecorderExecutor & executor)29 explicit InitState(StateId stateId, RecorderExecutor& executor) : State(stateId, "InitState", executor) 30 { 31 } 32 33 ~InitState() override = default; 34 SetVideoSource(const Plugin::Any & param)35 std::tuple<ErrorCode, Action> SetVideoSource(const Plugin::Any& param) override 36 { 37 auto ret = executor_.DoSetVideoSource(param); 38 Action action = (ret == ErrorCode::SUCCESS) ? Action::TRANS_TO_RECORDING_SETTING : Action::ACTION_BUTT; 39 return {ret, action}; 40 } 41 SetAudioSource(const Plugin::Any & param)42 std::tuple<ErrorCode, Action> SetAudioSource(const Plugin::Any& param) override 43 { 44 auto ret = executor_.DoSetAudioSource(param); 45 Action action = (ret == ErrorCode::SUCCESS) ? Action::TRANS_TO_RECORDING_SETTING : Action::ACTION_BUTT; 46 return {ret, action}; 47 } 48 Stop(const Plugin::Any & param)49 std::tuple<ErrorCode, Action> Stop(const Plugin::Any& param) override 50 { 51 return {ErrorCode::ERROR_INVALID_OPERATION, Action::TRANS_TO_ERROR}; 52 } 53 OnComplete()54 std::tuple<ErrorCode, Action> OnComplete() override 55 { 56 auto ret = executor_.DoOnComplete(); 57 return {ret, Action::ACTION_BUTT}; 58 } 59 }; 60 } // namespace Record 61 } // namespace Media 62 } // namespace OHOS 63 #endif // HISTREAMER_HIRECORDER_INIT_STATE_H 64